How to Extract Audio from WebM File
Asked Answered
B

2

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

Boatel answered 4/9, 2019 at 0:8 Comment(0)
M
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.

Middlemost answered 29/12, 2020 at 14:40 Comment(3)
Would you consider editing/modifying an existing answer instead of providing a similar duplicate?Danie
on debian/ubuntu you need to install mkvtoolnix package -> apt install mkvtoolnixDefoliate
mkvtoolnix GUI is not (more - since 2017) able to do as much as the command line, prefer the command line.Blender
D
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%
Danie answered 7/1, 2020 at 3:33 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.