24

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?

pepoluan
  • 1,332

7 Answers7

12

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.

NM64
  • 156
8

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.
xpt
  • 9,385
  • 44
  • 120
  • 178
6

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.

goweon
  • 1,821
2

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.

pepoluan
  • 1,332
1

Surprisingly, I find aac sometimes sharper, even though I can see more data on spectrum on 16kHz+ (up to 24 kHz) when I look at opus samples.

Don't know the chemistry here, maybe it's due to what exactly aac tries to preserve.

Usually, when I can, I try to (performing this with a browser addon) see two high-bitrate tracks (opus&aac mostly), open in separate tabs and listen. If it's speech track, or music track, I can listen & make a decision. But. Being freaky, I also can download them both & put into audition and look at the data. Doesn't give much, cause we'll still have to listen to audio, but you can see what is there and if there something missing.


With mp3, we could loose a lot of data if it's not v5/256+ bitrate.

Edit: used to keep my portable music library in vorbis/ogg on my cowon before switching to m4a/aac. Was very decent on highs and what I was trying to listen/feel.

But with opus&aac it's different. On lower bitrates, opus could be way better having still as much of the scene fullness as it can. But aac tries to save.. what's important (?). Could still loose some highs, but maintain juice of the spectrum (noticed long time ago that aac releases could deliver better bass section rather other codecs). (for movies I still prefer sometimes aac or original ac3 tracks if not dts, but not the opus/heaac - don't know the reason for it yet, though it fine enough to watch, but not to enjoy the experience. If heaac heavily compresses the track, opus just make it complete but dull.)


Perhaps, one better listen and choose wisely. Mostly, both of them are decent, though sometimes one is better than other for any particular purpose.

0

Choose Opus for better audio quality, always. It is true that generation loss is worse between different formats, but Opus is just that much more efficient that this is not relevant.

If the AAC track was 160 kbps CBR, this would be more questionable, especially considering the excellent AAC encoder YouTube uses, but since it's only 128 kbps CBR, the choice is clear.

damian101
  • 103
-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).

Ely
  • 1