Convert GIF to MP4 with FFmpeg (Smaller and Smoother)
Turn an animated GIF into an H.264 MP4 that is far smaller and plays on every device.
Run ffmpeg -i animation.gif -movflags +faststart -pix_fmt yuv420p animation.mp4.
01Command
Command
$ ffmpeg -i animation.gif -movflags +faststart -pix_fmt yuv420p animation.mp402What it does
GIF is an ancient format: huge files, 256 colors, no sound. Re-encoding to H.264 MP4 typically shrinks the file by 80–90% with smoother motion. -pix_fmt yuv420p keeps it compatible with Windows players, phones and social apps, while +faststart moves the index to the file head so it starts playing instantly online.
03Risk
!Warning: If the output shows green or gray edges, the GIF width/height wasn't divisible by 2 — add a crop or scale filter, e.g. -vf crop=trunc(iw/2)*2:trunc(ih/2)*2.
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- mov/mp4 muxer — FFmpeg Formats DocumentationEvidence: Documents the +faststart flag that relocates the MP4 index for immediate playback and streaming.
Last verified: 2026-09-18 · Category: Media