1MKVMERGE(1) User Commands MKVMERGE(1)
2
3
4
6 mkvmerge - Merge multimedia streams into a Matroska(TM) file
7
9 mkvmerge [global options] {-o out} [options1] {file1}
10 [[options2] {file2}] [@options-file.json]
11
13 This program takes the input from several media files and joins their
14 streams (all of them or just a selection) into a Matroska(TM) file; see
15 the Matroska(TM) website[1].
16
17 Important
18 The order of command line options is important. Please read the
19 section "Option order" if you're new to the program.
20
21 Global options
22 -v, --verbose
23 Increase verbosity.
24
25 -q, --quiet
26 Suppress status output.
27
28 -o, --output file-name
29 Write to the file file-name. If splitting is used then this
30 parameter is treated a bit differently. See the explanation for the
31 --split option for details.
32
33 -w, --webm
34 Create a WebM compliant file. This is also turned on if the output
35 file name's extension is "webm". This mode enforces several
36 restrictions. The only allowed codecs are VP8, VP9 video and Opus,
37 Vorbis audio tracks. The DocType header item is changed to "webm".
38
39 For chapters and tags only a subset of elements are allowed.
40 mkvmerge(1) will automatically remove all elements not allowed by
41 the specification.
42
43 --title title
44 Sets the general title for the output file, e.g. the movie name.
45
46 --default-language language-code
47 Sets the default language code that will be used for tracks for
48 which no language is set with the --language option and for which
49 the source container doesn't provide a language.
50
51 The default language code is 'und' for 'undefined'.
52
53 Segment info handling (global options)
54 --segmentinfo filename.xml
55 Read segment information from an XML file. This file can contain
56 the segment family UID, segment UID, previous and next segment UID
57 elements. An example file and a DTD are included in the MKVToolNix
58 distribution.
59
60 See the section about segment info XML files below for details.
61
62 --segment-uid SID1,SID2,...
63 Sets the segment UIDs to use. This is a comma-separated list of
64 128-bit segment UIDs in the usual UID form: hex numbers with or
65 without the "0x" prefix, with or without spaces, exactly 32 digits.
66
67 If SID starts with = then its rest is interpreted as the name of a
68 Matroska file whose segment UID is read and used.
69
70 Each file created contains one segment, and each segment has one
71 segment UID. If more segment UIDs are specified than segments are
72 created then the surplus UIDs are ignored. If fewer UIDs are
73 specified than segments are created then random UIDs will be
74 created for them.
75
76 Chapter and tag handling (global options)
77 --chapter-language language-code
78 Sets the ISO 639-2 language code that is written for each chapter
79 entry. Defaults to 'eng'. See the section about chapters below for
80 details.
81
82 This option can be used both for simple chapter files and for
83 source files that contain chapters but no information about the
84 chapters' language, e.g. MP4 and OGM files.
85
86 The language set with this option is also used when chapters are
87 generated with the --generate-chapters option.
88
89 --chapter-charset character-set
90 Sets the character set that is used for the conversion to UTF-8 for
91 simple chapter files. See the section about text files and
92 character sets for an explanation how mkvmerge(1) converts between
93 character sets.
94
95 This switch does also apply to chapters that are copied from
96 certain container types, e.g. Ogg/OGM and MP4 files. See the
97 section about chapters below for details.
98
99 --chapter-sync d[,o[/p]]
100 Adjust the timestamps of the chapters in the following source file
101 by d ms. Alternatively you can use the --sync option with the
102 special track ID -2 (see section special track IDs).
103
104 o/p: adjust the timestamps by o/p to fix linear drifts. p defaults
105 to 1 if omitted. Both o and p can be floating point numbers.
106
107 Defaults: no manual sync correction (which is the same as d = 0 and
108 o/p = 1.0).
109
110 This option can be used multiple times for an input file applying
111 to several tracks by selecting different track IDs each time.
112
113 --generate-chapters mode
114 mkvmerge(1) can create chapters automatically. The following two
115 modes are currently supported:
116
117 • 'when-appending' – This mode creates one chapter at the start
118 and one chapter whenever a file is appended.
119
120 This mode also works with split modes 'parts:' and
121 'parts-frames:'. For these modes one chapter will be generated
122 for each appended timestamp range (those whose start timestamps
123 are prefixed with '+').
124
125 Note
126 mkvmerge(1) requires a video or an audio track to be
127 present in order to be able to determine when a new file is
128 appended. If one or more video tracks are muxed the first
129 one is used. Otherwise the first audio track is used.
130
131 • 'interval:time-spec' – This mode creates one chapter at fixed
132 intervals given by time-spec. The format is either the form
133 HH:MM:SS.nnnnnnnnn or a number followed by one of the units
134 's', 'ms' or 'us'.
135
136 Example: --generate-chapters interval:45s
137
138 The names for the new chapters are controlled by the option
139 --generate-chapters-name-template. The language is set with
140 --chapter-language which must occur before --generate-chapters.
141
142 --generate-chapters-name-template template
143 This sets the name template for chapter names generated by the
144 option --generate-chapters. If the option is not used then default
145 'Chapter <NUM:2>' will be used.
146
147 There are several variables that can be used in the template that
148 are replaced by their actual values when a chapter is generated.
149 The string '<NUM>' will be replaced by the chapter number. The
150 string '<START>' will be replaced by the chapter's start timestamp.
151
152 The strings '<FILE_NAME>' and '<FILE_NAME_WITH_EXT>' are only
153 filled when generating chapters for appended files. They will be
154 replaced by the appended file's name wihtout respectively with its
155 extension. Note that only the file's base name and extension are
156 inserted, not its directory or drive components.
157
158 You can specify a minimum number of places for the chapter number
159 with '<NUM:places>', e.g. '<NUM:3>'. The resulting number will be
160 padded with leading zeroes if the number of places is less than
161 specified.
162
163 You can control the format used by the start timestamp with
164 <START:format>. The format defaults to '%H:%M:%S' if none is given.
165 Valid format codes are:
166
167 • %h – hours
168
169 • %H – hours zero-padded to two places
170
171 • %m – minutes
172
173 • %M – minutes zero-padded to two places
174
175 • %s – seconds
176
177 • %S – seconds zero-padded to two places
178
179 • %n – nanoseconds with nine places
180
181 • %<1-9>n – nanoseconds with up to nine places (e.g. three places
182 with %3n)
183
184 --cue-chapter-name-format format
185 mkvmerge(1) supports reading CUE sheets for audio files as the
186 input for chapters. CUE sheets usually contain the entries
187 PERFORMER and TITLE for each index entry. mkvmerge(1) uses these
188 two strings in order to construct the chapter name. With this
189 option the format used for this name can be set.
190
191 If this option is not given then mkvmerge(1) defaults to the format
192 '%p - %t' (the performer, followed by a space, a dash, another
193 space and the title).
194
195 If the format is given then everything except the following meta
196 characters is copied as-is, and the meta characters are replaced
197 like this:
198
199 • %p is replaced by the current entry's PERFORMER string,
200
201 • %t is replaced by the current entry's TITLE string,
202
203 • %n is replaced by the current track number and
204
205 • %N is replaced by the current track number padded with a
206 leading zero if it is < 10.
207
208 --chapters file-name
209 Read chapter information from the file file-name. See the section
210 about chapters below for details.
211
212 --global-tags file-name
213 Read global tags from the file file-name. See the section about
214 tags below for details.
215
216 General output control (advanced global options)
217 --track-order FID1:TID1,FID2:TID2,...
218 This option changes the order in which the tracks for an input file
219 are created. The argument is a comma separated list of pairs IDs.
220 Each pair contains first the file ID (FID1) which is simply the
221 number of the file on the command line starting at 0. The second is
222 a track ID (TID1) from that file. If some track IDs are omitted
223 then those tracks are created after the ones given with this option
224 have been created.
225
226 --cluster-length spec
227 Limit the number of data blocks or the duration of data in each
228 cluster. The spec parameter can either be a number n without a unit
229 or a number d postfixed with 'ms'.
230
231 If no unit is used then mkvmerge(1) will put at most n data blocks
232 into each cluster. The maximum number of blocks is 65535.
233
234 If the number d is postfixed with 'ms' then mkvmerge(1) puts at
235 most d milliseconds of data into each cluster. The minimum for d is
236 '100ms', and the maximum is '32000ms'.
237
238 mkvmerge(1) defaults to putting at most 65535 data blocks and
239 5000ms of data into a cluster.
240
241 Programs trying to find a certain frame can only seek directly to a
242 cluster and have to read the whole cluster afterwards. Therefore
243 creating larger clusters may lead to imprecise or slow seeking.
244
245 --clusters-in-meta-seek
246 Tells mkvmerge(1) to create a meta seek element at the end of the
247 file containing all clusters. See also the section about the
248 Matroska(TM) file layout.
249
250 --timestamp-scale factor
251 Forces the timestamp scale factor to factor. Valid values are in
252 the range 1000..10000000 or the special value -1.
253
254 Normally mkvmerge(1) will use a value of 1000000 which means that
255 timestamps and durations will have a precision of 1ms. For files
256 that will not contain a video track but at least one audio track
257 mkvmerge(1) will automatically chose a timestamp scale factor so
258 that all timestamps and durations have a precision of one audio
259 sample. This causes bigger overhead but allows precise seeking and
260 extraction.
261
262 If the special value -1 is used then mkvmerge(1) will use sample
263 precision even if a video track is present.
264
265 --enable-durations
266 Write durations for all blocks. This will increase file size and
267 does not offer any additional value for players at the moment.
268
269 --no-cues
270 Tells mkvmerge(1) not to create and write the cue data which can be
271 compared to an index in an AVI. Matroska(TM) files can be played
272 back without the cue data, but seeking will probably be imprecise
273 and slower. Use this only if you're really desperate for space or
274 for testing purposes. See also option --cues which can be specified
275 for each input file.
276
277 --no-date
278 By default mkvmerge(1) sets the "date" segment information field to
279 the time & date when multiplexing started. With this option that
280 field is not written at all.
281
282 --disable-lacing
283 Disables lacing for all tracks. This will increase the file's size,
284 especially if there are many audio tracks. This option is not
285 intended for everyday use.
286
287 --disable-track-statistics-tags
288 Normally mkvmerge(1) will write certain tags with statistics for
289 each track. If such tags are already present then they will be
290 overwritten. The tags are BPS, DURATION, NUMBER_OF_BYTES and
291 NUMBER_OF_FRAMES.
292
293 Enabling this option prevents mkvmerge(1) from writing those tags
294 and from touching any existing tags with same names.
295
296 --disable-language-ietf
297 Normally mkvmerge(1) will write the new IETF BCP 47 language
298 elements in addition to the legacy language elements in track
299 headers, chapters and tags. If this option is used, only the legacy
300 elements are written.
301
302 File splitting, linking, appending and concatenation (more global options)
303 --split specification
304 Splits the output file after a given size or a given time. Please
305 note that tracks can only be split right before a key frame.
306 Therefore the split point may be a bit off from what the user has
307 specified.
308
309 At the moment mkvmerge(1) supports the following modes:
310
311 1. Splitting by size.
312
313 Syntax: --split [size:]d[k|m|g]
314
315 Examples: --split size:700m or --split 150000000
316
317 The parameter d may end with 'k', 'm' or 'g' to indicate that
318 the size is in KB, MB or GB respectively. Otherwise a size in
319 bytes is assumed. After the current output file has reached
320 this size limit a new one will be started.
321
322 The 'size:' prefix may be omitted for compatibility reasons.
323
324 2. Splitting after a duration.
325
326 Syntax: --split [duration:]HH:MM:SS.nnnnnnnnn|ds
327
328 Examples: --split duration:00:60:00.000 or --split 3600s
329
330 The parameter must either have the form HH:MM:SS.nnnnnnnnn for
331 specifying the duration in up to nano-second precision or be a
332 number d followed by the letter 's' for the duration in
333 seconds. HH is the number of hours, MM the number of minutes,
334 SS the number of seconds and nnnnnnnnn the number of
335 nanoseconds. Both the number of hours and the number of
336 nanoseconds can be omitted. There can be up to nine digits
337 after the decimal point. After the duration of the contents in
338 the current output has reached this limit a new output file
339 will be started.
340
341 The 'duration:' prefix may be omitted for compatibility
342 reasons.
343
344 3. Splitting after specific timestamps.
345
346 Syntax: --split timestamps:A[,B[,C...]]
347
348 Example: --split timestamps:00:45:00.000,01:20:00.250,6300s
349
350 The parameters A, B, C etc must all have the same format as the
351 ones used for the duration (see above). The list of timestamps
352 is separated by commas. After the input stream has reached the
353 current split point's timestamp a new file is created. Then the
354 next split point given in this list is used.
355
356 The 'timestamps:' prefix must not be omitted.
357
358 4. Keeping specific parts by specifying timestamp ranges while
359 discarding others.
360
361 Syntax: --split
362 parts:start1-end1[,[+]start2-end2[,[+]start3-end3...]]
363
364 Examples:
365
366 1. --split parts:00:01:20-00:02:45,00:05:50-00:10:30
367
368 2. --split parts:00:01:20-00:02:45,+00:05:50-00:10:30
369
370 3. --split parts:-00:02:45,00:05:50-
371
372 The parts mode tells mkvmerge(1) to keep certain ranges of
373 timestamps while discarding others. The ranges to keep have to
374 be listed after the parts: keyword and be separated by commas.
375 A range itself consists of a start and an end timestamp in the
376 same format the other variations of --split accept (e.g. both
377 00:01:20 and 80s refer to the same timestamp).
378
379 If a start timestamp is left out then it defaults to the
380 previous range's end timestamp. If there was no previous range
381 then it defaults to the start of the file (see example 3).
382
383 If an end timestamp is left out then it defaults to the end of
384 the source files which basically tells mkvmerge(1) to keep the
385 rest (see example 3).
386
387 Normally each range will be written to a new file. This can be
388 changed so that consecutive ranges are written to the same
389 file. For that the user has to prefix the start timestamp with
390 a +. This tells mkvmerge(1) not to create a new file and
391 instead append the range to the same file the previous range
392 was written to. Timestamps will be adjusted so that there will
393 be no gap in the output file even if there was a gap in the two
394 ranges in the input file.
395
396 In example 1 mkvmerge(1) will create two files. The first will
397 contain the content starting from 00:01:20 until 00:02:45. The
398 second file will contain the content starting from 00:05:50
399 until 00:10:30.
400
401 In example 2 mkvmerge(1) will create only one file. This file
402 will contain both the content starting from 00:01:20 until
403 00:02:45 and the content starting from 00:05:50 until 00:10:30.
404
405 In example 3 mkvmerge(1) will create two files. The first will
406 contain the content from the start of the source files until
407 00:02:45. The second file will contain the content starting
408 from 00:05:50 until the end of the source files.
409
410 Note
411 Note that mkvmerge(1) only makes decisions about splitting
412 at key frame positions. This applies to both the start and
413 the end of each range. So even if an end timestamp is
414 between two key frames mkvmerge(1) will continue outputting
415 the frames up to but excluding the following key frame.
416
417 5. Keeping specific parts by specifying frame/field number ranges
418 while discarding others.
419
420 Syntax: --split
421 parts-frames:start1-end1[,[+]start2-end2[,[+]start3-end3...]]
422
423 Examples:
424
425 1. --split parts-frames:137-258,548-1211
426
427 2. --split parts-frames:733-912,+1592-2730
428
429 3. --split parts-frames:-430,2512-
430
431 The parts-frames mode tells mkvmerge(1) to keep certain ranges
432 of frame/field numbers while discarding others. The ranges to
433 keep have to be listed after the parts-frames: keyword and be
434 separated by commas. A range itself consists of a start and an
435 end frame/field number. Numbering starts at 1.
436
437 If a start number is left out then it defaults to the previous
438 range's end number. If there was no previous range then it
439 defaults to the start of the file (see example 3).
440
441 If an end number is left out then it defaults to the end of the
442 source files which basically tells mkvmerge(1) to keep the rest
443 (see example 3).
444
445 Normally each range will be written to a new file. This can be
446 changed so that consecutive ranges are written to the same
447 file. For that the user has to prefix the start number with a
448 +. This tells mkvmerge(1) not to create a new file and instead
449 append the range to the same file the previous range was
450 written to. Timestamps will be adjusted so that there will be
451 no gap in the output file even if there was a gap in the two
452 ranges in the input file.
453
454 Note
455 Note that mkvmerge(1) only makes decisions about splitting
456 at key frame positions. This applies to both the start and
457 the end of each range. So even if an end frame/field number
458 is between two key frames mkvmerge(1) will continue
459 outputting the frames up to but excluding the following key
460 frame.
461 In example 1 mkvmerge(1) will create two files. The first will
462 contain the content starting from the first key frame at or
463 after 137 up to but excluding the first key frame at or after
464 258. The second file will contain the content starting from 548
465 until 1211.
466
467 In example 2 mkvmerge(1) will create only one file. This file
468 will contain both the content starting from 733 until 912 and
469 the content starting from 1592 until 2730.
470
471 In example 3 mkvmerge(1) will create two files. The first will
472 contain the content from the start of the source files until
473 430. The second file will contain the content starting from
474 2512 until the end of the source files.
475
476 This mode considers only the first video track that is output.
477 If no video track is output no splitting will occur.
478
479 Note
480 The numbers given with this argument are interpreted based
481 on the number of Matroska(TM) blocks that are output. A
482 single Matroska(TM) block contains either a full frame (for
483 progressive content) or a single field (for interlaced
484 content). mkvmerge does not distinguish between those two
485 and simply counts the number of blocks. For example: If one
486 wanted to split after the 25th full frame with interlaced
487 content one would have to use 50 (two fields per full
488 frame) as the split point.
489
490 6. Splitting after specific frames/fields.
491
492 Syntax: --split frames:A[,B[,C...]]
493
494 Example: --split frames:120,237,891
495
496 The parameters A, B, C etc must all be positive integers.
497 Numbering starts at 1. The list of frame/field numbers is
498 separated by commas. After the input stream has reached the
499 current split point's frame/field number a new file is created.
500 Then the next split point given in this list is used.
501
502 The 'frames:' prefix must not be omitted.
503
504 This mode considers only the first video track that is output.
505 If no video track is output no splitting will occur.
506
507 Note
508 The numbers given with this argument are interpreted based
509 on the number of Matroska(TM) blocks that are output. A
510 single Matroska(TM) block contains either a full frame (for
511 progressive content) or a single field (for interlaced
512 content). mkvmerge does not distinguish between those two
513 and simply counts the number of blocks. For example: If one
514 wanted to split after the 25th full frame with interlaced
515 content one would have to use 50 (two fields per full
516 frame) as the split point.
517
518 7. Splitting before specific chapters.
519
520 Syntax: --split chapters:all or --split chapters:A[,B[,C...]]
521
522 Example: --split chapters:5,8
523
524 The parameters A, B, C etc must all be positive integers.
525 Numbering starts at 1. The list of chapter numbers is separated
526 by commas. Splitting will occur right before the first key
527 frame whose timestamp is equal to or bigger than the start
528 timestamp for the chapters whose numbers are listed. A chapter
529 starting at 0s is never considered for splitting and discarded
530 silently.
531
532 The keyword all can be used instead of listing all chapter
533 numbers manually.
534
535 The 'chapters:' prefix must not be omitted.
536
537 Note
538 The Matroska(TM) file format supports arbitrary deeply
539 nested chapter structures called 'edition entries' and
540 'chapter atoms'. However, this mode only considers the
541 top-most level of chapters across all edition entries.
542
543 For this splitting mode the output filename is treated differently
544 than for the normal operation. It may contain a printf like
545 expression '%d' including an optional field width, e.g. '%02d'. If
546 it does then the current file number will be formatted
547 appropriately and inserted at that point in the filename. If there
548 is no such pattern then a pattern of '-%03d' is assumed right
549 before the file's extension: '-o output.mkv' would result in
550 'output-001.mkv' and so on. If there's no extension then '-%03d'
551 will be appended to the name.
552
553 Another possible pattern is '%c' which will be replaced by the name
554 of the first chapter in the file. Note that when '%c' is present,
555 the pattern '-%03d' will not be added automatically.
556
557 --link
558 Link files to one another when splitting the output file. See the
559 section on file linking below for details.
560
561 --link-to-previous segment-UID
562 Links the first output file to the segment with the segment UID
563 given by the segment-UID parameter. See the section on file linking
564 below for details.
565
566 If SID starts with = then its rest is interpreted as the name of a
567 Matroska file whose segment UID is read and used.
568
569 --link-to-next segment-UID
570 Links the last output file to the segment with the segment UID
571 given by the segment-UID parameter. See the section on file linking
572 below for details.
573
574 If SID starts with = then its rest is interpreted as the name of a
575 Matroska file whose segment UID is read and used.
576
577 --append-mode mode
578 Determines how timestamps are calculated when appending files. The
579 parameter mode can have two values: 'file' which is also the
580 default and 'track'.
581
582 When mkvmerge appends a track (called 'track2_1' from now on) from
583 a second file (called 'file2') to a track (called 'track1_1') from
584 the first file (called 'file1') then it has to offset all
585 timestamps for 'track2_1' by an amount. For 'file' mode this amount
586 is the highest timestamp encountered in 'file1' even if that
587 timestamp was from a different track than 'track1_1'. In track mode
588 the offset is the highest timestamp of 'track1_1'.
589
590 Unfortunately mkvmerge cannot detect which mode to use reliably.
591 Therefore it defaults to 'file' mode. 'file' mode usually works
592 better for files that have been created independently of each
593 other; e.g. when appending AVI or MP4 files. 'track' mode may work
594 better for sources that are essentially just parts of one big file,
595 e.g. for VOB and EVO files.
596
597 Subtitle tracks are always treated as if 'file' mode were active
598 even if 'track' mode actually is.
599
600 --append-to SFID1:STID1:DFID1:DTID1[,...]
601 This option controls to which track another track is appended. Each
602 spec contains four IDs: a file ID, a track ID, a second file ID and
603 a second track ID. The first pair, "source file ID" and "source
604 track ID", identifies the track that is to be appended. The second
605 pair, "destination file ID" and "destination track ID", identifies
606 the track the first one is appended to.
607
608 If this option has been omitted then a standard mapping is used.
609 This standard mapping appends each track from the current file to a
610 track from the previous file with the same track ID. This allows
611 for easy appending if a movie has been split into two parts and
612 both file have the same number of tracks and track IDs with the
613 command mkvmerge -o output.mkv part1.mkv +part2.mkv.
614
615 +
616 A single '+' causes the next file to be appended instead of added.
617 The '+' can also be put in front of the next file name. Therefore
618 the following two commands are equivalent:
619
620 $ mkvmerge -o full.mkv file1.mkv + file2.mkv
621 $ mkvmerge -o full.mkv file1.mkv +file2.mkv
622
623 [ file1 file2 ]
624 If multiple file names are contained in a pair of square brackets
625 then the second and all following files will be appended to the
626 first file named within the brackets.
627
628 This is an alternative syntax to using '+' between the file names.
629 Therefore the following two commands are equivalent:
630
631 $ mkvmerge -o full.mkv file1.mkv + file2.mkv
632 $ mkvmerge -o full.mkv '[' file1.mkv file2.mkv ']'
633
634 =
635 For certain file types (MPEG program streams = VOBs) mkvmerge(1)
636 normally looks for files in the same directory as an input file
637 that have the same base name and only differ in their running
638 number (e.g. 'VTS_01_1.VOB', 'VTS_01_2.VOB', 'VTS_01_3.VOB' etc)
639 and treats all of those files as if they were concatenated into a
640 single big file. This option, a single '=', causes mkvmerge not to
641 look for those additional files.
642
643 The '=' can also be put in front of the next file name. Therefore
644 the following two commands are equivalent:
645
646 $ mkvmerge -o full.mkv = file1.vob
647 $ mkvmerge -o full.mkv =file1.vob
648
649 ( file1 file2 )
650 If multiple file names are contained in a pair of parenthesis then
651 those files will be treated as if they were concatenated into a
652 single big file consisting of the content of each of the files one
653 after the other.
654
655 This can be used for e.g. VOB files coming from a DVD or MPEG
656 transport streams. It cannot be used if each file contains its own
657 set of headers which is usually the case with stand-alone files
658 like AVI or MP4.
659
660 Putting a file name into parenthesis also prevents mkvmerge(1) from
661 looking for additional files with the same base name as described
662 in option =. Therefore these two command lines are equivalent:
663
664 $ mkvmerge -o out.mkv = file.mkv
665 $ mkvmerge -o out.mkv '(' file.mkv ')'
666
667 Several things should be noted:
668
669 1. There must be spaces both after the opening and before the
670 closing parenthesis.
671
672 2. Every parameter between parenthesis is interpreted as a file
673 name. Therefore all options applying to this logical file must
674 be listed before the opening parenthesis.
675
676 3. Some shells treat parenthesis as special characters. Hence you
677 must escape or quote them as shown in the example above.
678
679 Attachment support (more global options)
680 --attachment-description description
681 Plain text description of the following attachment. Applies to the
682 next --attach-file or --attach-file-once option.
683
684 --attachment-mime-type MIME type
685 MIME type of the following attachment. Applies to the next
686 --attach-file or --attach-file-once option. A list of officially
687 recognized MIME types can be found e.g. at the IANA homepage[2].
688 The MIME type is mandatory for an attachment.
689
690 --attachment-name name
691 Sets the name that will be stored in the output file for this
692 attachment. If this option is not given then the name will be
693 derived from the file name of the attachment as given with the
694 --attach-file or the --attach-file-once option.
695
696 --attach-file file-name, --attach-file-once file-name
697 Creates a file attachment inside the Matroska(TM) file. The MIME
698 type must have been set before this option can used. The difference
699 between the two forms is that during splitting the files attached
700 with --attach-file are attached to all output files while the ones
701 attached with --attach-file-once are only attached to the first
702 file created. If splitting is not used then both do the same.
703
704 mkvextract(1) can be used to extract attached files from a
705 Matroska(TM) file.
706
707 Options that can be used for each input file
708 -a, --audio-tracks [!]n,m,...
709 Copy the audio tracks n, m etc. The numbers are track IDs which can
710 be obtained with the --identify switch. They're not simply the
711 track numbers (see section track IDs). Default: copy all audio
712 tracks.
713
714 Instead of track IDs you can also provide ISO 639-2 language codes.
715 This will only work for source files that provide language tags for
716 their tracks.
717
718 Default: copy all tracks of this kind.
719
720 If the IDs are prefixed with ! then the meaning is reversed: copy
721 all tracks of this kind but the ones listed after the !.
722
723 -d, --video-tracks [!]n,m,...
724 Copy the video tracks n, m etc. The numbers are track IDs which can
725 be obtained with the --identify switch. They're not simply the
726 track numbers (see section track IDs). Default: copy all video
727 tracks.
728
729 Instead of track IDs you can also provide ISO 639-2 language codes.
730 This will only work for source files that provide language tags for
731 their tracks.
732
733 If the IDs are prefixed with ! then the meaning is reversed: copy
734 all tracks of this kind but the ones listed after the !.
735
736 -s, --subtitle-tracks [!]n,m,...
737 Copy the subtitle tracks n, m etc. The numbers are track IDs which
738 can be obtained with the --identify switch. They're not simply the
739 track numbers (see section track IDs). Default: copy all subtitle
740 tracks.
741
742 Instead of track IDs you can also provide ISO 639-2 language codes.
743 This will only work for source files that provide language tags for
744 their tracks.
745
746 If the IDs are prefixed with ! then the meaning is reversed: copy
747 all tracks of this kind but the ones listed after the !.
748
749 -b, --button-tracks [!]n,m,...
750 Copy the button tracks n, m etc. The numbers are track IDs which
751 can be obtained with the --identify switch. They're not simply the
752 track numbers (see section track IDs). Default: copy all button
753 tracks.
754
755 Instead of track IDs you can also provide ISO 639-2 language codes.
756 This will only work for source files that provide language tags for
757 their tracks.
758
759 If the IDs are prefixed with ! then the meaning is reversed: copy
760 all tracks of this kind but the ones listed after the !.
761
762 --track-tags [!]n,m,...
763 Copy the tags for tracks n, m etc. The numbers are track IDs which
764 can be obtained with the --identify switch (see section track IDs).
765 They're not simply the track numbers. Default: copy tags for all
766 tracks.
767
768 If the IDs are prefixed with ! then the meaning is reversed: copy
769 everything but the IDs listed after the !.
770
771 -m, --attachments [!]n[:all|first],m[:all|first],...
772 Copy the attachments with the IDs n, m etc to all or only the first
773 output file. Each ID can be followed by either ':all' (which is the
774 default if neither is entered) or ':first'. If splitting is active
775 then those attachments whose IDs are specified with ':all' are
776 copied to all of the resulting output files while the others are
777 only copied into the first output file. If splitting is not active
778 then both variants have the same effect.
779
780 The default is to copy all attachments to all output files.
781
782 If the IDs are prefixed with ! then the meaning is reversed: copy
783 everything but the IDs listed after the !.
784
785 -A, --no-audio
786 Don't copy any audio track from this file.
787
788 -D, --no-video
789 Don't copy any video track from this file.
790
791 -S, --no-subtitles
792 Don't copy any subtitle track from this file.
793
794 -B, --no-buttons
795 Don't copy any button track from this file.
796
797 -T, --no-track-tags
798 Don't copy any track specific tags from this file.
799
800 --no-chapters
801 Don't copy chapters from this file.
802
803 -M, --no-attachments
804 Don't copy attachments from this file.
805
806 --no-global-tags
807 Don't copy global tags from this file.
808
809 -y, --sync TID:d[,o[/p]]
810 Adjust the timestamps of the track with the id TID by d ms. The
811 track IDs are the same as the ones given with --identify (see
812 section track IDs).
813
814 o/p: adjust the timestamps by o/p to fix linear drifts. p defaults
815 to 1 if omitted. Both o and p can be floating point numbers.
816
817 Defaults: no manual sync correction (which is the same as d = 0 and
818 o/p = 1.0).
819
820 This option can be used multiple times for an input file applying
821 to several tracks by selecting different track IDs each time.
822
823 --cues TID:none|iframes|all
824 Controls for which tracks cue (index) entries are created for the
825 given track (see section track IDs). 'none' inhibits the creation
826 of cue entries. For 'iframes' only blocks with no backward or
827 forward references ( = I frames in video tracks) are put into the
828 cue sheet. 'all' causes mkvmerge(1) to create cue entries for all
829 blocks which will make the file very big.
830
831 The default is 'iframes' for video and subtitle tracks and 'none'
832 for audio tracks. See also option --no-cues which inhibits the
833 creation of cue entries regardless of the --cues options used.
834
835 This option can be used multiple times for an input file applying
836 to several tracks by selecting different track IDs each time.
837
838 --default-track TID[:bool]
839 Sets the "default track" flag for the given track (see section
840 track IDs) if the optional argument bool is set to 1 or if it isn't
841 present. The flag will be set if the source container doesn't
842 provide that information and the user doesn't specify it via this
843 option.
844
845 If the user does not explicitly select a track during playback, the
846 player should select one of the tracks that has its "default track"
847 flag set, taking user preferences such as their preferred language
848 into account.
849
850 This option can be used multiple times for an input file applying
851 to several tracks by selecting different track IDs each time.
852
853 --forced-track TID[:bool]
854 Sets the "forced display" flag for the given track (see section
855 track IDs) if the optional argument bool is set to 1 or if it isn't
856 present. Use this for tracks containing onscreen text or
857 foreign-language dialogue.
858
859 This option can be used multiple times for an input file applying
860 to several tracks by selecting different track IDs each time.
861
862 --hearing-impaired-flag TID[:bool]
863 Sets the "hearing impaired" flag for the given track (see section
864 track IDs) if the optional argument bool is set to 1 or if it isn't
865 present. This flag can be set if the track is suitable for users
866 with hearing impairments.
867
868 This option can be used multiple times for an input file applying
869 to several tracks by selecting different track IDs each time.
870
871 --visual-impaired-flag TID[:bool]
872 Sets the "visual impaired" flag for the given track (see section
873 track IDs) if the optional argument bool is set to 1 or if it isn't
874 present. This flag can be set if the track is suitable for users
875 with visual impairments.
876
877 This option can be used multiple times for an input file applying
878 to several tracks by selecting different track IDs each time.
879
880 --text-descriptions-flag TID[:bool]
881 Sets the "text descriptions" flag for the given track (see section
882 track IDs) if the optional argument bool is set to 1 or if it isn't
883 present. This flag can be set if the track contains textual
884 descriptions of video content suitable for playback via a
885 text-to-speech system for a visually-impaired user.
886
887 This option can be used multiple times for an input file applying
888 to several tracks by selecting different track IDs each time.
889
890 --original-flag TID[:bool]
891 Sets the "original language" flag for the given track (see section
892 track IDs) if the optional argument bool is set to 1 or if it isn't
893 present. This flag can be set if the track is in the content's
894 original language (not a translation).
895
896 This option can be used multiple times for an input file applying
897 to several tracks by selecting different track IDs each time.
898
899 --commentary-flag TID[:bool]
900 Sets the "commentary" flag for the given track (see section track
901 IDs) if the optional argument bool is set to 1 or if it isn't
902 present. This flag can be set if the track contains commentary.
903
904 This option can be used multiple times for an input file applying
905 to several tracks by selecting different track IDs each time.
906
907 --blockadd TID:level
908 Keep only the BlockAdditions up to the level level for the given
909 track. The default is to keep all levels. This option only affects
910 certain kinds of codecs like WAVPACK4.
911
912 --track-name TID:name
913 Sets the track name for the given track (see section track IDs) to
914 name.
915
916 --language TID:language
917 Sets the language for the given track (see section track IDs). Both
918 ISO 639-2 language codes and ISO 639-1 country codes are allowed.
919 The country codes will be converted to language codes
920 automatically. All languages including their ISO 639-2 codes can be
921 listed with the --list-languages option.
922
923 This option can be used multiple times for an input file applying
924 to several tracks by selecting different track IDs each time.
925
926 -t, --tags TID:file-name
927 Read tags for the track with the number TID from the file
928 file-name. See the section about tags below for details.
929
930 --aac-is-sbr TID[:0|1]
931 Tells mkvmerge(1) that the track with the ID TID is SBR AAC (also
932 known as HE-AAC or AAC+). This options is needed if a) the source
933 file is an AAC file (not for a Matroska(TM) file) and b) the AAC
934 file contains SBR AAC data. The reason for this switch is that it
935 is technically impossible to automatically tell normal AAC data
936 from SBR AAC data without decoding a complete AAC frame. As there
937 are several patent issues with AAC decoders mkvmerge(1) will never
938 contain this decoding stage. So for SBR AAC files this switch is
939 mandatory. The resulting file might not play back correctly or even
940 not at all if the switch was omitted.
941
942 If the source file is a Matroska(TM) file then the CodecID should
943 be enough to detect SBR AAC. However, if the CodecID is wrong then
944 this switch can be used to correct that.
945
946 If mkvmerge wrongfully detects that an AAC file is SBR then you can
947 add ':0' to the track ID.
948
949 --reduce-to-core TID
950 Some audio codecs have a lossy core and optional extensions that
951 implement lossless decoding. This option tells mkvmerge(1) to only
952 copy the core but not the extensions. By default mkvmerge(1) copies
953 both the core and the extensions.
954
955 Currently only DTS tracks are affected by this option. TrueHD
956 tracks that contain an embedded AC-3 core are instead presented as
957 two separate tracks for which the user can select which track to
958 copy. For DTS such a scheme would not work as the HD extensions
959 cannot be decoded by themselves – unlike the TrueHD data.
960
961 --remove-dialog-normalization-gain TID
962 Some audio codecs contain header fields that tell the decoder or
963 player to apply a (usually negative) gain for dialog normalization.
964 This option tells mkvmerge(1) to remove or minimize that gain by
965 modifying the corresponding header fields.
966
967 Currently only AC-3, DTS and TrueHD tracks are affected by this
968 option.
969
970 --timestamps TID:file-name
971 Read the timestamps to be used for the specific track ID from
972 file-name. These timestamps forcefully override the timestamps that
973 mkvmerge(1) normally calculates. Read the section about external
974 timestamp files.
975
976 --default-duration TID:x
977 Forces the default duration of a given track to the specified
978 value. Also modifies the track's timestamps to match the default
979 duration. The argument x must be postfixed with 's', 'ms', 'us',
980 'ns', 'fps', 'p' or 'i' to specify the default duration in seconds,
981 milliseconds, microseconds, nanoseconds, 'frames per second',
982 'progressive frames per second' or 'interlaced frames per second'
983 respectively. The number x itself can be a floating point number or
984 a fraction.
985
986 If the default duration is not forced then mkvmerge will try to
987 derive the track's default duration from the container and/or the
988 encoded bitstream for certain track types, e.g. AVC/H.264 or
989 MPEG-2.
990
991 This option can also be used to change the FPS of video tracks
992 without having to use an external timestamp file.
993
994 --fix-bitstream-timing-information TID[:0|1]
995 Normally mkvmerge(1) does not change the timing information
996 (frame/field rate) stored in the video bitstream. With this option
997 that information is adjusted to match the container timing
998 information. The container timing information can come from various
999 sources: from the command line (see option --default-duration), the
1000 source container or derived from the bitstream.
1001
1002 Note
1003 This has only been implemented for AVC/H.264 video tracks so
1004 far.
1005
1006 --compression TID:n
1007 Selects the compression method to be used for the track. Note that
1008 the player also has to support this method. Valid values are
1009 'none', 'zlib' and 'mpeg4_p2'/'mpeg4p2'.
1010
1011 The compression method 'mpeg4_p2'/'mpeg4p2' is a special
1012 compression method called 'header removal' that is only available
1013 for MPEG4 part 2 video tracks.
1014
1015 The default for some subtitle types is 'zlib' compression. This
1016 compression method is also the one that most if not all playback
1017 applications support. Support for other compression methods other
1018 than 'none' is not assured.
1019
1020 Options that only apply to video tracks
1021 -f, --fourcc TID:FourCC
1022 Forces the FourCC to the specified value. Works only for video
1023 tracks in the 'MS compatibility mode'.
1024
1025 --display-dimensions TID:widthxheight
1026 Matroska(TM) files contain two values that set the display
1027 properties that a player should scale the image on playback to:
1028 display width and display height. These values can be set with this
1029 option, e.g. '1:640x480'.
1030
1031 Another way to specify the values is to use the --aspect-ratio or
1032 the --aspect-ratio-factor option (see below). These options are
1033 mutually exclusive.
1034
1035 --aspect-ratio TID:ratio|width/height
1036 Matroska(TM) files contain two values that set the display
1037 properties that a player should scale the image on playback to:
1038 display width and display height. With this option mkvmerge(1) will
1039 automatically calculate the display width and display height based
1040 on the image's original width and height and the aspect ratio given
1041 with this option. The ratio can be given either as a floating point
1042 number ratio or as a fraction 'width/height', e.g. '16/9'.
1043
1044 Another way to specify the values is to use the
1045 --aspect-ratio-factor or --display-dimensions options (see above
1046 and below). These options are mutually exclusive.
1047
1048 --aspect-ratio-factor TID:factor|n/d
1049 Another way to set the aspect ratio is to specify a factor. The
1050 original aspect ratio is first multiplied with this factor and used
1051 as the target aspect ratio afterwards.
1052
1053 Another way to specify the values is to use the --aspect-ratio or
1054 --display-dimensions options (see above). These options are
1055 mutually exclusive.
1056
1057 --cropping TID:left,top,right,bottom
1058 Sets the pixel cropping parameters of a video track to the given
1059 values.
1060
1061 --colour-matrix-coefficients TID:n
1062 Sets the matrix coefficients of the video used to derive luma and
1063 chroma values from red, green and blue color primaries. The
1064 parameter n is an integer rangeing from 0 and 10.
1065
1066 Valid values and their meaning are:
1067
1068 0: GBR, 1: BT709, 2: unspecified, 3: reserved, 4: FCC, 5: BT470BG,
1069 6: SMPTE 170M, 7: SMPTE 240M, 8: YCOCG, 9: BT2020 non-constant
1070 luminance, 10: BT2020 constant luminance
1071
1072 --colour-bits-per-channel TID:n
1073 Sets the number of coded bits for a colour channel. A value of 0
1074 indicates that the number of bits is unspecified.
1075
1076 --chroma-subsample TID:hori,vert
1077 The amount of pixels to remove in the Cr and Cb channels for every
1078 pixel not removed horizontally/vertically.
1079
1080 Example: For video with 4:2:0 chroma subsampling, the parameter
1081 should be set to TID:1,1.
1082
1083 --cb-subsample TID:hori,vert
1084 The amount of pixels to remove in the Cb channel for every pixel
1085 not removed horizontally/vertically. This is additive with
1086 --chroma-subsample.
1087
1088 Example: For video with 4:2:1 chroma subsampling, the parameter
1089 --chroma-subsample should be set to TID:1,0 and Cb-subsample should
1090 be set to TID:1,0.
1091
1092 --chroma-siting TID:hori,vert
1093 Sets how chroma is sited horizontally/vertically (0: unspecified,
1094 1: top collocated, 2: half).
1095
1096 --colour-range TID:n
1097 Sets the clipping of the color ranges (0: unspecified, 1: broadcast
1098 range, 2: full range (no clipping), 3: defined by
1099 MatrixCoefficients/TransferCharacteristics).
1100
1101 --colour-transfer-characteristics TID:n
1102 The transfer characteristics of the video.
1103
1104 Valid values and their meaning are:
1105
1106 0: reserved, 1: ITU-R BT.709, 2: unspecified, 3: reserved, 4: gamma
1107 2.2 curve, 5: gamma 2.8 curve, 6: SMPTE 170M, 7: SMPTE 240M, 8:
1108 linear, 9: log, 10: log sqrt, 11: IEC 61966-2-4, 12: ITU-R BT.1361
1109 extended colour gamut, 13: IEC 61966-2-1, 14: ITU-R BT.2020 10 bit,
1110 15: ITU-R BT.2020 12 bit, 16: SMPTE ST 2084, 17: SMPTE ST 428-1;
1111 18: ARIB STD-B67 (HLG)
1112
1113 --colour-primaries TID:n
1114 Sets the colour primaries of the video.
1115
1116 Valid values and their meaning are:
1117
1118 0: reserved, 1: ITU-R BT.709, 2: unspecified, 3: reserved, 4: ITU-R
1119 BT.470M, 5: ITU-R BT.470BG, 6: SMPTE 170M, 7: SMPTE 240M, 8: FILM,
1120 9: ITU-R BT.2020, 10: SMPTE ST 428-1, 22: JEDEC P22 phosphors
1121
1122 --max-content-light TID:n
1123 Sets the maximum brightness of a single pixel (Maximum Content
1124 Light Level) in candelas per square meter (cd/m²). The value of n
1125 should be a non-negtive integer.
1126
1127 --max-frame-light TID:n
1128 Sets the maximum brightness of a single full frame (Maximum
1129 Frame-Average Light Level) in candelas per square meter (cd/m²).
1130 The value of n should be a non-negtive integer.
1131
1132 --chromaticity-coordinates
1133 TID:red-x,red-y,green-x,green-y,blue-x,blue-y
1134 Sets the red/green/blue chromaticity coordinates as defined by CIE
1135 1931.
1136
1137 --white-colour-coordinates TID:x,y
1138 Sets the white colour chromaticity coordinates as defined by CIE
1139 1931.
1140
1141 --max-luminance TID:float
1142 Sets the maximum luminance in candelas per square meter (cd/m²).
1143 The value should be less than 9999.99.
1144
1145 --min-luminance TID:float
1146 Sets the minimum luminance in candelas per square meter (cd/m²).
1147 The value should be less than 999.9999.
1148
1149 --projection-type TID:method
1150 Sets the video projection method used. Valid values are 0
1151 (rectangular projection), 1 (equirectangular projection), 2
1152 (cubemap projection) and 3 (mesh projection).
1153
1154 --projection-private TID:data
1155 Sets private data that only applies to a specific projection. Data
1156 must be given as hex numbers with or without the "0x" prefix, with
1157 or without spaces.
1158
1159 --projection-pose-yaw TID:float
1160 Specifies a yaw rotation to the projection.
1161
1162 --projection-pose-pitch TID:float
1163 Specifies a pitch rotation to the projection.
1164
1165 --projection-pose-roll TID:float
1166 Specifies a roll rotation to the projection.
1167
1168 --field-order TID:n
1169 Sets the field order for the video track with the track ID TID. The
1170 order must be one of the following numbers:
1171
1172 0: progressive; 1: interlaced with top field displayed first and
1173 top field stored first; 2: undetermined field order; 6: interlaced
1174 with bottom field displayed first and bottom field stored first; 9:
1175 interlaced with bottom field displayed first and top field stored
1176 first; 14: interlaced with top field displayed first and bottom
1177 field stored first
1178
1179 --stereo-mode TID:n|keyword
1180 Sets the stereo mode for the video track with the track ID TID. The
1181 mode can either be a number n between 0 and 14 or one of these
1182 keywords:
1183
1184 'mono', 'side_by_side_left_first', 'top_bottom_right_first',
1185 'top_bottom_left_first', 'checkerboard_right_first',
1186 'checkerboard_left_first', 'row_interleaved_right_first',
1187 'row_interleaved_left_first', 'column_interleaved_right_first',
1188 'column_interleaved_left_first', 'anaglyph_cyan_red',
1189 'side_by_side_right_first', 'anaglyph_green_magenta',
1190 'both_eyes_laced_left_first', 'both_eyes_laced_right_first'.
1191
1192 Options that only apply to text subtitle tracks
1193 --sub-charset TID:character-set
1194 Sets the character set for the conversion to UTF-8 for UTF-8
1195 subtitles for the given track ID. If not specified the charset will
1196 be derived from the current locale settings. Note that a charset is
1197 not needed for subtitles read from Matroska(TM) files or from Kate
1198 streams, as these are always stored in UTF-8. See the section about
1199 text files and character sets for an explanation how mkvmerge(1)
1200 converts between character sets.
1201
1202 This option can be used multiple times for an input file applying
1203 to several tracks by selecting different track IDs each time.
1204
1205 Other options
1206 -i, --identify file-name
1207 Will let mkvmerge(1) probe the single file and report its type, the
1208 tracks contained in the file and their track IDs. If this option is
1209 used then the only other option allowed is the filename.
1210
1211 The output format used for the result can be changed with the
1212 option --identification-format.
1213
1214 -J file-name
1215 This is a convenient alias for "--identification-format json
1216 --identify file-name".
1217
1218 -F, --identification-format format
1219 Determines the output format used by the --identify option. The
1220 following formats are supported: text (the default if this option
1221 isn't used) and json.
1222
1223 1. The text format is short and human-readable. It consists of one
1224 line per item found (container, tracks, attachments etc.).
1225
1226 This format is not meant to be parsed. The output will be
1227 translated into the language mkvmerge(1) uses (see also
1228 --ui-language).
1229
1230 2. The json format outputs a machine-readable JSON representation.
1231 This format follows the JSON schema described in the following
1232 file:
1233
1234 mkvmerge-identification-output-schema-v14.json[3]
1235
1236 All versions of the JSON schema are available both online and
1237 in the released source code archives.
1238
1239 --probe-range-percentage percentage
1240 File types such as MPEG program and transport streams (.vob, .m2ts)
1241 require parsing a certain amount of data in order to detect all
1242 tracks contained in the file. This amount is 0.3% of the source
1243 file's size or 10 MB, whichever is higher.
1244
1245 If tracks are known to be present but not found then the percentage
1246 to probe can be changed with this option. The minimum of 10 MB is
1247 built-in and cannot be changed.
1248
1249 -l, --list-types
1250 Lists supported input file types.
1251
1252 --list-languages
1253 Lists all languages and their ISO 639-2 code which can be used with
1254 the --language option.
1255
1256 --priority priority
1257 Sets the process priority that mkvmerge(1) runs with. Valid values
1258 are 'lowest', 'lower', 'normal', 'higher' and 'highest'. If nothing
1259 is given then 'normal' is used. On Unix like systems mkvmerge(1)
1260 will use the nice(2) function. Therefore only the super user can
1261 use 'higher' and 'highest'. On Windows all values are useable for
1262 every user.
1263
1264 Selecting 'lowest' also causes mkvmerge(1) to select idle I/O
1265 priority in addition to the lowest possible process priority.
1266
1267 --command-line-charset character-set
1268 Sets the character set to convert strings given on the command line
1269 from. It defaults to the character set given by system's current
1270 locale. This settings applies to arguments of the following
1271 options: --title, --track-name and --attachment-description.
1272
1273 --output-charset character-set
1274 Sets the character set to which strings are converted that are to
1275 be output. It defaults to the character set given by system's
1276 current locale.
1277
1278 -r, --redirect-output file-name
1279 Writes all messages to the file file-name instead of to the
1280 console. While this can be done easily with output redirection
1281 there are cases in which this option is needed: when the terminal
1282 reinterprets the output before writing it to a file. The character
1283 set set with --output-charset is honored.
1284
1285 --flush-on-close
1286 Tells the program to flush all data cached in memory to storage
1287 when closing files opened for writing. This can be used to prevent
1288 data loss on power outages or to circumvent certain problems in the
1289 operating system or drivers. The downside is that multiplexing will
1290 take longer as mkvmerge will wait until all data has been written
1291 to the storage before exiting. See issues #2469 and #2480 on the
1292 MKVToolNix bug tracker for in-depth discussions on the pros and
1293 cons.
1294
1295 --ui-language code
1296 Forces the translations for the language code to be used (e.g.
1297 'de_DE' for the German translations). Entering 'list' as the code
1298 will cause the program to output a list of available translations.
1299
1300 --abort-on-warnings
1301 Tells the program to abort after the first warning is emitted. The
1302 program's exit code will be 1.
1303
1304 --deterministic seed
1305 Enables the creation of byte-identical files if the same version of
1306 mkvmerge(1) is used with the same source files, the same set of
1307 options and the same seed. Note that the "date" segment information
1308 field is not written in this mode.
1309
1310 The seed can be an arbitrary string and does not have to be a
1311 number.
1312
1313 The result of byte-identical files is only guaranteed under the
1314 following conditions:
1315
1316 1. The same version of mkvmerge(1) built with the same versions of
1317 libEBML and libMatroska is used.
1318
1319 2. The source files used are byte-identical.
1320
1321 3. The same command line options are used in the same order (with
1322 the notable exception of --output ...).
1323
1324 Using other versions of mkvmerge(1) or other command-line options
1325 may result in the same byte-identical file but is not guaranteed to
1326 do so.
1327
1328 --debug topic
1329 Turn on debugging for a specific feature. This option is only
1330 useful for developers.
1331
1332 --engage feature
1333 Turn on experimental features. A list of available features can be
1334 requested with mkvmerge --engage list. These features are not meant
1335 to be used in normal situations.
1336
1337 --gui-mode
1338 Turns on GUI mode. In this mode specially-formatted lines may be
1339 output that can tell a controlling GUI what's happening. These
1340 messages follow the format '#GUI#message'. The message may be
1341 followed by key/value pairs as in
1342 '#GUI#message#key1=value1#key2=value2...'. Neither the messages nor
1343 the keys are ever translated and always output in English.
1344
1345 @options-file.json
1346 Reads additional command line arguments from the file options-file.
1347 See the section about option files for further information.
1348
1349 --capabilities
1350 Lists information about optional features that have been compiled
1351 in and exit. The first line output will be the version information.
1352 All following lines contain exactly one word whose presence
1353 indicates that the feature has been compiled in. These features
1354 are:
1355
1356 • 'FLAC' -- reading raw FLAC files and handling FLAC tracks in
1357 other containers, e.g. Ogg(TM) or Matroska(TM).
1358
1359 -h, --help
1360 Show usage information and exit.
1361
1362 -V, --version
1363 Show version information and exit.
1364
1366 For each file the user can select which tracks mkvmerge(1) should take.
1367 They are all put into the file specified with -o. A list of known (and
1368 supported) source formats can be obtained with the -l option.
1369
1370 Important
1371 The order of command line options is important. Please read the
1372 section "Option order" if you're new to the program.
1373
1375 The order in which options are entered is important for some options.
1376 Options fall into two categories:
1377
1378 1. Options that affect the whole program and are not tied to any input
1379 file. These include but are not limited to --command-line-charset,
1380 --output or --title. These can appear anywhere on the command line.
1381
1382 2. Options that affect a single input file or a single track in an
1383 input file. These options all apply to the following input file on
1384 the command line. All options applying to the same input (or to
1385 tracks from the same input file) file can be written in any order
1386 as long as they all appear before that input file's name. Examples
1387 for options applying to an input file are --no-chapters or
1388 --chapter-charset. Examples for options applying to a single track
1389 are --default-duration or --language.
1390
1391 The options are processed from left to right. If an option appears
1392 multiple times within the same scope then the last occurrence will be
1393 used. Therefore the title will be set to "Something else" in the
1394 following example:
1395
1396 $ mkvmerge -o output.mkv --title 'This and that' input.avi --title 'Something else'
1397
1398 The following example shows that using the --language option twice is
1399 OK because they're used in different scopes. Even though they apply to
1400 the same track ID they apply to different input files and therefore
1401 have different scopes:
1402
1403 $ mkvmerge -o output.mkv --language 0:fre français.ogg --language 0:deu deutsch.ogg
1404
1406 Let's assume you have a file called MyMovie.avi and the audio track in
1407 a separate file, e.g. 'MyMovie.wav'. First you want to encode the audio
1408 to OggVorbis(TM):
1409
1410 $ oggenc -q4 -oMyMovie.ogg MyMovie.wav
1411
1412 After a couple of minutes you can join video and audio:
1413
1414 $ mkvmerge -o MyMovie-with-sound.mkv MyMovie.avi MyMovie.ogg
1415
1416 If your AVI already contains an audio track then it will be copied as
1417 well (if mkvmerge(1) supports the audio format). To avoid that simply
1418 do
1419
1420 $ mkvmerge -o MyMovie-with-sound.mkv -A MyMovie.avi MyMovie.ogg
1421
1422 After some minutes of consideration you rip another audio track, e.g.
1423 the director's comments or another language to 'MyMovie-add-audio.wav'.
1424 Encode it again and join it up with the other file:
1425
1426 $ oggenc -q4 -oMyMovie-add-audio.ogg MyMovie-add-audio.wav
1427 $ mkvmerge -o MM-complete.mkv MyMovie-with-sound.mkv MyMovie-add-audio.ogg
1428
1429 The same result can be achieved with
1430
1431 $ mkvmerge -o MM-complete.mkv -A MyMovie.avi MyMovie.ogg MyMovie-add-audio.ogg
1432
1433 Now fire up mplayer(TM) and enjoy. If you have multiple audio tracks
1434 (or even video tracks) then you can tell mplayer(TM) which track to
1435 play with the '-vid' and '-aid' options. These are 0-based and do not
1436 distinguish between video and audio.
1437
1438 If you need an audio track synchronized you can do that easily. First
1439 find out which track ID the Vorbis track has with
1440
1441 $ mkvmerge --identify outofsync.ogg
1442
1443 Now you can use that ID in the following command line:
1444
1445 $ mkvmerge -o goodsync.mkv -A source.avi -y 12345:200 outofsync.ogg
1446
1447 This would add 200ms of silence at the beginning of the audio track
1448 with the ID 12345 taken from 'outofsync.ogg'.
1449
1450 Some movies start synced correctly but slowly drift out of sync. For
1451 these kind of movies you can specify a delay factor that is applied to
1452 all timestamps -- no data is added or removed. So if you make that
1453 factor too big or too small you'll get bad results. An example is that
1454 an episode I transcoded was 0.2 seconds out of sync at the end of the
1455 movie which was 77340 frames long. At 29.97fps 0.2 seconds correspond
1456 to approx. 6 frames. So I did
1457
1458 $ mkvmerge -o goodsync.mkv -y 23456:0,77346/77340 outofsync.mkv
1459
1460 The result was fine.
1461
1462 The sync options can also be used for subtitles in the same manner.
1463
1464 For text subtitles you can either use some Windows software (like
1465 SubRipper(TM)) or the subrip(TM) package found in transcode(1)'s
1466 sources in the 'contrib/subrip' directory. The general process is:
1467
1468 1. extract a raw subtitle stream from the source:
1469
1470 $ tccat -i /path/to/copied/dvd/ -T 1 -L | tcextract -x ps1 -t vob -a 0x20 | subtitle2pgm -o mymovie
1471
1472 2. convert the resulting PGM images to text with gocr:
1473
1474 $ pgm2txt mymovie
1475
1476 3. spell-check the resulting text files:
1477
1478 $ ispell -d american *txt
1479
1480 4. convert the text files to a SRT file:
1481
1482 $ srttool -s -w -i mymovie.srtx -o mymovie.srt
1483
1484 The resulting file can be used as another input file for mkvmerge(1):
1485
1486 $ mkvmerge -o mymovie.mkv mymovie.avi mymovie.srt
1487
1488 If you want to specify the language for a given track then this is
1489 easily done. First find out the ISO 639-2 code for your language.
1490 mkvmerge(1) can list all of those codes for you:
1491
1492 $ mkvmerge --list-languages
1493
1494 Search the list for the languages you need. Let's assume you have put
1495 two audio tracks into a Matroska(TM) file and want to set their
1496 language codes and that their track IDs are 2 and 3. This can be done
1497 with
1498
1499 $ mkvmerge -o with-lang-codes.mkv --language 2:ger --language 3:dut without-lang-codes.mkv
1500
1501 As you can see you can use the --language switch multiple times.
1502
1503 Maybe you'd also like to have the player use the Dutch language as the
1504 default language. You also have extra subtitles, e.g. in English and
1505 French, and want to have the player display the French ones by default.
1506 This can be done with
1507
1508 $ mkvmerge -o with-lang-codes.mkv --language 2:ger --language 3:dut --default-track 3 without-lang-codes.mkv --language 0:eng english.srt --default-track 0 --language 0:fre french.srt
1509
1510 If you do not see the language or default track flags that you've
1511 specified in mkvinfo(1)'s output then please read the section about
1512 default values.
1513
1514 Turn off the compression for an input file.
1515
1516 $ mkvmerge -o no-compression.mkv --compression -1:none MyMovie.avi --compression -1:none mymovie.srt
1517
1519 Regular track IDs
1520 Some of the options for mkvmerge(1) need a track ID to specify which
1521 track they should be applied to. Those track IDs are printed by the
1522 readers when demuxing the current input file, or if mkvmerge(1) is
1523 called with the --identify option. An example for such output:
1524
1525 $ mkvmerge -i v.mkv
1526 File 'v.mkv': container: Matroska(TM)
1527 Track ID 0: video (V_MS/VFW/FOURCC, DIV3)
1528 Track ID 1: audio (A_MPEG/L3)
1529
1530 Do not confuse the track IDs that are assigned to the tracks that are
1531 placed in the output MKV file with the track IDs of the input files.
1532 Only the input file track IDs are used for options needing these
1533 values.
1534
1535 Also note that each input file has its own set of track IDs. Therefore
1536 the track IDs for file 'file1.ext' as reported by 'mkvmerge --identify'
1537 do not change no matter how many other input files are there or in
1538 which position 'file1.ext' is used.
1539
1540 Track IDs are assigned like this:
1541
1542 • AVI files: The video track has the ID 0. The audio tracks get IDs
1543 in ascending order starting at 1.
1544
1545 • AAC, AC-3, MP3, SRT and WAV files: The one 'track' in that file
1546 gets the ID 0.
1547
1548 • Most other files: The track IDs are assigned in order the tracks
1549 are found in the file starting at 0.
1550
1551 The options that use the track IDs are the ones whose description
1552 contains 'TID'. The following options use track IDs as well:
1553 --audio-tracks, --video-tracks, --subtitle-tracks, --button-tracks and
1554 --track-tags.
1555
1556 Special track IDs
1557 There are several IDs that have special meaning and do not occur in the
1558 identification output.
1559
1560 The special track ID '-1' is a wild card and applies the given switch
1561 to all tracks that are read from an input file.
1562
1563 The special track ID '-2' refers to the chapters in a source file.
1564 Currently only the --sync option uses this special ID. As an
1565 alternative to --sync -2:... the option --chapter-sync ... can be
1566 used.
1567
1569 Note
1570 This section applies to all programs in MKVToolNix even if it only
1571 mentions mkvmerge(1).
1572
1573 Introduction
1574 All text in a Matroska(TM) file is encoded in UTF-8. This means that
1575 mkvmerge(1) has to convert every text file it reads as well as every
1576 text given on the command line from one character set into UTF-8. In
1577 return this also means that mkvmerge(1)'s output has to be converted
1578 back to that character set from UTF-8, e.g. if a non-English
1579 translation is used with --ui-language or for text originating from a
1580 Matroska(TM) file.
1581
1582 mkvmerge(1) does this conversion automatically based on the presence of
1583 a byte order marker (short: BOM) or the system's current locale. How
1584 the character set is inferred from the locale depends on the operating
1585 system that mkvmerge(1) is run on.
1586
1587 Byte order markers (BOM)
1588 Text files that start with a BOM are already encoded in one
1589 representation of UTF. mkvmerge(1) supports the following five modes:
1590 UTF-8, UTF-16 Little and Big Endian, UTF-32 Little and Big Endian. Text
1591 files with a BOM are automatically converted to UTF-8. Any of the
1592 parameters that would otherwise set the character set for such a file
1593 (e.g. --sub-charset) is silently ignored.
1594
1595 Linux and Unix-like systems including macOS
1596 On Unix-like systems mkvmerge(1) uses the setlocale(3) system call
1597 which in turn uses the environment variables LANG, LC_ALL and LC_CYPE.
1598 The resulting character set is often one of UTF-8 or the ISO-8859-*
1599 family and is used for all text file operations and for encoding
1600 strings on the command line and for output to the console.
1601
1602 Windows
1603 On Windows the default character set used for converting text files is
1604 determined by a call to the GetACP() system call.
1605
1606 Reading the command line is done with the GetCommandLineW() function
1607 which already returns a Unicode string. Therefore the option
1608 --command-line-charset is ignored on Windows.
1609
1610 Output to the console consists of three scenarios:
1611
1612 1. If the output is redirected with the option --redirect-output then
1613 the default charset is UTF-8. This can be changed with
1614 --output-charset.
1615
1616 2. If the output is redirected with cmd.exe itself, e.g. with mkvinfo
1617 file.mkv > info.txt, then the charset is always UTF-8 and cannot be
1618 changed.
1619
1620 3. Otherwise (when writing directly to the console) the Windows
1621 function WriteConsoleW() is used and the option --output-charset is
1622 ignored. The console should be able to output all Unicode
1623 characters for which the corresponding language support is
1624 installed (e.g. Chinese characters might not be displayed on
1625 English Windows versions).
1626
1627 Command line options
1628 The following options exist that allow specifying the character sets:
1629
1630 • --sub-charset for text subtitle files and for text subtitle tracks
1631 stored in container formats for which the character set cannot be
1632 determined unambiguously (e.g. Ogg files),
1633
1634 • --chapter-charset for chapter text files and for chapters and file
1635 titles stored in container formats for which the character set
1636 cannot be determined unambiguously (e.g. Ogg files for chapter
1637 information, track and file titles etc; MP4 files for chapter
1638 information),
1639
1640 • --command-line-charset for all strings on the command line,
1641
1642 • --output-charset for all strings written to the console or to a
1643 file if the output has been redirected with the --redirect-output
1644 option. On non-Windows systems the default for the output charset
1645 is the system's current charset. On Windows it defaults to UTF-8
1646 both for redirecting with --redirect-output and with cmd.exe
1647 itself, e.g. mkvinfo file.mkv > info.txt.
1648
1650 An option file is a file mkvmerge(1) can read additional command line
1651 arguments from. This can be used in order to circumvent certain
1652 limitations of the shell or the operating system when executing
1653 external programs like a limited command line length.
1654
1655 An option file contains JSON-formatted data. Its content must be a
1656 valid JSON array consisting solely of JSON strings. The file's encoding
1657 must be UTF-8. The file should not start with a byte order marker
1658 (BOM), but if one exists, it will be skipped.
1659
1660 The rules for escaping special characters inside JSON are the ones in
1661 the official JSON specification, RFC 7159[4].
1662
1663 The command line 'mkvmerge -o "my file.mkv" -A "a movie.avi" sound.ogg'
1664 could be converted into the following JSON option file called e.g.
1665 'options.json':
1666
1667 [
1668 "-o",
1669 "c:\\Matroska\\my file.mkv",
1670 "--title",
1671 "#65",
1672 "-A",
1673 "a movie.avi",
1674 "sound.ogg"
1675 ]
1676
1678 Matroska(TM) supports file linking which simply says that a specific
1679 file is the predecessor or successor of the current file. To be
1680 precise, it's not really the files that are linked but the Matroska(TM)
1681 segments. As most files will probably only contain one Matroska(TM)
1682 segment the following explanations use the term 'file linking' although
1683 'segment linking' would be more appropriate.
1684
1685 Each segment is identified by a unique 128 bit wide segment UID. This
1686 UID is automatically generated by mkvmerge(1). The linking is done
1687 primarily via putting the segment UIDs (short: SID) of the
1688 previous/next file into the segment header information. mkvinfo(1)
1689 prints these SIDs if it finds them.
1690
1691 If a file is split into several smaller ones and linking is used then
1692 the timestamps will not start at 0 again but will continue where the
1693 last file has left off. This way the absolute time is kept even if the
1694 previous files are not available (e.g. when streaming). If no linking
1695 is used then the timestamps should start at 0 for each file. By default
1696 mkvmerge(1) does not use file linking. If you want that you can turn it
1697 on with the --link option. This option is only useful if splitting is
1698 activated as well.
1699
1700 Regardless of whether splitting is active or not the user can tell
1701 mkvmerge(1) to link the produced files to specific SIDs. This is
1702 achieved with the options --link-to-previous and --link-to-next. These
1703 options accept a segment SID in the format that mkvinfo(1) outputs: 16
1704 hexadecimal numbers between 0x00 and 0xff prefixed with '0x' each, e.g.
1705 '0x41 0xda 0x73 0x66 0xd9 0xcf 0xb2 0x1e 0xae 0x78 0xeb 0xb4 0x5e 0xca
1706 0xb3 0x93'. Alternatively a shorter form can be used: 16 hexadecimal
1707 numbers between 0x00 and 0xff without the '0x' prefixes and without the
1708 spaces, e.g. '41da7366d9cfb21eae78ebb45ecab393'.
1709
1710 If splitting is used then the first file is linked to the SID given
1711 with --link-to-previous and the last file is linked to the SID given
1712 with --link-to-next. If splitting is not used then the one output file
1713 will be linked to both of the two SIDs.
1714
1716 The Matroska(TM) specification states that some elements have a default
1717 value. Usually an element is not written to the file if its value is
1718 equal to its default value in order to save space. The elements that
1719 the user might miss in mkvinfo(1)'s output are the language and the
1720 default track flag elements. The default value for the language is
1721 English ('eng'), and the default value for the default track flag is
1722 true. Therefore if you used --language 0:eng for a track then it will
1723 not show up in mkvinfo(1)'s output.
1724
1726 Maybe you also want to keep some photos along with your Matroska(TM)
1727 file, or you're using SSA subtitles and need a special TrueType(TM)
1728 font that's really rare. In these cases you can attach those files to
1729 the Matroska(TM) file. They will not be just appended to the file but
1730 embedded in it. A player can then show those files (the 'photos' case)
1731 or use them to render the subtitles (the 'TrueType(TM) fonts' case).
1732
1733 Here's an example how to attach a photo and a TrueType(TM) font to the
1734 output file:
1735
1736 $ mkvmerge -o output.mkv -A video.avi sound.ogg \
1737 --attachment-description "Me and the band behind the stage in a small get-together" \
1738 --attachment-mime-type image/jpeg \
1739 --attach-file me_and_the_band.jpg \
1740 --attachment-description "The real rare and unbelievably good looking font" \
1741 --attachment-mime-type application/octet-stream \
1742 --attach-file really_cool_font.ttf
1743
1744 If a Matroska(TM) containing attachments file is used as an input file
1745 then mkvmerge(1) will copy the attachments into the new file. The
1746 selection which attachments are copied and which are not can be changed
1747 with the options --attachments and --no-attachments.
1748
1750 The Matroska(TM) chapter system is more powerful than the old known
1751 system used by OGM files. The full specifications can be found at the
1752 Matroska(TM) website[1].
1753
1754 mkvmerge(1) supports two kinds of chapter files as its input. The first
1755 format, called 'simple chapter format', is the same format that the OGM
1756 tools expect. The second format is a XML based chapter format which
1757 supports all of Matroska(TM)'s chapter functionality.
1758
1759 Apart from dedicated chapter files mkvmerge(1) can also read chapters
1760 from other file formats (e.g. MP4, Ogg, Blu-rays or DVDs).
1761
1762 The simple chapter format
1763 This format consists of pairs of lines that start with 'CHAPTERxx=' and
1764 'CHAPTERxxNAME=' respectively. The first one contains the start
1765 timestamp while the second one contains the title. Here's an example:
1766
1767 CHAPTER01=00:00:00.000
1768 CHAPTER01NAME=Intro
1769 CHAPTER02=00:02:30.000
1770 CHAPTER02NAME=Baby prepares to rock
1771 CHAPTER03=00:02:42.300
1772 CHAPTER03NAME=Baby rocks the house
1773
1774 mkvmerge(1) will transform every pair or lines into one Matroska(TM)
1775 ChapterAtom. It does not set any ChapterTrackNumber which means that
1776 the chapters all apply to all tracks in the file.
1777
1778 As this is a text file character set conversion may need to be done.
1779 See the section about text files and character sets for an explanation
1780 how mkvmerge(1) converts between character sets.
1781
1782 The XML based chapter format
1783 The XML based chapter format looks like this example:
1784
1785 <?xml version="1.0" encoding="ISO-8859-1"?>
1786 <!DOCTYPE Chapters SYSTEM "matroskachapters.dtd">
1787 <Chapters>
1788 <EditionEntry>
1789 <ChapterAtom>
1790 <ChapterTimeStart>00:00:30.000</ChapterTimeStart>
1791 <ChapterTimeEnd>00:01:20.000</ChapterTimeEnd>
1792 <ChapterDisplay>
1793 <ChapterString>A short chapter</ChapterString>
1794 <ChapterLanguage>eng</ChapterLanguage>
1795 </ChapterDisplay>
1796 <ChapterAtom>
1797 <ChapterTimeStart>00:00:46.000</ChapterTimeStart>
1798 <ChapterTimeEnd>00:01:10.000</ChapterTimeEnd>
1799 <ChapterDisplay>
1800 <ChapterString>A part of that short chapter</ChapterString>
1801 <ChapterLanguage>eng</ChapterLanguage>
1802 </ChapterDisplay>
1803 </ChapterAtom>
1804 </ChapterAtom>
1805 </EditionEntry>
1806 </Chapters>
1807
1808 With this format three things are possible that are not possible with
1809 the simple chapter format:
1810
1811 1. The timestamp for the end of the chapter can be set,
1812
1813 2. chapters can be nested,
1814
1815 3. the language and country can be set.
1816
1817 The mkvtoolnix distribution contains some sample files in the doc
1818 subdirectory which can be used as a basis.
1819
1820 The following lists the supported XML tags, their data types and, where
1821 appropriate, the valid range for their values:
1822
1823 Chapters (master)
1824 EditionEntry (master)
1825 EditionUID (unsigned integer, valid range: 1 <= value)
1826 EditionFlagHidden (unsigned integer, valid range: 0 <= value <= 1)
1827 EditionFlagDefault (unsigned integer, valid range: 0 <= value <= 1)
1828 EditionFlagOrdered (unsigned integer, valid range: 0 <= value <= 1)
1829 ChapterAtom (master)
1830 ChapterAtom (master)
1831 ChapterUID (unsigned integer, valid range: 1 <= value)
1832 ChapterTimeStart (unsigned integer)
1833 ChapterTimeEnd (unsigned integer)
1834 ChapterFlagHidden (unsigned integer, valid range: 0 <= value <= 1)
1835 ChapterFlagEnabled (unsigned integer, valid range: 0 <= value <= 1)
1836 ChapterSegmentUID (binary, valid range: 1 <= length in bytes)
1837 ChapterSegmentEditionUID (unsigned integer, valid range: 1 <= value)
1838 ChapterPhysicalEquiv (unsigned integer)
1839 ChapterTrack (master)
1840 ChapterTrackNumber (unsigned integer, valid range: 1 <= value)
1841 ChapterDisplay (master)
1842 ChapterString (UTF-8 string)
1843 ChapterLanguage (UTF-8 string)
1844 ChapterCountry (UTF-8 string)
1845 ChapterProcess (master)
1846 ChapterProcessCodecID (unsigned integer)
1847 ChapterProcessPrivate (binary)
1848 ChapterProcessCommand (master)
1849 ChapterProcessTime (unsigned integer)
1850 ChapterProcessData (binary)
1851
1852 Reading chapters from Blu-rays
1853 mkvmerge(1) can read chapters from unencrypted Blu-rays. For that you
1854 can use the path to one of the MPLS play lists with the --chapters
1855 parameter.
1856
1857 Example: --chapters /srv/blurays/BigBuckBunny/BDMV/PLAYLIST/00001.mpls
1858
1859 Reading chapters from DVDs
1860 When MKVToolNix is compiled with the libdvdread(TM) library,
1861 mkvmerge(1) can read chapters from DVDs. For that you can use the path
1862 to one of the folders or files on the DVD with the --chapters
1863 parameter. As DVDs can contain more than one title and each title has
1864 its own set of chapters, you can append a colon and the desired title
1865 number to the end of the file name argument. The title number defaults
1866 to 1.
1867
1868 Example: --chapters /srv/dvds/BigBuckBunny/VIDEO_TS:2
1869
1870 General notes
1871 When splitting files mkvmerge(1) will correctly adjust the chapters as
1872 well. This means that each file only includes the chapter entries that
1873 apply to it, and that the timestamps will be offset to match the new
1874 timestamps of each output file.
1875
1876 mkvmerge(1) is able to copy chapters from Matroska(TM) source files
1877 unless this is explicitly disabled with the --no-chapters option. The
1878 chapters from all sources (Matroska(TM) files, Ogg files, MP4 files,
1879 chapter text files) are usually not merged but end up in separate
1880 ChapterEditions. Only if chapters are read from several Matroska(TM) or
1881 XML files that share the same edition UIDs will chapters be merged into
1882 a single ChapterEdition. If such a merge is desired in other situations
1883 as well then the user has to extract the chapters from all sources with
1884 mkvextract(1) first, merge the XML files manually and mux them
1885 afterwards.
1886
1888 Introduction
1889 Matroska(TM)'s tag system is similar to that of other containers: a set
1890 of KEY=VALUE pairs. However, in Matroska(TM) these tags can also be
1891 nested, and both the KEY and the VALUE are elements of their own. The
1892 example file example-tags-2.xml shows how to use this system.
1893
1894 Scope of the tags
1895 Matroska(TM) tags do not automatically apply to the complete file. They
1896 can, but they also may apply to different parts of the file: to one or
1897 more tracks, to one or more chapters, or even to a combination of both.
1898 The Matroska(TM) specification[5] gives more details about this fact.
1899
1900 One important fact is that tags are linked to tracks or chapters with
1901 the Targets Matroska(TM) tag element, and that the UIDs used for this
1902 linking are not the track IDs mkvmerge(1) uses everywhere. Instead the
1903 numbers used are the UIDs which mkvmerge(1) calculates automatically
1904 (if the track is taken from a file format other than Matroska(TM)) or
1905 which are copied from the source file if the track's source file is a
1906 Matroska(TM) file. Therefore it is difficult to know which UIDs to use
1907 in the tag file before the file is handed over to mkvmerge(1).
1908
1909 mkvmerge(1) knows two options with which you can add tags to
1910 Matroska(TM) files: The --global-tags and the --tags options. The
1911 difference is that the former option, --global-tags, will make the tags
1912 apply to the complete file by removing any of those Targets elements
1913 mentioned above. The latter option, --tags, automatically inserts the
1914 UID that mkvmerge(1) generates for the tag specified with the TID part
1915 of the --tags option.
1916
1917 Example
1918 Let's say that you want to add tags to a video track read from an AVI.
1919 mkvmerge --identify file.avi tells you that the video track's ID (do
1920 not mix this ID with the UID!) is 0. So you create your tag file, leave
1921 out all Targets elements and call mkvmerge(1):
1922
1923 $ mkvmerge -o file.mkv --tags 0:tags.xml file.avi
1924
1925 Tag file format
1926 mkvmerge(1) supports a XML based tag file format. The format is very
1927 closely modeled after the Matroska(TM) specification[5]. Both the
1928 binary and the source distributions of MKVToolNix come with a sample
1929 file called example-tags-2.xml which simply lists all known tags and
1930 which can be used as a basis for real life tag files.
1931
1932 The basics are:
1933
1934 • The outermost element must be <Tags>.
1935
1936 • One logical tag is contained inside one pair of <Tag> XML tags.
1937
1938 • White spaces directly before and after tag contents are ignored.
1939
1940 Data types
1941 The new Matroska(TM) tagging system only knows two data types, a UTF-8
1942 string and a binary type. The first is used for the tag's name and the
1943 <String> element while the binary type is used for the <Binary>
1944 element.
1945
1946 As binary data itself would not fit into a XML file mkvmerge(1)
1947 supports two other methods of storing binary data. If the contents of a
1948 XML tag starts with '@' then the following text is treated as a file
1949 name. The corresponding file's content is copied into the Matroska(TM)
1950 element.
1951
1952 Otherwise the data is expected to be Base64 encoded. This is an
1953 encoding that transforms binary data into a limited set of ASCII
1954 characters and is used e.g. in email programs. mkvextract(1) will
1955 output Base64 encoded data for binary elements.
1956
1957 The deprecated tagging system knows some more data types which can be
1958 found in the official Matroska(TM) tag specs. As mkvmerge(1) does not
1959 support this system anymore these types aren't described here.
1960
1961 Known tags for the XML file format
1962 The following lists the supported XML tags, their data types and, where
1963 appropriate, the valid range for their values:
1964
1965 Tags (master)
1966 Tag (master)
1967 Targets (master)
1968 TargetTypeValue (unsigned integer)
1969 TargetType (UTF-8 string)
1970 TrackUID (unsigned integer)
1971 EditionUID (unsigned integer)
1972 ChapterUID (unsigned integer)
1973 AttachmentUID (unsigned integer)
1974 Simple (master)
1975 Simple (master)
1976 Name (UTF-8 string)
1977 TagLanguage (UTF-8 string)
1978 DefaultLanguage (unsigned integer)
1979 String (UTF-8 string)
1980 Binary (binary)
1981
1983 With a segment info XML file it is possible to set certain values in
1984 the "segment information" header field of a Matroska(TM) file. All of
1985 these values cannot be set via other command line options.
1986
1987 Other "segment information" header fields can be set via command line
1988 options but not via the XML file. This includes e.g. the --title and
1989 the --timestamp-scale options.
1990
1991 There are other elements that can be set neither via command line
1992 options nor via the XML files. These include the following elements:
1993 DateUTC (also known as the "muxing date"), MuxingApp, WritingApp and
1994 Duration. They're always set by mkvmerge(1) itself.
1995
1996 The following lists the supported XML tags, their data types and, where
1997 appropriate, the valid range for their values:
1998
1999 Info (master)
2000 SegmentUID (binary, valid range: length in bytes == 16)
2001 SegmentFilename (UTF-8 string)
2002 PreviousSegmentUID (binary, valid range: length in bytes == 16)
2003 PreviousSegmentFilename (UTF-8 string)
2004 NextSegmentUID (binary, valid range: length in bytes == 16)
2005 NextSegmentFilename (UTF-8 string)
2006 SegmentFamily (binary, valid range: length in bytes == 16)
2007 ChapterTranslate (master)
2008 ChapterTranslateEditionUID (unsigned integer)
2009 ChapterTranslateCodec (unsigned integer)
2010 ChapterTranslateID (binary)
2011
2013 The Matroska(TM) file layout is quite flexible. mkvmerge(1) will
2014 render a file in a predefined way. The resulting file looks like this:
2015
2016 [EBML head] [segment {meta seek #1} [segment information] [track
2017 information] {attachments} {chapters} [cluster 1] {cluster 2} ...
2018 {cluster n} {cues} {meta seek #2} {tags}]
2019
2020 The elements in curly braces are optional and depend on the contents
2021 and options used. A couple of notes:
2022
2023 • meta seek #1 includes only a small number of level 1 elements, and
2024 only if they actually exist: attachments, chapters, cues, tags,
2025 meta seek #2. Older versions of mkvmerge(1) used to put the
2026 clusters into this meta seek element as well. Therefore some
2027 imprecise guessing was necessary to reserve enough space. It often
2028 failed. Now only the clusters are stored in meta seek #2, and meta
2029 seek #1 refers to the meta seek element #2.
2030
2031 • Attachment, chapter and tag elements are only present if they were
2032 added.
2033
2034 The shortest possible Matroska(TM) file would look like this:
2035
2036 [EBML head] [segment [segment information] [track information] [cluster
2037 1]]
2038
2039 This might be the case for audio-only files.
2040
2042 mkvmerge(1) allows the user to chose the timestamps for a specific
2043 track himself. This can be used in order to create files with variable
2044 frame rate video or include gaps in audio. A frame in this case is the
2045 unit that mkvmerge(1) creates separately per Matroska(TM) block. For
2046 video this is exactly one frame, for audio this is one packet of the
2047 specific audio type. E.g. for AC-3 this would be a packet containing
2048 1536 samples.
2049
2050 Timestamp files that are used when tracks are appended to each other
2051 must only be specified for the first part in a chain of tracks. For
2052 example if you append two files, v1.avi and v2.avi, and want to use
2053 timestamps then your command line must look something like this:
2054
2055 $ mkvmerge ... --timestamps 0:my_timestamps.txt v1.avi +v2.avi
2056
2057 There are four formats that are recognized by mkvmerge(1). The first
2058 line always contains the version number. Empty lines, lines containing
2059 only whitespace and lines beginning with '#' are ignored.
2060
2061 Timestamp file format v1
2062 This format starts with the version line. The second line declares the
2063 default number of frames per second. All following lines contain three
2064 numbers separated by commas: the start frame (0 is the first frame),
2065 the end frame and the number of frames in this range. The FPS is a
2066 floating point number with the dot '.' as the decimal point. The ranges
2067 can contain gaps for which the default FPS is used. An example:
2068
2069 # timestamp format v1
2070 assume 27.930
2071 800,1000,25
2072 1500,1700,30
2073
2074 Timestamp file format v2
2075 In this format each line contains a timestamp for the corresponding
2076 frame. This timestamp must be given in millisecond precision. It can be
2077 a floating point number, but it doesn't have to be. You have to give at
2078 least as many timestamp lines as there are frames in the track. The
2079 timestamps in this file must be sorted. Example for 25fps:
2080
2081 # timestamp format v2
2082 0
2083 40
2084 80
2085
2086 Timestamp file format v3
2087 In this format each line contains a duration in seconds followed by an
2088 optional number of frames per second. Both can be floating point
2089 numbers. If the number of frames per second is not present the default
2090 one is used. For audio you should let the codec calculate the frame
2091 timestamps itself. For that you should be using 0.0 as the number of
2092 frames per second. You can also create gaps in the stream by using the
2093 'gap' keyword followed by the duration of the gap. Example for an audio
2094 file:
2095
2096 # timestamp format v3
2097 assume 0.0
2098 25.325
2099 7.530,38.236
2100 gap, 10.050
2101 2.000,38.236
2102
2103 Timestamp file format v4
2104 This format is identical to the v2 format. The only difference is that
2105 the timestamps do not have to be sorted. This format should almost
2106 never be used.
2107
2109 mkvmerge(1) exits with one of three exit codes:
2110
2111 • 0 -- This exit code means that muxing has completed successfully.
2112
2113 • 1 -- In this case mkvmerge(1) has output at least one warning, but
2114 muxing did continue. A warning is prefixed with the text
2115 'Warning:'. Depending on the issues involved the resulting file
2116 might be ok or not. The user is urged to check both the warning and
2117 the resulting file.
2118
2119 • 2 -- This exit code is used after an error occurred. mkvmerge(1)
2120 aborts right after outputting the error message. Error messages
2121 range from wrong command line arguments over read/write errors to
2122 broken files.
2123
2125 mkvmerge(1) uses the default variables that determine the system's
2126 locale (e.g. LANG and the LC_* family). Additional variables:
2127
2128 MKVMERGE_DEBUG, MKVTOOLNIX_DEBUG and its short form MTX_DEBUG
2129 The content is treated as if it had been passed via the --debug
2130 option.
2131
2132 MKVMERGE_ENGAGE, MKVTOOLNIX_ENGAGE and its short form MTX_ENGAGE
2133 The content is treated as if it had been passed via the --engage
2134 option.
2135
2137 mkvinfo(1), mkvextract(1), mkvpropedit(1), mkvtoolnix-gui(1)
2138
2140 The latest version can always be found at the MKVToolNix homepage[6].
2141
2143 Moritz Bunkus <moritz@bunkus.org>
2144 Developer
2145
2147 1. the Matroska(TM) website
2148 https://www.matroska.org/
2149
2150 2. the IANA homepage
2151 https://www.iana.org/assignments/media-types/
2152
2153 3. mkvmerge-identification-output-schema-v14.json
2154 https://mkvtoolnix.download/doc/mkvmerge-identification-output-schema-v14.json
2155
2156 4. RFC 7159
2157 https://tools.ietf.org/html/rfc7159
2158
2159 5. Matroska(TM) specification
2160 https://www.matroska.org/technical/specs/index.html
2161
2162 6. the MKVToolNix homepage
2163 https://mkvtoolnix.download/
2164
2165
2166
2167MKVToolNix 63.0.0 2021-11-14 MKVMERGE(1)