Tuesday 14 September 2010

Converting from ogg to mp3 in Matroska (mkv) files

NB, this is very vague. Please do not just copy and paste, it probably won't work and will most likely cause you to lose the file you are working on. This is an example and you'll need
to alter it to your specific mkv file:


You'll need mkvtoolnix, and lame installed.

First, get information about the video file:

mkvinfo file.mkv

extract the video and audio files you want to convert:

mkvextract tracks 1:file.vid
mkvextract tracks 2:file.en.ogg

convert (just ogg to mp3 for me)

oggdec file.eng.ogg -R -b 16 -o - | lame -s 48 -b 16 -m s -x -r - -q 2 -b 128 file.eng.mp3

Merge back into the mkv container:


mkvmerge -o file.2.mkv file.vid file.eng.mp3

You can now check file.2.mkv to see if it works correct.