How to download the highest quality .mp3 with youtube-dl on Sierra?

11,472

According to youtube-dl --help:

--audio-format FORMAT Specify audio format: "best", "aac", "flac", "mp3", "m4a", "opus", "vorbis", or "wav"; "best" by default; No effect without -x

So just add -x:

youtube-dl -x -f bestaudio --audio-quality 0 --audio-format mp3 \ 
    https://www.youtube.com/watch?v=3zy1SNH-VqE

However the result is a lossy-to-lossy re-encode, which is less than great. You can list the available formats with youtube-dl -F:

youtube-dl -F https://www.youtube.com/watch?v=3zy1SNH-VqE

There you can see that your best options are 160k Opus, or 128k Ogg. And indeed Opus has a much richer sound:

youtube-dl -x -f bestaudio --audio-quality 0 https://www.youtube.com/watch?v=3zy1SNH-VqE

You can play .opus files with ffplay.

Share:
11,472

Related videos on Youtube

Harrison
Author by

Harrison

Updated on September 18, 2022

Comments

  • Harrison
    Harrison almost 2 years

    I'm trying to use youtube-dl to download the highest quality .mp3 files from youtube videos. I've installed youtube-dl and ffmpeg and downloaded libav.

    I found this command:

    youtube-dl -f bestaudio --audio-quality 0 --audio-format mp3 https://www.youtube.com/watch?v=3zy1SNH-VqE
    

    posted elsewhere, which is supposed to get an .mp3 of the highest quality, but it only downloads a .webm, and the filesize appears to be around the 128 kbps range.

    I used to get an error that said I needed to download ffprobe or avprobe, so I'm not sure I have the ffmpeg and libav installed properly.

    Also, I saw some discussion elsewhere, is ffprobe or avprobe better?

  • Harrison
    Harrison over 6 years
    Thanks for the clarification. It seems like YouTube's maximum quality is 160k Opus, which is disappointing. Is it possible to command it to download the Opus file and automatically convert to .mp3?
  • Satō Katsura
    Satō Katsura over 6 years
    The first command above does that. But converting Opus to MP3 is a lossy-to-lossy re-encode, which is iffy for plain speech, and horrible for music. Basically once you get a lossy encoding you can't usefully convert it to anything else.
  • Harrison
    Harrison over 6 years
    When I enter the command, it only downloads it in opus. When I convert the 160 opus file to mp3 using convertio, it comes out to 243k, and sounds decent enough. Are you saying that the stated 243k is an inflated representation of the quality?
  • Satō Katsura
    Satō Katsura over 6 years
    Pretty much, yes. Sampling rate alone is not a good measure of quality. This is explained at length on just about any audiophile forum out there. Opus is a codec intended for low bitrate speech. That's all it does, and that's what makes re-encodes from Opus to MP3 even worse than other lossy-to-lossy re-encodes.