How video compression works: bitrate, keyframes and codecs

Uncompressed 1080p video is about 3 gigabits per second โ€” a minute would fill 22 GB. The MP4 on your phone is a few hundred megabytes for an hour. That thousandfold difference is video compression, and understanding its four ideas explains every setting in a compressor and every artefact you've ever seen in a stream.

Size is bitrate times duration

The single most useful fact: file size = bitrate ร— duration. Bitrate is the data allowed per second, and everything else โ€” resolution, frame rate, codec, quality โ€” decides how good the picture looks at that bitrate. A 60-second clip at 5 Mbps is 37.5 MB regardless of what's in it; at 1 Mbps it's 7.5 MB and looks worse. The bitrate calculator does the arithmetic for any length.

Where the compression comes from

Video is redundant in three ways, and codecs exploit all three. Spatially, nearby pixels are similar: like JPG, each frame is cut into blocks and transformed so that smooth areas compress to almost nothing while edges keep their detail. Temporally, consecutive frames are nearly identical: instead of storing a frame, the codec stores which blocks moved where (motion vectors) and the small difference that remains. Perceptually, eyes are insensitive to fine colour detail and to noise in busy areas, so colour is stored at lower resolution and quantisation is coarser where it won't be seen. A static talking head compresses superbly; confetti, rain and fast pans do not โ€” there's little redundancy to remove โ€” which is why sports streams pixelate on the action.

Keyframes, P-frames and why seeking stutters

Temporal prediction needs something to predict from. A keyframe (I-frame) is a complete picture; the frames after it (P- and B-frames) are stored as changes relative to neighbours, often a tenth the size. Encoders insert a keyframe every couple of seconds, which is why seeking lands on slightly different points and why a corrupted keyframe smears the next second of video. Streaming and screen-sharing use fewer keyframes for efficiency; editing formats use more โ€” sometimes every frame โ€” so that cuts are exact.

Resolution, frame rate and codec

Resolution sets how many pixels there are to compress: 1080p has 2.25ร— the pixels of 720p and needs roughly that much more bitrate for the same quality โ€” the reason "compress" usually means "downscale". Frame rate matters less than people think; 30 fps is plenty for talking and screen content, 60 for games and sport. The codec sets efficiency: H.264 is the compatible baseline, H.265/HEVC and VP9 need about 30โ€“50% less bitrate for the same quality, AV1 less still, at the cost of slower encoding and patchier support (WebM vs MP4: containers, codecs, and which one to send covers the formats). Two encodes of the same file at the same bitrate can differ a lot in quality depending on the encoder's speed preset โ€” slower is better.

Shrinking a file sensibly

  1. Trim first. Seconds you don't need are the cheapest bytes to lose โ€” the trimmer.
  2. Downscale to the destination. A phone screen or a chat window never shows 4K; 720p at 2.5 Mbps looks the same there and is a fifth the size.
  3. Set bitrate by content. Talking heads and screen recordings look fine at 1โ€“2 Mbps in 720p; action needs 4โ€“8.
  4. Don't re-encode repeatedly. Each generation loses quality; keep the original and compress from it.
  5. Remember audio. 128 kbps AAC is transparent for speech; a 320 kbps track on a 1 Mbps video is a quarter of the file.

Browsers can do this on-device now โ€” real-time re-recording with the compressor, or true re-encoding through WebCodecs in the MP4 converter โ€” so shrinking a video for WhatsApp no longer means uploading it to a website first.

Sources and further reading

The claims in this guide rest on these references, which were checked when the guide was last updated. Spotted an error? The contact page says how to report it.

  1. Video compression picture types (I, P, B frames) โ€” Wikipedia
  2. Bit rate โ€” Wikipedia
  3. Advanced Video Coding (H.264) โ€” Wikipedia

Try the tool

Frequently asked questions

What bitrate should I use for 1080p?

About 4โ€“6 Mbps for general content, 8+ for sport or gaming, 2โ€“3 for talking heads. For 720p, roughly half. Streaming services use less by encoding slowly with efficient codecs.

Why does my compressed video look blocky?

The bitrate is too low for the motion in the picture: the codec runs out of bits and coarsens the blocks. Raise the bitrate, lower the resolution, or accept it for static content only.

Does lowering the frame rate reduce file size much?

Less than you'd expect โ€” the predicted frames between keyframes are already small. Lowering resolution or bitrate has a far bigger effect.

Is compressing a video the same as zipping it?

No. Zip is lossless and barely shrinks video, which is already compressed. Video compression is lossy: it discards detail the codec judges unseen.