Understanding GIF → MP4 / WebM
The 10× file-size win that nobody bothers with.
Why turning a GIF into MP4 is one command, what gets fixed in the conversion, and the HTML attribute that makes the result behave like a GIF in a page.
Conversion is decode-once + re-encode.
GIF stores frames as full pictures (no inter-frame prediction). Convert by decoding each frame, feeding it to a video encoder (H.264, VP9, AV1) that does inter-frame compression. The resulting file is typically 5-15× smaller for the same visual content. The motion looks better too: full 24-bit colour instead of GIF's 256-colour palette.
A worked conversion.
A 5MB GIF. ffmpeg -i in.gif -c:v libx264 -pix_fmt yuv420p -movflags +faststart out.mp4. The -pix_fmt yuv420p ensures broad compatibility (some players reject YUV 4:4:4); -movflags +faststart moves the metadata atom to the front of the file so it plays before fully downloading. Output is typically ~500 KB-1 MB — 5-10× smaller than the source.
GIF → MP4
-c:v libx264 -pix_fmt yuv420p -movflags +faststart
H.264 in MP4 with broad playback compatibility.
5MB GIF → ~700KB MP4
= 7× smaller, identical visual
GIF → WebM (VP9)
-c:v libvpx-vp9 -pix_fmt yuv420p
Smaller again; doesn't play in older Safari.
5MB GIF → ~400KB WebM
= 12× smaller, browser-native
The auto-loop HTML attribute.
For the resulting video to behave like an inline GIF in a web page, embed it with <video autoplay loop muted playsinline></video>. All four attributes matter. autoplay: start playing immediately. loop: restart at the end. muted: required by browsers to allow autoplay (silent video can autoplay; audio can't). playsinline: iOS Safari plays the video inline rather than fullscreen. Together they recreate the GIF UX on a 10× smaller file.
When to keep GIF.
Email clients don't play HTML5 video — Outlook, Gmail render GIFs inline but videos as attachments. Word documents and PowerPoint embed GIFs natively but handle videos awkwardly. Slack and Discord auto-convert uploaded GIFs to MP4 server-side but only when uploaded as files, not when pasted as inline links. For any context where you don't control the renderer, GIF stays the universal fallback. For your own website or app, MP4 always wins.
Frame rate after conversion.
GIFs typically encode at 10-15 fps to keep file size manageable; the converted MP4 inherits the same frame rate. If the result feels choppy and you want smoother motion, you'd need the original higher-frame-rate source — the GIF already discarded that information. Don't "interpolate" the GIF to higher fps; interpolation produces synthetic-looking artifacts. Convert the original source to MP4 directly if you have it.