Get youtube-dl video for a particular size, like 480p or 720p
This answer is very involved:
youtube-dl -f 'bestvideo[height<=480]+bestaudio/best[height<=480]'
Surely I don't have to memorize all this just to get a 480p video in one stroke?
I usually use -F
to get a list of streams, and then -f
to select both the audio and the video. It's not overly burdensome, but I hoped there was some simpler shortcut to a certain video size, since it is such a common task.
I have read the help, in fact searched for every occurrence of the word "size", and they are all references to file size, none to video size.
Solution 1:
No, there isn't a one-letter shortcut option.
The simplified version, changed to request an exact height (=
vs <=
), is:
youtube-dl -f 'bestvideo[height=480]+bestaudio'
This longer version is needed because all new YouTube uploads use separate audio and video streams. If you had used -f 'best[height=480]'
only, it would work for low-resolution modes (e.g. 360p), but often wouldn't find any combined high-resolution stream at all.
Youtube-dl ended up having this kind of format specification because its users wanted flexibility – it's not just that you need a specific resolution, but other users also need specific formats (e.g. H.264 video only; MP4 container only; any audio except OPUS; etc.), or specific stream types (e.g. audio only), or various other constraints.
You did not find any results in documentation because as you noticed, the term "size" is ambiguous, so pixel dimensions are referred to as "resolution" instead. Indeed the documentation contains this example:
If you want to only download some DASH formats (for example if you are not interested in getting videos with a resolution higher than 1080p), you can add
-f bestvideo[height<=?1080]+bestaudio/best
to your configuration file.
So the earlier answer is correct and matches the youtube-dl author's recommended approach.