How to do I convert an webm (video) to a (animated) gif on the command line?

Solution 1:

From here:

ffmpeg -i input.webm -pix_fmt rgb24 output.gif

Solution 2:

Barafu's answer is alright. But, the resulting gif may have color conversion issue as ffmpeg complains on Incompatible pixel format 'rgb24' for codec 'gif'. Here is what I find works:

First, create PNG Palette:

ffmpeg -y -i input.webm -vf palettegen palette.png

Then, use the palette to produce gif:

ffmpeg -y -i input.webm -i palette.png -filter_complex paletteuse -r 10 output.gif

Source:

Covert MP4/Webm - ubuntubuzz.com