CH02 / Formats & streaming

AV1, VP9, H.264 or HEVC: which codec should you keep?

Last updated Editorial team Video Downloader Info11 segments~5 min

Key takeaways

  1. H.264 (AVC) is the most compatible video codec: virtually every phone, TV, browser and editor can decode it, often in hardware.
  2. 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.
  3. VP9 and AV1 are distributed royalty-free (AV1 by the Alliance for Open Media); H.264 and HEVC are covered by patent licensing pools.
  4. 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.
  5. yt-dlp's -S option lets you prefer a codec, for example -S vcodec:h264 for maximum compatibility.
Visualisation of VP9 macroblocks on a frame of the open movie Tears of Steel
Image: VP9 macroblocks ToS f00808,Mango Blender Open Movie Project , Blender Foundation,CC BY 3.0,via Wikimedia Commons.

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
  • -crf sets 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.
  • -preset trades speed for efficiency.
  • -c:a copy avoids 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_name gives the codec (av1, vp9, hevc, h264).
  • pix_fmt reveals the bit depth: yuv420p is 8-bit, yuv420p10le is 10-bit, often a sign of HDR.
  • avg_frame_rate tells 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

  1. Keep the original codec when archiving.
  2. Choose H.264 for universal playback, AV1 or VP9 for smaller modern files.
  3. Use yt-dlp -S to express preferences instead of rigid filters.
  4. Inspect with ffprobe before deciding anything.
  5. 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

ToolLicence
FFmpegLGPL 2.1+ (some builds GPL)
SVT-AV1BSD-3-Clause with AOMedia patent licence
x264GPL 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

  1. ITU-T Recommendation H.264 (Advanced video coding) · ITU-T
  2. ITU-T Recommendation H.265 (High efficiency video coding) · ITU-T
  3. AV1 specification and licensing · Alliance for Open Media
  4. VP9 video codec · WebM Project
  5. FFmpeg encoding guides (H.264, AV1) · FFmpeg wiki
  6. yt-dlp README: sorting formats · yt-dlp project