FFmpeg recipe
FFmpeg: Convert MP4 to GIF with Custom Palette
Default ffmpeg GIF uses the web palette and looks posterized. Custom palette extraction picks the optimal 256 colors for your specific clip.
Command
ffmpeg -i input.mp4 -vf "fps=15,scale=480:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -y output.gifPrefer no terminal?
Use the Video to GIF in your browser
What each flag does
| -i | Input file. Can be a video, audio, or image. Repeat for multiple inputs. |
|---|---|
| -y | Overwrite output file without confirmation. |
| -vf "..." | Filter chain: set FPS, resize, then split → palettegen → paletteuse for optimal color quality. |
| fps=15 | 15 fps is the GIF sweet spot — smooth enough, file size half of 30 fps. |
| scale=480:-1 | Resize to 480 px wide, height auto. Smaller width = much smaller GIF. |
| palettegen | Build a custom 256-color palette tuned to this clip. |
Notes & gotchas
- Drop FPS to 12 or width to 360 for stricter file size budgets.
- Add dither=bayer:bayer_scale=5 to paletteuse for smoother gradients (slightly larger file).
Related recipes
Convert MOV → MP4 · MOV → MP4
Convert MOV to MP4 with FFmpeg using H.264 video and AAC audio. CRF 23 default keeps quality visually identical.
Convert HEVC → H.264 · HEVC → H.264
Convert HEVC (H.265) video to H.264 with FFmpeg so it plays on Windows, in Chrome, and on older Macs.
Convert MKV → MP4 · MKV → MP4
Convert MKV to MP4 with FFmpeg using stream-copy. Remuxes the H.264 / AAC streams without re-encoding.
Convert MP4 → WebM · MP4 → WebM
Convert MP4 to WebM with FFmpeg using VP9 video and Opus audio. ~30% smaller for the web.