I understand (maybe incorrectly) that webm audio files downloaded from youtube are basically vorbis streams inside an opus file structure. Is there a way to extract that stream and save it as an ogg file without transcoding? So far, all of my experiments have either produced just opus files with an ogg extension (using -c:a copy for example), or transcoded files that have a drastic loss of quality.
.webm files indeed can contain vorbis audio, but it can also contain opus audio. Also an ogg file can contain both audio formats. One can transfer the audio without conversion to an
ffmpeg -i "$INPUTFILE" -vn -c:a copy "$(basename "$INPUTFILE" .webm)".ogg
If you need vorbis audio in an ogg container, but your
.webm contains opus audio, then you need to transcode obviously.
-q 6 setting will result in a file with variable bitrate at about 192 kbps. This is a setting where quality loss mostly will not be perceived anymore ("transparent"), and is a setting optimal to achieve excellent quality at a minimum file size. In
ffmpeg, the corresponding option is
ffmpeg -i "$INPUTFILE" -vn -c:a libvorbis -qscale:a 6 "$(basename "$INPUTFILE" .webm)".ogg
The range is -1 to 10, where 10 is very high quality.The default is
-qscale:a 3, which corresponds to an average bitrate of about 112. (See full details)