Convert video to GIF with ffmpeg
Produce a small looping GIF for docs, bug reports and chat by trimming frame rate and size.
Run ffmpeg -i input.mp4 -vf "fps=12,scale=480:-1" output.gif to make a 12 fps, 480px-wide GIF that loops automatically.
01Command
Command
$ ffmpeg -i input.mp4 -vf "fps=12,scale=480:-1" output.gif02What it does
GIF files balloon quickly, so the trick is a filter chain: fps=12 drops the frame rate, scale=480:-1 resizes to 480px wide and keeps the aspect ratio, and ffmpeg encodes straight to animated GIF. The order inside -vf matters — scaling after the fps filter avoids decoding wasted frames. Adding -ss and -to before -i trims the source to just the moment you need.
03Risk
!Warning: GIF stores only 256 colors per frame, so gradients and photos will band — for quality use MP4/WebM and embed video instead. A 10-second 480p GIF at 12 fps can still weigh tens of MB; shrink the dimensions before complaining about the file size.
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- ffmpeg(1) — Arch Manual PagesEvidence: Same -vf/--filter option documented for video filtering, including fps and scale filters.
- ffmpeg(1) — Debian bookwormEvidence: Documents the -vf option for applying a filtergraph such as fps and scale filters to the output stream.
Last verified: 2026-09-19 · Category: Media