FFmpeg 可以从 uvc /dev/video0 以除 1920x1080 之外的任何分辨率捕获

FFmpeg 可以从 uvc /dev/video0 以除 1920x1080 之外的任何分辨率捕获

基本上,问题在于 FFmpeg 无法在我的 Linux 系统上捕获 1920x1080,而其他视频捕获应用程序可以,但 FFmpeg 可以成功从同一系统上的同一设备捕获其他分辨率。很奇怪。我尝试了许多 FFmpeg 命令行组合,念了很多咒语,但都没有解决问题。

我在配备 16GB RAM 的 Ryzen 2200G 上的 Ubuntu 19.04 桌面上使用 FFmpeg。

我的目标是创建一个可以在网络浏览器中显示的 H264 mp4 视频,数据来自 USB UVC 设备。生成的文件应该可以在 Windows 上的 QuickTime 播放器和网络浏览器中正常播放。

以下是有关我的设置和已知用途的一些事实:

  1. 我有一个 HDMI UVC 转 USB 设备,可以输入 4K 视频。
  2. 当我使用 FFmpeg 以任何分辨率(除 1920x1080 外)捕获视频时,FFmpeg 都可以正常工作
  3. FFmpeg 也能很好地捕获 4k 输入以及所有较低分辨率
  4. gstreamer 似乎能够捕获数据 - 它创建了一个巨大的文件(参见下面的附录 1 输出)
  5. Ubuntu 的桌面 guvcview 程序可以毫无问题地显示来自 uvc 设备的视频,并且不需要任何特殊配置。
  6. 我使用命令行模式下的 Ubuntu 桌面 guvcview 程序从 1920x1080 的 uvc 设备捕获视频,并且处理得很好。

附录 1:uvc 设备

ubuntu@render001:~$ ls /dev/vid*
/dev/video0  /dev/video1

附录 2:uvc 设备信息

ubuntu@render001:~$ v4l2-ctl --all
Driver Info:
Driver name      : uvcvideo
Card type        : Cam Link 4K: Cam Link 4K
Bus info         : usb-0000:08:00.3-4
Driver version   : 5.0.8
Capabilities     : 0x84a00001
Video Capture
Metadata Capture
Streaming
Extended Pix Format
Device Capabilities
Device Caps      : 0x04200001
Video Capture
Streaming
Extended Pix Format
Priority: 2
Video input : 0 (Input 1: ok)
Format Video Capture:
Width/Height      : 1920/1080
Pixel Format      : 'YUYV' (YUYV 4:2:2)
Field             : None
Bytes per Line    : 3840
Size Image        : 4147200
Colorspace        : sRGB
Transfer Function : Default (maps to sRGB)
YCbCr/HSV Encoding: Default (maps to ITU-R 601)
Quantization      : Default (maps to Limited Range)
Flags             :
Crop Capability Video Capture:
Bounds      : Left 0, Top 0, Width 1920, Height 1080
Default     : Left 0, Top 0, Width 1920, Height 1080
Pixel Aspect: 1/1
Selection: crop_default, Left 0, Top 0, Width 1920, Height 1080, Flags:
Selection: crop_bounds, Left 0, Top 0, Width 1920, Height 1080, Flags:
Streaming Parameters Video Capture:
Capabilities     : timeperframe
Frames per second: 60.000 (60/1)
Read buffers     : 0
                     brightness 0x00980900 (int)    : min=0 max=255 step=1 default=128 value=128
                       contrast 0x00980901 (int)    : min=0 max=255 step=1 default=128 value=128
                     saturation 0x00980902 (int)    : min=0 max=255 step=1 default=128 value=128
                            hue 0x00980903 (int)    : min=0 max=255 step=1 default=128 value=128

附录3:失败的FFmpeg案例输出

ubuntu@render001:~$ ffmpeg -y -t 5 -f video4linux2  -i /dev/video0  out.mov
ffmpeg version N-94046-gc9c1711 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 8 (Ubuntu 8.3.0-6ubuntu1)
  configuration: --prefix=/home/ubuntu/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/ubuntu/ffmpeg_build/include --extra-ldflags=-L/home/ubuntu/ffmpeg_build/lib --extra-libs='-lpthread -lm' --bindir=/home/ubuntu/bin --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree
  libavutil      56. 28.100 / 56. 28.100
  libavcodec     58. 53.100 / 58. 53.100
  libavformat    58. 27.103 / 58. 27.103
  libavdevice    58.  7.100 / 58.  7.100
  libavfilter     7. 55.100 /  7. 55.100
  libswscale      5.  4.101 /  5.  4.101
  libswresample   3.  4.100 /  3.  4.100
  libpostproc    55.  4.100 / 55.  4.100

