FFMPEG > 转码后的视频帧数不足

FFMPEG > 转码后的视频帧数不足

我正在尝试对视频进行转码(通过电话以流式传输模式通过 javascript 媒体记录器接收)以使用 VP9 编解码器,同时解决对这些视频时长的担忧,我使用的 ffmpeg 命令如下:

ffmpeg -i video-input -map 0 -crf 40 -deadline realtime -threads 8 -cpu-used 8 -b:v 0 -movflags +faststart -row-mt 1 -c:v libvpx-vp9 video-output;

该命令适用于大多数视频,除了某些视频外,转码后的视频与输入视频相比包含的帧很少,输入视频大小为 29MB,而输出只有 80KB。

ffmpeg 不返回错误消息

转换失败时 fffmpeg 命令的输出:

    ffmpeg version 5.1.3 Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 11 (GCC)
  configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --docdir=/usr/share/doc/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64-v2 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' --extra-ldflags='-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 ' --extra-cflags=' -I/usr/include/rav1e' --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 --enable-bzlib --enable-chromaprint --disable-crystalhd --enable-fontconfig --enable-frei0r --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libaom --enable-libdav1d --enable-libass --enable-libbluray --enable-libbs2b --enable-libcdio --enable-libdrm --enable-libjack --enable-libjxl --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libilbc --enable-libmp3lame --enable-libmysofa --enable-nvenc --enable-openal --enable-opencl --enable-opengl --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librav1e --enable-librubberband --enable-libsmbclient --enable-version3 --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtesseract --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-version3 --enable-vapoursynth --enable-libvpx --enable-vulkan --enable-libshaderc --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libxml2 --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-avfilter --enable-libmodplug --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-lto --enable-libmfx --enable-runtime-cpudetect
  libavutil      57. 28.100 / 57. 28.100
  libavcodec     59. 37.100 / 59. 37.100
  libavformat    59. 27.100 / 59. 27.100
  libavdevice    59.  7.100 / 59.  7.100
  libavfilter     8. 44.100 /  8. 44.100
  libswscale      6.  7.100 /  6.  7.100
  libswresample   4.  7.100 /  4.  7.100
  libpostproc    56.  6.100 / 56.  6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/video-input':
  Metadata:
    major_brand     : iso5
    minor_version   : 1
    compatible_brands: isomiso5hlsf
    creation_time   : 2024-03-17T19:39:41.000000Z
  Duration: 1988:25:02.86, start: 0.000000, bitrate: 0 kb/s
  Stream #0:0[0x1](und): Video: h264 (Baseline) (avc1 / 0x31637661), yuvj420p(pc, progressive), 1280x720, 0 kb/s, 0.0001 fps, 600 tbr, 600 tbn (default)
    Metadata:
      creation_time   : 2024-03-17T19:39:41.000000Z
      handler_name    : Core Media Video
      vendor_id       : [0][0][0][0]
    Side data:
      displaymatrix: rotation of -90.00 degrees
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> vp9 (libvpx-vp9))
Press [q] to stop, [?] for help
[swscaler @ 0x55e0f943c5c0] [swscaler @ 0x55e0f944aa40] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55e0f943c5c0] [swscaler @ 0x55e0f9479500] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55e0f943c5c0] [swscaler @ 0x55e0f94a7340] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55e0f943c5c0] [swscaler @ 0x55e0f94d5980] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55e0f943c5c0] [swscaler @ 0x55e0f9503fc0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55e0f943c5c0] [swscaler @ 0x55e0f9531e00] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55e0f943c5c0] [swscaler @ 0x55e0f9560440] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55e0f943c5c0] [swscaler @ 0x55e0f958ea80] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55e0f943c5c0] [swscaler @ 0x55e0f95a1600] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55e0f943c5c0] [swscaler @ 0x55e0f9554f80] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55e0f943c5c0] [swscaler @ 0x55e0f94fe4c0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55e0f943c5c0] [swscaler @ 0x55e0f9588440] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55e0f943c5c0] [swscaler @ 0x55e0f952e340] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55e0f943c5c0] [swscaler @ 0x55e0f9462700] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55e0f943c5c0] [swscaler @ 0x55e0f9492540] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55e0f943c5c0] [swscaler @ 0x55e0f94c0380] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55e0f943c5c0] [swscaler @ 0x55e0f94d6d80] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55e0f943c5c0] [swscaler @ 0x55e0f9548d00] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55e0f943c5c0] [swscaler @ 0x55e0f94ec540] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55e0f943c5c0] [swscaler @ 0x55e0f9573580] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55e0f943c5c0] [swscaler @ 0x55e0f9519380] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55e0f943c5c0] [swscaler @ 0x55e0f944d2c0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55e0f943c5c0] [swscaler @ 0x55e0f947b140] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55e0f943c5c0] [swscaler @ 0x55e0f94ab740] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55e0f943c5c0] [swscaler @ 0x55e0f94d6d80] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55e0f943c5c0] [swscaler @ 0x55e0f9548d00] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55e0f943c5c0] [swscaler @ 0x55e0f94ec540] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55e0f943c5c0] [swscaler @ 0x55e0f9573580] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55e0f943c5c0] [swscaler @ 0x55e0f9519380] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55e0f943c5c0] [swscaler @ 0x55e0f944d2c0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55e0f943c5c0] [swscaler @ 0x55e0f947b140] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x55e0f943c5c0] [swscaler @ 0x55e0f94ab740] deprecated pixel format used, make sure you did set range correctly
[libvpx-vp9 @ 0x55e0f80371c0] v1.9.0
Output #0, webm, to '/video-output.webm':
  Metadata:
    major_brand     : iso5
    minor_version   : 1
    compatible_brands: isomiso5hlsf
    encoder         : Lavf59.27.100
  Stream #0:0(und): Video: vp9, yuv420p(tv, progressive), 720x1280, q=2-31, 0.0001 fps, 1k tbn (default)
    Metadata:
      creation_time   : 2024-03-17T19:39:41.000000Z
      handler_name    : Core Media Video
      vendor_id       : [0][0][0][0]
      encoder         : Lavc59.37.100 libvpx-vp9
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
      displaymatrix: rotation of -0.00 degrees
