How to get best quality audio using youtube-dl

audio-streamingyoutube-dl

I am using youtube-dl on Linux to download videos from YouTube and extract the audio. This is my way of building a small music collection.

Anyways, I know that there is an option --audio-quality= with 0 being best and 9 being worst. Is this all I need to do to get the best quality audio?

Also, does anyone know if downloading from soundcloud could get higher quality?

Best Answer

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.

Related Question