尝试使用 FFMPEG 将 webm 视频缩放到其分辨率的 50%,但不断出现错误(顺便说一句,视频具有透明度)

Trying to scale a webm video to 50% of its resolution using FFMPEG but keep getting an error (video has transparency btw)

我正在尝试使用这行命令缩小具有透明度的 webm 视频(基于此 Whosebug 问题中的答案@ ):

ffmpeg -c:v libvpx -i in.webm -c:v libvpx -vf scale=400:416 -auto-alt-ref 0 out.webm

但我不断收到错误消息(例如):

[libvpx @ 00000128eb6123c0] Invalid sync code 310042.
[libvpx @ 00000128eb6123c0] Failed to decode frame: Bitstream not supported by this decoder
Cannot determine format of input stream 0:0 after EOF

完整日志(我删除了大量带有“...”的完全相同的消息):

ffmpeg version 2021-02-02-git-2367affc2c-full_build-www.gyan.dev Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 10.2.0 (Rev6, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-libsnappy --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libdav1d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libglslang --enable-vulkan --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
  libavutil      56. 64.100 / 56. 64.100
  libavcodec     58.120.100 / 58.120.100
  libavformat    58. 65.101 / 58. 65.101
  libavdevice    58. 11.103 / 58. 11.103
  libavfilter     7.101.100 /  7.101.100
  libswscale      5.  8.100 /  5.  8.100
  libswresample   3.  8.100 /  3.  8.100
  libpostproc    55.  8.100 / 55.  8.100
[libvpx @ 00000128eb6123c0] v1.9.0-146-gebb5ffc1d
[libvpx @ 00000128eb6123c0] Invalid sync code 310042.
[libvpx @ 00000128eb6123c0] Failed to decode frame: Bitstream not supported by this decoder
[libvpx @ 00000128eb6123c0] Invalid sync code 007a49.
[libvpx @ 00000128eb6123c0] Failed to decode frame: Bitstream not supported by this decoder
[libvpx @ 00000128eb6123c0] Invalid sync code 01f096.
[libvpx @ 00000128eb6123c0] Failed to decode frame: Bitstream not supported by this decoder
...
...
...
[libvpx @ 00000128eb6123c0] Invalid sync code 01f096.
[libvpx @ 00000128eb6123c0] Failed to decode frame: Bitstream not supported by this decoder
[libvpx @ 00000128eb6123c0] Invalid sync code 01f096.
[libvpx @ 00000128eb6123c0] Failed to decode frame: Bitstream not supported by this decoder
[libvpx @ 00000128eb6123c0] Invalid sync code 01f096.
[libvpx @ 00000128eb6123c0] Failed to decode frame: Bitstream not supported by this decoder
[libvpx @ 00000128eb6123c0] Invalid sync code 01f096.
[matroska,webm @ 00000128eb60f040] decoding for stream 0 failed
[matroska,webm @ 00000128eb60f040] Could not find codec parameters for stream 0 (Video: vp8 (libvpx), none(progressive), 800x832): unspecified pixel format
Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options
Input #0, matroska,webm, from 'in.webm':
  Metadata:
    encoder         : libwebm-0.2.1.0
    creation_time   : 2017-12-02T12:06:12.000000Z
  Duration: 00:00:10.00, start: 0.000000, bitrate: 2592 kb/s
    Stream #0:0(eng): Video: vp8, none(progressive), 800x832, SAR 1:1 DAR 25:26, 30 fps, 30 tbr, 1k tbn, 1k tbc (default)
    Metadata:
      alpha_mode      : 1
[libvpx @ 00000128eb612a40] v1.9.0-146-gebb5ffc1d
Stream mapping:
  Stream #0:0 -> #0:0 (vp8 (libvpx) -> vp8 (libvpx))
Press [q] to stop, [?] for help
[libvpx @ 00000128eb612a40] Failed to decode frame: Bitstream not supported by this decoder
Error while decoding stream #0:0: Invalid data found when processing input
[libvpx @ 00000128eb612a40] Failed to decode frame: Bitstream not supported by this decoder
Error while decoding stream #0:0: Invalid data found when processing input
[libvpx @ 00000128eb612a40] Failed to decode frame: Bitstream not supported by this decoder
...
...
...
Error while decoding stream #0:0: Invalid data found when processing input
[NULL @ 00000128eb6123c0] Invalid sync code 01f096.
[libvpx @ 00000128eb612a40] Failed to decode frame: Bitstream not supported by this decoder
Error while decoding stream #0:0: Invalid data found when processing input
[NULL @ 00000128eb6123c0] Invalid sync code 01f096.
[libvpx @ 00000128eb612a40] Failed to decode frame: Bitstream not supported by this decoder
Error while decoding stream #0:0: Invalid data found when processing input
[NULL @ 00000128eb6123c0] Invalid sync code 009c96.
[libvpx @ 00000128eb612a40] Failed to decode frame: Bitstream not supported by this decoder
Error while decoding stream #0:0: Invalid data found when processing input
Cannot determine format of input stream 0:0 after EOF
Error marking filters as finished
Conversion failed!

ffmpeg -i input.webm 的日志:

ffmpeg version 2021-02-02-git-2367affc2c-full_build-www.gyan.dev Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 10.2.0 (Rev6, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-libsnappy --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libdav1d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libglslang --enable-vulkan --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
  libavutil      56. 64.100 / 56. 64.100
  libavcodec     58.120.100 / 58.120.100
  libavformat    58. 65.101 / 58. 65.101
  libavdevice    58. 11.103 / 58. 11.103
  libavfilter     7.101.100 /  7.101.100
  libswscale      5.  8.100 /  5.  8.100
  libswresample   3.  8.100 /  3.  8.100
  libpostproc    55.  8.100 / 55.  8.100
Input #0, matroska,webm, from 'input.webm':
  Metadata:
    encoder         : libwebm-0.2.1.0
    creation_time   : 2017-12-02T12:06:12.000000Z
  Duration: 00:00:10.00, start: 0.000000, bitrate: 2592 kb/s
    Stream #0:0(eng): Video: vp9 (Profile 0), yuv420p(tv), 800x832, SAR 1:1 DAR 25:26, 30 fps, 30 tbr, 1k tbn, 1k tbc (default)
    Metadata:
      alpha_mode      : 1
At least one output file must be specified

使用

ffmpeg -c:v libvpx-vp9 -i in.webm -c:v libvpx -vf scale=400:416 -auto-alt-ref 0 out.webm

输入视频是VP9,而libvpx解码器是VP8。

如果你想要 VP9 流,对输出做同样的事情。