Lossless extraction of streams from WebM

30

16

I would like to extract streams from WebM video files without converting them (re-compression), can somebody recommend any software that can allow this?

Karolinger

Posted 2012-04-16T03:31:02.577

Reputation: 861

Answers

17

Since WebM is a Matroska subset, mkvtoolnix should let you demux the files. It's open source, cross platform, and the author provides binaries for Windows.

afrazier

Posted 2012-04-16T03:31:02.577

Reputation: 21 316

2How do I use it on webm files? – theonlygusti – 2017-08-21T00:35:51.260

29

To extract audio from a WebM file, using the ffmpeg tool (https://www.ffmpeg.org/download.html) :

ffmpeg -i "input.webm" -vn -acodec copy "output.oga"

Explanation :
"-i input.webm" designates the input file
"-vn" removes the video stream from the output
"-acodec copy" tells ffmpeg to copy the audio stream as-is (no re-compression)
"output.oga" designates the output file.

NB : Use quotes "" around filenames that contain spaces.

The output file extension has to match with the format of the audio stream contained in the source webm file.

I use ".oga" as output file extension because most webm files I handle contain Vorbis audio.
".oga" is the prefered extension in this case, even if .ogg is still a frequently encountered extension for vorbis audio-only files.

This command line based on ffmpeg should give you the audio format from the source file :
ffmpeg -i "inputfile.ext" Search for the line containing the text "Audio", usually near the end of the command output.

In my case, this is the output :
Stream #0:1: Audio: vorbis, 44100 Hz, stereo, fltp (default)

Reading this wikipedia page might give you some insight on which file extensions should be used with which audio formats : http://en.wikipedia.org/wiki/Audio_file_format

Etienne Delavennat

Posted 2012-04-16T03:31:02.577

Reputation: 391

5

If the webm source has a Opus stream, the.opus file extension is encouraged.

– Marc.2377 – 2017-07-26T00:19:48.903

Thanks for a detailed answer! I actually needed to convert the audio to AAC (because XLD doesn't support OGG yet), so I had to just switch the audio codec flag to use AAC. https://trac.ffmpeg.org/wiki/Encode/AAC

– Rafał Cieślak – 2018-12-12T23:45:20.967

Media Info is a good tool to inspect the, well, media info of media files. Can inspect files and folders and can output to userdefined formats. Which one could then input to ffmpeg. – Nils – 2019-04-30T03:37:57.603

1

Video files have a container format and codec formats.

Its hard to 'extract' the video bits easily, but it is possible to change the container format to something you can consume whilst not altering the video bits:

ffmpeg using -vcodec copy (and typically -an to strip any audio)

Will

Posted 2012-04-16T03:31:02.577

Reputation: 329

0

With MKVToolNix – Matroska tools for Linux/Unix and Windows:

mkvextract.exe "file.webm" tracks 0:"file_audio.ogg"

(assuming audio track ID is 0 - you can check with mkvinfo.exe or mkvtoolnix-gui.exe)

ellockie

Posted 2012-04-16T03:31:02.577

Reputation: 161