Saturday, January 15, 2011

Extracting Subtitles from a MKV


You have a .MKV (Matroska Video) video file with embedded subtitles and you need to extract them to separate .SRT (Subtitles) file. Here is how to do this with the help of freeware software.
You will need the following:
  1. a .MKV File with a built-in Subtitles track (how to check will follow shortly)
  2. Your favourite media player. For this post I use VLC Media Player 
  3. MKVToolnix – a set of cross platform tools for .MKV files (get them from here)
And here is how you get going.

Step #1 – Verify that your MKV file actually does have built-in subtitles

The easiest way is to check is to open the file using VLC Player. Select Tools --> Media Info (or press Ctrl+J). Switch to the “Codec Details” tab. Expand all the items underneath until you find one with the type “Subtitle”.  An example can be seen in the screenshot on the right.

Another way of doing this is to use the mkvinfo tool from the MKVToolnix collection mentioned above. If you are, start up mkvinfo in graphical mode with the following command line:


mkvinfo –g {Press Enter}

Then open up your .MKV file (Select File --> Open). You should see the same information as we saw before here too (see screenshot).

Important: Make a note of the “Track Number” for our subtitle track. In our case, the value is 3. This will come in handy with the extraction process.
Step #2 – Extract the Subtitles into a .SRT file
We will now use the mkvextract tool from the MKVToolnix kit. The exact command line format to use is:

mkvextract.exe tracks {path of the MKV file}  {track number we noted in the previous step}:{Filename to save the subtitles to}

In the case of my example, this will look like the following:

mkvextract.exe tracks "c:\My_MKV_Video_File.mkv" 3:My_MKV_Video_File.srt

Note the number used to prefix the .SRT filename. This is “Track Number” we noted in the previous step.

Going beyond
The mkvextract tool is just as capable of extracting other tracks - audio or video. All you need to do is use the right track number as prefix. So for instance, if the first track is audio, you can extract it with very little modification to the command we used before

mkvextract.exe tracks "c:\My_MKV_Video_File.mkv" 1:Audio_track.mp3

Again, note that we prefixed the MP3 filename with the right track number. We can also combine all of what we did above to extract both audio and subtitles in one single line:

mkvextract.exe tracks "c:\My_MKV_Video_File.mkv" 1:Audio_track.MP3 3:My_MKV_Video_File.srt

For more possibilities, look through the documentation of the mkvextract tool. And if this work for you or you did something cooler with this - I would love to hear from you. Please leave me a comment below.

See also: Extracting an MP3 from a Youtube video

Labels:

32 Comments:

At 7/03/2011 11:02 pm, Blogger Eyolf said...

I have Windows 7 Ultimate 64 bit, mkvmerge GUI v4.8.0 and a .mkv file with a subtitle file that I want.

When I load my video file I get all the different things under Tracks, chapter and tags. I uncheck all, except my chosen tracks of subtitles and as output filename I rename it from my_video.mkv to my_video.srt and then I press "Start muxing".

Is there anything I can do to improve this ? I want norwegian subtitles and I get some funny letters...

 
At 11/03/2011 12:31 am, Blogger creamy odor said...

Eyolf, it doesn't work that way. You need to follow the steps outlined on this page i.e. identify the track you want, then use the command line to extract it.
A couple of things I found that might be useful:
1. If you're using VLC (as I did) to identify the track you want to extract, add 1 to the stream number when using the command line, as VLC starts at 0 (zero).
2. By default the track extracts to the installed MKV toolkit's data folder.

BTW Thanks to his Techie Self.

 
At 11/03/2011 5:58 am, Blogger CASHBALLER said...

This worked perfectly for me, unlike many other things I tried. Thanks for the quick, easy tutorial.

 
At 12/04/2011 10:29 pm, Blogger davidmcdavid said...

Worked perfectly. Thank you.

 
At 1/14/2012 4:14 am, Blogger vilagan said...

Help anyone:
I tried this command:
mkvextract tracks c:\iso\wolmi.mkv 3:wolmi.srt

Warning: Unsupported CodecID 'S_VOBSUB' for ID:3. The track will be skipped. Nothing To Do.

Interestingly, the mkv doesn't show it's subtitle in VLC nor any player except KMPLAYER. Does this mean this mkv uses vobsub instead of text and mkvextract doesn't have an ocr to read it?

Thanks anyone!!!

 
At 1/14/2012 8:50 am, Blogger Mayuresh said...

That's correct. It's seems to be an extraction tool. No OCR.

 
At 4/29/2012 10:26 am, Anonymous inventory software said...

Perfect. Able to extract subtitle out. Thanks

 
At 4/29/2012 11:14 am, Anonymous Mayuresh said...

Approve.
--
Mayuresh

 
At 5/07/2012 12:14 am, Anonymous fgsfds said...

Love how the program closes before I can type anything into the command line, 10/10 best unusable software I've ever downloaded.

 
At 5/18/2012 3:52 pm, Anonymous Visadio said...