frame=    1 fps=0.0 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=    2 fps=0.0 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A dup=0 drop=471 speed=   0x    
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55e0f8010cc0] DTS 14421 < 14422 out of order
frame=    2 fps=0.0 q=40.0 Lsize=      38kB time=02:43:52.83 bitrate=   0.0kbits/s dup=0 drop=725 speed=1.22e+04x    
video:37kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.819037%

转换成功后 fffmpeg 命令的输出如下:

ffmpeg version 5.1.4 Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 11 (GCC)
  configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --docdir=/usr/share/doc/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64-v2 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' --extra-ldflags='-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 ' --extra-cflags=' -I/usr/include/rav1e' --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 --enable-bzlib --disable-crystalhd --enable-fontconfig --enable-frei0r --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libaom --enable-libdav1d --enable-libass --enable-libbluray --enable-libcdio --enable-libdrm --enable-libjack --enable-libjxl --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-nvenc --enable-openal --enable-opencl --enable-opengl --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-version3 --enable-vapoursynth --enable-libvpx --enable-vulkan --enable-libshaderc --enable-libx264 --enable-libx265 --enable-libxvid --enable-libxml2 --enable-libzimg --enable-libzvbi --enable-lv2 --enable-avfilter --enable-libmodplug --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-lto --enable-libmfx --enable-runtime-cpudetect
  libavutil      57. 28.100 / 57. 28.100
  libavcodec     59. 37.100 / 59. 37.100
  libavformat    59. 27.100 / 59. 27.100
  libavdevice    59.  7.100 / 59.  7.100
  libavfilter     8. 44.100 /  8. 44.100
  libswscale      6.  7.100 /  6.  7.100
  libswresample   4.  7.100 /  4.  7.100
  libpostproc    56.  6.100 / 56.  6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/video-input':
  Metadata:
    major_brand     : iso5
    minor_version   : 1
    compatible_brands: isomiso5hlsf
    creation_time   : 2024-01-19T08:29:28.000000Z
  Duration: 00:00:19.47, start: 0.000000, bitrate: 9967 kb/s
  Stream #0:0[0x1](und): Video: h264 (Baseline) (avc1 / 0x31637661), yuvj420p(pc, progressive), 1280x720, 9964 kb/s, 30.05 fps, 30 tbr, 600 tbn (default)
    Metadata:
      creation_time   : 2024-01-19T08:29:28.000000Z
      handler_name    : Core Media Video
      vendor_id       : [0][0][0][0]
    Side data:
      displaymatrix: rotation of -90.00 degrees
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> vp9 (libvpx-vp9))
Press [q] to stop, [?] for help
[swscaler @ 0x5624f2cdb900] [swscaler @ 0x5624f2ce9680] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x5624f2cdb900] [swscaler @ 0x5624f2d18100] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x5624f2cdb900] [swscaler @ 0x5624f2d46740] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x5624f2cdb900] [swscaler @ 0x5624f2d74580] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x5624f2cdb900] [swscaler @ 0x5624f2da2bc0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x5624f2cdb900] [swscaler @ 0x5624f2dd1200] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x5624f2cdb900] [swscaler @ 0x5624f2ce9680] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x5624f2cdb900] [swscaler @ 0x5624f2d00940] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x5624f2cdb900] [swscaler @ 0x5624f2d2f000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x5624f2cdb900] [swscaler @ 0x5624f2db5d00] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x5624f2cdb900] [swscaler @ 0x5624f2d89f00] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x5624f2cdb900] [swscaler @ 0x5624f2d5bb00] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x5624f2cdb900] [swscaler @ 0x5624f2d592c0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x5624f2cdb900] [swscaler @ 0x5624f2de3d80] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x5624f2cdb900] [swscaler @ 0x5624f2d00940] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x5624f2cdb900] [swscaler @ 0x5624f2d2f000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x5624f2cdb900] [swscaler @ 0x5624f2db5d00] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x5624f2cdb900] [swscaler @ 0x5624f2d89f00] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x5624f2cdb900] [swscaler @ 0x5624f2d592c0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x5624f2cdb900] [swscaler @ 0x5624f2de3d80] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x5624f2cdb900] [swscaler @ 0x5624f2d00940] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x5624f2cdb900] [swscaler @ 0x5624f2d2f000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x5624f2cdb900] [swscaler @ 0x5624f2db5d00] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x5624f2cdb900] [swscaler @ 0x5624f2d89f00] deprecated pixel format used, make sure you did set range correctly
[libvpx-vp9 @ 0x5624f1b5e400] v1.9.0
Output #0, webm, to 'video-output.webm':
  Metadata:
    major_brand     : iso5
    minor_version   : 1
    compatible_brands: isomiso5hlsf
    encoder         : Lavf59.27.100
  Stream #0:0(und): Video: vp9, yuv420p(tv, progressive), 720x1280, q=2-31, 30 fps, 1k tbn (default)
    Metadata:
      creation_time   : 2024-01-19T08:29:28.000000Z
      handler_name    : Core Media Video
      vendor_id       : [0][0][0][0]
      encoder         : Lavc59.37.100 libvpx-vp9
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
      displaymatrix: rotation of -0.00 degrees
