videocompression Blog
How Does Video Compression Work?
How Does Video Compression Work?
A minute of raw 1080p video is roughly 10 gigabytes. Yet the movie you stream is a few gigabytes *per hour*. Video compression routinely shrinks footage by 100x or more — while still looking good. Here's how, in plain English.
The core idea: remove what you won't miss
Compression exploits three kinds of redundancy:
- Spatial redundancy — within a single frame, neighboring pixels look alike (a blue sky is mostly just... blue).
- Temporal redundancy — between frames, most of the picture doesn't change. In a talking-head video, only the mouth moves.
- Perceptual redundancy — your eyes are less sensitive to fine color detail than to brightness, so color can be stored more coarsely.
I, P and B frames
Instead of storing every frame fully, encoders store:
- I-frames (keyframes) — complete pictures, like a JPEG. Large, but self-contained.
- P-frames — store only *what changed* since the last frame ("this block moved 3 pixels left").
- B-frames — the cleverest: they reference frames *before and after*, predicting motion in both directions.
A typical stream is mostly tiny P and B frames anchored by occasional I-frames. That's where the biggest savings come from.
Transform, quantize, entropy-code
Each block of pixels goes through a pipeline:
- Transform (DCT) — converts pixel data into frequencies. Most image energy concentrates in a few low frequencies.
- Quantization — the lossy step. High frequencies get rounded aggressively or zeroed out. This is where quality is *decided*: the famous CRF/quality setting directly controls how brutal this rounding is.
- Entropy coding — the remaining data is packed losslessly (like a ZIP file).
Higher CRF = harsher quantization = smaller file, more artifacts. Lower CRF = gentler = bigger file, cleaner image.
Motion compensation: the real magic
The encoder searches for where each block of the image *moved* between frames and stores just a motion vector ("shifted 12 pixels right") plus the small leftover difference. Static backgrounds cost almost nothing. This is why a slideshow compresses to nearly nothing while confetti exploding compresses terribly — there's no shortcut for pure randomness.
Codecs: H.264, HEVC, VP9, AV1
A codec is just the agreed-upon recipe for all of the above. Newer codecs are smarter at prediction, so they need fewer bits for the same quality:
- H.264 — the universal baseline. Plays everywhere, ~2x the size of modern codecs.
- HEVC (H.265) — ~40–50% smaller than H.264, great for 4K, but patent licensing limits it.
- VP9 — Google's royalty-free answer, powers YouTube.
- AV1 — the current champion: ~30% smaller than HEVC, royalty-free, backed by Netflix, Google, Meta. Slower to encode, but the future.
CRF vs. bitrate: how you control it
- CRF (Constant Rate Factor) — you pick a *quality level* (e.g. 23), the encoder varies the bitrate as needed. Best for files you keep. Lower number = better quality.
- Target bitrate — you pick a *file size*, quality varies. Best for streaming, where bandwidth is fixed.
For most people, CRF 23 (H.264) or CRF 28 (AV1) hits the sweet spot.
The takeaway
Video compression is prediction plus clever discarding: store one full frame, then just the *differences*, and round away detail your eyes won't catch. Modern codecs just predict better. If you want to try it hands-on, our free online video compressor lets you transcode MP4 and WebM with adjustable CRF right in your browser — no upload, no install.