With youtube-dl I first look what video quality is available and then in second step I download highest possible quality (in this example -f 137+140
). Youtube-d
I've found some weird cases where the default (see #5447, #5456) bestvideo+bestaudio/best
would download 720p video even when a 1080p was available. The reason that the bitrate on the 720p was very slightly higher, therefore it seemed better quality for youtube-dl. I prefer the higher res, also all other fancy youtube downloader applications downloaded the 1080p (as control).
Therefore I propose and use this:
-f ("bestvideo[width>=1920]"/bestvideo)+bestaudio/best
It will look for the best, at least 1920 wide video. If that's not available, it'll resort to what it would normally choose. The /best part at the end is part of the default config.
On a side note I recommend putting the %(format_id)s
somewhere in the filename, so you know what that file is using. If you later want to re-download a bunch of videos without using archive, with --no-overwrites
, a better/different quality will form a new filename next to the old one (so you can compare or whatever).
Or you could just use,
youtube-dl https://www.youtube.com/watch?v=blabla
This will download the highest quality video and audio and merge them automatically. And I think I have heard somewhere that you need ffmpeg installed to have this automatic behavior. But I bet most systems have it already.
Since the numbers of format are limited I did:
youtube-dl -f 299+140 "http://www.youtube.com/watch?v=P9pzm5b6FFY"
youtube-dl -f 137+140 "http://www.youtube.com/watch?v=P9pzm5b6FFY"
youtube-dl -f best "http://www.youtube.com/watch?v=P9pzm5b6FFY"
If the 299+140 has been downloaded the 137+140 won't be and if none of those have you'll have the best starting with 22. The only problem is that you'll have the best in webm as a duplicate but you can use the ext!=webm to avoid this.
Of course you can start at 313+140 or whatever higher format you want.
Just use -f bestvideo+bestaudio/best
for highest resulting quality available.
If you wanted to prefer MP4 format containers instead of WebM, use:
-f bestvideo[ext!=webm]+bestaudio[ext!=webm]/best[ext!=webm]
.
youtube-dl -f best 'youtube_URL'
or,
youtube-dl -f 'bestvideo+bestaudio/bestvideo+bestaudio' --merge-output-format mp4 'youtube_URL'
or,
youtube-dl -f 'bestvideo[ext=webm]+bestaudio[ext=m4a]/bestvideo+bestaudio' --merge-output-format mp4 'youtube_URL'
Hope it helps!