20

No, this is not a duplicate of this question.

I have been using youtube-dl to download some music videos from YouTube. I noted that left to its defaults, youtube-dl will use bestvideo+bestaudio, and with recent videos, for bestaudio it will nearly invariably download the Opus track.

I know that, encoded from source, Opus tracks usually have better quality than AAC tracks at the same bitrate.

However, I also know that Opus audio is not supported by the MP4 container, and since uploads to YouTube does not (yet) support MKV, the original upload would be using AAC. Which means the Opus audio track will be a lossy-transcode from AAC, potentially reducing quality.

(FI, I have no problem playing the remuxed video+audio using MPC-HC + K-Lite Mega Codecs, and I also have no problem extracting the audio using ffmpeg -c:a copy and playing it using Foobar2000)

So, my question is: Do you think I should download the AAC track instead of the Opus track, or should I just let youtube-dl does its stuff? What benefit will I get downloading the Opus track compared to downloading the AAC track?

1
  • 1
    Good question. I thought the best approach is for youtube-dl to download the bestvideo one as-is, without re-encoding. I actually had been wondering why youtube-dl is doing lots of re-encoding lately. It is a known fact that whatever encoding method is, no matter how good it is, if encoding from a not-so-good source, it will make things worse than before. I.e., I really hope youtube-dl will download the best one as-is, without re-encoding, as much as possible.
    – xpt
    Mar 5 '16 at 15:21
8

You do not have to worry so much about the source audio being AAC because, even though YouTube recommends using it as well as the MP4 container, the MKV container and lossless codecs like PCM and FLAC are in fact supported (I've been using MKV + FLAC for years now on YouTube).

But even then, if the user does in fact upload their audio in AAC, YouTube will in fact still transcode it for their AAC encodes. YouTube also recommends uploading at 48KHz, but only their Opus encodes are in 48KHz - YouTube uses 44.1KHz for both AAC and Vorbis, so both of those encodes are likely to have been downsampled as well.

In the end, Opus should still be higher quality.

2
  • 1
    YOOOO... I never knew that YouTube accepts FLAC!!! (I know it already accepts MKV, but never realized about FLAC) Thanks for the info!
    – pepoluan
    Dec 1 '17 at 6:42
  • Aaaahh, and thank you about the information w.r.t. YouTube re-encoding audio tracks to AAC!! That's VERY eye-opening... I guess I'll download in Opus from now on. Marking your answer as 'the'! :-)
    – pepoluan
    Dec 1 '17 at 6:43
7

Not to commenting on the youtube-dl but trying to answer your Opus audio related questions.

As ffcvt suggested, "the Opus audio codec is becoming the best thing ever for compressing audio -- A 64K Opu audio stream is comparable to mp3 files of 128K to 256K bandwidth".

If you are interested, check this out for some comprehensive info on Opus, which includes links to Sound Examples you can test out yourself.

I know your are worrying about the lossy-transcode comparing to AAC because of the potentially reducing quality, however, let me tell you, most people won't notice any differences, including some sound experts. Of course your experience will be different. So test out those Sound Examples yourself and see how different you can tell from each of them, and find your comfortable level. If you want to fine tune the bandwidth parameters, ffcvt can help.

Overall, Opus is a new audio codec, and it will become a new standard for audio on the web. Features include:

  • Better compression than mp3/ogg/aac.
  • Good for both music and spoken word.
  • Dynamically adjustable bitrate, audio bandwidth, and coding delay.
  • Good for real-time and pre-recorded applications.
4
  • Good points. But I wonder is there a benefit of downloading the Opus track, though? Even when Opus becomes the de facto standard for audio encoding, I don't think support for AAC playback will disappear...
    – pepoluan
    Mar 5 '16 at 20:58
  • 1
    Agree. No argument with AAC encode/playback, and honestly, I don't know if there is ready-made Opus track for downloading or not either. But if there is one, and provided that you personally can't tell the differences between Opus & AAC track, I don't see the point of downloading the AAC track myself. Opus would be smaller, takes less time to download, and takes less space on disk too, yet it'd be exactly the same to human ears.
    – xpt
    Mar 5 '16 at 21:30
  • 1
    And how to detect Opus file bitrate? VLC doesn't show it in its info
    – Suncatcher
    Apr 23 '18 at 9:46
  • That's a different question, @Suncatcher.
    – xpt
    Apr 23 '18 at 13:58
5

AAC is likely slightly better, though at bitrates found on Youtube, there is not a large difference, so you should choose the format based on other requirements like compatibility.

While it is true that all video and audio on Youtube are transcoded, Opus does not gain an advantage from this as indicated by the current answer. Repeated transcodes using the same codec does not reduce quality as much as you would expect from a normal transcode. Since the encoder tends to make the same or similar decisions about what data to throw away, a second pass will actually tend to keep the same data that was preserved during the first pass, resulting in fewer differences between repeated transcodes.

Here is one test demonstrating this phenomenon: After 100-passes of AAC transcodes, the result is surprisingly high quality. Additionally, IIRC on certain codecs, if you repeatedly transcode with the same settings, quality will amazingly not drop below a certain threshold, reaching an asymptote that depends on bitrate.

