Convert MP4 to GIF with FFmpeg

Turns a video into an animated GIF using a generated palette, which is the difference between a usable GIF and a muddy one.

ffmpeg -i https://cdn.rendobar.com/assets/examples/sample.mp4 -vf "fps=12,scale=480:-1:flags=lanczos,split[a][b];[a]palettegen[p];[b][p]paletteuse" -t 3 out.gif
Encode
1420 ms
Output
1055.6 KB
Cost
$0.0030
Result
480x270

job_e027dbc335914995

The part everyone gets wrong

GIF is limited to 256 colours per frame, so the palette is the entire quality story. palettegen builds one from your actual footage and paletteuse applies it. Skipping that step is why most FFmpeg GIFs look worse than the source for no reason.

What the common version does

Without a generated palette FFmpeg falls back to a fixed 216-colour web palette, which is where the banding comes from. Measured, it is also HALF the size, so the palette is a quality decision that costs bytes rather than a free win.

ffmpeg -i https://cdn.rendobar.com/assets/examples/sample.mp4 -vf "fps=12,scale=480:-1" -t 3 out.gif
It succeeds, and that is the problem

It did not error. It produced 536.3 KB against the correct command's 1055.6 KB, a 2.0x smaller file. A pipeline would accept this silently.

job_9aeec1c105b74d37

Frequently asked questions

How do I convert mp4 to gif?

Turns a video into an animated GIF using a generated palette, which is the difference between a usable GIF and a muddy one.

What goes wrong most often?

GIF is limited to 256 colours per frame, so the palette is the entire quality story. palettegen builds one from your actual footage and paletteuse applies it. Skipping that step is why most FFmpeg GIFs look worse than the source for no reason.

What happens if I get it wrong?

We ran the naive version too. It did not error. It produced 536.3 KB against the correct command's 1055.6 KB, a 2.0x smaller file. A pipeline would accept this silently.

Do I need FFmpeg installed?

Not with Rendobar. The command on this page ran through the API against a URL, with no local FFmpeg and no server. The job id below it is the job that produced these numbers.

Run this without installing FFmpeg

This exact command ran through the API against a URL.