

"$mkvextract" tracks "$filename" $trackNumber:"$fileBasename $trackNumber($trackLanguage).srt" > /dev/null 2>&1`

# trackID trackLanguage trackCodecID trackCodec # following format, one line per subtitle track, fields delimited by tabulator: # Parse info about all subtitles tracks from file. # Get all MKV/MP4 files in this dir and its subdirsįind "$DIR" -type f \( -iname '*.mkv' -o -iname '*.mp4' \) | while read filename # If no directory is given, work in local dir ToolPath='/Applications/MKVToolNix.app/Contents/MacOS/' # and just dragged it to the Applications folder.

on macOS, if you downloaded MKVToolNix app # MKVToolNix path - Leave empty if you have the tools added to $PATH. # Extract subtitles from each MKV/MP4 file in the given directory You only need to have MKVToolNix installed, no other dependencies. I have rewritten the script from scratch, and also properly commented it in case someone needs to tweak it later. This was actually spotted by mokubai in his comment under this question: there's a similar question on AskUbuntu forums, and one of the answers supplies a complete script, however it is not working. I know there already are several answers in here, but neither completely answers the question if you need to use command line on macOS, so I am adding mine too. As you mention ffmpeg -i filename.mkv is also usable. Though the comments suggest using mkvmerge -i to get a more directly usable track number for mkvextract. Use mkvinfo to get information about tracks. I found it more reliable and accurate than SubtitleEdit alone, for some reason its DVD/MKV extractor is not entirely reliable.įor command line and alternative operating systems (you mention Ubuntu) you can use mkvextract which is a part of mkvtoolnix that you have already installed.įrom an answer by Cornelius in Extract subtitles from mkv on AskUbuntu: You can then import these files into SubtitleEdit. For DVD subtitles it will export two files, the index of subtitle time and position locations and the actual graphical subtitles. 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".īy default your subtitle tracks will then be exported with the name FileName_TrackNo.ext. I use MKVCleaver for this as it provides a simple GUI interface for mkvtoolnix on Windows.
