Use the -c:v libvpx
option before the input to change the decoder like in this example for the first frame (-frames:v 1
):
ffmpeg -c:v libvpx -i input.webm -frames:v 1 -c:v libwebp -y output.webp
This comment says that:
FFmpeg's native VPx decoders don't decode alpha. You have to use the libvpx decoder
You can check your decoders using ffmpeg -decoders | grep libvpx
and you should see an output like this:
V....D libvpx libvpx VP8 (codec vp8)
V....D libvpx-vp9 libvpx VP9 (codec vp9)
According to that output, libvpx
would be the decoder for VP8 and libvpx-vp9
for VP9.
You can check the codec of your video using ffprobe input.webm
. You should see an output like this:
Stream #0:0(eng): Video: vp8, yuv420p(progressive), 640x360, SAR 1:1 DAR 16:9, 30 fps, 30 tbr, 1k tbn, 1k tbc (default)
Metadata:
alpha_mode : 1
For converting a whole webm (VP8) to an animated webp use:
ffmpeg -c:v libvpx -i input.webm output.webp
For converting a whole webm (VP9) to an animated webp use:
ffmpeg -c:v libvpx-vp9 -i input.webm output.webp