Ubuntu – Extract content from MKV files

Let’s assume you’ve made a Matroska file with one video track, two
audio tracks and two subtitle tracks, and you need the second audio
track and the first subtitle track.
So first fire up mkvmerge with the –identify option:

$ mkvmerge -i movie.mkv
File ’movie.mkv’: container: Matroska
Track ID 1: video (V_MS/VFW/FOURCC, DIV3)
Track ID 2: audio (A_MPEG/L3)
Track ID 3: audio (A_VORBIS)
Track ID 4: subtitles (S_TEXT/UTF8)
Track ID 5: subtitles (S_TEXT/UTF8)

Now you can call mkvextract like this:

$ mkvextract tracks movie.mkv 3:audio.ogg 4:subtitles.srt

Another example. Let’s assume you have a Matroska file with one
RealVideo v10 track, one Vorbis audio track and one RealAudio (COOK)
track. The identification output might look like this:

$ mkvmerge -i movie2.mkv
File ’movie2.mkv’: container: Matroska
Track ID 1: video (V_REAL/RV40)
Track ID 2: audio (A_VORBIS)
Track ID 3: audio (A_REAL/COOK)

Let’s further assume you want only need the video and the RealAudio
track but both in the same output file. This is possible for RealMedia
files by using the same output name for those tracks that you want to
end up in the same file:

$ mkvextract tracks movie2.mkv 1:extracted.rm 3:extracted.rm

Sometimes you the raw data of a track might even be useful, e.g. for
MPEG-1 tracks. In this case you can use a track flag like this:

$ mkvextract tracks movie3.mkv –fullraw 1:extracted.mpeg

If you need the timecodes for all the blocks of track 2 from a file
then you can let mkvextract create a timecode v2 format file like this:

$ mkvextract timecodes_v2 input.mkv 2:timecodes-track2.txt

Leave a Reply

Your email address will not be published. Required fields are marked *