9

For .webm files obtained with youtube-dl -f bestaudio containing no video stream, is it preferable to run ffmpeg -i input.webm -vn -c:a copy output.opus or can one simply rename the source file, changing the extension?

I mean, the audio stream is clearly the same, but regarding the metadata, is there any downside with the second approach?

[Update] I checked metadata with mediainfo. Even if I save the ffmpeg output to .webm (by running ffmpeg -i input.webm -vn -c:a copy output.webm), the metadata differs.

Notice the new entry called "Bit depth":

comparison webm input and webm output with mediainfo GUI

And for the record, this is the .opus result:

opus output of mediainfo GUI

I'd like a canonical answer on whether there's something in the container definition that identifies it as a "pure audio" file as opposed to an audio/video file, something that is handled correctly only by "re-wrapping" the stream in a new container file.

Marc.2377
  • 1,457
  • 4
  • 23
  • 51
  • 2
    Suggestion: You can answer this question yourself by using MediaInfo or with a no-op command (`ffmpeg -i input.webm` vs `ffmpeg -i output.opus`). Have you tried this? – oldmud0 Jul 26 '17 at 01:38
  • @oldmud0 I had tried mediainfo, but not the second suggestion. I updated the question to address your comment. Thanks. – Marc.2377 Jul 26 '17 at 02:28

1 Answers1

12

WebM is a subset of Matroska, which is a container format for multimedia data. Opus is an audio format (an audio codec), which is usually stored inside an Ogg container, but can also be stored inside a Matroska container or a WebM container.

When an Opus audio track is stored in an Ogg container, the file name suffix is usually '.opus' (but when a Vorbis audio track is stored in an Ogg file, the suffix is usually '.ogg')

If you change the file name suffix (from '.webm' to '.opus'), the data inside the file will stay the same.

What I usually do to extract the audio track from a webm file is:

mkvextract file/path.webm tracks 0:file/path.opus

Note that 'file/path.opus' will be an Ogg container with Opus format (if that's what the WebM contained).

mkvextract can be obtained by installing package 'mkvtoolnix-cli' in ArchLinux, for instance.

Nattgew
  • 1,133
  • 2
  • 12
  • 16
Elifarley
  • 648
  • 8
  • 10
  • 1
    I might have an old version of mkvextract, but I had to change the order of the arguments for it to work: mkvextract tracks file/path.webm 0:file/path.opus – PLN Oct 24 '18 at 16:55
  • 1
    Thanks. Is using mkvextract instead of ffmpeg just a matter of preference in this case? – Marc.2377 Oct 26 '18 at 02:26
  • 2
    Can "naked" opus audio track exist as files as well? Or is it always embedded in a container format? If I extract an opus "something" from a WebM file, is it an opus track or an Ogg file? – Sandburg Sep 08 '20 at 14:35