3

I have this command that I found somewhere on SuperUser that converts an MP4 to a GIF:

ffmpeg -i INPUT_FILE.MP4 -vf "fps=16,scale=160:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 OUTPUT_FILE.GIF

It works great, but FFmpeg likes to use all 256 colors, which makes the GIF really big. I would like FFmpeg to use like, maybe 32 or 64 colors because it helps to reduce the file size and makes it easier for my hardware to parse the GIF.

I'm using an ATSAMD51 to display the GIF on a screen, so fewer colors = faster rendering.

On ezgif.com you can optimize GIFs. I would like to do something like this in FFmpeg:

Picture of what I want to do in FFmpeg

So, is it possible to have FFmpeg use a specified amount of colors while converting an MP4 to a GIF? (Oh, and no transparency, please! It slows down decoding.)

(Also, I'm running Windows 10 and I'm a noob at FFmpeg)

1 Answer 1

6

Use max_colors and reserve_transparent options in palettegen:

ffmpeg -i input.mp4 -vf "fps=16,scale=160:-1:flags=lanczos,split[s0][s1];[s0]palettegen=max_colors=32:reserve_transparent=0[p];[s1][p]paletteuse" -loop 0 output.gif

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .