-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:3gp, aac, flv, m4a, mp3, mp4, ogg, wav, webm
Special Format Selectors
yt-dlp provides special names to select particular formats:- Best Quality
- Worst Quality
- All Formats
b,best- Best quality format with both video and audiobv,bestvideo- Best video-only formatba,bestaudio- Best audio-only formatb*,best*- Best format that contains either video or audiobv*,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 byteswidth- Video widthheight- Video heighttbr- Total bitrate in kbpsabr- Audio bitrate in kbpsvbr- Video bitrate in kbpsfps- Frame rateaudio_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 extensionacodec- Audio codec namevcodec- Video codec namecontainer- Container formatprotocol- Download protocollanguage- Language codeformat_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 formatres- Video resolution (smallest dimension)fps- Frame ratehdr- Dynamic range (DV>HDR12>HDR10+>HDR10>HLG>SDR)codec- Video/audio codec preferencesize- Filesize (exact or approximate)br- Bitrate (total/video/audio)asr- Audio sample rateproto- Protocol preferenceext- File extension preferencelang- Language preference
- Resolution
- Filesize
- Codec
- Protocol
Sort Order
- Fields are sorted in descending order by default
- Prefix with
+to reverse to ascending order - Suffix with
:VALUEto prefer values up to that limit - Suffix with
~VALUEto prefer values closest to that limit
Practical Examples
Interactive Selection
Use-f - to interactively choose the format for each video: