How video compression works.
Most frames in a video look almost identical to the one before. Modern codecs (H.264, HEVC, AV1) exploit that: a few full-quality "keyframes" (I-frames), and many smaller frames that only encode the differences (P and B-frames). Toggle between motion-compensated and all-keyframe to see the ~5× size difference.
Why most frames can be tiny
Adjacent video frames are 95-99% the same pixels. The camera moves, lighting changes, objects shift, but most pixels just don\'t change much frame to frame. A P-frame says "almost like frame N-1, with these specific patches moved by these vectors and these residuals." A B-frame does the same but can also reference the NEXT frame (which is why decoding order ≠ display order). The result: average frame size is a fraction of what each would be standalone.
Scene cuts and the I-frame budget
At a scene cut, the previous frame is useless as a reference — everything\'s different. The encoder detects the scene change and inserts an I-frame. This is why fast-cut videos (action movies, sports highlights) are larger per minute than slow videos (talking heads). It\'s also why scrubbing in a player snaps to I-frames — random seek can\'t start mid-GOP because P/B frames depend on their reference frames.
H.264 vs H.265 vs AV1
H.264 (AVC, 2003) was the watershed — quality + size + compatibility nobody else could match for 15 years. H.265 (HEVC, 2013) compresses ~50% better but has licensing landmines. AV1 (AOMedia, 2018) compresses ~30% better than H.265, is royalty-free, and is what YouTube/Netflix push when your hardware supports it. Encoding AV1 is currently 5-10× slower than H.264; decoding catches up as hardware ships. The general law: each generation roughly halves the bitrate for the same quality, at 5-10× the encode cost.
Codecs and compression →
DCT and entropy coding, motion estimation algorithms, rate control, bitrate ladders, HDR + 10-bit, why hardware decoders matter for battery life.
Open the Codex →