Skip to content


Extracting a Vorbis audio track to an Ogg audio file

A little while ago, I wanted to extract an audio track from a WebM video grabbed on Youtube (NB: jDownloader is a great piece of software to download Youtube videos, apart from the fact that it literally take ages to load). The audio track of most (or maybe even all, I believe WebM is a modified Matroska with support for just VP8 and Vorbis?) WebM videos is in Vorbis, so of course I wanted to extract it into an Ogg container (without re-encoding it in the process).

To do this, I used mkvextract, which is part of MKVToolNix. Unfortunately, no GUI is provided to do what we want (however, with the mkvmerge GUI you can create MKA audio files). But the command line is very simple:
mkvextract tracks [yourWebmFile.webm] 2:[yourOggFile.ogg]
Let’s explain it more in details:

  • mkvextract is the program we use. Of course, this is considering that you browsed with the command line to the folder where MKVToolNix is installed
  • tracks is the instruction we want it to perform (as listed in mkvextract --help)
  • then of course, the input file
  • "2" means we extract track 2. If your original file has one video and one audio track, the audio track you want will probably be track 2, but that’s not a guarantee. If it’s not, just try other numbers
  • finally, a column and the output file

Posted in multimedia.


6 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. Anonymous says

    thanks for helpful post! btw, video track is 0 and audio is 1 ;]

  2. David Dernoncourt says

    Hm, I have to admit I only ever tried this on one single file. Probably track number depends on the file, actually. Thanks for the info!

  3. Morgan says

    Haha about jDownloader taking for-f**king ever to load. I wish it was a bit lighter, with less features. (I don’t think the automatic link parsing is really necessary, so I just disable that)

  4. kankaren gama-gari says

    #!/bin/bash
    # webm-to-ogg; script to extract vorbis from .webm file
    # usage: webm-to-ogg TheMovieFile.webm
    # requires MKVToolNix
    in=$1
    track=$(mkvmerge --identify "$in" |grep A_VORBIS)
    # example: Track ID 1: audio (A_VORBIS)
    track=$(echo "$track" |sed 's/^Track\ ID\ //')
    track=$(echo "$track" |sed 's/:.*//')
    out=$(echo "$in" |sed 's/\.webm$/\.ogg/')
    mkvextract tracks "$in" "$track:$out"

    • kankaren gama-gari says

      In this line…
      track=$(mkvmerge –identify β€œ$in” |grep A_VORBIS)
      …there are supposted to be two dashes before “identify”

      • David Dernoncourt says

        Yeah, WordPress tends to mess up dashes… I’ll add a code tag, should fix things up. Thanks for the neat script πŸ™‚



Some HTML is OK

or, reply to this post via trackback.

Please solve the CAPTCHA below in order to fight spamWordPress CAPTCHA