Formats guide
yt-dlp MP4 won't play? Get H.264 instead of AV1 or VP9
The file ends in .mp4, plays fine in Chrome or VLC, and then QuickTime shows a black screen, Premiere refuses to import it, or an iPhone plays the sound with no picture. The container is MP4, but the video inside is AV1 or VP9. yt-dlp picked it on purpose: at the same resolution those files are smaller, and its default sort prefers AV1, then VP9, then H.265, then H.264.
The fix is one flag: -t mp4. The rest of this page shows how to check what you got, what that flag does, and how to fix a file you already downloaded.
Check which codecs the file has
ffprobe -v error -show_entries stream=codec_type,codec_name -of compact=p=0:nk=1 video.mp4This prints one line per stream:
av1|video
aac|audioav1 or vp9 is the problem. h264 plays almost everywhere. Audio matters too: Opus inside an MP4 is another thing older Apple players and some editors reject, where AAC always works.
Before downloading, yt-dlp -F URL lists every format with its VCODEC: avc1.* is H.264, av01.* is AV1, vp09.* or vp9 is VP9, hev1.*/hvc1.* is H.265.
Ask yt-dlp for H.264 and AAC
Recent yt-dlp versions have a preset for exactly this:
yt-dlp -t mp4 "URL"yt-dlp --help lists it as shorthand for --merge-output-format mp4 --remux-video mp4 -S vcodec:h264,lang,quality,res,fps,hdr:12,acodec:aac. The -S part is what changes the pick: it sorts H.264 video and AAC audio first instead of the smallest codec. On older versions without -t, write the sort yourself:
yt-dlp -S "vcodec:h264,res,acodec:m4a" --merge-output-format mp4 "URL"On a video that offers AV1, H.265 and H.264 at the same resolution, plain yt-dlp picked the AV1 stream, and both commands above picked the H.264 one (avc1.64001E) with AAC audio. You can check the pick without downloading anything:
yt-dlp -t mp4 --print "%(vcodec)s %(acodec)s %(resolution)s" "URL"-S is a preference, not a filter. If a video has no H.264 at the height you want, you get the best other codec rather than an error. YouTube usually has no H.264 above 1080p, so -t mp4on a 4K video tends to give you H.264 at 1080p (the sort puts codec before resolution). If you'd rather fail than get anything else, use a filter:
yt-dlp -f "bv*[vcodec^=avc1]+ba[ext=m4a]/b[ext=mp4][vcodec^=avc1]" "URL"Expect bigger files: at 1080p the H.264 version can be up to about 2.5 times the size of the AV1 one. More on how -f and -S differ in format selection.
Fix a file you already downloaded
Changing the container won't help. Remuxing (--remux-video, or ffmpeg -c copy) moves the same AV1 stream into a new box. You have to re-encode the video:
ffmpeg -i video.mp4 -c:v libx264 -crf 20 -preset medium -pix_fmt yuv420p \
-c:a aac -movflags +faststart video-h264.mp4-crf 20is close to visually lossless for most video; raise it (23, 26) for smaller files.-pix_fmt yuv420pkeeps the 8-bit format every player supports.-c:a aacre-encodes Opus audio. If ffprobe already saidaac, use-c:a copyinstead.-movflags +faststartlets the file start playing in a browser before it has fully loaded.
Re-encoding is slow (often slower than real time for 1080p on a small server) and loses a little quality, so when you can download again, -t mp4 is better.
One catch with yt-dlp's own --recode-video mp4: it only re-encodes when the extension changes. A file that is already .mp4 is skipped with "already is in target format", AV1 or not. Use ffmpeg as above, or fix the format choice instead.
Make it the default
Put the preset in your config file so every download plays everywhere:
# ~/.config/yt-dlp/config
-t mp4See the yt-dlp config file for where it lives on each OS. If merging fails with an ffmpeg error, see ffmpeg not found.
In an app
If your app hands downloaded videos to users, an editor or a phone, the same choice comes up in code. The Importly API takes a link and returns the file, and compatibleCodecs: true asks for H.264 and AAC. Each result reports its videoCodec and audioCodec, so the app can check before it plays or edits the file.
For builders
Using yt-dlp inside an app or script?
Paste a link to see what a managed media-import API returns — no install, no signup.
Building this into an app? See the API your backend calls instead