透明地将 mp4 转换为 webm?

Convert mp4 to webm with transparency?

我知道如何 convert mp4 to webm with ffmpeg:

ffmpeg -y -i me939371029.mp4 -r 30  out3.webm

但我想使用 webm transparency。该指南使用 Blender,但 Blender 是一种不容易自动化的桌面工具,只能输出必须转换为视频的 PNG。 我想要一个接受视频输入、颜色和视频输出的命令行应用程序。 例如:

some-app -i video.mp4 -transparent ff0000 -o video.webm

如果 ffmpeg 中没有这样的东西我会感到惊讶,但我似乎找不到它。

假设要抠出的颜色是00ff00,使用

ffmpeg -i input.mp4 -c:v libvpx -vf "colorkey=0x00ff00:0.1:0.1,format=yuva420p" out.webm

colorkey=0x00ff00:0.1:0.1

部分由 : 分隔。第一部分是关键颜色。颜色

0x00ff00

是绿色的。

第二个是相似度

0.01 matches only the exact key color, while 1.0 matches everything.

第三个是混合百分比

0.0 makes pixels either fully transparent, or not transparent at all.

Higher values result in semi-transparent pixels, with a higher transparency the more similar the pixels color is to the key color.

ffmpeg colorkey documentation


正在解决auto_alt_ref错误

当您 运行 进入错误提示时: Transparency encoding with auto_alt_ref does not work Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

您可以通过添加参数 -auto-alt-ref 0

来禁用 auto_alt_ref