thank you soooooooooo much :)

 
At 5/20/2012 3:51 pm, Anonymous Sobame said...

How can a CLI app "close" before you can type? Too much GUI for you... (check both on Wikipedia willya)

 
At 5/20/2012 4:08 pm, Anonymous Mayuresh said...

You said it :)
--
Mayuresh

 
At 7/01/2012 5:03 pm, Anonymous Benturath said...

Great! As a beginner, I don't know where to type those commands.

 
At 7/01/2012 8:50 pm, Anonymous clippabluntz said...

 you have no idea what you're doing, please don't blame it on this excellent piece of software

 
At 7/02/2012 11:39 am, Anonymous Mayuresh said...

@Benturath - Try opening a command prompt (Start > Run > cmd, and press Enter). However, if you've never run a Command at the prompt before I would tread very very carefully. But once you do, there's no going back to being a mouse-only user (I mean it's fun and addictive) :-)

 
At 7/21/2012 9:33 am, Anonymous mkazem7 said...

this
is so greaaaaaaaaaaaaaaaat. thanks so much

 
At 7/27/2012 7:20 pm, Anonymous sah said...

where can i find the extracted srt?

 
At 7/27/2012 8:19 pm, Anonymous Mayuresh said...

You can specify the name and path of the srt file in the command line E.g. C:\my_video.srt.
--
Mayuresh

 
At 9/21/2012 4:43 pm, Anonymous JustMe said...

Works like a charm!

Thanks

 
At 9/22/2012 8:54 am, Anonymous Dusan said...

Perfect !!!! Thank you

 
At 9/28/2012 7:22 pm, Anonymous Michael Kenward said...

I was delighted to find this one.I could not unravel the official description of command-line operations.

Just one problem. While I specify .srt subtitle files – as instructed here – I actually get.sub.

I know that it is something that I am doing wrong, but I can't for the life of me figure it out. I tried adding some of the other switches on the official list. No luck.

 
At 9/28/2012 9:45 pm, Anonymous Mayuresh said...

Perhaps you could post the command line you execute we can try and figure it out?
--
Mayuresh

 
At 10/25/2012 12:50 am, Anonymous iSWORD said...

Thanks bro! :)

 
At 12/14/2012 9:34 am, Anonymous Djaenul Arifin said...

first time so confuse and finally excited! thank you so much

 
At 12/16/2012 8:19 pm, Anonymous SeaMonkey82 said...

Thanks!

 
At 4/01/2013 6:14 am, Anonymous Alexis Garcia said...

Thank you for share. I was able to extract SRT from MKV in 5 seconds (i had the MKV in an SSD). Thanks!

 
At 6/07/2013 5:14 pm, Anonymous Pranav said...

Thank you very much... ^_^
this worked perfectly... :-)

 
At 6/30/2013 12:24 am, Anonymous richi said...

Thanks it works great,

I was also wondered where the created .srt file was and it was in the c:MKVToolkit folder.

 
At 7/14/2013 12:46 am, Anonymous Erik said...

Thanks! Now I don't need to play those .mkv files that lag my PC :3

 
At 7/25/2013 11:49 am, Anonymous Mayuresh said...

Delighted I could be of help to so many of you. And thanks for letting me know :)

 
At 8/28/2013 7:42 am, Anonymous Dragon said...

I wanted to extract some embedded subs and this article was the first thing I found. I admit I was unfamiliar with both MKVtoolnix and using the command prompt. The main article left me rather baffled but after reading Mayuresh's comment to Benturath I was able to get it all figured out. I guess I'm saying the article could have been more novice friendly to begin with.

Afterwards I found a GUI for MKVtoolnix called MKVcleaver. I found that it makes the whole extraction process feel more straight forward for the command-prompt-inexperienced like myself. I used version 6.02 which I believe is currently the latest version.

I hope it's alright for me to post a link...

MKVcleaver home site:
http://apps.einsof-haras.ca/help.html

A second alternative to using the command prompt involves creating a shortcut to mkvextract.exe(found in your MKVtoolnix folder).

2) Right-click the shortcut and choose Properties.

3) under the 'Shortcut' tab you can put your command line in the "Target:" field.

So if MKVtoolnix is installed to c:\ you would put this in the "Target:" field:

C:\MKVToolNix\mkvextract.exe tracks "c:\My_MKV_Video_File.mkv" 3:c:\My_MKV_Video_File.srt

That way, when you have a .mkv file to extract a track from, you can edit that "Target:" field to have the .mkv file location and track number/filetype.

4)Then click Apply at the bottom of the preferences window and double-click the shortcut. It will run the .exe with the command line.

Thanks to Mayuresh for getting me pointed in the right direction.

 
At 10/20/2013 3:08 pm, Anonymous ElgaN said...

I can't change the command, I mean it says .idx not .srt?
How can I change that?!

 

Post a Comment

<< Home