通过多个 IP 摄像机捕获视频数据包

发布于 2024-09-05 19:07:54 字数 325 浏览 8 评论 0原文

我们正在开发一个 C 语言应用程序,它是简单的 RTSP/RTP 客户端,用于录制来自 Axis 多个摄像机的视频。我们为每个相机启动一个 pthread,用于建立 RTP 会话,并开始记录使用 recvfrom() 调用捕获的数据包。 单个摄像头单个 pthread 可以很好地记录一天多的时间,没有出现任何问题。

但使用更多可用摄像机(大约 25 个(即 25 个 pthreads))进行测试时,记录到文件的情况可以正常进行 15 到 20 分钟,然后记录就会停止。该应用程序仍然保持运行。一个半月以来,我们一直在尝试各种实施方案,但似乎没有任何帮助。请提供建议。

我们使用的是CentOS 5平台

We are working on a C language application which is simple RTSP/RTP client to record video from Axis a number of Cameras. We launch a pthread for each of the camera which establishes the RTP session and begin to record the packets captured using the recvfrom() call.
A single camera single pthread records fine for well over a day without issues.

But testing with more cameras available,about 25(so 25 pthreads), the recording to file goes fine for like 15 to 20 mins and then the recording just stops. The application still keeps running. Its been over a month and a half we have been trying with varied implementations but nothing seems to help. Please provide suggestions.

We are using CentOS 5 platform

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

死开点丶别碍眼 2024-09-12 19:07:55

定义“记录”这是否意味着将数据写入文件?如何控制对文件的访问?

您不能让多个线程同时尝试写入。所以阿隆的评论似乎是中肯的。您的写访问控制机制有问题。

Define "record" Does that mean write data to a file? How do you control access to the file?

You can't have several threads all trying to write at the exact same time. So the comment by Alon seems to be pertinent. Your write access control machanism has problems.

洋洋洒洒 2024-09-12 19:07:55
void *IPThread(void *ptr)
{
//Establish RTSP session
//Bind to RTP ports(video)
//Increase Socket buffer size to 625KB

record_fd=open(record_name, O_CREAT|O_RDWR|O_TRUNC, 0777);
while(1)
{
    if(poll(RTP/RTCP ports)) //a timeout value of 1
    {
        if(RTCP event)
        RTCPhandler();
        if(RTP event)
        {
            recvfrom(); //the normal socket api recvfrom
            WritePacketToFile(record_fd)
            {
            //Create new record_fd after 100MB
            }
        }
    }
}
}

即使坚持单线程实现是可以的,为什么多线程方法会这样(大约 15 分钟后不记录)..?

void *IPThread(void *ptr)
{
//Establish RTSP session
//Bind to RTP ports(video)
//Increase Socket buffer size to 625KB

record_fd=open(record_name, O_CREAT|O_RDWR|O_TRUNC, 0777);
while(1)
{
    if(poll(RTP/RTCP ports)) //a timeout value of 1
    {
        if(RTCP event)
        RTCPhandler();
        if(RTP event)
        {
            recvfrom(); //the normal socket api recvfrom
            WritePacketToFile(record_fd)
            {
            //Create new record_fd after 100MB
            }
        }
    }
}
}

even if it is alright to stick to the single threaded implementation why is the multithreaded approach behaving such a way(not recording after ~15 mins)..?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文