Filtering Formats
You can filter video formats by putting conditions in brackets, as in -f "best[height=720]"
(or -f "[filesize>10M]"
since filters without a selector are interpreted as best
).
Numeric Meta Fields
The following numeric meta fields can be used with comparisons <
, <=
, >
, >=
, =
(equals), !=
(not equals):
filesize
: The number of bytes, if known in advancefilesize_approx
: An estimate for the number of byteswidth
: Width of the video, if knownheight
: Height of the video, if knownaspect_ratio
: Aspect ratio of the video, if knowntbr
: Average bitrate of audio and video in kbpsabr
: Average audio bitrate in kbpsvbr
: Average video bitrate in kbpsasr
: Audio sampling rate in Hertzfps
: Frame rateaudio_channels
: The number of audio channelsstretched_ratio
:width:height
of the video's pixels, if not square
String Meta Fields
Also filtering work for comparisons =
(equals), ^=
(starts with), $=
(ends with), *=
(contains), ~=
(matches regex) and following string meta fields:
url
: Video URLext
: File extensionacodec
: Name of the audio codec in usevcodec
: Name of the video codec in usecontainer
: Name of the container formatprotocol
: The protocol that will be used for the actual download, lower-case (http
,https
,rtsp
,rtmp
,rtmpe
,mms
,f4m
,ism
,http_dash_segments
,m3u8
, orm3u8_native
)language
: Language codedynamic_range
: The dynamic range of the videoformat_id
: A short description of the formatformat
: A human-readable description of the formatformat_note
: Additional info about the formatresolution
: Textual description of width and height
Advanced Filtering
Any string comparison may be prefixed with negation !
in order to produce an opposite comparison, e.g. !*=
(does not contain). The comparand of a string comparison needs to be quoted with either double or single quotes if it contains spaces or special characters other than ._-
.
Note: None of the aforementioned meta fields are guaranteed to be present since this solely depends on the metadata obtained by the particular extractor, i.e. the metadata offered by the website. Any other field made available by the extractor can also be used for filtering.
Formats for which the value is not known are excluded unless you put a question mark (?
) after the operator. You can combine format filters, so -f "bv[height<=?720][tbr>500]"
selects up to 720p videos (or videos where the height is not known) with a bitrate of at least 500 kbps. You can also use the filters with all
to download all formats that satisfy the filter, e.g. -f "all[vcodec=none]"
selects all audio-only formats.
Format selectors can also be grouped using parentheses; e.g. -f "(mp4,webm)[height<480]"
will download the best pre-merged mp4 and webm formats with a height lower than 480.