重要的提示:此时FFmpeg挂了,按Control+后显示如下C

Input #0, video4linux2,v4l2, from '/dev/video0':
  Duration: N/A, bitrate: 1492992 kb/s
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1920x1080, 1492992 kb/s, 60 fps, 60 tbr, 1000k tbn, 1000k tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
Press [q] to stop, [?] for help
Finishing stream 0:0 without any data written to it.
[libx264 @ 0x55efe29a1c00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x55efe29a1c00] profile High, level 4.2
[libx264 @ 0x55efe29a1c00] 264 - core 155 r2917 0a84d98 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mov, to 'out.mov':
  Metadata:
    encoder         : Lavf58.27.103
    Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1920x1080, q=-1--1, 60 fps, 15360 tbn, 60 tbc
    Metadata:
      encoder         : Lavc58.53.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
frame=    0 fps=0.0 q=0.0 Lsize=       0kB time=00:00:00.00 bitrate=N/A speed=   0x
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Exiting normally, received signal 2.

附录 4:成功的 FFmpeg 案例输出 - 请注意,唯一的区别是 UVC 设备输入的分辨率更改为 3840x2160。输出的 .mov 文件可以在 Quicktime 播放器或浏览器中正常播放。

ffmpeg -y -t 5 -f video4linux2  -i /dev/video0  out.mov
ffmpeg version N-94046-gc9c1711 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 8 (Ubuntu 8.3.0-6ubuntu1)
  configuration: --prefix=/home/ubuntu/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/ubuntu/ffmpeg_build/include --extra-ldflags=-L/home/ubuntu/ffmpeg_build/lib --extra-libs='-lpthread -lm' --bindir=/home/ubuntu/bin --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree
  libavutil      56. 28.100 / 56. 28.100
  libavcodec     58. 53.100 / 58. 53.100
  libavformat    58. 27.103 / 58. 27.103
  libavdevice    58.  7.100 / 58.  7.100
  libavfilter     7. 55.100 /  7. 55.100
  libswscale      5.  4.101 /  5.  4.101
  libswresample   3.  4.100 /  3.  4.100
  libpostproc    55.  4.100 / 55.  4.100
Input #0, video4linux2,v4l2, from '/dev/video0':
  Duration: N/A, start: 625.791663, bitrate: 2985984 kb/s
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 3840x2160, 2985984 kb/s, 30 fps, 30 tbr, 1000k tbn, 1000k tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 @ 0x5586ca510300] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x5586ca510300] profile High, level 5.1
[libx264 @ 0x5586ca510300] 264 - core 155 r2917 0a84d98 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mov, to 'out.mov':
  Metadata:
    encoder         : Lavf58.27.103
    Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 3840x2160, q=-1--1, 30 fps, 15360 tbn, 30 tbc
    Metadata:
      encoder         : Lavc58.53.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
frame=  151 fps= 18 q=-1.0 Lsize=     476kB time=00:00:04.93 bitrate= 791.1kbits/s dup=11 drop=0 speed=0.588x
video:474kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.538915%
[libx264 @ 0x5586ca510300] frame I:1     Avg QP:19.12  size:115507
[libx264 @ 0x5586ca510300] frame P:38    Avg QP:18.89  size:  6063
[libx264 @ 0x5586ca510300] frame B:112   Avg QP:21.48  size:  1238
[libx264 @ 0x5586ca510300] consecutive B-frames:  0.7%  1.3%  0.0% 98.0%
[libx264 @ 0x5586ca510300] mb I  I16..4: 23.5% 70.7%  5.8%
[libx264 @ 0x5586ca510300] mb P  I16..4:  0.1%  0.1%  0.0%  P16..4:  9.8%  0.0%  0.3%  0.0%  0.0%    skip:89.6%
[libx264 @ 0x5586ca510300] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  2.6%  0.0%  0.0%  direct: 0.0%  skip:97.4%  L0:34.6% L1:65.4% BI: 0.0%
[libx264 @ 0x5586ca510300] 8x8 transform intra:69.0% inter:99.8%
[libx264 @ 0x5586ca510300] coded y,uvDC,uvAC intra: 21.6% 55.2% 9.8% inter: 0.4% 3.0% 0.0%
[libx264 @ 0x5586ca510300] i16 v,h,dc,p: 56% 32%  7%  5%
[libx264 @ 0x5586ca510300] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 39% 10% 42%  2%  2%  1%  2%  1%  1%
[libx264 @ 0x5586ca510300] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 41% 12% 21%  7%  5%  4%  5%  5%  1%
[libx264 @ 0x5586ca510300] i8c dc,h,v,p: 60% 25% 14%  2%
[libx264 @ 0x5586ca510300] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x5586ca510300] ref P L0: 81.0%  0.3% 15.1%  3.6%
[libx264 @ 0x5586ca510300] ref B L0: 68.4% 31.5%  0.2%
[libx264 @ 0x5586ca510300] ref B L1: 99.5%  0.5%
[libx264 @ 0x5586ca510300] kb/s:770.14
ubuntu@render001:~$

