How can I convert animated gif (with Alpha channel) to animated webp?

I stuck with transparent background, I can't figure out how to convert gif with transparent background to webP with transparent background, Its keep a 'trail' of the images,

ffmpeg -i test.gif animation.webp

For example, I want to convert this gif - https://imgur.com/tCSn2No to webP,

The output for now is - https://media.giphy.com/media/UqevOuKr66xO04zRBa/giphy.gif

how can I achieve that using ffmpeg?

  • Hey, still got the same issue. please help
    – Nirel
    Jun 11, 2019 at 18:43
  • did you find a solution?
    – mars
    Mar 27, 2020 at 17:29

3 Answers 3


I'm not sure if you were able to figure this one out, but I was able to get this to work by setting pixel format to yuv420p.

ffmpeg -i transparent.gif -vcodec webp -loop 0 -pix_fmt yuv420p transparent.webp

to complement @abvarun226 answer:

use yuva420p instead of yuv420p to add alpha channel and keep transparency.

ffmpeg -i transparent.gif -vcodec webp -loop 0 -pix_fmt yuva420p transparent.webp

and to save time you can use the following bat to convert all files in your folder:

for %%i in (*.gif) do (ffmpeg.exe -i "%%i" -y -vcodec webp -loop 0 -pix_fmt yuva420p "%%~ni.webp")

there is no problem convert that gif on my system, using compiled ffmpeg with all options enabled

--with-chromaprint --with-decklink --with-fdk-aac --with-game-music-emu --with-libbluray --with-libbs2b --with-libcaca --with-libgsm --with-libmodplug --with-librsvg --with-libsoxr --with-libssh --with-libvidstab --with-libvmaf --with-libxml2 --with-opencore-amr --with-openh264 --with-openjpeg --with-openssl --with-rtmpdump --with-rubberband --with-speex --with-srt --with-tesseract --with-two-lame --with-wavpack --with-webp --with-xvid --with-zeromq --with-zimg
  • What do you mean? what is the command? Unrecognized option '-with-chromaprint'. Error splitting the argument list: Option not found
    – Nirel
    Jun 26, 2019 at 17:34
  • @Nirel thats compilaition option, not some ffmpeg command, you can find it here trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu
    – warungman
    Jun 28, 2019 at 8:40
  • My point is your problem might be caused by missing dependency or compilation option, or maybe you should check your ffmpeg version using ffmpeg --version. Mine is on version 4.1.3
    – warungman
    Jun 28, 2019 at 8:43
  • Does the ffmpeg -i test.gif animation.webp command act like it should act in your machine?
    – Nirel
    Jun 28, 2019 at 14:54
  • did you get this fixed? I'm struggling with the same issue @Nirel
    – mars
    Mar 29, 2020 at 14:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.