Tuesday, December 13, 2011

MKVmerge Batch Commands, Remove Tracks

To remove a particular track from an MKV file, the following notation should work:

mkvmerge -o output.mkv -atrack !2 input.mkv 

But I wasn't able to get the exclamation mart (meaning DON'T copy this track) to work. For some reason I kept getting "track not found" message. This should work with --vtrack or --strack (subtitle) or whatever.

Fortunately, I wanted to remove all the subtitles from my files, so I used the following instead:

mkvmerge -o output.mkv --no-subtitles input.mkv

If you only want to do this on one file, the mkvmergeGUI is fast and easy, but if you want to do it on a whole directory of files, you want to use this at the command line in a "For Loop," like so:

for i in *mkv; do mkvmerge -o ./newfiles/`basename "$i" mkv`.mkv --no-subtitles "$i" ; done

This will remove all subtitle tracks from all MKV files in the current folder, then put the new files in a previously-created sub-folder named "newfiles".

5 comments:

  1. i was unexpected at this time.

    ReplyDelete
  2. What if you just want the output to the same directory? and what is the correct syntax for this to be placed in a batch file?

    ReplyDelete
  3. The ! is a bash keyword that will get expanded/substituted, for a history item. !2 means replace with history item 2. This messes it up. You need to delimit it with a \ or enclose the argument in single quotes ', to prevent the expansion. Then it will work.

    ReplyDelete
  4. Avdshare Video Converter can Remove subtitles from MKV without recoding the original streams
    https://www.avdshare.com/remove-subtitles-from-mkv

    ReplyDelete
  5. Avdshare Video Converter can Remove subtitles from MKV without recoding the original streams
    https://www.avdshare.com/remove-subtitles-from-mkv

    ReplyDelete