H.264 is a widely used video codec designed to cut the enormous bandwidth and storage demands of full-motion video. The explanation begins with a comparison: a five-second recording of a mostly unchanged webpage can be far smaller than a single lossless PNG screenshot. H.264 achieves this by discarding information that viewers are less likely to notice, rather than preserving every pixel exactly. It transforms image data into frequency components, where fine details correspond to higher frequencies, then quantizes the image by reducing those components. It also separates brightness from color: because human vision is more sensitive to fine brightness changes than color changes, chroma subsampling stores color at lower resolution while retaining full-resolution luminance.
The larger savings come from exploiting similarities between frames. H.264 divides images into blocks and represents motion instead of repeatedly encoding every pixel. An I-frame stores a complete image; subsequent P-frames describe changes relative to earlier frames, while B-frames can use both earlier and later frames as references. A decoder reconstructs the video by combining these predictions with the stored reference frames. In a static scene, such as a webpage, most blocks barely change, so the codec needs to record only a small amount of new information over time. Together, perceptual detail reduction, lower-resolution color, and motion compensation explain how H.264 can deliver visually convincing video using a fraction of the data required by uncompressed frames.
Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.