How to Download YouTube Videos in H.264 Only (Not AV1 or VP9)
Why your downloads come out as AV1 or VP9
YouTube stores each video in several codecs. yt-dlp, like most downloaders, ranks them by quality, and its default order prefers AV1, then VP9, then H.264. So unless you ask, you get AV1 or VP9.
We checked with yt-dlp 2026.11.17 on a public 4K video. With default settings it picked AV1 at 2160p. With the H.264 filter below it picked H.264 at 1080p in an MP4.
When H.264 is the right choice
- Editing. Many editing apps, especially older versions, import H.264 without trouble but struggle with AV1.
- Older phones, TVs and media players. Smooth AV1 playback needs hardware decoding that many devices made before about 2020 don't have.
- Pipelines and tools. Some processing tools, players and upload targets accept only H.264 in MP4.
- Predictable files. A whole batch in one codec means one set of settings downstream.
The trade-off: at the same quality, AV1 and VP9 files are smaller, and they're the only way to get 1440p, 4K or 8K from YouTube.
Check which codec a file has
ffprobe -v error -select_streams v:0 -show_entries stream=codec_name -of default=nw=1 video.mp4
It prints codec_name=h264, vp9 or av1.
With yt-dlp: filter for H.264
A filter is strict: it only accepts streams whose codec starts with avc1, paired with AAC audio so the result fits in an MP4.
yt-dlp -f "bv*[vcodec^=avc1]+ba[acodec^=mp4a]/b[vcodec^=avc1]" --merge-output-format mp4 "https://www.youtube.com/watch?v=VIDEO_ID"
To cap the height as well, add it to the video part, for example bv*[vcodec^=avc1][height<=720].
If you'd rather prefer H.264 but still get something when it's missing, sort instead of filtering:
yt-dlp -S "vcodec:h264,res,acodec:m4a" --merge-output-format mp4 "https://www.youtube.com/watch?v=VIDEO_ID"
Sorting puts H.264 first but falls back to other codecs, so check the result with ffprobe if you need a guarantee.
With the VideoDL API: one field
Send video_codec as a list in order of preference. With only "avc1", the job fails with code 52 (format unavailable) if a video has no H.264 stream. Add "any" at the end to fall back to any codec instead.
{
"url": "https://www.youtube.com/watch?v=VIDEO_ID",
"resolution": "1080",
"video_codec": ["avc1", "any"],
"container": "mp4"
}
The finished job's codecs field tells you what you got, for example {"video": "avc1.640028", "audio": "mp4a.40.2"}. You can also accept h264 as an alias of avc1, or list up to three codecs, like ["avc1", "vp9", "any"].
To make H.264 the default for every request, open Download Settings in your dashboard and set Preferred codec to H.264. Fields you send with a request override the saved settings for that request only.
Need 4K in H.264?
YouTube doesn't offer it, so the only way is to download the 4K AV1 or VP9 stream and re-encode it. That takes a while and makes a much larger file:
ffmpeg -i video-4k.webm -c:v libx264 -crf 18 -preset slow -c:a aac -b:a 192k video-4k-h264.mp4
Lower -crf means higher quality and bigger files. 18 is close to visually lossless. Re-encoding never adds detail, so start from the highest-quality source.
FAQ
How do I download YouTube videos in H.264 with yt-dlp?
Filter for the codec: yt-dlp -f "bv*[vcodec^=avc1]+ba[acodec^=mp4a]/b[vcodec^=avc1]" --merge-output-format mp4 URL. This only accepts H.264 video with AAC audio, saved as MP4.
Why does yt-dlp download AV1 instead of H.264?
yt-dlp ranks codecs by quality and prefers AV1, then VP9, then H.264. Unless you filter or sort for H.264, it picks the best available, which on YouTube is usually AV1 or VP9.
Can I download a 4K YouTube video in H.264?
Not directly. In our tests YouTube offers H.264 only up to 1080p. For 4K in H.264, download the AV1 or VP9 version and re-encode it with ffmpeg.
What does avc1 mean in yt-dlp?
avc1 is the codec ID for H.264 (also called AVC) in MP4 files. Filtering on vcodec^=avc1 selects H.264 video streams.
How do I request H.264 from the VideoDL API?
Send "video_codec": ["avc1"] in the start-download request. Add "any" as the last item to fall back to another codec when a video has no H.264 stream.
H.264 downloads, without the yt-dlp upkeep
Set your codec once and every download arrives the same way, in your cloud or as a link. From $12/month, with a free trial.
Keep reading
All articles →
How to download YouTube videos with an API
A developer's guide to downloading YouTube videos with an API — cURL, Python and Node examples, plus DIY yt-dlp vs a managed API.
YouTube to MP3 by API
Extract audio from YouTube videos by API in MP3, M4A, Opus, FLAC or WAV. Which format to pick for transcription, editing or archives, with yt-dlp equivalents.
Build a YouTube clipping app
Clip makers, GIF tools and sticker apps all start with the same step: getting the source video reliably. The architecture, the FFmpeg commands, and a download layer that won't break at 3 AM.