从 ffmpeg 向 ffserver 发送 2 个不同的摄像头源

Send 2 different camera feeds to ffserver from ffmpeg

我目前在一个项目中工作,我必须通过 TCP 连接将 2 个网络摄像头流从一台计算机流式传输到另一台计算机,我可以毫无问题地流式传输 1 个:

使用

ffserver.conf:

            HTTPPort 8090
            HTTPBindAddress 0.0.0.0
            MaxClients 40
            MaxBandwidth 30000

            CustomLog -
            NoDaemon

            <Stream status.html>
            Format status
            ACL allow localhost
            ACL allow 192.168.0.0 192.168.255.255
            </Stream>

           #feed for camera 1
           <Feed webcam1.ffm>
           File /tmp/webcam1.ffm
           FileMaxSize 100M
           </Feed>

           #feed for camera 2
           <Feed webcam2.ffm>
           File /tmp/webcam2.ffm
           FileMaxSize 100M
           </Feed>

          #stream for feed 1
          <Stream webcam1.mjpeg>
          Feed webcam1.ffm
          Format mjpeg
          VideoSize 1280x720
          VideoFrameRate 30
          Preroll 0
          NoAudio
          Strict -1
          </Stream>

          #stream for feed2
          <Stream webcam2.mjpeg>
          Feed webcam2.ffm
          Format mjpeg
          VideoSize 1280x720
          VideoFrameRate 30
          Preroll 0
          NoAudio
          Strict -1
          </Stream>

命令到 运行 ffserver:

          ffserver /etc/ffserver.conf

向 ffserver 发送命令:

         ffmpeg -v 2 -r 20 -f video4linux2 -i /dev/video0 http://localhost:8090/webcam1.ffm

而且效果很好,但是当我尝试 运行 另一个提要时:

         ffmpeg -v 2 -r 20 -f video4linux2 -i /dev/video1 http://localhost:8090/webcam2.ffm

我只能看到第二个流,而第一个流不再工作。 一些想法?

同时使用多个 USB 网络摄像头可能会使总线饱和。这似乎是你的情况,因为启动第二个摄像头会切断第一个摄像头。

The situation has improved from when USB1.1 was common. Most even low-end motherboards have multiple USB2/3 controllers, which are entirely independent and can run multiple cameras without concern. USB2 can support multiple cameras at low resolution and framerate. High framerate high resolution cameras sending uncompressed images may still saturate the bus

Source

可能的解决方案:

  1. 切换到 MJPEG 输入(使用较低的带宽)

检查您设备的功能:

ffmpeg -f v4l2 -list_formats all -i /dev/video0

如果它支持 MJPEG,则使用它代替原始视频:

ffplay -f v4l2 -input_format mjpeg -i /dev/video0 ...

  1. 为第二个摄像头使用不同的 USB 控制器

如果主板不具有多个控制器,则获取 PCI USB 卡。