formats · 5 min read
GIF vs MP4: choosing a looping format
A GIF is an animated image: every frame is stored as a picture built from a palette of at most 256 colours. An MP4 is compressed video that stores the differences between frames, which is why an MP4 of the same clip is typically far smaller.
GIF wins where video will not autoplay or cannot be embedded; MP4 wins on size, colour, frame rate and audio. Choose per destination rather than converting everything one way.
What a GIF actually is
The GIF89a specification defines an image format with a global colour table, optional per-frame palettes, one-bit transparency and a delay per frame measured in hundredths of a second, plus a loop counter. Each frame is encoded as an independent image, compressed with LZW, a lossless method that looks for repeated byte patterns within that frame. There is no temporal prediction and no audio track at all.
An MP4 is a container for compressed video and audio. Codecs such as H.264, HEVC or AV1 describe motion between frames, so a slow pan or a static background costs very little data. Looping is not part of the file: a player, a web page or an app decides to replay it. That is why an MP4 can loop seamlessly on a site while the same file shows a pause button in a different app.
Why the same clip is so much bigger as a GIF
With no inter-frame compression, every GIF frame pays for the whole picture. A 480 by 270 frame at one byte per pixel is roughly 130 kilobytes before compression; LZW might bring that down, but thirty frames for three seconds at ten frames per second still add up quickly. An MP4 encoded at a modest bitrate spends a similar amount of data on the whole three-second clip, not on each frame.
Two smaller details make GIFs worse than the arithmetic suggests. A 256-colour palette has to be dithered across photographic footage, and the resulting speckle compresses poorly and looks soft. Frame delays are also quantised to hundredths of a second, and browsers have historically stretched very short delays to about a tenth of a second, so a fast GIF can play slower than the video it came from.
Where an MP4 (or WebM) is the better loop
For anything photographic, an MP4 is smaller, smoother and can carry audio. A muted, autoplaying HTML video loops on a page with the attributes autoplay, muted, loop and playsinline; the muted part matters because browsers block autoplay with sound. WebM can additionally store an alpha channel with VP9, something H.264 in MP4 cannot do, which matters for transparent overlays on the web.
The catch is context. Browsers, social feeds and modern chat apps play a looping video well, but email clients usually strip or block video, and some documentation systems render inline images while showing video as a download link. Autoplay is also a preference users can disable, so a video that must move without interaction is still safer as a GIF in the narrow places that accept one.
Where GIF still wins
GIF remains the format of least resistance in text-first environments. It renders inline in almost every chat client, email client, issue tracker and Markdown renderer, often without a click and without a plugin. There are no controls to explain and no codec to negotiate: if the image pipeline accepts an image, it probably accepts a GIF.
That convenience has an accessibility cost. A GIF plays forever and cannot be paused in most of those environments, which is uncomfortable for readers sensitive to motion, so keep loops short and avoid flashing. On the web, respect the reduced-motion setting and offer a static alternative where the animation carries meaning. Interface artwork such as status icons is better served by SVG, which stays sharp at any size without a palette.
Making a good GIF from a video
Start with the shortest section that communicates the idea, usually two to five seconds. Extract it at eight to twelve frames per second rather than the source frame rate, scale the width down to a few hundred pixels, and avoid the busiest part of the frame. A palette generated from the actual clip keeps colours closer to the original than a generic one, but flat colours and simple shapes will always survive GIF better than gradients and skin tones.
Then judge the file where it will live, not on the desktop. If a GIF comes out at several megabytes, an MP4 will do the same job far more efficiently wherever video is allowed, and the GIF can stay as a fallback. Converting the GIF back to MP4 rarely helps: the palette and frame loss are already in the image, and video compression cannot put them back.