yt-dlp Format Selection, Explained
yt-dlp format selection explained: read the -F table, write -f selectors such as bv*+ba/b, sort with -S res:1080 or vcodec:h264, and choose the container.
What you get with no options
Run yt-dlp with only a URL and it already aims for the best quality. The README states the default as -f "bv*+ba/b". Read left to right, that says: take the best format that contains video, add the best audio-only format if the video has no sound of its own, merge the two, and if none of that is possible fall back to the best single file that has both.
The merge is done by FFmpeg. Without FFmpeg installed, yt-dlp cannot join separate streams, and the default changes to the best single file, with a warning that is easy to miss. On YouTube that file is a much lower resolution. If your downloads are stuck at 360p or 720p, that is the first thing to check.
Format options exist for the times when best is not what you want: a smaller file, a resolution cap, a codec your television can play, or audio only.
List the formats with -F
-F prints a table of everything a video offers and downloads nothing. Each row is one format. The columns that matter are the ID at the start of the row, the extension, the resolution and frame rate, the file size where the site reports it, the bitrate, and the video and audio codecs.
On YouTube most rows are marked video only or audio only. That is why merging is needed: the high resolutions exist only as separate picture and sound. IDs are specific to each site, and the set on offer changes from video to video, so a number that works today on one video is not a setting to reuse everywhere.
- List every format
yt-dlp -F "URL"- List them in sorted order, worst to best
yt-dlp -v -F "URL"
The -f selector language
-f takes an expression that names what to download. The simplest expression is an ID from the table. The useful ones are built from a few short names and three operators.
- One exact format by its ID
yt-dlp -f 18 "URL"- The default, written out
yt-dlp -f "bv*+ba/b" "URL"- Best audio-only format
yt-dlp -f ba "URL"
- b — the best format that has both video and audio in one file.
- bv — the best video-only format. bv* is the best format that contains video, with or without audio.
- ba — the best audio-only format.
- A plus sign merges: bv+ba downloads the best video and the best audio and joins them.
- A slash is a fallback: bv*+ba/b tries the left side first and uses the right side only if the left is not available.
- A comma downloads several formats as separate files: bv,ba saves the video and the audio without merging them.
Filters in square brackets
A selector can carry conditions in brackets. bv*[height<=1080] is the best video no taller than 1080 pixels; ba[ext=m4a] is the best audio in an m4a file. Numbers compare with <, <=, >, >= and =. Text fields such as ext, vcodec and acodec also accept ^= for starts with and *= for contains. Several brackets in a row must all be true.
Filters are strict. If nothing matches, yt-dlp does not pick the nearest thing; it stops with “Requested format is not available”. That is why filtered selectors are normally written with fallbacks after slashes. It is also why formats whose value is unknown are excluded unless you put a question mark after the operator, as in [height<=?720].
Always put the whole expression in double quotes. In a Windows terminal the < and > characters would otherwise be taken as redirection.
- Up to 1080p, strictly, with fallbacks
yt-dlp -f "bv*[height<=1080]+ba/b[height<=1080]" "URL"- MP4 video with M4A audio where available
yt-dlp -f "bv*[ext=mp4]+ba[ext=m4a]/b[ext=mp4] / bv*+ba/b" "URL"
Sorting with -S
-S is the newer and, for most purposes, better tool. It does not exclude anything. It changes how formats are ranked, and -f then takes the top of the list as usual. Because nothing is excluded, a sort cannot come up empty.
You give it fields in order of importance. A field followed by a colon and a value means prefer this value and do not go above it. So -S "res:1080" prefers the largest resolution up to 1080p, and takes the smallest available if nothing is that low. Resolution is measured on the shorter side, so it behaves correctly for vertical video. A plus sign in front reverses a field: -S "+size" prefers the smallest file.
Codecs work the same way. -S "vcodec:h264" prefers H.264 over the newer codecs. Combine fields with commas and the first one wins ties: "res:1080,vcodec:h264" settles the resolution first and prefers H.264 among formats at that resolution. The README recommends sorting over the worst selectors too: for a small file, use -S "+size,+br" and not -f worst.
- Best quality up to 1080p
yt-dlp -S "res:1080" "URL"- Prefer H.264 video
yt-dlp -S "vcodec:h264" "URL"- Up to 720p, preferring higher frame rates
yt-dlp -S "res:720,fps" "URL"- The smallest file available
yt-dlp -S "+size,+br" "URL"
Choosing the container
Selecting formats decides which streams you get. The file they end up in is a separate choice. When yt-dlp merges, it picks a container that suits the codecs, which is why 4K downloads often arrive as WEBM or MKV.
--merge-output-format names the containers the merge may use, in order of preference, for example mp4/mkv. It is ignored when no merge takes place. --remux-video moves the finished download into another container without re-encoding, and fails if that container cannot hold the codecs. Neither changes the codec inside the file.
For a file that plays on nearly anything, the mp4 preset combines all three ideas: -t mp4 prefers H.264 video and AAC audio, merges to MP4 and remuxes to MP4 if needed.
- Merge into MP4 if possible, otherwise MKV
yt-dlp --merge-output-format "mp4/mkv" "URL"- Repackage the result as MKV
yt-dlp --remux-video mkv "URL"- The compatible MP4 preset
yt-dlp -t mp4 "URL"
Worked examples
These are complete commands for the requests that come up most often. Each one keeps the default selector and only changes the ranking or the container, so none of them fails when a video lacks a particular format.
- 1080p in H.264 with AAC sound, as MP4
yt-dlp -S "res:1080,vcodec:h264,acodec:aac" --merge-output-format mp4 "URL"- The highest quality there is, in an MKV
yt-dlp --merge-output-format mkv "URL"- A small 480p copy for a phone
yt-dlp -S "res:480" "URL"- Audio only, original codec
yt-dlp -x "URL"- A playlist capped at 720p
yt-dlp -S "res:720" -o "%(playlist_title)s/%(playlist_index)02d - %(title)s.%(ext)s" "PLAYLIST_URL"
The same choices as menus
If the syntax above is more than you want to keep in your head, GetVideosLocally, the Windows app this site is about, presents the common choices as menus. Quality defaults to Best available (up to 8K) and can be set lower; the format is MP4, MKV, WEBM or MOV for video, or FLAC, WAV, MP3 at 320 kbps or OPUS for audio. yt-dlp and FFmpeg are bundled, so merging works from the first download.
A window cannot expose every selector and sort field, and for unusual requests the command line remains the right tool. Whichever you use, download only what you are allowed to save: your own uploads, public-domain and Creative Commons material, and content you have permission for.
FAQ
What does bv*+ba/b mean?
It is yt-dlp’s default. Take the best format that contains video, merge in the best audio-only format if the video has no sound, and if that is not possible use the best single file that has both.
What is the difference between -f and -S?
-f selects and can filter formats out, so a strict filter may match nothing and stop with an error. -S only changes the ranking, so there is always a result. For limits such as a maximum resolution, -S is usually the better choice.
How do I download 1080p with yt-dlp?
Use yt-dlp -S "res:1080" "URL". It takes the best quality up to 1080p and falls back to the nearest lower resolution when 1080p does not exist. FFmpeg must be installed for the merge.
Why do I get “Requested format is not available”?
The -f expression matched nothing: a format ID from another video, or a filter this video cannot satisfy. Run -F to see what exists, add a fallback after a slash, or switch to -S.
Does --merge-output-format mp4 convert the video?
No. It only chooses the container used when streams are merged. The codecs stay as downloaded. To get a broadly compatible file, prefer H.264 with -S "vcodec:h264" or use -t mp4.
Download GetVideosLocally for Windows. Free and open source.