Convert a video to GIF
Take a few seconds of footage and get back a looping GIF.
How it works
A clip that sits on disc as a 2 MB MP4 leaves here as a GIF several times that size, and the ratio widens with every second added to the range. That is the trade the format offers and it is worth taking deliberately. What comes back plays inline in a chat window, in an email client and in a wiki that will not embed video, with no player furniture and no tap to start. What goes is roughly an order of magnitude of disc space, the sound, and whatever colour the palette could not afford to keep.
Frame rate is the lever with the straightest line
Footage arrives at 24, 30 or 60 frames a second. A GIF at 12 is usually indistinguishable for the things people post, because a two-second loop is read as a gesture rather than as motion, and the eye objects to a posterised face long before it objects to the interval between frames. Measured here on ten seconds of synthetic 480×270 footage in which every pixel changes every frame, at 128 colours: 240 frames encoded to 1,865,349 bytes and the same ten seconds sampled at 120 frames encoded to 1,008,500. Halving the rate took 46% off the file.
Below 12 the return falls away. The same ten seconds at 100 frames measured 859,320 bytes, a further 15% for a rate at which a hand crossing the frame starts to arrive in discrete places. The default is 12 for that reason: it collects nearly all of the saving and leaves the motion legible. The encode itself is quick — those 120 frames took 502 ms in this repo, so the decode ahead of it is the slow half.
What the file can say about timing
A GIF cannot express an arbitrary interval. Each frame carries a delay in hundredths of a second as a 16-bit count, so the encoder has to round. Twelve a second is 83.3 ms and the file can only say 80: writing those 120 frames at 83 and decoding the result returned 80. Ten and twenty are the only rates offered here that land on a whole hundredth. Twelve and 24 both play about 4% fast, 15 plays about 5% slow, so a five-second loop finishes a fifth of a second early. On a loop nobody notices. Anything cut to a beat will drift.
One palette has to cover the whole clip
A still gets its colours chosen for itself. A clip gets one set chosen for all of it at once, which is a much harder problem the moment the light changes. Measured on a 40-frame 320×180 test whose second half is 45% darker, quantised to 128 entries as a single palette: the worst channel error came to 69 of 255 on the bright half against 30 on the dark half. The halves are not served equally, and the one the palette favoured less is where the damage lands.
It looks like flat steps across a sky, a contour line appearing on a cheek that had none, and a visible change in how coarse the picture is at the moment the lighting shifts. A range that stays in one lighting state quantises better than a longer one that visits two, so a shorter cut is usually cleaner as well as smaller. Dropping from 256 entries to 128 on the ten-second test took the file from 1,701,583 bytes to 1,008,500 without touching the frame rate.
Dithering costs far more on footage than on a still
Error diffusion swaps a visible band for a fine pattern of alternating entries, and on one image that is often the better picture. Across an animation it is expensive. The same ten seconds measured 1,008,500 bytes plain and 5,725,928 dithered, 468% more, because the scattered noise differs on pixels that never moved and each frame turns into a full redraw instead of a small patch. On flat material it costs nothing: a synthetic screen recording holding four colours measured 15,951 bytes with dithering and 15,951 without, since a palette that already holds every colour exactly has no error to spread.
Cut the clip before converting it
Every second converted costs its own frames and there is no discount for the part nobody watches. The range here opens on the first five seconds and stops at fifteen; a longer section belongs in `trim-video` first, which copies the compressed packets straight through wherever the cut lands on a keyframe. Converting the trimmed file afterwards means the frames this page decodes are only the frames you meant to keep.
The refusal at the start of a job is arithmetic rather than caution. Every frame stays decoded at four bytes a pixel until the last one arrives, because the palette is chosen from all of them together. Ten seconds at 480 wide and 24 a second is 240 frames of 480×270: 124,416,000 bytes of pixels before one byte of GIF exists, against the working set of about 250 MB a phone hands a tab. The page works that figure out from your settings and names the duration, rate and width that would fit instead of stopping once the bar has moved.
Questions
Does the video leave my machine?
No, and the check is stronger than reading a network panel. Load the page, then turn off your network connection and convert anyway. The file is read by the page, decoded and encoded in a Web Worker on your own processor, and handed back as a download, so the whole job completes with nothing to talk to.
Why is the GIF larger than the video it came out of?
Because it is being stored a different way, and the difference is measured in multiples rather than percentages. Ten seconds of moving 480×270 footage came to 1,008,500 bytes here at 12 frames a second and 128 colours. The same picture as H.264 at an ordinary bitrate is a few hundred kilobytes. Use GIF where the destination will not take a video and use the video everywhere else.
The GIF runs slightly fast compared to the source. Why?
Frame delays in a GIF are whole hundredths of a second, so 12 frames a second is written as 80 ms rather than the true 83.3. That is about 4% quick, and it accumulates: a five-second range ends roughly 0.2 s early. Choosing 10 or 20 frames a second avoids it, because 100 ms and 50 ms are exact.
It refused before it started. What do I change?
The message names the projected memory and three settings in the order they matter. Shortening the range is worth the most, because frames are counted from it directly. Lowering the frame rate is next and scales the same way. Halving the width is last on the list here only because the first two are usually enough; it removes three quarters of the pixels. The refusal happens before any frame is decoded, so nothing has been spent when you see it.