Since most video software encodes the audio track as AAC, the AAC track Youtube provides is likely an AAC -> AAC transcode, which will be better than an AAC -> Opus transcode.

Additionally, Opus is not always the best option for music. Although Opus is very good at a variety of audio, it does not necessarily beat all other lossy codecs in every case. Opus was originally designed as a low bit rate, low latency, speech codec for telephony applications. And while many incremental improvements were made so that it could deal with a much larger variety of audio, it still shows weaknesses in a few areas as a result of that initial design decision.

For example, Opus has an Achilles' heel where tonal music can be glaringly bad. In the 64kbps listening test, it failed miserably on a harpsichord sample (#2) against AAC. In the 96kbps listening test, it failed again on a guitar sample (take_your_finger_from_my_hair) and was even beat by MP3! Opus was originally designed with a short MDCT window for low latency, so it occasionally shows odd problems in places where AAC doesn't. The short window creates low frequency resolution that must be compensated by increasing the bitrate in order to get good quality on tonal sounds, implemented in the encoder with tonality estimation.

8
  • Keep in mind that the AAC encodes that YouTube makes seems to pretty solidly stick to ~128kbps while their Opus encodes can peak all the way up to ~160kbps. Additionally, the AAC encodes will have their audio spectrum cut off at ~16KHz while the Opus and even the Vorbis encodes will go all the way up to ~20KHz. While it's not AAC, with a few of my own music uploads that used 320kbps 44100KHz MP3 (because I was unable to locate lossless versions), the Opus versions definitely sounded better. Nov 20 '18 at 9:28
  • Derp, didn't know superuser has an edit-count limit. It was actually a 160kbps MP3 at 44100Hz (not KHz :P) which I mixed up with the other couple 44100Hz 320kbps MP3 uploads (which are actually missing Opus encodes). Additionally, somewhat older Opus encodes (as in maybe two years old) have even higher bitrates that can peak all the way to ~180kbps. I also will be trying to do some listening tests with YouTube by uploading AAC audio encoded from a lossless source at various bitrates and report back at some point. Nov 20 '18 at 10:03
  • 1
    Opus on Youtube average 128kbps, same as AAC, which is also VBR. Additionally, most audio is transparent or very close at those settings. So there isn't that much of a difference there
    – goweon
    Nov 21 '18 at 19:32
  • 1
    But those listening tests you are referring to were comparing a nascent Opus encoder (~5 years ago) to extremely mature AAC, MP3, and Vorbis encoders. And considering Opus' low-latency nature, it's to be expected that it wouldn't be better at absolutely everything right off the bat. But even if it still isn't better at those specific types of music even today, one must consider that AAC certainly isn't better than even 1.0 Opus at other types of music (particularly more complicated electronic type genres that are all the rage anymore) Nov 21 '18 at 23:31
  • 1
    This is a misconception. Youtube does not serve Opus at 160k, even if it claims to. If you download the opus track, it actually sits closer to 100k for all videos, same as AAC and MP3. Additionally. You'd be hard pressed to hear any difference between AAC vs Opus at 160k, so the codec question becomes a bit moot.
    – goweon
    Oct 21 '19 at 17:38
1

Okay, I want to share what I finally do:

  • If it's a short clip, say <5m, I use default behavior
  • If it's a long-ish clip, so >5m, I use -f best

The reason is that, out of quite a number of downloads, I have come upon a couple of failures (cut audio, mostly) with default behavior. It seems that YouTube's Opus transcoding from AAC is buggy.

With short files, I can watch+listen for problems, and redownload using -f best if necessary.

Long files, though, are difficult to watch+listen properly (hearing fatigue + need to set aside some not quite insignificant time). So I just take the safe way out with -f best.

2
  • 1
    I don't seem to find any audio problems with long audio clips in .opus files extracted from webm containers.
    – jj_
    Sep 19 '17 at 7:42
  • 1
    @jj_ I might be just unfortunate, then :-D ... probably hitting a time when YouTube was glitching on their side.
    – pepoluan
    Dec 1 '17 at 6:44
-2

If you're using any Linux distro you're in luck, just install 'video downloader'! It downloads audio and video files. If left alone it will download audios in MP3 fomat @ 192kbps and 48000hz sampling rate. What it does is download the audio file in opus and reencode it to MP3. If you want, you can cancel the download after it has downloaded the opus file when it shows the downloaded file is the same as size of the projected file size. Then go to the /downloads/videodownloader/name of the file and look a file with a .webm extension. That is the opus file that you want. Just rename it to the name you want and change the extension to .opus. Play it in VLC and check the Codec info. It'll show opus @ 32bit and 48000hz sampling rate. I was able to download an 8 hour audio file successfully.

Videos will be in .webm format (db9 + opus).

1
  • -1 I was not asking about the "how". youtube-dl -- available on Linux and Windows -- is good enough for all my needs. What I was asking is the "which".
    – pepoluan
    Sep 26 '20 at 12:52

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.