Skip to content

Choosing Formats

Every download is a choice among formats, made by you or — if you say nothing — by yt-dlp's default preference for the best on offer. This chapter teaches the choice; every selector below was test-run in the lab (transcript t05), and one honest failure of a filter is kept at the end.

Two shapes of format list

Chapter 4's list was the simple shape: complete files, picture and sound together (progressive formats). The other shape serves them separately. A TED talk's list (abridged):

ID             EXT RESOLUTION |  FILESIZE  | VCODEC  ACODEC
-----------------------------------------------------------
hls-audio0-low mp4 audio only |  ~4.93MiB  |         aac
hls-150        mp4 240x180    | ~20.71MiB  | h264
hls-450        mp4 320x240    | ~58.14MiB  | h264
hls-1017       mp4 640x480    |~139.63MiB  | h264

The hls- rows are video-only; the sound lives in the hls-audio0 rows. Neither half is a watchable film on its own — they are made to be merged (chapter 2's postprocessor, ffmpeg doing the joining).

Choosing

yt-dlp -f 480p <URL>            # by ID, from the -F table
yt-dlp -f b <URL>               # best overall
yt-dlp -f w <URL>               # worst (smallest) overall
yt-dlp -f bv+ba <URL>           # best video + best audio, merged
yt-dlp -f "hls-150+hls-audio0-low" <URL>   # a named pair

The lab merged that named TED pair into one MP4 holding both streams — transcript t11 verifies the result with ffprobe: h264 video at 320x180 and AAC audio, 19 minutes 11 seconds.

Filters narrow a selector:

yt-dlp -f "b[height<=480]" <URL>

means "the best format no taller than 480 pixels". Against chapter 4's table the lab watched this pick 480p, plain b pick 720p, and w pick 240p.

Sorting states a preference instead of a hard cut:

yt-dlp -S "res:360" <URL>

prefers formats nearest 360p while still taking the best of everything else; the lab watched it pick 360p from the same table. And selectors chain with / — "this, or failing that, this":

yt-dlp -f "bv[height<=480]+ba/b" <URL>

Test the choice before the download

Selectors are easy to mistype and the penalty is a long download of the wrong thing. Dry-run them:

yt-dlp --simulate -f "b[height<=480]" \
  --print format_id --print height <URL>

--print shows any extracted fact — title, duration, ID, the format a selector chose — without downloading. The lab's four test runs are transcript t05; make this your habit on any new site.

The cautionary tale

Filters match on the metadata the extractor reports, and not every format carries every fact. Downloading a trailer from the same PeerTube instance as chapter 4, the lab asked for b[height<=360]/b and received the biggest file on offer — a 2578x1080 format, 33 MB (transcript t12). Cause: that video's direct-file formats report no numeric height, its two streamable variants are both taller than 360, so the filter matched nothing — and the /b fallback dutifully took the best. Nothing malfunctioned; the instruction meant something narrower than the reader intended. Read the -F table first, and let fallbacks be a deliberate choice, not a surprise.