8

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
    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
5

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.

  • 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.
  • 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
  • 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
0

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.

  • 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
0

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 difference 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 and forces you to up the bitrate to get good quality on tonal music. This was later built into the encoder with tonality estimation, but it's still not a completely solved problem.

  • 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. – Nintendo Maniac 64 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. – Nintendo Maniac 64 Nov 20 '18 at 10:03
  • 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
  • I haven't done my listening tests just yet, but if you download the audio stream and play it back in foobar2000 and look at the status bar showing the current bitrate, you'll see that Opus is extremely variable and regularly if not most of the time goes above that 128kbps while AAC is much less varied and tends to stick much closer to that 128kbps. And again, YouTube's AAC encodes remove frequencies above 16KHz which by definition will make them lower fidelity regardless of how perceptible that actually is (especially since "normal" AAC encodes do not have this 16KHz "wall") – Nintendo Maniac 64 Nov 21 '18 at 19:40
  • However, Opus has an Achilles' heel where tonal music can be glaringly bad. In the 64kbps listening test, it failed miserably on a harpsichord sample against AAC. In the 96kbps test, it failed again on guitar and was even beat by MP3! Opus was originally designed with a short MDCT window for low latency telephony, not high quality music, so it occasionally shows odd problems in places where AAC doesn't. To get good quality on tonal music, you're forced to ramp up the bitrate dramatically, which was later built into the encoder, but it's still not really a solved problem. – goweon Nov 21 '18 at 19:50

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.