ffmpeg 使用 1080p 或 60fps 的网络摄像头时会冻结 - Logitech Streamcam OBS Studio

ffmpeg 使用 1080p 或 60fps 的网络摄像头时会冻结 - Logitech Streamcam OBS Studio

我需要以 1080p(1920x1080)60fps 的速度使用我的 Logitech Streamcam 网络摄像头,但它在 OBS Studio 中或 guvcview 中都无法工作,如果我想将输出保存为视频文件,ffmpeg 就会冻结 :( 提前感谢您的帮助。

**更新(2)2 月 3 日:新的 dmesg 信息/数据


OBS工作室

以下步骤没有问题,但如果我更改为 1080p 和/或 60fps,ffmpeg 就会冻结。

# sudo modprobe v4l2loopback
# ffmpeg -f v4l2 -input_format mjpeg -framerate 30 -s 1280x720 -i /dev/video0 -pix_fmt yuyv422 -f v4l2 /dev/video2

Ffmpeg => 视频文件 720p@30

以下步骤没有问题,但如果我更改为 1080p 和/或 60fps,ffmpeg 就会冻结。

# ffmpeg -f v4l2 -input_format mjpeg -framerate 30 -s 1280x720 -i /dev/video0 -pix_fmt yuvj422p video-test-output.mp4

Ffmpeg => 视频文件 1080p@30

通过以下步骤 ffmpeg 冻结

# ffmpeg -f v4l2 -input_format mjpeg -framerate 30 -s 1920x1080 -i /dev/video0 -pix_fmt yuvj422p video-test-output.mp4
ffmpeg version 4.1.4-1build2 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.2.1-4ubuntu1)
  configuration: --prefix=/usr --extra-version=1build2 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
[video4linux2,v4l2 @ 0x55cf92dc5ac0] Could not find codec parameters for stream 0 (Video: mjpeg, none(bt470bg/unknown/unknown), 1920x1080): unspecified pixel format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, video4linux2,v4l2, from '/dev/video0':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: mjpeg, none(bt470bg/unknown/unknown), 1920x1080, 30 fps, 30 tbr, 1000k tbn, 1000k tbc
Stream mapping:
  Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
Press [q] to stop, [?] for help
Cannot determine format of input stream 0:0 after EOF
Error marking filters as finished
Exiting normally, received signal 2.

测试 (1) 我尝试将网络摄像头设置更改为 1080p,但没有成功。

# v4l2-ctl --device /dev/video0 --set-fmt-video=width=1920,height=1080,pixelformat=MJPG

可能有用的其他信息/数据

# uname -r
5.3.0-64-generic
# dmesg
[    5.120382] usb 2-8: current rate 16000 is different from the runtime rate 48000
[    5.121990] snd_hda_codec_realtek hdaudioC2D0: autoconfig for ALC1220: line_outs=3 (0x14/0x15/0x16/0x0/0x0) type:line
[    5.121992] snd_hda_codec_realtek hdaudioC2D0:    speaker_outs=0 (0x0/0x0/0x0/0x0/0x0)
[    5.121993] snd_hda_codec_realtek hdaudioC2D0:    hp_outs=1 (0x1b/0x0/0x0/0x0/0x0)
[    5.121994] snd_hda_codec_realtek hdaudioC2D0:    mono: mono_out=0x0
[    5.121995] snd_hda_codec_realtek hdaudioC2D0:    dig-out=0x1e/0x0
[    5.121995] snd_hda_codec_realtek hdaudioC2D0:    inputs:
[    5.121997] snd_hda_codec_realtek hdaudioC2D0:      Front Mic=0x19
[    5.121998] snd_hda_codec_realtek hdaudioC2D0:      Rear Mic=0x18
[    5.121998] snd_hda_codec_realtek hdaudioC2D0:      Line=0x1a
[    5.141136] uvcvideo: Found UVC 1.00 device Logitech StreamCam (046d:0893)
[    5.157490] uvcvideo 2-8:1.0: Entity type for entity Processing 3 was not initialized!
[    5.157493] uvcvideo 2-8:1.0: Entity type for entity Extension 14 was not initialized!
[    5.157495] uvcvideo 2-8:1.0: Entity type for entity Extension 6 was not initialized!
[    5.157496] uvcvideo 2-8:1.0: Entity type for entity Extension 8 was not initialized!
[    5.157498] uvcvideo 2-8:1.0: Entity type for entity Extension 9 was not initialized!
[    5.157499] uvcvideo 2-8:1.0: Entity type for entity Extension 10 was not initialized!
[    5.157500] uvcvideo 2-8:1.0: Entity type for entity Extension 11 was not initialized!
[    5.157502] uvcvideo 2-8:1.0: Entity type for entity Camera 1 was not initialized!
[    5.157583] input: Logitech StreamCam as /devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-8/2-8:1.0/input/input32
[    5.157671] usbcore: registered new interface driver uvcvideo
[    5.157672] USB Video Class driver (1.1.1)