frame=    1 fps=0.0 q=0.0 size=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
frame=   55 fps=0.0 q=31.0 size=       1kB time=00:00:01.00 bitrate=   5.1kbits/s speed=1.94x    
frame=  117 fps=114 q=35.0 size=       1kB time=00:00:03.13 bitrate=   1.6kbits/s dup=0 drop=1 speed=3.06x    
frame=  160 fps=105 q=40.0 size=     512kB time=00:00:04.56 bitrate= 918.2kbits/s dup=0 drop=1 speed=2.99x    
frame=  223 fps=110 q=38.0 size=     512kB time=00:00:06.66 bitrate= 629.0kbits/s dup=0 drop=1 speed=3.28x    
frame=  288 fps=113 q=40.0 size=    1024kB time=00:00:08.83 bitrate= 949.6kbits/s dup=0 drop=2 speed=3.48x    
frame=  350 fps=115 q=40.0 size=    1024kB time=00:00:10.93 bitrate= 767.2kbits/s dup=0 drop=2 speed=3.59x    
frame=  412 fps=116 q=40.0 size=    1280kB time=00:00:13.00 bitrate= 806.5kbits/s dup=0 drop=2 speed=3.66x    
frame=  476 fps=118 q=40.0 size=    1280kB time=00:00:15.13 bitrate= 692.9kbits/s dup=0 drop=2 speed=3.74x    
frame=  532 fps=117 q=40.0 size=    1280kB time=00:00:17.00 bitrate= 616.8kbits/s dup=0 drop=3 speed=3.74x    
frame=  582 fps=116 q=40.0 Lsize=    2098kB time=00:00:19.50 bitrate= 881.4kbits/s dup=0 drop=3 speed= 3.9x    
video:2093kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.227047%

你能帮我吗?非常感谢

相关内容