Skip to main content
By default, yt-dlp tries to download the best available quality. This is generally equivalent to using -f bestvideo*+bestaudio/best. However, you have granular control over which formats to download.

Basic Format Selection

The general syntax for format selection is -f FORMAT (or --format FORMAT) where FORMAT is a selector expression.

Simple Format Codes

The simplest case is requesting a specific format by its code:
Format codes are extractor-specific and may vary between different video sites.

File Extension Selection

You can download by file extension to get the best quality format of that type:
Supported extensions: 3gp, aac, flv, m4a, mp3, mp4, ogg, wav, webm

Special Format Selectors

yt-dlp provides special names to select particular formats:
  • b, best - Best quality format with both video and audio
  • bv, bestvideo - Best video-only format
  • ba, bestaudio - Best audio-only format
  • b*, best* - Best format that contains either video or audio
  • bv*, bestvideo* - Best format that contains video (may include audio)
  • ba*, bestaudio* - Best format that contains audio (may include video)

Format Selection by Preference

Specify multiple formats in order of preference using slashes:

Downloading Multiple Formats

Use commas to download several formats of the same video:

Merging Formats

Merge video and audio using the + operator (requires ffmpeg):

Filtering Formats

Filter formats by putting conditions in brackets:

Numeric Filters

Available numeric fields with comparisons <, <=, >, >=, =, !=:
  • filesize - Number of bytes (if known)
  • filesize_approx - Estimated number of bytes
  • width - Video width
  • height - Video height
  • tbr - Total bitrate in kbps
  • abr - Audio bitrate in kbps
  • vbr - Video bitrate in kbps
  • fps - Frame rate
  • audio_channels - Number of audio channels
The ? after an operator includes formats where the value is unknown. For example, [height<=?720] includes videos up to 720p AND videos where height is not known.

String Filters

Available string fields with comparisons =, ^= (starts with), $= (ends with), *= (contains), ~= (regex):
  • ext - File extension
  • acodec - Audio codec name
  • vcodec - Video codec name
  • container - Container format
  • protocol - Download protocol
  • language - Language code
  • format_id - Format identifier

Combining Filters

Use parentheses to group filters:

Sorting Formats

Change quality criteria using -S (--format-sort):

Available Sort Fields

  • quality - Quality of the format
  • res - Video resolution (smallest dimension)
  • fps - Frame rate
  • hdr - Dynamic range (DV > HDR12 > HDR10+ > HDR10 > HLG > SDR)
  • codec - Video/audio codec preference
  • size - Filesize (exact or approximate)
  • br - Bitrate (total/video/audio)
  • asr - Audio sample rate
  • proto - Protocol preference
  • ext - File extension preference
  • lang - Language preference

Sort Order

  • Fields are sorted in descending order by default
  • Prefix with + to reverse to ascending order
  • Suffix with :VALUE to prefer values up to that limit
  • Suffix with ~VALUE to prefer values closest to that limit

Practical Examples

Interactive Selection

Use -f - to interactively choose the format for each video:

Common Patterns

YouTube Best Quality

Save Bandwidth

Archive Quality