2

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?

2

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.

  • 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? – Harrison Sep 27 '17 at 20:40
  • 1
    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. – Satō Katsura Sep 28 '17 at 5:14
  • 1
    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? – Harrison Sep 28 '17 at 23:44
  • 1
    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. – Satō Katsura Sep 29 '17 at 7:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.