AV1, VP9, H.264 or HEVC: which codec should you keep?
Key takeaways
- H.264 (AVC) is the most compatible video codec: virtually every phone, TV, browser and editor can decode it, often in hardware.
- HEVC (H.265), VP9 and AV1 are newer codecs that generally reach the same visual quality as H.264 at lower bitrates, at the cost of narrower or newer hardware support.
- VP9 and AV1 are distributed royalty-free (AV1 by the Alliance for Open Media); H.264 and HEVC are covered by patent licensing pools.
- For archiving, the best codec is the one the source already used: every lossy re-encode loses quality, so keep the original stream and create a compatible copy only if needed.
- yt-dlp's -S option lets you prefer a codec, for example -S vcodec:h264 for maximum compatibility.

For a downloaded video, the best codec is usually the one it already has. Every lossy re-encode removes information, so for archiving you keep the original stream. The real choice happens before downloading, when a site offers the same video in several codecs: AV1 and VP9 give smaller files at equal quality, HEVC sits in between, and H.264 plays on absolutely everything. This guide compares them and shows how to choose with yt-dlp and FFmpeg.
What is a video codec, in one paragraph?
A codec (coder-decoder) compresses video by removing redundancy between and within frames: it splits each image into blocks, predicts them from neighbouring blocks or previous frames, and stores only the difference. Newer codecs use larger and more flexible blocks, better prediction and smarter filtering. That improves efficiency but demands more computing power to encode and decode. The codec is distinct from the container that wraps it.
How do the four codecs compare?
| H.264 / AVC | HEVC / H.265 | VP9 | AV1 | |
|---|---|---|---|---|
| Published by | ITU-T and ISO/IEC (2003) | ITU-T and ISO/IEC (2013) | Google / WebM Project (2013) | Alliance for Open Media (2018) |
| Efficiency vs H.264 | Reference | Better | Better | Generally best of the four |
| Hardware decoding | Near universal | Common on recent devices | Common on recent devices and browsers | Spreading, mainly recent devices |
| Royalties | Patent pool | Several patent pools | Royalty-free | Royalty-free |
| Typical containers | MP4, MKV, TS | MP4, MKV, TS | WebM, MKV | MP4, WebM, MKV |
| Free encoder | x264 (GPL) | x265 (GPL) | libvpx (BSD) | SVT-AV1, libaom (BSD) |
We deliberately give no universal percentage for “efficiency”: it depends on content, resolution, encoder settings and the quality metric used. Independent tests consistently rank AV1 and HEVC ahead of H.264, with VP9 close to HEVC, but the gap varies widely.
Which codec should I download?
Decide by where the file will be played:
- Old TV, car screen, older phone, video editor: H.264. Its compatibility is unmatched.
- Recent computer or phone: VP9 or AV1. Smaller files, same perceived quality.
- Long-term archive: the highest-quality original the site provides, whatever its codec, stored in MKV. A future player will always decode a standard codec; it cannot restore detail that a re-encode removed.
- HDR content: VP9 Profile 2 or AV1 with 10-bit colour, and only if your screen supports HDR.
How do I choose the codec with yt-dlp?
Run -F to see the codecs on offer (avc1 is H.264, hev1/hvc1 HEVC, vp09 VP9, av01 AV1), then rank them with -S:
# Maximum compatibility: prefer H.264 video and AAC audio
yt-dlp -S "vcodec:h264,acodec:aac" URL
# Smallest files at good quality: prefer AV1, cap at 1080p
yt-dlp -S "res:1080,vcodec:av01" URL
-S is a preference, not a hard filter: if H.264 is not available, yt-dlp falls back gracefully instead of failing. The README’s “Sorting formats” section lists every sort field.
How do I check which codec a file uses?
ffprobe -v error -select_streams v:0 \
-show_entries stream=codec_name,profile,pix_fmt,width,height \
-of default=noprint_wrappers=1 video.mkv
codec_name gives the codec, profile the profile (for example High for H.264, Profile 2 for HDR VP9), and pix_fmt the bit depth (yuv420p10le means 10-bit).
When is re-encoding justified, and how?
Re-encode only when a device cannot play the original and no compatible version exists, and keep the original next to the copy. With FFmpeg:
# Compatible H.264 copy, audio left untouched
ffmpeg -i original.mkv -c:v libx264 -crf 20 -preset slow -c:a copy compatible.mp4
# Space-saving AV1 copy with SVT-AV1
ffmpeg -i original.mkv -c:v libsvtav1 -crf 30 -preset 6 -c:a copy smaller.mkv
-crfsets a constant quality target: lower means better quality and bigger files. The scales differ between encoders, so a value for x264 does not transfer to SVT-AV1.-presettrades speed for efficiency.-c:a copyavoids re-encoding the audio; see extracting audio without re-encoding.
The FFmpeg wiki’s encoding guides document the recommended ranges for each encoder.
What about licensing and the open web?
H.264 and HEVC are covered by patents licensed through pools; this mainly concerns companies that ship encoders, decoders or paid content. VP9 and AV1 were created to offer royalty-free alternatives for the web. For an archivist, the practical consequence is simple: free tools like FFmpeg, VLC and dav1d decode all four, so any of them is safe to keep.
How do I read a codec report quickly?
This ffprobe command prints just the fields that matter for archiving decisions:
ffprobe -v error -select_streams v:0 \
-show_entries stream=codec_name,profile,width,height,pix_fmt,avg_frame_rate \
-of default=noprint_wrappers=1 video.mkv
codec_namegives the codec (av1,vp9,hevc,h264).pix_fmtreveals the bit depth:yuv420pis 8-bit,yuv420p10leis 10-bit, often a sign of HDR.avg_frame_ratetells you whether you have 25, 30, 50 or 60 frames per second, which matters if you later combine clips.
What goes wrong with codecs, and how do I fix it?
| Problem | Cause | Fix |
|---|---|---|
| Sound but black or frozen picture | The player cannot decode the video codec (often AV1 or HEVC on older hardware) | Update the player, use VLC, or download an H.264 version instead |
| Colours look washed out | A 10-bit HDR file shown on an SDR screen without tone mapping | Watch on an HDR-capable display or pick the SDR format when downloading |
| Fans spin and playback stutters | Software decoding of a codec the GPU does not accelerate | Choose a codec your hardware decodes, typically H.264 on older machines |
| File much larger than expected | An older codec at the same resolution | Accept it, or prefer VP9 or AV1 when the playback devices support them |
Which codec fits which use?
- Personal archive watched on a recent computer: keep the best original, usually AV1 or VP9, in MKV.
- Family videos played on TVs and old tablets: H.264 with AAC in MP4, even if the file is larger.
- Editing footage: H.264 or HEVC in MP4 or MOV; editing software handles them more predictably.
- Bandwidth-limited downloads: AV1 gives the smallest file at a given quality when your devices can decode it, as explained in our offline and low-bandwidth guide.
Summary
- Keep the original codec when archiving.
- Choose H.264 for universal playback, AV1 or VP9 for smaller modern files.
- Use
yt-dlp -Sto express preferences instead of rigid filters. - Inspect with ffprobe before deciding anything.
- If you must re-encode, do it once, from the best source, and keep the source.
Codecs are only one layer: the delivery protocol (HLS or DASH) and the container complete the picture.
Open-source tools in this guide
| Tool | Licence |
|---|---|
| FFmpeg | LGPL 2.1+ (some builds GPL) |
| SVT-AV1 | BSD-3-Clause with AOMedia patent licence |
| x264 | GPL 2.0+ |
| dav1d (AV1 decoder) | BSD-2-Clause |
Frequently asked questions
Is AV1 better than H.264?
For compression efficiency, yes: AV1 generally delivers similar quality at a lower bitrate. For compatibility, no: older phones, TVs and computers cannot decode AV1 in hardware, so playback may be impossible or drain the battery. Pick H.264 when the file must play everywhere.
Should I convert my downloads to AV1 to save space?
Only with care. Converting from one lossy codec to another always loses some quality, and encoding AV1 is slow. If the source is already AV1 or VP9, keep it. If storage is the issue, a single careful re-encode from the best source is acceptable, but keep the original when it matters.
Why does my downloaded video play without picture?
The player can read the container but not the video codec, often AV1 or HEVC on an older device. Check the codec with ffprobe or MediaInfo, update the player (VLC includes the dav1d AV1 decoder), or download an H.264 version with yt-dlp -S vcodec:h264.
What does VP9.2 mean in yt-dlp format lists?
It refers to VP9 Profile 2, which supports 10-bit and 12-bit colour, typically used for HDR video. Standard VP9 uses Profile 0 with 8-bit colour. Playing Profile 2 correctly requires an HDR-capable decoder and display.
Do I have to pay royalties to use H.264 or HEVC?
End users watching or storing personal files are generally not the target of codec patent licences; licences mainly concern companies that ship encoders, decoders or commercial content. Free decoders such as FFmpeg are widely used. Check the licensing pool terms if you distribute products.
Sources and open data
- ITU-T Recommendation H.264 (Advanced video coding) · ITU-T
- ITU-T Recommendation H.265 (High efficiency video coding) · ITU-T
- AV1 specification and licensing · Alliance for Open Media
- VP9 video codec · WebM Project
- FFmpeg encoding guides (H.264, AV1) · FFmpeg wiki
- yt-dlp README: sorting formats · yt-dlp project
Related guides
- MP4 vs MKV vs WebM
Container or codec? What MP4, MKV, WebM and MPEG-TS can hold, which one to keep for a downloaded video, and how to switch containers without quality loss.
- Audio: Opus, AAC, MP3
Save the soundtrack of a video losslessly: identify Opus, AAC or MP3 audio, copy it with FFmpeg or yt-dlp, and convert only when a device requires it.
- yt-dlp guide
A practical yt-dlp guide: install and update it safely, pick formats with -f and -S, name files, grab subtitles and keep a download archive.
- FFmpeg for video files
FFmpeg commands for downloaded video: merge separate audio and video, remux TS to MP4 without quality loss, cut clips, join parts and convert only when needed.
- MPEG-DASH / mpd
How MPEG-DASH works: the .mpd manifest, periods, adaptation sets and representations, and how to save a DASH stream legally with yt-dlp or FFmpeg.