youtube-dl: Download Opus audio or AAC audio?
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.
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.
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.