I noticed that the files from the OPUS downloads are encapsulated in a WEBM container (WEBM is a video+audio container). That's maybe OK for VLC, but it's bad for other (audio only) players.
As audio only, OPUS should be encapsulated in an OGG container (just like VORBIS), but unlike OGG-Vorbis that uses the OGG extension, OGG-OPUS should use the extension OPUS, see below.
I also noticed that the OPUS formats 249, 250 and 251 have a WEBM container as default.
So we need to repack the OPUS stream (without transcoding it) from the WEBM to an OGG container after the download is done.
# youtube-dl output with -F or --list-formats
format code extension resolution note
249 webm audio only DASH audio 50k , opus @ 50k, ?.??MiB
250 webm audio only DASH audio 63k , opus @ 70k, ?.??MiB
251 webm audio only DASH audio 123k , opus @160k, ?.??MiB
From: https://tools.ietf.org/html/rfc7845#section-9
9. Content Type
An "Ogg Opus file" consists of one or more sequentially multiplexed
segments, each containing exactly one Ogg Opus stream. The
RECOMMENDED mime-type for Ogg Opus files is "audio/ogg".
If more specificity is desired, one MAY indicate the presence of Opus
streams using the codecs parameter defined in [RFC6381] and
[RFC5334], e.g.,
audio/ogg; codecs=opus
for an Ogg Opus file.
The RECOMMENDED filename extension for Ogg Opus files is '.opus'.
(see #1372 for previous discussion)
@Stypox @kapodamy This might be the source of the problem I described in #2340 as well. If implementing this _still_ doesn't fix that, then it might need a fix similar to the one required by #2152 implemented in #2149 as well.
@opusforlife2 I tried implement this in the past but I have not found any documentation/specification about the OGG format, how the audio data is stored, etc.
The only documentation I found only shows how the header is formed. I also can't find utilities like BMFF Viewer or MKV Toolnix that allow debug/inspect the file.
@kapodamy Are the docs at https://xiph.org/ogg/doc/ incomplete or irrelevant?
https://www.xiph.org/oggz/ seems to be the official inpection tool.
1_ for me is imcoplete
2_ thanks, thats was looking for
@kapodamy Do you specifically need more documentation on the Ogg container or on the Opus codec as well?
nope i basically used an hex editor and the oggz-dump for this (no joke)
@DocSniper. Your title for this issue should be edited. We should not use .ogg since Youtube does not use Vorbis anymore. As your linked documentation says, we should always remux Opus audio downloads to the .opus container for audio player compatibility and to not confuse people by making them think it is a Vorbis file when it is actually an Opus file.
@Pentaphon the title of this thread is absolutely correct.
You seem to mess up container format and audio codec a bit ?
Brief overview of the relationship between the container format OGG and the audio codecs/formats Vorbis and Opus and how they relate to each other:
Opus packets are not self-delimiting, but are designed to be used inside a container of some sort which supplies the decoder with each packet's length. Opus was originally specified for encapsulation in Ogg containers, specified as _audio/ogg; codecs=opus_, and for Ogg Opus files the _.opus_ filename extension is recommended.
The .opus filename extension, I mean. Title should be Repack OPUS to OGG container with .opus extension