8

I just want to get a audio file(opus codec used) only in webm file. I try to search what is webm format, how to parse, but I cant get info well. I check that webm format is from mkv, then should I check the mkv first?

there is just one github code, but I cant find way how parse the audio from webm. https://github.com/webmproject/libwebm/tree/master/webm_parser

anthumchris
  • 8,245
  • 2
  • 28
  • 53
user225549
  • 177
  • 2
  • 9

2 Answers2

10

You're really going to want the MKVToolNix. These include the tool mkvextract in another answer.

The MKVToolNix is actually a series of tools (mkvmerge, mkvinfo, mkvextract, mkvpropedit). First you asked how to parse the info. You can find the details using:

mkvinfo file.webm
mkvinfo file.webm -a

The first command will parse the overall structure. The second gives the detail of each frame. Use the --help switch if you want all commands.

To extract the audio, do

mkvextract file.webm tracks X:newfile.opus

Where X is the track number that you've identified as wanted from mkvinfo previously. Webm and MKV can have multiple tracks. "newfile.opus" is the new file that you want to create, choose the name you want.

There is also a mkvtoolnix gui, but I've never used that.

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
3

mkvextract can extract audio for you, and I recommend having a look at the mkvtoolsnix source code.

For example, you can extract audio from a WebM file into an Ogg Opus file like this:

$ mkvextract ~/audio/bubbles.webm tracks 0:audio.opus

Extracting track 0 with the CodecID 'A_OPUS' to the file 'audio.opus'. Container format: Ogg (Opus in Ogg)
Progress: 100%
anthumchris
  • 8,245
  • 2
  • 28
  • 53