Video Codecs Cheat Sheet — H.264 vs H.265 vs VP9 vs AV1
A printable reference for choosing the right video codec. Covers compression efficiency, encoding speed, hardware support, licensing, and platform compatibility.
Video Codecs Comparison Table
| Feature | H.264 (AVC) | H.265 (HEVC) | VP9 | AV1 | |---------|-------------|--------------|-----|-----| | Released | 2003 | 2013 | 2013 | 2018 | | Compression profile | Mature baseline | Higher-efficiency option | Higher-efficiency web option | Newer high-efficiency option | | Encoding speed | Fast | Moderate | Slow | Very slow | | Decoding speed | Very fast | Fast | Moderate | Moderate | | Hardware decode | Universal | Newer devices | Chrome/Android | Newest only | | Licensing | Patent pool | Patent pool | Royalty-free | Royalty-free | | Container | MP4, MKV | MP4, MKV | WebM, MKV | MP4, WebM, MKV | | Best for | Universal | Apple/mobile | Web (Google) | Future standard |
Browser Support
| Codec | Chrome | Firefox | Safari | Edge | |-------|--------|---------|--------|------| | H.264 | ✅ | ✅ | ✅ | ✅ | | H.265 | ⚠️ HW only | ❌ | ✅ | ⚠️ HW only | | VP9 | ✅ | ✅ | ✅ 14.1+ | ✅ | | AV1 | ✅ 70+ | ✅ 67+ | ✅ 17+ | ✅ 79+ |
Download sample MP4 files (H.264 + H.265), MKV files (H.264/H.265/VP9), and WebM files (VP9/AV1).
When to Use Each Codec
- Universal compatibility → H.264 in MP4 → sample MP4
- Apple ecosystem → H.265 in MP4 (iPhones encode natively)
- Web streaming → VP9 in WebM (Google/YouTube) → sample WebM
- Best compression → AV1 (if you can afford slow encoding)
- Archival / Plex → H.265 in MKV → sample MKV
Container Formats
| Container | Video Codecs | Audio Codecs | Subtitles | Browser | |-----------|-------------|-------------|-----------|---------| | MP4 | H.264, H.265, AV1 | AAC, AC3 | Limited | All | | MKV | Any | Any | SRT, ASS, PGS | None | | WebM | VP8, VP9, AV1 | Vorbis, Opus | WebVTT | Chrome/Firefox | | MOV | H.264, H.265, ProRes | AAC, PCM | Limited | Safari | | AVI | DivX, H.264 | MP3, PCM | None | None |
FFmpeg Quick Reference
# H.264 encoding (universal)
ffmpeg -i input.mov -c:v libx264 -crf 23 -c:a aac output.mp4
# H.265 encoding
ffmpeg -i input.mov -c:v libx265 -crf 28 -c:a aac output.mp4
# VP9 encoding (royalty-free)
ffmpeg -i input.mov -c:v libvpx-vp9 -crf 30 -b:v 0 -c:a libopus output.webm
# AV1 encoding
ffmpeg -i input.mov -c:v libaom-av1 -crf 30 -c:a libopus output.webm
# Remux MKV to MP4 (instant, no re-encoding)
ffmpeg -i input.mkv -c copy output.mp4
Measure quality, size, and speed
There is no universal codec ratio. Results change with the source, encoder implementation, preset, hardware acceleration, resolution, motion, grain, audio settings, and quality target. CRF values from different encoders are not directly equivalent.
For a defensible comparison:
- Use the same lossless source clip and audio policy.
- Record FFmpeg and encoder versions plus every command-line option.
- Encode each codec at several quality settings instead of comparing one CRF value.
- Record output bytes and elapsed encoding time.
- Compare visual quality using the same metric and manual review.
- Test decoding on the actual browser and device matrix.
Publish the source clip or its checksum with the results so another person can repeat the experiment.
Decision Flowchart
- Needs to play everywhere? → H.264 in MP4
- Web-only, Chrome/Firefox? → VP9 in WebM
- Apple devices primary? → H.265 in MP4
- Smallest possible, time not an issue? → AV1
- Archival with multiple audio/subs? → H.265 in MKV