附录7:成功的gstreamer案例输出

ubuntu@render001:~$ gst-launch-1.0 -v v4l2src device=/dev/video0 ! video/x-raw,framerate=60/1,width=1920,height=1080 ! filesink location=gopro2.mp4
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
/GstPipeline:pipeline0/GstV4l2Src:v4l2src0.GstPad:src: caps = video/x-raw, framerate=(fraction)60/1, width=(int)1920, height=(int)1080, format=(string)YUY2, pixel-aspect-ratio=(fraction)1/1, colorimetry=(string)bt709, interlace-mode=(string)progressive
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:src: caps = video/x-raw, framerate=(fraction)60/1, width=(int)1920, height=(int)1080, format=(string)YUY2, pixel-aspect-ratio=(fraction)1/1, colorimetry=(string)bt709, interlace-mode=(string)progressive
/GstPipeline:pipeline0/GstFileSink:filesink0.GstPad:sink: caps = video/x-raw, framerate=(fraction)60/1, width=(int)1920, height=(int)1080, format=(string)YUY2, pixel-aspect-ratio=(fraction)1/1, colorimetry=(string)bt709, interlace-mode=(string)progressive
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:sink: caps = video/x-raw, framerate=(fraction)60/1, width=(int)1920, height=(int)1080, format=(string)YUY2, pixel-aspect-ratio=(fraction)1/1, colorimetry=(string)bt709, interlace-mode=(string)progressive
^Chandling interrupt.
Interrupt: Stopping pipeline ...
Execution ended after 0:00:02.464259973
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...
ubuntu@render001:~$ ls -lah gopro2.mp4
-rw-rw-r-- 1 ubuntu ubuntu 550M Jun 16 12:33 gopro2.mp4
ubuntu@render001:~$

附录8:成功的guvcview案例输出

ubuntu@render001:~$ guvcview --device=/dev/video0 --video=./guvcoutput.mkv --video_timer=5 --exit_on_term --verbosity=10
GUVCVIEW: version 2.0.6
GUVCVIEW: language catalog=> dir:/usr/share/locale type:en_AU.UTF-8 

完整附录 7输出日志继续在这里

以下是一些可能有用的 FFmpeg 信息也一样。

编辑回复评论:

ubuntu@render001:~$ ffmpeg -f v4l2 -list_formats all -i /dev/video0
ffmpeg version N-94046-gc9c1711 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 8 (Ubuntu 8.3.0-6ubuntu1)
  configuration: --prefix=/home/ubuntu/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/ubuntu/ffmpeg_build/include --extra-ldflags=-L/home/ubuntu/ffmpeg_build/lib --extra-libs='-lpthread -lm' --bindir=/home/ubuntu/bin --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree
  libavutil      56. 28.100 / 56. 28.100
  libavcodec     58. 53.100 / 58. 53.100
  libavformat    58. 27.103 / 58. 27.103
  libavdevice    58.  7.100 / 58.  7.100
  libavfilter     7. 55.100 /  7. 55.100
  libswscale      5.  4.101 /  5.  4.101
  libswresample   3.  4.100 /  3.  4.100
  libpostproc    55.  4.100 / 55.  4.100
[video4linux2,v4l2 @ 0x55fddc42a940] Raw       :     yuyv422 :           YUYV 4:2:2 : 1920x1080
[video4linux2,v4l2 @ 0x55fddc42a940] Raw       :        nv12 :         Y/CbCr 4:2:0 : 1920x1080
[video4linux2,v4l2 @ 0x55fddc42a940] Raw       :     yuv420p :     Planar YUV 4:2:0 : 1920x1080
/dev/video0: Immediate exit requested

答案1

根据 FFmpeg 报告的支持格式:

