logo logo

How to extract embedded subtitles (.srt/.ass) from MKV files

Here’s the trouble:

  • I had downloaded some movie in MKV format and I want to watch it with my whole family in my standard DVD player that can’t play MKV file.
  • The movie already had multilingual subtitles embedded on it (not separated .srt file) and I want to extract it so the subtitles will appear on the DVD.
  • My favorite video converter application (winFF and Handbrake) can’t extract and re-embed the subtitles into target video (.avi divx).
  • So, I use winFF to convert MKV file into .AVI (divx) file then somehow I need to extract that subtitle from the MKV.

FYI: I’m using Ubuntu 10.04 to do all these commands

Here’s the step you need to do to extract subtitle (.srt) from a MKV movie:


[1] Install mkvtoolnix to manipulate MKV movie

sudo apt-get install mkvtoolnix

[2] get info about ‘tracks’ available in the MKV movie using mkvinfo tool, example:

mkvinfo The.Last.Airbender.2010.DVDRip.mkv

You’ll get output like these:

+ EBML head
|+ EBML version: 1
|+ EBML read version: 1
|+ EBML maximum ID length: 4
|+ (Unknown element: EBMLMaxSizeLength; ID: 0x42f3 size: 4)
|+ Doc type: matroska
|+ Doc type version: 1
|+ Doc type read version: 1
+ Segment, size 419085130
|+ Seek head (subentries will be skipped)
|+ EbmlVoid (size: 4027)
|+ Segment information
| + Timecode scale: 1000000
| + Muxing application: libebml v1.0.0 + libmatroska v1.0.0
| + Writing application: mkvmerge v4.0.0 ('The Stars were mine') built on Jun  6 2010 16:18:42
| + Duration: 6194.809s (01:43:14.809)
| + Date: Thu Sep 30 13:15:40 2010 UTC
| + Segment UID: 0xb8 0x71 0x57 0x1a 0xe2 0x01 0x01 0xaa 0x89 0x7c 0xd3 0x7d 0x92 0x93 0x68 0xcd
|+ Segment tracks
| + A track
|  + Track number: 1
|  + Track UID: 1
|  + Track type: video
|  + Default flag: 0
|  + Lacing flag: 0
|  + MinCache: 1
|  + Codec ID: V_MPEG4/ISO/AVC
|  + CodecPrivate, length 42
|  + Default duration: 41.708ms (23.976 fps for a video track)
|  + Name: united300.blogspot.com | 300mbunited.com | rapidpremium.net
|  + Video track
|   + Pixel width: 720
|   + Pixel height: 304
|   + Display width: 45
|   + Display height: 19
| + A track
|  + Track number: 2
|  + Track UID: 2801639845
|  + Track type: audio
|  + Codec ID: A_AAC
|  + CodecPrivate, length 7
|  + Default duration: 42.667ms (23.438 fps for a video track)
|  + Language: und
|  + Name: united300.blogspot.com | 300mbunited.com | rapidpremium.net
|  + Audio track
|   + Sampling frequency: 24000
|   + Channels: 2
|   + Output sampling frequency: 48000
| + A track
|  + Track number: 3
|  + Track UID: 3809036424
|  + Track type: subtitles
|  + Lacing flag: 0
|  + Codec ID: S_TEXT/UTF8
|  + Name: united300.blogspot.com | 300mbunited.com | rapidpremium.net
| + A track
|  + Track number: 4
|  + Track UID: 4155987585
|  + Track type: subtitles
|  + Default flag: 0
|  + Lacing flag: 0
|  + Codec ID: S_TEXT/UTF8
|  + Language: fre
|  + Name: united300.blogspot.com | 300mbunited.com | rapidpremium.net
| + A track
|  + Track number: 5
|  + Track UID: 1685097127
|  + Track type: subtitles
|  + Default flag: 0
|  + Lacing flag: 0
|  + Codec ID: S_TEXT/UTF8
|  + Language: spa
|  + Name: united300.blogspot.com | 300mbunited.com | rapidpremium.net
|+ EbmlVoid (size: 1180)
|+ Cluster

As you may notice from the output, there are 5 ‘tracks’ available in the MKV: track #1 is the video(H.264), track #2 is the audio (AAC), track #3 is subtitle, track #4 is subtitle in French and track #5 is subtitle in Spanish


[3] So, it’s clear, well extract track #3 which is a subtitle (although no language mentioned, it’s in English). To do that, use mkvextract command (for example):

mkvextract tracks The.Last.Airbender.2010.DVDRip.mkv 3:The.Last.Airbender.2010.DVDRip.srt

that command above will produce The.Last.Airbender.2010.DVDRip.srt which is the subtitle I want.


[4] One last step is to make sure that the file is in MSDOS (CR-LF) format by using ‘flip’ command (if you haven’t install it yet, do it using sudo apt-get install flip):

flip -m The.Last.Airbender.2010.DVDRip.srt

Now, you’re ready to pair-up the subtitle with the converted video from winFF!
Note: notice that the subtitle codec is S_TEXT/UTF8, if you found another MKV that has subtitle with codec S_TEXT/SSA or S_TEXT/ASS the the subtitle should be in SSA/ASS format respectively (.ssa/.ass)

bottom

One Response to “How to extract embedded subtitles (.srt/.ass) from MKV files”

  1. Zeinab says:

    Nice howto, it works as described. Many thanks.

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

bottom