2021 年 2 月 3 日:我的计算机完全加载后,我插入了网络摄像头,这是 dmesg 信息:

# dmesg
[  553.490310] usb 2-7: new SuperSpeed Gen 1 USB device number 2 using xhci_hcd
[  553.517111] usb 2-7: New USB device found, idVendor=046d, idProduct=0893, bcdDevice= 3.17
[  553.517114] usb 2-7: New USB device strings: Mfr=0, Product=2, SerialNumber=3
[  553.517116] usb 2-7: Product: Logitech StreamCam
[  553.517118] usb 2-7: SerialNumber: XR6W1K92
[  553.541903] usb 2-7: current rate 16000 is different from the runtime rate 24000
[  553.548111] usb 2-7: current rate 16000 is different from the runtime rate 32000
[  553.554401] usb 2-7: current rate 16000 is different from the runtime rate 48000
[  553.573341] hid-generic 0003:046D:0893.0008: hiddev5,hidraw7: USB HID v1.11 Device [Logitech StreamCam] on usb-0000:02:00.0-7/input5
[  553.629854] videodev: Linux video capture interface: v2.00
[  553.642019] uvcvideo: Found UVC 1.00 device Logitech StreamCam (046d:0893)
[  553.657973] uvcvideo 2-7:1.0: Entity type for entity Processing 3 was not initialized!
[  553.657975] uvcvideo 2-7:1.0: Entity type for entity Extension 14 was not initialized!
[  553.657977] uvcvideo 2-7:1.0: Entity type for entity Extension 6 was not initialized!
[  553.657978] uvcvideo 2-7:1.0: Entity type for entity Extension 8 was not initialized!
[  553.657979] uvcvideo 2-7:1.0: Entity type for entity Extension 9 was not initialized!
[  553.657981] uvcvideo 2-7:1.0: Entity type for entity Extension 10 was not initialized!
[  553.657982] uvcvideo 2-7:1.0: Entity type for entity Extension 11 was not initialized!
[  553.657983] uvcvideo 2-7:1.0: Entity type for entity Camera 1 was not initialized!
[  553.658054] input: Logitech StreamCam as /devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb2/2-7/2-7:1.0/input/input32
[  553.658127] usbcore: registered new interface driver uvcvideo
[  553.658128] USB Video Class driver (1.1.1)
[  553.724131] usb 2-7: current rate 16000 is different from the runtime rate 48000
[  553.737390] usb 2-7: current rate 16000 is different from the runtime rate 48000
[  553.755142] usb 2-7: current rate 16000 is different from the runtime rate 48000
# lsusb
Bus 002 Device 002: ID 046d:0893 Logitech, Inc. Logitech StreamCam
# v4l2-ctl -V
Format Video Capture:
    Width/Height      : 1280/720
    Pixel Format      : 'MJPG' (Motion-JPEG)
    Field             : None
    Bytes per Line    : 0
    Size Image        : 1843200
    Colorspace        : sRGB
    Transfer Function : Default (maps to sRGB)
    YCbCr/HSV Encoding: Default (maps to ITU-R 601)
    Quantization      : Default (maps to Full Range)
    Flags             :
