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 .ogg file:

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.

In oggenc, a -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 -qscale:a 6:

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)

| improve this answer | |
  • Thanks. That's what I was afraid of. The webm files from youtube have opus audio in them, and my media player won't play them, even if embedded in an ogg file. I haven't found a way to transcode them without losing quality, or else hugely increasing file size. – doctordruidphd Jul 14 at 12:28
  • Transcoding to vorbis should not lead to a huge increase in file size. Of course, there is (perceived or not) quality loss. Please consider accepting the question if it answers your concern (even not entirely to what you may have wished). – vanadium Jul 14 at 12:33

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.