ffmpeg rawvideo编解码器丢帧

ffmpeg rawvideo编解码器丢帧

我有一个EasyCap 采集卡并尝试从摄像机中的 Hi8 磁带中捕获视频。素材以 25 FPS 的速度录制。当我尝试使用该-c:v rawvideo选项进行捕获时,它以 25 FPS 的速度进行捕获,但会出现一些丢帧的情况。但是,如果我使用该-c:v copy选项,它以 50 FPS 的速度进行捕获,但不会丢帧。

我对这种行为感到困惑。为什么使用该选项会丢帧-c:v rawvideo?为什么该-c:v copy选项使用 50 FPS?那么从摄像机捕获视频的正确方法是什么?


代码和输出

使用-c:v rawvideo

$ ffmpeg -f v4l2 -i /dev/video0 -c:v rawvideo -t 00:01:00 a.avi
ffmpeg version n4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 10.1.0 (GCC)
  configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libmfx --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librav1e --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-nvdec --enable-nvenc --enable-omx --enable-shared --enable-version3
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100
Input #0, video4linux2,v4l2, from '/dev/video0':
  Duration: N/A, start: 113727.197262, bitrate: 165888 kb/s
    Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 720x576, 165888 kb/s, 25 fps, 25 tbr, 1000k tbn, 1000k tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> rawvideo (native))
Press [q] to stop, [?] for help
Output #0, avi, to 'a.avi':
  Metadata:
    ISFT            : Lavf58.45.100
    Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 720x576, q=2-31, 165888 kb/s, 25 fps, 25 tbn, 25 tbc
    Metadata:
      encoder         : Lavc58.91.100 rawvideo
frame= 1500 fps= 25 q=-0.0 Lsize= 1215049kB time=00:01:00.00 bitrate=165894.7kbits/s dup=0 drop=1 speed=   1x    
video:1215000kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.004058%

使用-c:v copy

$ ffmpeg -f v4l2 -i /dev/video0 -c:v copy -t 00:01:00 a.avi
ffmpeg version n4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 10.1.0 (GCC)
  configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libmfx --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librav1e --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-nvdec --enable-nvenc --enable-omx --enable-shared --enable-version3
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100
Input #0, video4linux2,v4l2, from '/dev/video0':
  Duration: N/A, start: 113835.003494, bitrate: 165888 kb/s
    Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 720x576, 165888 kb/s, 25 fps, 25 tbr, 1000k tbn, 1000k tbc
Output #0, avi, to 'a.avi':
  Metadata:
    ISFT            : Lavf58.45.100
    Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 720x576, q=2-31, 165888 kb/s, 25 fps, 25 tbr, 50 tbn, 50 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame= 1492 fps= 25 q=-1.0 Lsize= 1208613kB time=00:01:00.00 bitrate=165016.0kbits/s speed=   1x    
video:1208520kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.007716%

答案1

正如@Gyan 在评论中提到的,可以通过将视频-c:v copy保存到.mkv文件而不是 .txt 的选项以正确的帧速率保存视频.avi

不过我还是不确定为什么这个c:v rawvideo选项会导致帧数丢失...

相关内容