I need to convert mp4 video(1280×720) to webp file(512x512) such that the resulting webp file maintains aspect ratio and also gets entirely contained in 512x512 and the uncovered areas at the top and bottom should be transparent.
I tried the following ffmpeg command:
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
In the above command please note pad=512:512:-1:-1:color=#00000000
I have given the alpha values 00 but it outputs black color only.
I also referred to this site https://ffmpeg.org/ffmpeg-utils.html#color-syntax It says
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.
I tried both color=0x000000@0x00
and color=0x000000@0.0
but the result was opaque black.
I was just missing format filter before pad format=rgba,pad