View Single Post
Old 27th September 2013, 11:35    |  Link
Registered User
 
Join Date: Dec 2002
Posts: 5,565


Maybe we start from the beginning so you can get a clear understanding. I'm using the mkvmerge docs for reference.

This is the general order of an mkvmerge command-line:
Code:
mkvmerge [global options] {-o out} [options1] {file1} [[options2] {file2}] [@optionsfile]
We start off with simply muxing an h264 video to an mkv container:
Code:
mkvmerge -o output.mkv input.h264
The next exercise would be to mux one h264 video track and one idx/sub subtitle track:
Code:
mkvmerge -o output.mkv video.h264 subtitles.idx
As you can see mkvmerge simply adds all files that don't have a "-o" in front of them into the file.

Now we want to define the video language as "English" and the subtitle language as "Dutch":
Code:
mkvmerge -o output.mkv --language 0:eng video.h264 --language 0:dut subtitles.idx
Notice how I've used the TrackID "0" for both input files. Lessons learned:
- the input TrackID's apply for each input file on their own.
- the options of an input file go in front of the input file

Since working with raw files is boring we will now try adding an mkv input file that has 3 tracks, with the first track being English, the second track being Finnish and the third track being Japanese. We will also add an idx/sub subtitle that is supposed to be German:
Code:
mkvmerge -o output.mkv --language 0:eng --language 1:fin --language 2:jpn input.mkv --language 0:ger subtitles.idx
As you can see we count from 0 to 2 for the input file with three tracks and still only use 0 for the single track after that.

We can do the same, but now with a second subtitle track which we will also mark as "forced":
Code:
mkvmerge -o output.mkv --language 0:eng --language 1:fin --language 2:jpn input.mkv --language 0:ger subtitles.idx --language 0:ger --forced-track 0:yes forced_subtitles.idx
Now let's say we also want to use some global options, for example --engage no_cue_relative_position and --clusters-in-meta-seek. We will simply put them into the front:
Code:
mkvmerge --engage no_cue_relative_position --clusters-in-meta-seek -o output.mkv --language 0:eng --language 1:fin --language 2:jpn input.mkv --language 0:ger subtitles.idx --language 0:ger --forced-track 0:yes forced_subtitles.idx

Well, that's pretty much it. We just have to be careful sometimes:
1.) If our file names or other descriptions have spaces in them, we have to use quotes around them. For example if we have "forced subtitles.idx" or we want to name the a track "Director's comment":
Code:
mkvmerge --engage no_cue_relative_position --clusters-in-meta-seek -o output.mkv --language 0:eng --language 1:fin --language 2:jpn --track-name 2:"Director's comment" input.mkv --language 0:ger subtitles.idx --language 0:ger --forced-track 0:yes "forced subtitles.idx"
2.) Some special characters have to be escaped
3.) In some cases (numbered VOBs) mkvmerge tries to automatically load several files without asking. We can stop it from doing so if we add a "=" directly before the filename or if we put it in Parentheses with spaces: "(" filename ")", (see the end of chapter 2.5 in the mkvmerge docs)
Code:
mkvmerge --engage no_cue_relative_position --clusters-in-meta-seek -o output.mkv --language 0:eng --language 1:fin --language 2:jpn --track-name 2:"Director's comment" ( input.mkv ) --language 0:ger subtitles.idx --language 0:ger --forced-track 0:yes ="forced subtitles.idx"

Last edited by sneaker_ger; 27th September 2013 at 11:46.
sneaker_ger is offline