video - 使用ffmpeg从mp4文件转换后如何获得具有透明背景填充的动画webp文件?

标签 video ffmpeg h.264 webp

我需要将 mp4 视频 (1280×720) 转换为 webp 文件 (512x512),以便生成的 webp 文件保持纵横比并完全包含在 512x512 中,顶部和底部未覆盖的区域应该是透明的。

我尝试了以下 ffmpeg 命令:

ffmpeg -i sample.mp4 
-vcodec libwebp -filter:v fps=fps=20 -lossless 1 -loop 0 -preset default -an -vsync 0 -vf 
scale=512:512:force_original_aspect_ratio=decrease,pad=512:512:-1:-1:color=#00000000 sample.webp

在上面的命令中请注意pad=512:512:-1:-1:color=#00000000 我给了 alpha 值 00 但它只输出黑色。

我也引用了这个网站https://ffmpeg.org/ffmpeg-utils.html#color-syntax它说

It can be the name of a color as defined below (case insensitive match) or a [0x|#]RRGGBB[AA] sequence, possibly followed by @ and a string representing the alpha component. The alpha component may be a string composed of "0x" followed by a hexadecimal number or a decimal number between 0.0 and 1.0, which represents the opacity value (‘0x00’ or ‘0.0’ means completely transparent, ‘0xff’ or ‘1.0’ completely opaque). If the alpha component is not specified then ‘0xff’ is assumed.

我尝试了 color=0x000000@0x00color=0x000000@0.0 但结果是不透明的黑色。

最佳答案

我只是在 pad format=rgba,pad 之前缺少格式过滤器

关于video - 使用ffmpeg从mp4文件转换后如何获得具有透明背景填充的动画webp文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66144707/

相关文章:

c++ - 在不重新编码的情况下保存 H.264 RTP 流?

ffmpeg - 如何确保使用 -c :v copy is accurate 在 ffmpeg 中进行修剪

FFmpeg - 将 MP4 转换为 Webm 非常慢

ffmpeg 强制执行比特率值而不是指定的值

video - FFMPEG 播放叠加视频

FFMPEG 转码器产生损坏的视频

c++ - IMFTransform::ProcessInput() "The buffer was too small to carry out the requested action."

java - Webview 视频 (iframe) 不播放,除了静音

video - 我想将图像(3~4ea)和 mp3 转换为 mp4 文件

python - 使用 VLC 的 Python 绑定(bind)时,选项 --plugin-path 不再存在错误