FFmpeg · Command Guide

How to Turn a Video Into a GIF With FFmpeg

A naive conversion produces huge, ugly GIFs because FFmpeg's default color palette isn't built for the format. A two-pass palette approach fixes both problems.

A naive conversion produces huge, ugly GIFs because FFmpeg's default color palette isn't built for the format. A two-pass palette approach fixes both problems.

The command

ffmpeg -i input.mp4 -vf "fps=15,scale=480:-1:flags=lanczos,palettegen" palette.png ffmpeg -i input.mp4 -i palette.png -filter_complex "fps=15,scale=480:-1:flags=lanczos[x];[x][1:v]paletteuse" output.gif

What each flag does

fps=15Reduces frame rate — GIFs rarely need more than 10-15fps, and lower fps means a smaller file.
scale=480:-1:flags=lanczosResizes to 480px wide using a high-quality scaling algorithm; height auto-calculated.
palettegenFirst pass: analyzes the video and generates an optimized 256-color palette specific to its content.
paletteuseSecond pass: applies that custom palette instead of GIF's limited default one, which is what removes the banding and washed-out colors.

Where this goes wrong

Running a single-pass conversion straight to GIF (skipping the palette step) is the most common mistake — it uses a generic, low-quality default palette and produces visibly banded, dull colors, especially on anything with gradients or skin tones.

After the command

If the GIF is a promo teaser for a longer video, the video it's teasing is exactly what NULLFRAME's templates are built to produce.

See the templates

Common questions

Why is my GIF file still huge?+
Lower the fps further (10 is often enough for social use), reduce the width, or trim the clip shorter — GIF has no efficient compression for motion, so duration and resolution dominate file size directly.
Can I loop the GIF a specific number of times instead of forever?+
Yes — GIF looping is a metadata flag some tools respect; FFmpeg's default output loops infinitely, and changing that requires a separate flag depending on your GIF library, not FFmpeg's encoder itself.
Is GIF still the right format in 2026?+
For anywhere that supports it, an equivalent short muted MP4 or WebP is almost always smaller and higher quality — GIF's main advantage now is universal compatibility with old platforms that don't support video inline.