ubuntu@render001:~$ ffmpeg -f v4l2 -list_formats all -i /dev/video0
ffmpeg version N-94046-gc9c1711 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 8 (Ubuntu 8.3.0-6ubuntu1)
  configuration: --prefix=/home/ubuntu/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/ubuntu/ffmpeg_build/include --extra-ldflags=-L/home/ubuntu/ffmpeg_build/lib --extra-libs='-lpthread -lm' --bindir=/home/ubuntu/bin --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree
  libavutil      56. 28.100 / 56. 28.100
  libavcodec     58. 53.100 / 58. 53.100
  libavformat    58. 27.103 / 58. 27.103
  libavdevice    58.  7.100 / 58.  7.100
  libavfilter     7. 55.100 /  7. 55.100
  libswscale      5.  4.101 /  5.  4.101
  libswresample   3.  4.100 /  3.  4.100
  libpostproc    55.  4.100 / 55.  4.100
[video4linux2,v4l2 @ 0x55fddc42a940] Raw       :     yuyv422 :           YUYV 4:2:2 : 1920x1080
[video4linux2,v4l2 @ 0x55fddc42a940] Raw       :        nv12 :         Y/CbCr 4:2:0 : 1920x1080
[video4linux2,v4l2 @ 0x55fddc42a940] Raw       :     yuv420p :     Planar YUV 4:2:0 : 1920x1080
/dev/video0: Immediate exit requested

使用以下方法验证相同v4l2

v4l2-ctl -d 0 --list-formats-ext

以我的 Microsoft Lifecam 为例:

ioctl: VIDIOC_ENUM_FMT
    Index       : 0
    Type        : Video Capture
    Pixel Format: 'YUYV'
    Name        : YUYV 4:2:2
        Size: Discrete 640x480
            Interval: Discrete 0.033s (30.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)
        Size: Discrete 1280x720
            Interval: Discrete 0.100s (10.000 fps)
            Interval: Discrete 0.133s (7.500 fps)
        Size: Discrete 960x544
            Interval: Discrete 0.067s (15.000 fps)
            Interval: Discrete 0.100s (10.000 fps)
            Interval: Discrete 0.133s (7.500 fps)
        Size: Discrete 800x448
            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)
        Size: Discrete 640x360
            Interval: Discrete 0.033s (30.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)
        Size: Discrete 424x240
            Interval: Discrete 0.033s (30.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)
        Size: Discrete 352x288
            Interval: Discrete 0.033s (30.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)
        Size: Discrete 320x240
            Interval: Discrete 0.033s (30.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)
        Size: Discrete 800x600
            Interval: Discrete 0.067s (15.000 fps)
            Interval: Discrete 0.100s (10.000 fps)
            Interval: Discrete 0.133s (7.500 fps)
        Size: Discrete 176x144
            Interval: Discrete 0.033s (30.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)
        Size: Discrete 160x120
            Interval: Discrete 0.033s (30.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)
        Size: Discrete 1280x800
            Interval: Discrete 0.100s (10.000 fps)

    Index       : 1
    Type        : Video Capture
    Pixel Format: 'MJPG' (compressed)
    Name        : Motion-JPEG
        Size: Discrete 640x480
            Interval: Discrete 0.033s (30.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)
        Size: Discrete 1280x720
            Interval: Discrete 0.033s (30.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)
        Size: Discrete 960x544
            Interval: Discrete 0.033s (30.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)
        Size: Discrete 800x448
            Interval: Discrete 0.033s (30.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)
        Size: Discrete 640x360
            Interval: Discrete 0.033s (30.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)
        Size: Discrete 800x600
            Interval: Discrete 0.033s (30.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)
        Size: Discrete 416x240
            Interval: Discrete 0.033s (30.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)
        Size: Discrete 352x288
            Interval: Discrete 0.033s (30.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)
        Size: Discrete 176x144
            Interval: Discrete 0.033s (30.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)
        Size: Discrete 320x240
            Interval: Discrete 0.033s (30.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)
        Size: Discrete 160x120
            Interval: Discrete 0.033s (30.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)

您将看到,每种像素格式都有一个支持的帧速率。在这种情况下(可能也与您的情况相同),只有网络摄像头中的 mjpeg 编码器及其输出格式支持高帧速率(在我的情况下为 30fps)。

如果未指定所需的输入格式,则会导致帧速率不正确,即使-framerate明确指定了选项也是如此。如果指定了参数,情况也是如此-video_sizeuvc视频驱动程序只是忽略不支持的输出选项,这些输出选项主要受请求的格式控制(参见上面的示例)。

您可以使用以下代码片段:

ffmpeg -y -t 15 -f video4linux2 -video_size 1920x1080 -input_format nv12 -timestamps abs -use_libv4l2 1 -i /dev/video0 out.mov

並报告。

相关内容