The --audio-quality does not affect the audio quality of the source. It's a post processing option and will re-encode the audio.
Since any kind of (lossy) re-encoding will actually deteriorate the quality of the stream—or at least make it unnecessarily larger in size—I would recommend not to post-process the audio at all.
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.
If you have ffmpeg installed on your system, then youtube-dl can extract the audio automatically:
youtube-dl --audio-format best -x <url>
Otherwise, you will get a video file from which you have to extract the audio component.
ffmpegdoesn't reencode then why am I selecting the audio format? If I enter that line but withaacinstead, I don't get the same file but with a different extension. I get a different file with slightly different size and bitrate. – H.v.M. Mar 15 '16 at 23:02youtube-dlallows you to choose that format.ffmpegreally only multiplexes video and audio streams together into a single file. – slhck Mar 16 '16 at 10:14ffmpeg -i in.mp4 -c:a copy -vn out.m4aand end up with a different file thanffmpeg -i in.mp4 -c:a copy -vn out.mkv, although both contain the exact same audio data (and therefore have the same audio quality). – slhck Mar 16 '16 at 11:07youtube-dldoesn't re-encode? All videos I've tried in 240p, 480p and 1080p get the same quality of 253kbps, which seems kinda weird. Also, other services give 125kbps with what they claim is the best available quality and no re-encoding. For more details see here. – H.v.M. Mar 16 '16 at 12:04youtube-dlstill selects the highest quality video format. Do you have a specific video example? – slhck Mar 16 '16 at 15:07-xas an option, it'll download the audio-only variant with the highest bitrate (256k, format code 141, check out withyoutube-dl -F <url>). All other audio components of the other audiovisual representations have lower bitrates. – slhck Mar 16 '16 at 17:57youtube-dl --audio-format best -x https://www.youtube.com/watch?v=J9bjJEjK2dQyields 125kbps m4a, andyoutube-dl --format best -x https://www.youtube.com/watch?v=J9bjJEjK2dQyields 192kbps m4a. I guess it's because the format with highest audio quality isn't audio-only, and--audio-formatignores formats with video? But if I replace--audio-formatwith--format, maybe the format counted as 'best' has really high video quality but lower audio (1/2) – H.v.M. Apr 20 '16 at 17:40--format bestalso doesn't seem like a guarantee to have the best format. In fact, maybe it's possible that neither gives the best quality. What if one format has high video quality but medium audio quality, and one has high audio quality but low video quality, so the first is counted as best overall, and the second is not audio-only. – H.v.M. Apr 20 '16 at 17:44