Extracting Subtitles from mkv file
Solution 1
I use MKVCleaver for this as it provides a simple GUI interface for mkvtoolnix
on Windows.
You can simply drag and drop an MKV file (or files) on to it, click the check boxes for the tracks you want to extract, and then click "Extract Tracks".
By default your subtitle tracks will then be exported with the name FileName_TrackNo.ext
. For DVD subtitles it will export two files, the index of subtitle time and position locations and the actual graphical subtitles.
You can then import these files into SubtitleEdit. I found it more reliable and accurate than SubtitleEdit alone, for some reason its DVD/MKV extractor is not entirely reliable.
For command line and alternative operating systems (you mention Ubuntu) you can use mkvextract
which is a part of mkvtoolnix that you have already installed.
From an answer by Cornelius in Extract subtitles from mkv on AskUbuntu:
Run from terminal:
mkvextract tracks <your_mkv_video> <track_numer>:<subtitle_file.srt>
Use
mkvinfo
to get information about tracks.
Though the comments suggest using mkvmerge -i <filename>
to get a more directly usable track number for mkvextract
. As you mention ffmpeg -i filename.mkv
is also usable.
Solution 2
MKVCleaver is a good option with a clear GUI. But since no one has corrected the ffmpeg command, you can also do it with that. You just had one extra colon at the end of the -map.
Here is a working command:
ffmpeg -i Movie.mkv -map 0:s:0 subs.srt
Solution 3
My ten cents..... Maybe just one aspect but me myself just wrote a simple script as a Windows batch file to extract all SRT subtitles fråm a MKV video. She script loops all mkv files in current directory and generates one srt file for each sub. Each resulting subtitle file is named with weather or not it´s forced as well as the language.
I´m not a smooth script guru. It's not very beautyful but it works for med :-)
@ECHO OFF
REM A Windows Batch-script that extracts SRT subtitles from MKV video files.
REM Filename format is [VIDEOFILENAME].[FLAG-FORCED][LANGUAGECODE].srt
REM e.g. TestFile.1eng.srt for forced Engling track or TestFile.0eng.srt for unforced
setlocal enabledelayedexpansion
for %%f in (*.mkv) do (
ffprobe "%%f" -v panic -show_entries stream=index -select_streams v -of compact=p=0:nk=1 > probetmpfile
set /p videoID= < probetmpfile
ffprobe "%%f" -v panic -show_entries stream=index -select_streams a -of compact=p=0:nk=1 > probetmpfile
set /p audioID= < probetmpfile
ffprobe "%%f" -v panic -show_entries stream=index:disposition=forced:stream_tags=language -select_streams s -of compact=p=0:nk=1 > probetmpfile
for /L %%n in (0,1,99) do (
findstr %%n probetmpfile > tmpfile
set fileIsBlank=1
for /F %%a in (tmpfile) do set fileIsBlank=0
if %%n EQU !videoID! set fileIsBlank=1
if %%n EQU !audioID! set fileIsBlank=1
if !fileIsBlank! EQU 0 (
set /p subIdLang= < tmpFile
if %%n LSS 10 (mkvextract tracks "%%f" %%n:"%%~nf.!subIdLang:~2,1!!subIdLang:~4!.srt") else (mkvextract tracks "%%f" %%n:"%%~nf.!subIdLang:~3,1!!subIdLang:~5!.srt")
)
)
)
del tmpfile
del probetmpfile
pause
Solution 4
I have used Inviska MKV Extract, which required MKVToolNix(52.0.0), on MacOS 10.14.6 and worked perfect. Just drag and drop a number of .mkv files, select what you need of each file, audio or subtitles, and click begin.
Solution 5
I use Subtitle Edit https://www.videohelp.com/software/Subtitle-Edit
simply drag in the mkv file and then press save after you selected what subtitle from the mkv file you want and you can edit it easy too
Related videos on Youtube
![user227495](https://i.stack.imgur.com/qP0NE.png?s=256&g=1)
user227495
Updated on September 18, 2022Comments
-
user227495 almost 2 years
I have installed
MKVToolNix
andSubtitle edit
. I was able to extract subtitle usingSubtitle edit
through OCR. While it usable, it comes with a lot of errors.Now I thought of using
MKVToolNix
to extract the subtitle. I can see it listed among audio and video tracks. But I am not sure how to get it out of the program.After referring to a few guides on Google and here, I tried a few FFMPEG commands as well. None of them worked. For example
ffmpeg -i Movie.mkv -map 0:s:0: subs.srt
It will be great if anyone can help me find a solution. Thanks.
PS : I use Ubuntu 18.04.
-
Admin over 4 years
-
Admin over 4 yearsYes, it works. mkvinfo was not good enough though.
-
Admin over 4 yearsYes, the comments on the top answer there suggest that
mkvmerge -i <filename>
is the better way to get the subtitle track numbers to then feed intomkvextract
-
Admin over 4 yearsI found a workaround. Used
ffmpeg -i filename.mkv
. -
Admin over 4 yearsNeed the full output of
ffmpeg -i filename.mkv
to be able to provide an accurate answer. -
Admin over 2 yearsIf any Mac users are here looking for how to install mkvtoolnix, it appears to be available in brew.
-
-
user227495 over 4 yearsI forgot to mention. Will it work on Ubuntu 18.04 ? Thanks.
-
user227495 over 4 yearsI have an update. The files I get no matter
.sup
or.srt
are around 15 MB and unusable. I am not sure what is wrong. -
Mokubai over 4 yearsWhat are your source files? Where did they come from? Can you list the actual output of your
ffmpeg -i
command? -
user227495 over 4 yearsAn old TV show I got locally. It worked 3 hours ago. :( I will update with the command output. It is 43 minute, 800 MB.
-
Mokubai over 4 yearsIf it is an srt file then it should be just text. Is it opentable with notepad?
-
user227495 over 4 yearsI tried opening in Notepad and Gaupol. It hangs.
-
Mokubai over 4 yearsIt sounds from your original question that they are graphical subtitles, you might need to extract them as
idx
orsub
rather thansup
? -
user227495 over 4 yearsValid point. I will check. Thanks.
-
Chris18191 almost 3 yearsmy theory, as it just happened to me: wrong track number, extracted the audio (
Container format: Dolby Digital Plus (E-AC-3)
) instead of subtitles (Container format: SRT text subtitles
); incremented track number and it worked -
Mokubai almost 3 years@backspace the problem is entirely that some programs count from 0 (mkvextract) and some count from 1 (ffmpeg/mkvmerge) as the first element when enumerating the list of tracks in a file. That means when you go from one to the other you need to take that into account and either increment or decrement by 1 when bringing in information used by the other program. It is a form of off by one error, longer description at en.wikipedia.org/wiki/Off-by-one_error
-
martixy over 2 yearsWorth noting the program(x64) from the link is currently detected as a virus by windows (10) defender. Can't confirm if actual virus. Used it from a VM just to be safe.
-
Naveen Reddy Marthala over 2 yearswhat does
0:s:0
inmap
do? what are those two 0s and what's thats
for? -
Tankki3 over 2 yearsThe first number is which input you select (0 is the first and only input in my command), second character is what type of stream you select (s is subtitles, a is audio, v is video), third is which stream you select out of those. So like this: -map input_file_index:stream_type_specifier:stream_index So the code above takes the Movie.mkv, then its subtitle streams, then the first subtitle stream. (counting starts with 0, because it's an index.)
-
Tankki3 over 2 yearsHere is more information about the map command: trac.ffmpeg.org/wiki/Map
-
Admin about 2 yearsThis is the only solution that worked for me. I guess my subs were graphic ones so the built-in OCR worked great!
-
Admin about 2 yearsThis is a very promising start. Unfortunately, the script will also extract PGS subs to .SRT format. Would be nice if the script could detect
hdmv_pgs_subtitle
and extract it as PGS files.