Video codecs: H.264, H.265 and AV1
In short: A codec compresses video so that it needs only a fraction of the space; H.264 is the most widespread, H.265 and AV1 are more efficient.
In more detail: Uncompressed video is huge: a minute of Full HD video at 30 frames per second would arithmetically be over 10 GB. A codec (coder/decoder) reduces that to a few megabytes by omitting repetitions and barely perceptible details. The container format (MP4, MKV, WebM) packages video, audio and subtitles.
In Depth
How compression works
- Within a frame (intra): similar areas are combined, fine details rounded (as with JPEG).
- Between frames (inter): usually little changes. Only differences and motion vectors are stored. A keyframe (I-frame) contains a complete image, P and B frames store changes relative to it.
- Lossy: information is lost that you hardly notice at low compression.
The most important codecs
- H.264 / AVC: 2003, runs practically everywhere (phones, TVs, browsers). Good compatibility, solid efficiency.
- H.265 / HEVC: about 30 to 50 % smaller at the same quality, needed for 4K and HDR. Licensing is complicated (patent fees), not in all browsers.
- VP9 (Google): free, used by YouTube.
- AV1 (Alliance for Open Media): royalty-free, even more efficient than H.265 but very compute-intensive to encode; hardware decoders are becoming more common (Netflix, YouTube, newer GPUs).
- H.266 / VVC: even more efficient, little used.
Bitrate and settings
The bitrate (Mbit/s) determines quality and file size. Typical: 1080p at 5 to 8 Mbit/s for streaming. For encoding, CRF (constant quality) or fixed bitrate apply, with presets from “fast” to “slow” (slower = smaller). Hardware encoders (NVENC, QuickSync) are fast, software encoders (x264, x265) more efficient. Tool: ffmpeg -i input.mp4 -c:v libx265 -crf 26 output.mp4.
Choice and notes
For maximum compatibility H.264 in MP4 with AAC audio. For archive and 4K H.265 or AV1. Streaming uses adaptive bitrates (HLS, DASH), which switch quality depending on the connection. Each re-encoding lowers quality: edit from originals where possible. Check whether playback devices handle the codec in hardware, otherwise power consumption rises.
See also: Image compression, Compression, MPEG