To get the best audio quality possible you simply need to select a source format of high quality. Actually, youtube-dl will do that by default, but you can explicitly set it with --audio-format best. YouTube (and other providers) store different audio codecs with different bitrates, and youtube-dl will choose the best one from those.
will get you an audio version (-x, short for --extract-audio) in or converted to mp3 (that's the --audio-format option). youtube-dl will automatically pick the best quality and most appropriate format.
While you can use -f to select a particular format, this is intended for people who want lower quality because of limited bandwidth or storage space, or for debugging. By default, youtube-dl already downloads the highest quality.
However opus format might be inconvenient for many reasons.For example some media players especially in cars and telephones might not support it.Probably you just want to have audio in mp3 file.Below there is a solution on how to (using one command) download audio and convert it to probably most popular mp3 format with lossing as little quality as possible.
--audio-quality 0 tells youtube-dl to save audio file in the best quality (when converting to mp3).
Without this option mp3 audio-quality is set by default to 5 in 0-9 scale where 0 is the best quality and 9 the worst quality. So by default quality is worse.Youtube streams for nonpremium users with variable bitrate up to 160kbps in opus format. Opus format is newer than mp3 and has better compression than mp3 preserving the same quality. So 160kbps opus = 256kbps mp3.When audio-quality is default (5 in 0-9 scale) mp3 bitrate is limited to 160kbps which means that some sound quality is lost during compression. When audio-quality is set to 0 mp3 goes up to 300kbps preserving almost original quality.Almost original quality because mp3 is a lossy format so something is lost when converting to it. By using --audio-quality 0 option we just make sure that we loose as little as possible during this conversion. So difference between original opus audio file and audio file converted to mp3 is so small that it might be hard to spot by ear.
Since it doesn't specify --audio-format, youtube-dl won't do any reencoding, thus it doesn't lose audio quality. However, it may happen the video is available in a better quality (with a different ext=...).
Also 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.
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
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.
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.
I've been using youtube-dl to download audio from SoundCloud and now YouTube. There are several different ways to get audio only from YouTube, but they all seem to yield the same exact file, so I'm not sure which settings I should be using.
These commands will ensure you download the highest quality mp4 video and m4a audio from the video as a single file or will merge them back into a single mp4 (using ffmpeg in my case). If ffmpeg or avconv is not available, youtube-dl should fall back to the single file -f best option instead of the default.
notice that youtube-dl has labeled the last option 1280x720 as the 'best' quality and that's what it will download by default, but that the line starting with 137 is actually higher quality 1920x1080. Youtube has separated the video and audio streams for the lines labeled DASH so we also need to pick the highest quality audio which in this case is the line starting with 141. Then we run youtube-dl again this time specifying the audio and video:
and it will download the 1080p video and auto-merge it with the highest-quality audio. It should also auto-deleted the separate downloaded parts. This method is a little extra work, but will get you the best results.
This answer here, with the most votes, should be right to give you the best video quality available, but....it's not always. bestvideo+bestaudio seems to choose only the best video and best audio of the options that are video only and audio only, then it merges the two together. Note that this also appears to be identical to the default behavior of youtube-dl. However, on the video I was looking at, the best quality was a single, pre-merged file that was already in a format with combined video and audio. The bestvideo+bestaudio option did NOT choose this best quality 720p file because it was looking only for separate video and audio files. Details below.
Some video sites, such as youtube, offer not only different resolutions of video to download, but have options in youtube-dl called formats to download video and audio separately. For the case of youtube, it will only offer the highest quality video and highest quality audio separately. Here's an example output of using -F flag to show all formats available:
So there's a lot of different formats, but some are labelled "audio only" or "video only". If I selected to download one of those formats by using the specified format code such as with -f 137, I would really get either an audio file or a video file with no audio, which is usually not what you want. If I had ffmpeg installed and specified both video and audio formats with -f 137+140, then youtube-dl would download video and audio and afterwards combine them together into one video file.
If you don't have ffmpeg installed, youtube-dl will by default select the highest quality format that has both audio and video. This maxes out at 720p (and is usually specified by format code 22 so you would download with -f 22). If you do have ffmpeg installed, youtube-dl will be able download the real best quality video (1080p or better if available) and best quality audio, and after downloading mux (combine) them together into one video file so this is what I recommend.
youtube-dl with --format=bestvideo[ext=mp4]/bestaudio - downloads video that satisfies both requirements in one video, may not be the highest video or highest audio, doesn't need ffmpeg, always get the video type you ask for.
Maybe I don't understand but there already is a dropdown menu that allows you to choose the format. The fact that the plugin is adding the arguments to youtube-dl that makes sure you get that selected format is why you don't always get the highest quality video.
Personally I had no problem with mkv file. Allmost all newer Smart TVs and media players should play it. I have an old Popcorn Hour C200 which I still use from time to time which can also play mkv files.
Therefore I really would appreciate a possibility to download the highest quality also if a mkv file would be created and ffmpeg has to be installed.
And also from my side: Thank you for doing this.
Actually, I don't know what you mean. It was working properly. I use this plugin all the time. The only thing it isn't doing is downloading the highest quality video. It has never downloaded the wrong format. It would download the wrong format IF the plugin was changed to use --format=best and ffmpeg was installed.
It is downloading the file with the best quality that is already merged. Yes, I get it that some videos have a separate video file of higher quality and separate audio file of higher quality that can be merged into a single file IF ffmpeg is installed. The stuff I download is mostly music to listen to in my garage or old kid videos that don't have high quality streams.
760c119bf3