GIFs loop everywhere — chats, docs, README files, Slack threads — with zero plugins and zero player UI. Converting a video clip into one takes a single command; making it look good at a sane file size takes the workflow below.
The one-command version
```bash ffmpeg -i clip.mp4 -vf "fps=12,scale=480:-1" output.gif ```
Twelve frames per second at 480 pixels wide. That's the honest starting point — but the raw output is usually disappointing: 5-10× larger than the source video and grainy. GIF is an inefficient 1987 format (256 colors, no audio, no inter-frame compression worth the name), so everything past this command is about managing that inefficiency.
The quality workflow: palette first
Default GIF conversion picks a generic 256-color palette; footage shifts to posterized mud. The fix is generating a palette from the actual video:
```bash # Step 1: build the palette ffmpeg -i clip.mp4 -vf "fps=12,scale=480:-1:flags=lanczos,palettegen" palette.png
# Step 2: apply it ffmpeg -i clip.mp4 -i palette.png -filter_complex \ "fps=12,scale=480:-1:flags=lanczos[x];[x][1:v]paletteuse" output.gif ```
The visual difference is dramatic — gradients stay gradients. This two-pass pattern is the standard for a reason.
The four dials that matter
1. **fps**: 10-15 for normal motion. 24fps GIFs exist but double file size for movement GIF can't represent smoothly anyway. 2. **Width**: 480px for chat/README, 240-320px for emoji-adjacent reactions. Full-width 1080 GIFs are multi-hundred-MB mistakes. 3. **Duration**: keep it under 10 seconds — see our looping guide for cutting first. A tight 4-second loop beats a wandering 15-second one in every metric. 4. **Crop**: if the action occupies a corner of the frame, crop to it — `-vf "crop=480:480:200:100,fps=12,..."` — fewer pixels, smaller file, clearer subject.
Sizing sanity: the GIF ceiling
A workable ceiling is **under 8 MB** — Slack, GitHub, and most chat systems stay comfortable there. The combination that hits it for typical 5-second clips: 480px, 12fps, palette mode. If you're over, cut duration or width before anything else; no encoder flag rescues a clip that's simply too big for the format.
When GIF is the wrong answer
GIF's real superpower is universality, not quality. When any of these apply, use looping **video** instead:
- **Sound matters** — GIF is silent by format - **Longer than ~10 seconds** — MP4/WebM at the same visual quality runs 5-20× smaller (see our codecs guide) - **Full color fidelity** — photographs and gradients beyond 256 colors - **Modern platforms** — most social apps convert your GIF back to MP4 server-side anyway; sending MP4 directly skips a lossy round-trip
The `<video autoplay muted loop playsinline>` pattern (see our video-background guide) delivers the same auto-looping behavior at a fraction of the bytes. Use GIF where it's genuinely required: chat pickers, READMEs, doc embeds — and looping video everywhere else.
Quick reference
- Two-pass palette: `palettegen` → `paletteuse` — always - 480px / 12fps / <10s / <8 MB — the four guardrails - Crop to the action before scaling - If it doesn't absolutely need to be a GIF — it probably doesn't
No comments yet