GIF only supports 256 colors per frame, so the quality of the conversion comes down to which 256 colors get picked. The naive one-liner lets FFmpeg guess and you get banding. The high-quality approach generates a custom palette from your clip first, then maps the video onto it — the single biggest quality win available.
Key takeaways
- GIFs are capped at 256 colors; a custom palette is what makes them look good.
palettegenbuilds the palette,paletteuseapplies it with dithering.- Lower
fpsand a smallerscaleare the main file-size levers. - Trim the clip first — GIF size grows fast with length.
Quick one-liner
Good enough for a rough preview — scale down and cap the frame rate so it isn't enormous:
ffmpeg -i in.mp4 -vf "fps=12,scale=480:-1:flags=lanczos" out.gif
High-quality GIF (palettegen + paletteuse)
Generate a palette tuned to your clip, then reuse it. This removes most banding and keeps colors true:
# step 1: build a palette from the clip ffmpeg -i in.mp4 -vf "fps=15,scale=480:-1:flags=lanczos,palettegen" palette.png # step 2: render the GIF using that palette ffmpeg -i in.mp4 -i palette.png -filter_complex \ "fps=15,scale=480:-1:flags=lanczos[x];[x][1:v]paletteuse" out.gif
Shrink the GIF
If the file is still too big, pull the three levers: shorter clip, lower fps, smaller width. A single-palette pass with light dithering also helps:
# 3-second clip, 10 fps, 360px wide, lighter dithering ffmpeg -ss 0 -t 3 -i in.mp4 -i palette.png -filter_complex \ "fps=10,scale=360:-1[x];[x][1:v]paletteuse=dither=bayer:bayer_scale=3" small.gif
Export GIFs visually instead
FFmpegLab exports a GIF straight from the timeline with the palette step handled for you, so you get clean colors without running two passes — all offline. Trim to the exact moment first, or crop to frame it before exporting.