# v4l2-ctl --list-devices
Logitech StreamCam (usb-0000:02:00.0-8):
    /dev/video0
    /dev/video1
# v4l2-ctl --list-formats-ext -d /dev/video0
ioctl: VIDIOC_ENUM_FMT
    Type: Video Capture

    [0]: 'YUYV' (YUYV 4:2:2)
        Size: Discrete 640x480
            Interval: Discrete 0.033s (30.000 fps)
            Interval: Discrete 0.042s (24.000 fps)
            Interval: Discrete 0.050s (20.000 fps)
            Interval: Discrete 0.067s (15.000 fps)
            Interval: Discrete 0.100s (10.000 fps)
            Interval: Discrete 0.133s (7.500 fps)
            Interval: Discrete 0.200s (5.000 fps)
        Size: Discrete 176x144
            Interval: Discrete 0.033s (30.000 fps)
            Interval: Discrete 0.042s (24.000 fps)
            Interval: Discrete 0.050s (20.000 fps)
            Interval: Discrete 0.067s (15.000 fps)
            Interval: Discrete 0.100s (10.000 fps)
            Interval: Discrete 0.133s (7.500 fps)
            Interval: Discrete 0.200s (5.000 fps)
        Size: Discrete 320x240
            Interval: Discrete 0.033s (30.000 fps)
            Interval: Discrete 0.042s (24.000 fps)
            Interval: Discrete 0.050s (20.000 fps)
            Interval: Discrete 0.067s (15.000 fps)
            Interval: Discrete 0.100s (10.000 fps)
            Interval: Discrete 0.133s (7.500 fps)
            Interval: Discrete 0.200s (5.000 fps)
        Size: Discrete 424x240
            Interval: Discrete 0.033s (30.000 fps)
            Interval: Discrete 0.042s (24.000 fps)
            Interval: Discrete 0.050s (20.000 fps)
            Interval: Discrete 0.067s (15.000 fps)
            Interval: Discrete 0.100s (10.000 fps)
            Interval: Discrete 0.133s (7.500 fps)
            Interval: Discrete 0.200s (5.000 fps)
        Size: Discrete 640x360
            Interval: Discrete 0.033s (30.000 fps)
            Interval: Discrete 0.042s (24.000 fps)
            Interval: Discrete 0.050s (20.000 fps)
            Interval: Discrete 0.067s (15.000 fps)
            Interval: Discrete 0.100s (10.000 fps)
            Interval: Discrete 0.133s (7.500 fps)
            Interval: Discrete 0.200s (5.000 fps)
        Size: Discrete 848x480
            Interval: Discrete 0.033s (30.000 fps)
            Interval: Discrete 0.042s (24.000 fps)
            Interval: Discrete 0.050s (20.000 fps)
            Interval: Discrete 0.067s (15.000 fps)
            Interval: Discrete 0.100s (10.000 fps)
            Interval: Discrete 0.133s (7.500 fps)
            Interval: Discrete 0.200s (5.000 fps)
        Size: Discrete 960x540
            Interval: Discrete 0.033s (30.000 fps)
            Interval: Discrete 0.042s (24.000 fps)
            Interval: Discrete 0.050s (20.000 fps)
            Interval: Discrete 0.067s (15.000 fps)
            Interval: Discrete 0.100s (10.000 fps)
            Interval: Discrete 0.133s (7.500 fps)
            Interval: Discrete 0.200s (5.000 fps)
        Size: Discrete 1280x720
            Interval: Discrete 0.033s (30.000 fps)
            Interval: Discrete 0.042s (24.000 fps)
            Interval: Discrete 0.050s (20.000 fps)
            Interval: Discrete 0.067s (15.000 fps)
            Interval: Discrete 0.100s (10.000 fps)
            Interval: Discrete 0.133s (7.500 fps)
            Interval: Discrete 0.200s (5.000 fps)
        Size: Discrete 1600x896
            Interval: Discrete 0.033s (30.000 fps)
            Interval: Discrete 0.042s (24.000 fps)
            Interval: Discrete 0.050s (20.000 fps)
            Interval: Discrete 0.067s (15.000 fps)
            Interval: Discrete 0.100s (10.000 fps)
            Interval: Discrete 0.133s (7.500 fps)
            Interval: Discrete 0.200s (5.000 fps)
        Size: Discrete 1920x1080
            Interval: Discrete 0.033s (30.000 fps)
            Interval: Discrete 0.042s (24.000 fps)
            Interval: Discrete 0.050s (20.000 fps)
            Interval: Discrete 0.067s (15.000 fps)
            Interval: Discrete 0.100s (10.000 fps)
            Interval: Discrete 0.133s (7.500 fps)
            Interval: Discrete 0.200s (5.000 fps)
        Size: Discrete 2304x1296
            Interval: Discrete 0.200s (5.000 fps)
    [1]: 'MJPG' (Motion-JPEG, compressed)
        Size: Discrete 640x480
            Interval: Discrete 0.017s (60.000 fps)
            Interval: Discrete 0.033s (30.000 fps)
            Interval: Discrete 0.042s (24.000 fps)
            Interval: Discrete 0.050s (20.000 fps)
            Interval: Discrete 0.067s (15.000 fps)
            Interval: Discrete 0.100s (10.000 fps)
            Interval: Discrete 0.133s (7.500 fps)
            Interval: Discrete 0.200s (5.000 fps)
        Size: Discrete 176x144
            Interval: Discrete 0.017s (60.000 fps)
            Interval: Discrete 0.033s (30.000 fps)
            Interval: Discrete 0.042s (24.000 fps)
            Interval: Discrete 0.050s (20.000 fps)
            Interval: Discrete 0.067s (15.000 fps)
            Interval: Discrete 0.100s (10.000 fps)
            Interval: Discrete 0.133s (7.500 fps)
            Interval: Discrete 0.200s (5.000 fps)
        Size: Discrete 320x240
            Interval: Discrete 0.017s (60.000 fps)
            Interval: Discrete 0.033s (30.000 fps)
            Interval: Discrete 0.042s (24.000 fps)
            Interval: Discrete 0.050s (20.000 fps)
            Interval: Discrete 0.067s (15.000 fps)
            Interval: Discrete 0.100s (10.000 fps)
            Interval: Discrete 0.133s (7.500 fps)
            Interval: Discrete 0.200s (5.000 fps)
        Size: Discrete 424x240
            Interval: Discrete 0.017s (60.000 fps)
            Interval: Discrete 0.033s (30.000 fps)
            Interval: Discrete 0.042s (24.000 fps)
            Interval: Discrete 0.050s (20.000 fps)
            Interval: Discrete 0.067s (15.000 fps)
            Interval: Discrete 0.100s (10.000 fps)
            Interval: Discrete 0.133s (7.500 fps)
            Interval: Discrete 0.200s (5.000 fps)
        Size: Discrete 640x360
            Interval: Discrete 0.017s (60.000 fps)
            Interval: Discrete 0.033s (30.000 fps)
            Interval: Discrete 0.042s (24.000 fps)
            Interval: Discrete 0.050s (20.000 fps)
            Interval: Discrete 0.067s (15.000 fps)
            Interval: Discrete 0.100s (10.000 fps)
            Interval: Discrete 0.133s (7.500 fps)
            Interval: Discrete 0.200s (5.000 fps)
        Size: Discrete 848x480
            Interval: Discrete 0.017s (60.000 fps)
            Interval: Discrete 0.033s (30.000 fps)
            Interval: Discrete 0.042s (24.000 fps)
            Interval: Discrete 0.050s (20.000 fps)
            Interval: Discrete 0.067s (15.000 fps)
            Interval: Discrete 0.100s (10.000 fps)
            Interval: Discrete 0.133s (7.500 fps)
            Interval: Discrete 0.200s (5.000 fps)
        Size: Discrete 960x540
            Interval: Discrete 0.017s (60.000 fps)
            Interval: Discrete 0.033s (30.000 fps)
            Interval: Discrete 0.042s (24.000 fps)
            Interval: Discrete 0.050s (20.000 fps)
            Interval: Discrete 0.067s (15.000 fps)
            Interval: Discrete 0.100s (10.000 fps)
            Interval: Discrete 0.133s (7.500 fps)
            Interval: Discrete 0.200s (5.000 fps)
        Size: Discrete 1280x720
            Interval: Discrete 0.017s (60.000 fps)
            Interval: Discrete 0.033s (30.000 fps)
            Interval: Discrete 0.042s (24.000 fps)
            Interval: Discrete 0.050s (20.000 fps)
            Interval: Discrete 0.067s (15.000 fps)
            Interval: Discrete 0.100s (10.000 fps)
            Interval: Discrete 0.133s (7.500 fps)
            Interval: Discrete 0.200s (5.000 fps)
        Size: Discrete 1600x896
            Interval: Discrete 0.017s (60.000 fps)
            Interval: Discrete 0.033s (30.000 fps)
            Interval: Discrete 0.042s (24.000 fps)
            Interval: Discrete 0.050s (20.000 fps)
            Interval: Discrete 0.067s (15.000 fps)
            Interval: Discrete 0.100s (10.000 fps)
            Interval: Discrete 0.133s (7.500 fps)
            Interval: Discrete 0.200s (5.000 fps)
        Size: Discrete 1920x1080
            Interval: Discrete 0.017s (60.000 fps)
            Interval: Discrete 0.033s (30.000 fps)
            Interval: Discrete 0.042s (24.000 fps)
            Interval: Discrete 0.050s (20.000 fps)
            Interval: Discrete 0.067s (15.000 fps)
            Interval: Discrete 0.100s (10.000 fps)
            Interval: Discrete 0.133s (7.500 fps)
            Interval: Discrete 0.200s (5.000 fps)
    [2]: 'NV12' (Y/CbCr 4:2:0)
        Size: Discrete 640x480
            Interval: Discrete 0.033s (30.000 fps)
            Interval: Discrete 0.042s (24.000 fps)
            Interval: Discrete 0.050s (20.000 fps)
            Interval: Discrete 0.067s (15.000 fps)
            Interval: Discrete 0.100s (10.000 fps)
            Interval: Discrete 0.133s (7.500 fps)
            Interval: Discrete 0.200s (5.000 fps)
        Size: Discrete 640x360
            Interval: Discrete 0.033s (30.000 fps)
            Interval: Discrete 0.042s (24.000 fps)
            Interval: Discrete 0.050s (20.000 fps)
            Interval: Discrete 0.067s (15.000 fps)
            Interval: Discrete 0.100s (10.000 fps)
            Interval: Discrete 0.133s (7.500 fps)
            Interval: Discrete 0.200s (5.000 fps)
        Size: Discrete 1280x720
            Interval: Discrete 0.033s (30.000 fps)
            Interval: Discrete 0.042s (24.000 fps)
            Interval: Discrete 0.050s (20.000 fps)
            Interval: Discrete 0.067s (15.000 fps)
            Interval: Discrete 0.100s (10.000 fps)
            Interval: Discrete 0.133s (7.500 fps)
            Interval: Discrete 0.200s (5.000 fps)
        Size: Discrete 1920x1080
            Interval: Discrete 0.033s (30.000 fps)
            Interval: Discrete 0.042s (24.000 fps)
            Interval: Discrete 0.050s (20.000 fps)
            Interval: Discrete 0.067s (15.000 fps)
            Interval: Discrete 0.100s (10.000 fps)
            Interval: Discrete 0.133s (7.500 fps)
            Interval: Discrete 0.200s (5.000 fps)

答案1

我有一个假设,经过测试后,我发现它有效。

我认为问题可能是我的主板或 Xubuntu 操作系统无法正确处理直接 USB-C 连接。因此,我购买了一个 USB-C 转 USB-A 适配器,重要的是它是 3.0 才能获得较高的数据传输速率。现在对我来说一切都正常。

我不知道问题是什么,但我找到了解决方案。希望它可以帮助更多遇到同样问题的用户;)

相关内容