It is also worth noting other pieces out of
man youtube-dl (a online copy can be found here):
(For those thinking TL;DR, just read the 4th paragraph, and you can use
youtube-dl -x URL as it should download the best quality anyway :)
youtube-dl -f bestaudio URL works in my experience! However with both these options most of the time you will need convert to MP3 using
ffmpeg or similar - since you are already editing the file you can also tag it (use the old ID3 version for most device compatibility!).
By default youtube-dl tries to download the best quality, but sometimes you may want to download other format. The simplest case is requesting a specific format, for example
-f 22. You can get the list of available formats using
--list-formats, you can also use a file extension (currently it supports aac, m4a, mp3, mp4, ogg, wav, webm) or the special names best, bestvideo, bestaudio and worst.
If you want to download multiple videos and they don't have the same formats available, you can specify the order of preference using slashes, as in
-f 22/17/18. You can also filter the video results by putting a condition in brackets, as in
-f "best[height=720]" (or
"[filesize>10M]"). This works for filesize, height, width, tbr, abr, vbr, asr, and fps and the comparisons <, <=, >, >=, =, != and for ext, codec, vcodec, container, and protocol and the comparisons =, != . 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 "[height <=? 720][tbr>500]" selects up to 720p videos (or videos where the height is not known) with a bitrate of at least 500 KBit/s.
Use commas to download multiple formats, such as
-f 136/137/mp4/bestvideo,140/m4a/bestaudio. You can merge the video and
audio of two formats into a single
-f <video-format>+<audio-format> (requires ffmpeg or avconv), for example
Since the end of April 2015 and version 2015.04.26 youtube-dl uses
-f bestvideo+bestaudio/best as default format selection (see #5447, #5456). If ffmpeg or avconv are installed this results in downloading bestvideo and bestaudio separately and muxing them together into a single file giving the best overall quality available. Otherwise it falls back to best and results in downloading best available quality served as a single file. best is also needed for videos that don't come from YouTube because they don't provide the audio and video in two different files. 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. Note that if you use youtube-dl to stream to stdout (and most likely to pipe it to your media player then), i.e. you explicitly specify output template as
-o -, youtube-dl still uses
-f best format selection in order to start content delivery immediately to your player and not to wait until bestvideo and bestaudio are downloaded and muxed.
If you want to preserve the old format selection behavior (prior to youtube-dl 2015.04.26), i.e. you want to download best
available quality media served as a single file, you should explicitly specify your choice with
-f best. You may want to add it to the configuration file (#configuration) in order not to type it every time you run youtube-dl.
Can you please put the -b option back?
Most people asking this question are not aware that youtube-dl now defaults to downloading the highest available quality as reported by YouTube, which will be 1080p or 720p in some cases, so you no longer need the -b option. For some specific videos, maybe YouTube does not report them to be available in a specific high quality format you're interested in. In that case, simply request it with the
-f option and youtube-dl will try to download it.
Youtube (probably as it is supposed to be a video playing site) also apparently compresses the audio (see here) down to 120~KBs, which is quite low but for the most part seems OK.
To compare download videos, you can query the downloaded video/audio tracks (you may need to use
avprobe instead of
ffprobe) to see which is best:
$ ffprobe -hide_banner output-output-loads-of-options.webm
Input #0, matroska,webm, from 'output-output-loads-of-options.webm':
encoder : google
Duration: 00:04:02.63, start: 0.000000, bitrate: 118 kb/s
Stream #0:0(eng): Audio: vorbis, 44100 Hz, stereo, fltp (default)
$ ffprobe -hide_banner output_with_just_-x.ogg
Input #0, ogg, from 'output_with_just_-x':
Duration: 00:04:02.65, start: 0.000000, bitrate: 117 kb/s
Stream #0:0(eng): Audio: vorbis, 44100 Hz, stereo, fltp, 128 kb/s
LANGUAGE : eng
ENCODER : Lavf56.4.101