1MKVMERGE(1)                      User Commands                     MKVMERGE(1)
2
3
4

NAME

6       mkvmerge - Merge multimedia streams into a Matroska(TM) file
7

SYNOPSIS

9       mkvmerge [global options] {-o out} [options1] {file1}
10                [[options2] {file2}] [@options-file.json]
11

DESCRIPTION

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 a XML file. This file can contain the
56           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 ISO639-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                   Note
121                   mkvmerge(1) requires a video or an audio track to be
122                   present in order to be able to determine when a new file is
123                   appended. If one or more video tracks are muxed the first
124                   one is used. Otherwise the first audio track is used.
125
126           ·   'interval:time-spec' – This mode creates one chapter at fixed
127               intervals given by time-spec. The format is either the form
128               HH:MM:SS.nnnnnnnnn or a number followed by one of the units
129               's', 'ms' or 'us'.
130
131               Example: --generate-chapters interval:45s
132
133           The names for the new chapters are controlled by the option
134           --generate-chapters-name-template. The language is set with
135           --chapter-language which must occur before --generate-chapters.
136
137       --generate-chapters-name-template template
138           This sets the name template for chapter names generated by the
139           option --generate-chapters. If the option is not used then default
140           'Chapter <NUM:2>' will be used.
141
142           There are several variables that can be used in the template that
143           are replaced by their actual values when a chapter is generated.
144           The string '<NUM>' will be replaced by the chapter number. The
145           string '<START>' will be replaced by the chapter's start timestamp.
146
147           The strings '<FILE_NAME>' and '<FILE_NAME_WITH_EXT>' are only
148           filled when generating chapters for appended files. They will be
149           replaced by the appended file's name wihtout respectively with its
150           extension. Note that only the file's base name and extension are
151           inserted, not its directory or drive components.
152
153           You can specify a minimum number of places for the chapter number
154           with '<NUM:places>', e.g. '<NUM:3>'. The resulting number will be
155           padded with leading zeroes if the number of places is less than
156           specified.
157
158           You can control the format used by the start timestamp with
159           <START:format>. The format defaults to '%H:%M:%S' if none is given.
160           Valid format codes are:
161
162           ·   %h – hours
163
164           ·   %H – hours zero-padded to two places
165
166           ·   %m – minutes
167
168           ·   %M – minutes zero-padded to two places
169
170           ·   %s – seconds
171
172           ·   %S – seconds zero-padded to two places
173
174           ·   %n – nanoseconds with nine places
175
176           ·   %<1-9>n – nanoseconds with up to nine places (e.g. three places
177               with %3n)
178
179       --cue-chapter-name-format format
180           mkvmerge(1) supports reading CUE sheets for audio files as the
181           input for chapters.  CUE sheets usually contain the entries
182           PERFORMER and TITLE for each index entry.  mkvmerge(1) uses these
183           two strings in order to construct the chapter name. With this
184           option the format used for this name can be set.
185
186           If this option is not given then mkvmerge(1) defaults to the format
187           '%p - %t' (the performer, followed by a space, a dash, another
188           space and the title).
189
190           If the format is given then everything except the following meta
191           characters is copied as-is, and the meta characters are replaced
192           like this:
193
194           ·   %p is replaced by the current entry's PERFORMER string,
195
196           ·   %t is replaced by the current entry's TITLE string,
197
198           ·   %n is replaced by the current track number and
199
200           ·   %N is replaced by the current track number padded with a
201               leading zero if it is < 10.
202
203       --chapters file-name
204           Read chapter information from the file file-name. See the section
205           about chapters below for details.
206
207       --global-tags file-name
208           Read global tags from the file file-name. See the section about
209           tags below for details.
210
211   General output control (advanced global options)
212       --track-order FID1:TID1,FID2:TID2,...
213           This option changes the order in which the tracks for an input file
214           are created. The argument is a comma separated list of pairs IDs.
215           Each pair contains first the file ID (FID1) which is simply the
216           number of the file on the command line starting at 0. The second is
217           a track ID (TID1) from that file. If some track IDs are omitted
218           then those tracks are created after the ones given with this option
219           have been created.
220
221       --cluster-length spec
222           Limit the number of data blocks or the duration of data in each
223           cluster. The spec parameter can either be a number n without a unit
224           or a number d postfixed with 'ms'.
225
226           If no unit is used then mkvmerge(1) will put at most n data blocks
227           into each cluster. The maximum number of blocks is 65535.
228
229           If the number d is postfixed with 'ms' then mkvmerge(1) puts at
230           most d milliseconds of data into each cluster. The minimum for d is
231           '100ms', and the maximum is '32000ms'.
232
233           mkvmerge(1) defaults to putting at most 65535 data blocks and
234           5000ms of data into a cluster.
235
236           Programs trying to find a certain frame can only seek directly to a
237           cluster and have to read the whole cluster afterwards. Therefore
238           creating larger clusters may lead to imprecise or slow seeking.
239
240       --no-cues
241           Tells mkvmerge(1) not to create and write the cue data which can be
242           compared to an index in an AVI.  Matroska(TM) files can be played
243           back without the cue data, but seeking will probably be imprecise
244           and slower. Use this only if you're really desperate for space or
245           for testing purposes. See also option --cues which can be specified
246           for each input file.
247
248       --clusters-in-meta-seek
249           Tells mkvmerge(1) to create a meta seek element at the end of the
250           file containing all clusters. See also the section about the
251           Matroska(TM) file layout.
252
253       --disable-lacing
254           Disables lacing for all tracks. This will increase the file's size,
255           especially if there are many audio tracks. This option is not
256           intended for everyday use.
257
258       --enable-durations
259           Write durations for all blocks. This will increase file size and
260           does not offer any additional value for players at the moment.
261
262       --disable-track-statistics-tags
263           Normally mkvmerge(1) will write certain tags with statistics for
264           each track. If such tags are already present then they will be
265           overwritten. The tags are BPS, DURATION, NUMBER_OF_BYTES and
266           NUMBER_OF_FRAMES.
267
268           Enabling this option prevents mkvmerge(1) from writing those tags
269           and from touching any existing tags with same names.
270
271       --timestamp-scale factor
272           Forces the timestamp scale factor to factor. Valid values are in
273           the range 1000..10000000 or the special value -1.
274
275           Normally mkvmerge(1) will use a value of 1000000 which means that
276           timestamps and durations will have a precision of 1ms. For files
277           that will not contain a video track but at least one audio track
278           mkvmerge(1) will automatically chose a timestamp scale factor so
279           that all timestamps and durations have a precision of one audio
280           sample. This causes bigger overhead but allows precise seeking and
281           extraction.
282
283           If the special value -1 is used then mkvmerge(1) will use sample
284           precision even if a video track is present.
285
286   File splitting, linking, appending and concatenation (more global options)
287       --split specification
288           Splits the output file after a given size or a given time. Please
289           note that tracks can only be split right before a key frame.
290           Therefore the split point may be a bit off from what the user has
291           specified.
292
293           At the moment mkvmerge(1) supports four different modes.
294
295            1. Splitting by size.
296
297               Syntax: --split [size:]d[k|m|g]
298
299               Examples: --split size:700m or --split 150000000
300
301               The parameter d may end with 'k', 'm' or 'g' to indicate that
302               the size is in KB, MB or GB respectively. Otherwise a size in
303               bytes is assumed. After the current output file has reached
304               this size limit a new one will be started.
305
306               The 'size:' prefix may be omitted for compatibility reasons.
307
308            2. Splitting after a duration.
309
310               Syntax: --split [duration:]HH:MM:SS.nnnnnnnnn|ds
311
312               Examples: --split duration:00:60:00.000 or --split 3600s
313
314               The parameter must either have the form HH:MM:SS.nnnnnnnnn for
315               specifying the duration in up to nano-second precision or be a
316               number d followed by the letter 's' for the duration in
317               seconds.  HH is the number of hours, MM the number of minutes,
318               SS the number of seconds and nnnnnnnnn the number of
319               nanoseconds. Both the number of hours and the number of
320               nanoseconds can be omitted. There can be up to nine digits
321               after the decimal point. After the duration of the contents in
322               the current output has reached this limit a new output file
323               will be started.
324
325               The 'duration:' prefix may be omitted for compatibility
326               reasons.
327
328            3. Splitting after specific timestamps.
329
330               Syntax: --split timestamps:A[,B[,C...]]
331
332               Example: --split timestamps:00:45:00.000,01:20:00.250,6300s
333
334               The parameters A, B, C etc must all have the same format as the
335               ones used for the duration (see above). The list of timestamps
336               is separated by commas. After the input stream has reached the
337               current split point's timestamp a new file is created. Then the
338               next split point given in this list is used.
339
340               The 'timestamps:' prefix must not be omitted.
341
342            4. Keeping specific parts by specifying timestamp ranges while
343               discarding others.
344
345               Syntax: --split
346               parts:start1-end1[,[+]start2-end2[,[+]start3-end3...]]
347
348               Examples:
349
350                1. --split parts:00:01:20-00:02:45,00:05:50-00:10:30
351
352                2. --split parts:00:01:20-00:02:45,+00:05:50-00:10:30
353
354                3. --split parts:-00:02:45,00:05:50-
355
356               The parts mode tells mkvmerge(1) to keep certain ranges of
357               timestamps while discarding others. The ranges to keep have to
358               be listed after the parts: keyword and be separated by commas.
359               A range itself consists of a start and an end timestamp in the
360               same format the other variations of --split accept (e.g. both
361               00:01:20 and 80s refer to the same timestamp).
362
363               If a start timestamp is left out then it defaults to the
364               previous range's end timestamp. If there was no previous range
365               then it defaults to the start of the file (see example 3).
366
367               If an end timestamp is left out then it defaults to the end of
368               the source files which basically tells mkvmerge(1) to keep the
369               rest (see example 3).
370
371               Normally each range will be written to a new file. This can be
372               changed so that consecutive ranges are written to the same
373               file. For that the user has to prefix the start timestamp with
374               a +. This tells mkvmerge(1) not to create a new file and
375               instead append the range to the same file the previous range
376               was written to. Timestamps will be adjusted so that there will
377               be no gap in the output file even if there was a gap in the two
378               ranges in the input file.
379
380               In example 1 mkvmerge(1) will create two files. The first will
381               contain the content starting from 00:01:20 until 00:02:45. The
382               second file will contain the content starting from 00:05:50
383               until 00:10:30.
384
385               In example 2 mkvmerge(1) will create only one file. This file
386               will contain both the content starting from 00:01:20 until
387               00:02:45 and the content starting from 00:05:50 until 00:10:30.
388
389               In example 3 mkvmerge(1) will create two files. The first will
390               contain the content from the start of the source files until
391               00:02:45. The second file will contain the content starting
392               from 00:05:50 until the end of the source files.
393
394                   Note
395                   Note that mkvmerge(1) only makes decisions about splitting
396                   at key frame positions. This applies to both the start and
397                   the end of each range. So even if an end timestamp is
398                   between two key frames mkvmerge(1) will continue outputting
399                   the frames up to but excluding the following key frame.
400
401            5. Keeping specific parts by specifying frame/field number ranges
402               while discarding others.
403
404               Syntax: --split
405               parts-frames:start1-end1[,[+]start2-end2[,[+]start3-end3...]]
406
407               Examples:
408
409                1. --split parts-frames:137-258,548-1211
410
411                2. --split parts-frames:733-912,+1592-2730
412
413                3. --split parts-frames:-430,2512-
414
415               The parts-frames mode tells mkvmerge(1) to keep certain ranges
416               of frame/field numbers while discarding others. The ranges to
417               keep have to be listed after the parts-frames: keyword and be
418               separated by commas. A range itself consists of a start and an
419               end frame/field number. Numbering starts at 1.
420
421               If a start number is left out then it defaults to the previous
422               range's end number. If there was no previous range then it
423               defaults to the start of the file (see example 3).
424
425               If an end number is left out then it defaults to the end of the
426               source files which basically tells mkvmerge(1) to keep the rest
427               (see example 3).
428
429               Normally each range will be written to a new file. This can be
430               changed so that consecutive ranges are written to the same
431               file. For that the user has to prefix the start number with a
432               +. This tells mkvmerge(1) not to create a new file and instead
433               append the range to the same file the previous range was
434               written to. Timestamps will be adjusted so that there will be
435               no gap in the output file even if there was a gap in the two
436               ranges in the input file.
437
438                   Note
439                   Note that mkvmerge(1) only makes decisions about splitting
440                   at key frame positions. This applies to both the start and
441                   the end of each range. So even if an end frame/field number
442                   is between two key frames mkvmerge(1) will continue
443                   outputting the frames up to but excluding the following key
444                   frame.
445               In example 1 mkvmerge(1) will create two files. The first will
446               contain the content starting from the first key frame at or
447               after 137 up to but excluding the first key frame at or after
448               258. The second file will contain the content starting from 548
449               until 1211.
450
451               In example 2 mkvmerge(1) will create only one file. This file
452               will contain both the content starting from 733 until 912 and
453               the content starting from 1592 until 2730.
454
455               In example 3 mkvmerge(1) will create two files. The first will
456               contain the content from the start of the source files until
457               430. The second file will contain the content starting from
458               2512 until the end of the source files.
459
460               This mode considers only the first video track that is output.
461               If no video track is output no splitting will occur.
462
463                   Note
464                   The numbers given with this argument are interpreted based
465                   on the number of Matroska(TM) blocks that are output. A
466                   single Matroska(TM) block contains either a full frame (for
467                   progressive content) or a single field (for interlaced
468                   content). mkvmerge does not distinguish between those two
469                   and simply counts the number of blocks. For example: If one
470                   wanted to split after the 25th full frame with interlaced
471                   content one would have to use 50 (two fields per full
472                   frame) as the split point.
473
474            6. Splitting after specific frames/fields.
475
476               Syntax: --split frames:A[,B[,C...]]
477
478               Example: --split frames:120,237,891
479
480               The parameters A, B, C etc must all be positive integers.
481               Numbering starts at 1. The list of frame/field numbers is
482               separated by commas. After the input stream has reached the
483               current split point's frame/field number a new file is created.
484               Then the next split point given in this list is used.
485
486               The 'frames:' prefix must not be omitted.
487
488               This mode considers only the first video track that is output.
489               If no video track is output no splitting will occur.
490
491                   Note
492                   The numbers given with this argument are interpreted based
493                   on the number of Matroska(TM) blocks that are output. A
494                   single Matroska(TM) block contains either a full frame (for
495                   progressive content) or a single field (for interlaced
496                   content). mkvmerge does not distinguish between those two
497                   and simply counts the number of blocks. For example: If one
498                   wanted to split after the 25th full frame with interlaced
499                   content one would have to use 50 (two fields per full
500                   frame) as the split point.
501
502            7. Splitting before specific chapters.
503
504               Syntax: --split chapters:all or --split chapters:A[,B[,C...]]
505
506               Example: --split chapters:5,8
507
508               The parameters A, B, C etc must all be positive integers.
509               Numbering starts at 1. The list of chapter numbers is separated
510               by commas. Splitting will occur right before the first key
511               frame whose timestamp is equal to or bigger than the start
512               timestamp for the chapters whose numbers are listed. A chapter
513               starting at 0s is never considered for splitting and discarded
514               silently.
515
516               The keyword all can be used instead of listing all chapter
517               numbers manually.
518
519               The 'chapters:' prefix must not be omitted.
520
521                   Note
522                   The Matroska(TM) file format supports arbitrary deeply
523                   nested chapter structures called 'edition entries' and
524                   'chapter atoms'. However, this mode only considers the
525                   top-most level of chapters across all edition entries.
526
527           For this splitting mode the output filename is treated differently
528           than for the normal operation. It may contain a printf like
529           expression '%d' including an optional field width, e.g. '%02d'. If
530           it does then the current file number will be formatted
531           appropriately and inserted at that point in the filename. If there
532           is no such pattern then a pattern of '-%03d' is assumed right
533           before the file's extension: '-o output.mkv' would result in
534           'output-001.mkv' and so on. If there's no extension then '-%03d'
535           will be appended to the name.
536
537       --link
538           Link files to one another when splitting the output file. See the
539           section on file linking below for details.
540
541       --link-to-previous segment-UID
542           Links the first output file to the segment with the segment UID
543           given by the segment-UID parameter. See the section on file linking
544           below for details.
545
546           If SID starts with = then its rest is interpreted as the name of a
547           Matroska file whose segment UID is read and used.
548
549       --link-to-next segment-UID
550           Links the last output file to the segment with the segment UID
551           given by the segment-UID parameter. See the section on file linking
552           below for details.
553
554           If SID starts with = then its rest is interpreted as the name of a
555           Matroska file whose segment UID is read and used.
556
557       --append-mode mode
558           Determines how timestamps are calculated when appending files. The
559           parameter mode can have two values: 'file' which is also the
560           default and 'track'.
561
562           When mkvmerge appends a track (called 'track2_1' from now on) from
563           a second file (called 'file2') to a track (called 'track1_1') from
564           the first file (called 'file1') then it has to offset all
565           timestamps for 'track2_1' by an amount. For 'file' mode this amount
566           is the highest timestamp encountered in 'file1' even if that
567           timestamp was from a different track than 'track1_1'. In track mode
568           the offset is the highest timestamp of 'track1_1'.
569
570           Unfortunately mkvmerge cannot detect which mode to use reliably.
571           Therefore it defaults to 'file' mode. 'file' mode usually works
572           better for files that have been created independently of each
573           other; e.g. when appending AVI or MP4 files. 'track' mode may work
574           better for sources that are essentially just parts of one big file,
575           e.g. for VOB and EVO files.
576
577           Subtitle tracks are always treated as if 'file' mode were active
578           even if 'track' mode actually is.
579
580       --append-to SFID1:STID1:DFID1:DTID1[,...]
581           This option controls to which track another track is appended. Each
582           spec contains four IDs: a file ID, a track ID, a second file ID and
583           a second track ID. The first pair, "source file ID" and "source
584           track ID", identifies the track that is to be appended. The second
585           pair, "destination file ID" and "destination track ID", identifies
586           the track the first one is appended to.
587
588           If this option has been omitted then a standard mapping is used.
589           This standard mapping appends each track from the current file to a
590           track from the previous file with the same track ID. This allows
591           for easy appending if a movie has been split into two parts and
592           both file have the same number of tracks and track IDs with the
593           command mkvmerge -o output.mkv part1.mkv +part2.mkv.
594
595       +
596           A single '+' causes the next file to be appended instead of added.
597           The '+' can also be put in front of the next file name. Therefore
598           the following two commands are equivalent:
599
600               $ mkvmerge -o full.mkv file1.mkv + file2.mkv
601               $ mkvmerge -o full.mkv file1.mkv +file2.mkv
602
603       [ file1 file2 ]
604           If multiple file names are contained in a pair of square brackets
605           then the second and all following files will be appended to the
606           first file named within the brackets.
607
608           This is an alternative syntax to using '+' between the file names.
609           Therefore the following two commands are equivalent:
610
611               $ mkvmerge -o full.mkv file1.mkv + file2.mkv
612               $ mkvmerge -o full.mkv '[' file1.mkv file2.mkv ']'
613
614       =
615           Normally mkvmerge(1) looks for files in the same directory as an
616           input file that have the same base name and only differ in their
617           running number (e.g. 'VTS_01_1.VOB', 'VTS_01_2.VOB', 'VTS_01_3.VOB'
618           etc) and treats all of those files as if they were concatenated
619           into a single big file. This option, a single '=', causes mkvmerge
620           not to look for those additional files.
621
622           The '=' can also be put in front of the next file name. Therefore
623           the following two commands are equivalent:
624
625               $ mkvmerge -o full.mkv = file1.mkv
626               $ mkvmerge -o full.mkv =file1.mkv
627
628       ( file1 file2 )
629           If multiple file names are contained in a pair of parenthesis then
630           those files will be treated as if they were concatenated into a
631           single big file consisting of the content of each of the files one
632           after the other.
633
634           This can be used for e.g. VOB files coming from a DVD or MPEG
635           transport streams. It cannot be used if each file contains its own
636           set of headers which is usually the case with stand-alone files
637           like AVI or MP4.
638
639           Putting a file name into parenthesis also prevents mkvmerge(1) from
640           looking for additional files with the same base name as described
641           in option =. Therefore these two command lines are equivalent:
642
643               $ mkvmerge -o out.mkv = file.mkv
644               $ mkvmerge -o out.mkv '(' file.mkv ')'
645
646           Several things should be noted:
647
648            1. There must be spaces both after the opening and before the
649               closing parenthesis.
650
651            2. Every parameter between parenthesis is interpreted as a file
652               name. Therefore all options applying to this logical file must
653               be listed before the opening parenthesis.
654
655            3. Some shells treat parenthesis as special characters. Hence you
656               must escape or quote them as shown in the example above.
657
658   Attachment support (more global options)
659       --attachment-description description
660           Plain text description of the following attachment. Applies to the
661           next --attach-file or --attach-file-once option.
662
663       --attachment-mime-type MIME type
664           MIME type of the following attachment. Applies to the next
665           --attach-file or --attach-file-once option. A list of officially
666           recognized MIME types can be found e.g. at the IANA homepage[2].
667           The MIME type is mandatory for an attachment.
668
669       --attachment-name name
670           Sets the name that will be stored in the output file for this
671           attachment. If this option is not given then the name will be
672           derived from the file name of the attachment as given with the
673           --attach-file or the --attach-file-once option.
674
675       --attach-file file-name, --attach-file-once file-name
676           Creates a file attachment inside the Matroska(TM) file. The MIME
677           type must have been set before this option can used. The difference
678           between the two forms is that during splitting the files attached
679           with --attach-file are attached to all output files while the ones
680           attached with --attach-file-once are only attached to the first
681           file created. If splitting is not used then both do the same.
682
683           mkvextract(1) can be used to extract attached files from a
684           Matroska(TM) file.
685
686   Options that can be used for each input file
687       -a, --audio-tracks [!]n,m,...
688           Copy the audio tracks n, m etc. The numbers are track IDs which can
689           be obtained with the --identify switch. They're not simply the
690           track numbers (see section track IDs). Default: copy all audio
691           tracks.
692
693           Instead of track IDs you can also provide ISO 639-2 language codes.
694           This will only work for source files that provide language tags for
695           their tracks.
696
697           Default: copy all tracks of this kind.
698
699           If the IDs are prefixed with !  then the meaning is reversed: copy
700           all tracks of this kind but the ones listed after the !.
701
702       -d, --video-tracks [!]n,m,...
703           Copy the video tracks n, m etc. The numbers are track IDs which can
704           be obtained with the --identify switch. They're not simply the
705           track numbers (see section track IDs). Default: copy all video
706           tracks.
707
708           Instead of track IDs you can also provide ISO 639-2 language codes.
709           This will only work for source files that provide language tags for
710           their tracks.
711
712           If the IDs are prefixed with !  then the meaning is reversed: copy
713           all tracks of this kind but the ones listed after the !.
714
715       -s, --subtitle-tracks [!]n,m,...
716           Copy the subtitle tracks n, m etc. The numbers are track IDs which
717           can be obtained with the --identify switch. They're not simply the
718           track numbers (see section track IDs). Default: copy all subtitle
719           tracks.
720
721           Instead of track IDs you can also provide ISO 639-2 language codes.
722           This will only work for source files that provide language tags for
723           their tracks.
724
725           If the IDs are prefixed with !  then the meaning is reversed: copy
726           all tracks of this kind but the ones listed after the !.
727
728       -b, --button-tracks [!]n,m,...
729           Copy the button tracks n, m etc. The numbers are track IDs which
730           can be obtained with the --identify switch. They're not simply the
731           track numbers (see section track IDs). Default: copy all button
732           tracks.
733
734           Instead of track IDs you can also provide ISO 639-2 language codes.
735           This will only work for source files that provide language tags for
736           their tracks.
737
738           If the IDs are prefixed with !  then the meaning is reversed: copy
739           all tracks of this kind but the ones listed after the !.
740
741       --track-tags [!]n,m,...
742           Copy the tags for tracks n, m etc. The numbers are track IDs which
743           can be obtained with the --identify switch (see section track IDs).
744           They're not simply the track numbers. Default: copy tags for all
745           tracks.
746
747           If the IDs are prefixed with !  then the meaning is reversed: copy
748           everything but the IDs listed after the !.
749
750       -m, --attachments [!]n[:all|first],m[:all|first],...
751           Copy the attachments with the IDs n, m etc to all or only the first
752           output file. Each ID can be followed by either ':all' (which is the
753           default if neither is entered) or ':first'. If splitting is active
754           then those attachments whose IDs are specified with ':all' are
755           copied to all of the resulting output files while the others are
756           only copied into the first output file. If splitting is not active
757           then both variants have the same effect.
758
759           The default is to copy all attachments to all output files.
760
761           If the IDs are prefixed with !  then the meaning is reversed: copy
762           everything but the IDs listed after the !.
763
764       -A, --no-audio
765           Don't copy any audio track from this file.
766
767       -D, --no-video
768           Don't copy any video track from this file.
769
770       -S, --no-subtitles
771           Don't copy any subtitle track from this file.
772
773       -B, --no-buttons
774           Don't copy any button track from this file.
775
776       -T, --no-track-tags
777           Don't copy any track specific tags from this file.
778
779       --no-chapters
780           Don't copy chapters from this file.
781
782       -M, --no-attachments
783           Don't copy attachments from this file.
784
785       --no-global-tags
786           Don't copy global tags from this file.
787
788       --chapter-charset character-set
789           Sets the charset that is used for the conversion to UTF-8 for
790           chapter information contained in the source file. See the section
791           about text files and character sets for an explanation how
792           mkvmerge(1) converts between character sets.
793
794       --chapter-language language-code
795           Sets the ISO639-2 language code that is written for each chapter
796           entry. This option can be used for source files that contain
797           chapters but no information about the chapters' languages, e.g. for
798           MP4 and OGM files.
799
800       -y, --sync TID:d[,o[/p]]
801           Adjust the timestamps of the track with the id TID by d ms. The
802           track IDs are the same as the ones given with --identify (see
803           section track IDs).
804
805           o/p: adjust the timestamps by o/p to fix linear drifts.  p defaults
806           to 1 if omitted. Both o and p can be floating point numbers.
807
808           Defaults: no manual sync correction (which is the same as d = 0 and
809           o/p = 1.0).
810
811           This option can be used multiple times for an input file applying
812           to several tracks by selecting different track IDs each time.
813
814       --cues TID:none|iframes|all
815           Controls for which tracks cue (index) entries are created for the
816           given track (see section track IDs). 'none' inhibits the creation
817           of cue entries. For 'iframes' only blocks with no backward or
818           forward references ( = I frames in video tracks) are put into the
819           cue sheet. 'all' causes mkvmerge(1) to create cue entries for all
820           blocks which will make the file very big.
821
822           The default is 'iframes' for video and subtitle tracks and 'none'
823           for audio tracks. See also option --no-cues which inhibits the
824           creation of cue entries regardless of the --cues options used.
825
826           This option can be used multiple times for an input file applying
827           to several tracks by selecting different track IDs each time.
828
829       --default-track TID[:bool]
830           Sets the 'default' flag for the given track (see section track IDs)
831           if the optional argument bool is not present. If the user does not
832           explicitly select a track himself then the player should prefer the
833           track that has his 'default' flag set. Only one track of each kind
834           (audio, video, subtitles, buttons) can have his 'default' flag set.
835           If the user wants no track to have the default track flag set then
836           he has to set bool to 0 for all tracks.
837
838           This option can be used multiple times for an input file applying
839           to several tracks by selecting different track IDs each time.
840
841       --forced-track TID[:bool]
842           Sets the 'forced' flag for the given track (see section track IDs)
843           if the optional argument bool is not present. A player must play
844           all tracks for which this flag is set to 1.
845
846           This option can be used multiple times for an input file applying
847           to several tracks by selecting different track IDs each time.
848
849       --blockadd TID:level
850           Keep only the BlockAdditions up to the level level for the given
851           track. The default is to keep all levels. This option only affects
852           certain kinds of codecs like WAVPACK4.
853
854       --track-name TID:name
855           Sets the track name for the given track (see section track IDs) to
856           name.
857
858       --language TID:language
859           Sets the language for the given track (see section track IDs). Both
860           ISO639-2 language codes and ISO639-1 country codes are allowed. The
861           country codes will be converted to language codes automatically.
862           All languages including their ISO639-2 codes can be listed with the
863           --list-languages option.
864
865           This option can be used multiple times for an input file applying
866           to several tracks by selecting different track IDs each time.
867
868       -t, --tags TID:file-name
869           Read tags for the track with the number TID from the file
870           file-name. See the section about tags below for details.
871
872       --aac-is-sbr TID[:0|1]
873           Tells mkvmerge(1) that the track with the ID TID is SBR AAC (also
874           known as HE-AAC or AAC+). This options is needed if a) the source
875           file is an AAC file (not for a Matroska(TM) file) and b) the AAC
876           file contains SBR AAC data. The reason for this switch is that it
877           is technically impossible to automatically tell normal AAC data
878           from SBR AAC data without decoding a complete AAC frame. As there
879           are several patent issues with AAC decoders mkvmerge(1) will never
880           contain this decoding stage. So for SBR AAC files this switch is
881           mandatory. The resulting file might not play back correctly or even
882           not at all if the switch was omitted.
883
884           If the source file is a Matroska(TM) file then the CodecID should
885           be enough to detect SBR AAC. However, if the CodecID is wrong then
886           this switch can be used to correct that.
887
888           If mkvmerge wrongfully detects that an AAC file is SBR then you can
889           add ':0' to the track ID.
890
891       --reduce-to-core TID
892           Some audio codecs have a lossy core and optional extensions that
893           implement lossless decoding. This option tells mkvmerge(1) to only
894           copy the core but not the extensions. By default mkvmerge(1) copies
895           both the core and the extensions.
896
897           Currently only DTS tracks are affected by this option. TrueHD
898           tracks that contain an embedded AC-3 core are instead presented as
899           two separate tracks for which the user can select which track to
900           copy. For DTS such a scheme would not work as the HD extensions
901           cannot be decoded by themselves – unlike the TrueHD data.
902
903       --remove-dialog-normalization-gain TID
904           Some audio codecs contain header fields that tell the decoder or
905           player to apply a (usually negative) gain for dialog normalization.
906           This option tells mkvmerge(1) to remove or minimize that gain by
907           modifying the corresponding header fields.
908
909           Currently only AC-3, DTS and TrueHD tracks are affected by this
910           option.
911
912       --timestamps TID:file-name
913           Read the timestamps to be used for the specific track ID from
914           file-name. These timestamps forcefully override the timestamps that
915           mkvmerge(1) normally calculates. Read the section about external
916           timestamp files.
917
918       --default-duration TID:x
919           Forces the default duration of a given track to the specified
920           value. Also modifies the track's timestamps to match the default
921           duration. The argument x must be postfixed with 's', 'ms', 'us',
922           'ns', 'fps', 'p' or 'i' to specify the default duration in seconds,
923           milliseconds, microseconds, nanoseconds, 'frames per second',
924           'progressive frames per second' or 'interlaced frames per second'
925           respectively. The number x itself can be a floating point number or
926           a fraction.
927
928           If the default duration is not forced then mkvmerge will try to
929           derive the track's default duration from the container and/or the
930           encoded bitstream for certain track types, e.g. AVC/h.264 or
931           MPEG-2.
932
933           This option can also be used to change the FPS of video tracks
934           without having to use an external timestamp file.
935
936       --fix-bitstream-timing-information TID[:0|1]
937           Normally mkvmerge(1) does not change the timing information
938           (frame/field rate) stored in the video bitstream. With this option
939           that information is adjusted to match the container timing
940           information. The container timing information can come from various
941           sources: from the command line (see option --default-duration), the
942           source container or derived from the bitstream.
943
944               Note
945               This has only been implemented for AVC/h.264 video tracks so
946               far.
947
948       --nalu-size-length TID:n
949           Forces the NALU size length to n bytes. This parameter is only used
950           if the AVC/h.264 elementary stream packetizer is used. If left out
951           it defaults to 4 bytes, but there are files that contain frames or
952           slices that are all smaller than 65536 bytes. For such files you
953           can use this parameter and decrease the size to 2.
954
955       --compression TID:n
956           Selects the compression method to be used for the track. Note that
957           the player also has to support this method. Valid values are
958           'none', 'zlib' and 'mpeg4_p2'/'mpeg4p2'.
959
960           The compression method 'mpeg4_p2'/'mpeg4p2' is a special
961           compression method called 'header removal' that is only available
962           for MPEG4 part 2 video tracks.
963
964           The default for some subtitle types is 'zlib' compression. This
965           compression method is also the one that most if not all playback
966           applications support. Support for other compression methods other
967           than 'none' is not assured.
968
969   Options that only apply to video tracks
970       -f, --fourcc TID:FourCC
971           Forces the FourCC to the specified value. Works only for video
972           tracks in the 'MS compatibility mode'.
973
974       --display-dimensions TID:widthxheight
975           Matroska(TM) files contain two values that set the display
976           properties that a player should scale the image on playback to:
977           display width and display height. These values can be set with this
978           option, e.g. '1:640x480'.
979
980           Another way to specify the values is to use the --aspect-ratio or
981           the --aspect-ratio-factor option (see below). These options are
982           mutually exclusive.
983
984       --aspect-ratio TID:ratio|width/height
985           Matroska(TM) files contain two values that set the display
986           properties that a player should scale the image on playback to:
987           display width and display height. With this option mkvmerge(1) will
988           automatically calculate the display width and display height based
989           on the image's original width and height and the aspect ratio given
990           with this option. The ratio can be given either as a floating point
991           number ratio or as a fraction 'width/height', e.g. '16/9'.
992
993           Another way to specify the values is to use the
994           --aspect-ratio-factor or --display-dimensions options (see above
995           and below). These options are mutually exclusive.
996
997       --aspect-ratio-factor TID:factor|n/d
998           Another way to set the aspect ratio is to specify a factor. The
999           original aspect ratio is first multiplied with this factor and used
1000           as the target aspect ratio afterwards.
1001
1002           Another way to specify the values is to use the --aspect-ratio or
1003           --display-dimensions options (see above). These options are
1004           mutually exclusive.
1005
1006       --cropping TID:left,top,right,bottom
1007           Sets the pixel cropping parameters of a video track to the given
1008           values.
1009
1010       --colour-matrix TID:n
1011           Sets the matrix coefficients of the video used to derive luma and
1012           chroma values from red, green and blue color primaries. The
1013           parameter n is an integer rangeing from 0 and 10.
1014
1015           Valid values and their meaning are:
1016
1017           0: GBR, 1: BT709, 2: unspecified, 3: reserved, 4: FCC, 5: BT470BG,
1018           6: SMPTE 170M, 7: SMPTE 240M, 8: YCOCG, 9: BT2020 non-constant
1019           luminance, 10: BT2020 constant luminance
1020
1021       --colour-bits-per-channel TID:n
1022           Sets the number of coded bits for a colour channel. A value of 0
1023           indicates that the number of bits is unspecified.
1024
1025       --chroma-subsample TID:hori,vert
1026           The amount of pixels to remove in the Cr and Cb channels for every
1027           pixel not removed horizontally/vertically.
1028
1029           Example: For video with 4:2:0 chroma subsampling, the parameter
1030           should be set to TID:1,1.
1031
1032       --cb-subsample TID:hori,vert
1033           The amount of pixels to remove in the Cb channel for every pixel
1034           not removed horizontally/vertically. This is additive with
1035           --chroma-subsample.
1036
1037           Example: For video with 4:2:1 chroma subsampling, the parameter
1038           --chroma-subsample should be set to TID:1,0 and Cb-subsample should
1039           be set to TID:1,0.
1040
1041       --chroma-siting TID:hori,vert
1042           Sets how chroma is sited horizontally/vertically (0: unspecified,
1043           1: top collocated, 2: half).
1044
1045       --colour-range TID:n
1046           Sets the clipping of the color ranges (0: unspecified, 1: broadcast
1047           range, 2: full range (no clipping), 3: defined by
1048           MatrixCoefficients/TransferCharacteristics).
1049
1050       --colour-transfer-characteristics TID:n
1051           The transfer characteristics of the video.
1052
1053           Valid values and their meaning are:
1054
1055           0: reserved, 1: ITU-R BT.709, 2: unspecified, 3: reserved, 4: gamma
1056           2.2 curve, 5: gamma 2.8 curve, 6: SMPTE 170M, 7: SMPTE 240M, 8:
1057           linear, 9: log, 10: log sqrt, 11: IEC 61966-2-4, 12: ITU-R BT.1361
1058           extended colour gamut, 13: IEC 61966-2-1, 14: ITU-R BT.2020 10 bit,
1059           15: ITU-R BT.2020 12 bit, 16: SMPTE ST 2084, 17: SMPTE ST 428-1;
1060           18: ARIB STD-B67 (HLG)
1061
1062       --colour-primaries TID:n
1063           Sets the colour primaries of the video.
1064
1065           Valid values and their meaning are:
1066
1067           0: reserved, 1: ITU-R BT.709, 2: unspecified, 3: reserved, 4: ITU-R
1068           BT.470M, 5: ITU-R BT.470BG, 6: SMPTE 170M, 7: SMPTE 240M, 8: FILM,
1069           9: ITU-R BT.2020, 10: SMPTE ST 428-1, 22: JEDEC P22 phosphors
1070
1071       --max-content-light TID:n
1072           Sets the maximum brightness of a single pixel (Maximum Content
1073           Light Level) in candelas per square meter (cd/m²). The value of n
1074           should be a non-negtive integer.
1075
1076       --max-frame-light TID:n
1077           Sets the maximum brightness of a single full frame (Maximum
1078           Frame-Average Light Level) in candelas per square meter (cd/m²).
1079           The value of n should be a non-negtive integer.
1080
1081       --chromaticity-coordinates
1082       TID:red-x,red-y,green-x,green-y,blue-x,blue-y
1083           Sets the red/green/blue chromaticity coordinates as defined by CIE
1084           1931.
1085
1086       --white-colour-coordinates TID:x,y
1087           Sets the white colour chromaticity coordinates as defined by CIE
1088           1931.
1089
1090       --max-luminance TID:float
1091           Sets the maximum luminance in candelas per square meter (cd/m²).
1092           The value should be less than 9999.99.
1093
1094       --min-luminance TID:float
1095           Sets the minimum luminance in candelas per square meter (cd/m²).
1096           The value should be less than 999.9999.
1097
1098       --projection-type TID:method
1099           Sets the video projection method used. Valid values are 0
1100           (rectangular projection), 1 (equirectangular projection), 2
1101           (cubemap projection) and 3 (mesh projection).
1102
1103       --projection-private TID:data
1104           Sets private data that only applies to a specific projection. Data
1105           must be given as hex numbers with or without the "0x" prefix, with
1106           or without spaces.
1107
1108       --projection-pose-yaw TID:float
1109           Specifies a yaw rotation to the projection.
1110
1111       --projection-pose-pitch TID:float
1112           Specifies a pitch rotation to the projection.
1113
1114       --projection-pose-roll TID:float
1115           Specifies a roll rotation to the projection.
1116
1117       --field-order TID:n
1118           Sets the field order for the video track with the track ID TID. The
1119           order must be one of the following numbers:
1120
1121           0: progressive; 1: interlaced with top field displayed first and
1122           top field stored first; 2: undetermined field order; 6: interlaced
1123           with bottom field displayed first and bottom field stored first; 9:
1124           interlaced with bottom field displayed first and top field stored
1125           first; 14: interlaced with top field displayed first and bottom
1126           field stored first
1127
1128       --stereo-mode TID:n|keyword
1129           Sets the stereo mode for the video track with the track ID TID. The
1130           mode can either be a number n between 0 and 14 or one of these
1131           keywords:
1132
1133           'mono', 'side_by_side_left_first', 'top_bottom_right_first',
1134           'top_bottom_left_first', 'checkerboard_right_first',
1135           'checkerboard_left_first', 'row_interleaved_right_first',
1136           'row_interleaved_left_first', 'column_interleaved_right_first',
1137           'column_interleaved_left_first', 'anaglyph_cyan_red',
1138           'side_by_side_right_first', 'anaglyph_green_magenta',
1139           'both_eyes_laced_left_first', 'both_eyes_laced_right_first'.
1140
1141   Options that only apply to text subtitle tracks
1142       --sub-charset TID:character-set
1143           Sets the character set for the conversion to UTF-8 for UTF-8
1144           subtitles for the given track ID. If not specified the charset will
1145           be derived from the current locale settings. Note that a charset is
1146           not needed for subtitles read from Matroska(TM) files or from Kate
1147           streams, as these are always stored in UTF-8. See the section about
1148           text files and character sets for an explanation how mkvmerge(1)
1149           converts between character sets.
1150
1151           This option can be used multiple times for an input file applying
1152           to several tracks by selecting different track IDs each time.
1153
1154   Other options
1155       -i, --identify file-name
1156           Will let mkvmerge(1) probe the single file and report its type, the
1157           tracks contained in the file and their track IDs. If this option is
1158           used then the only other option allowed is the filename.
1159
1160           The output format used for the result can be changed with the
1161           option --identification-format.
1162
1163       -J file-name
1164           This is a convenient alias for "--identification-format json
1165           --identify file-name".
1166
1167       -F, --identification-format format
1168           Determines the output format used by the --identify option. The
1169           following formats are supported: text (the default if this option
1170           isn't used) and json.
1171
1172            1. The text format is short and human-readable. It consists of one
1173               line per item found (container, tracks, attachments etc.).
1174
1175               This format is not meant to be parsed. The output will be
1176               translated into the language mkvmerge(1) uses (see also
1177               --ui-language).
1178
1179            2. The json format outputs a machine-readable JSON representation.
1180               This format follows the JSON schema described in the following
1181               file:
1182
1183               mkvmerge-identification-output-schema-v11.json[3]
1184
1185               All versions of the JSON schema are available both online and
1186               in the released source code archives.
1187
1188       --probe-range-percentage percentage
1189           File types such as MPEG program and transport streams (.vob, .m2ts)
1190           require parsing a certain amount of data in order to detect all
1191           tracks contained in the file. This amount is 0.3% of the source
1192           file's size or 10 MB, whichever is higher.
1193
1194           If tracks are known to be present but not found then the percentage
1195           to probe can be changed with this option. The minimum of 10 MB is
1196           built-in and cannot be changed.
1197
1198       -l, --list-types
1199           Lists supported input file types.
1200
1201       --list-languages
1202           Lists all languages and their ISO639-2 code which can be used with
1203           the --language option.
1204
1205       --priority priority
1206           Sets the process priority that mkvmerge(1) runs with. Valid values
1207           are 'lowest', 'lower', 'normal', 'higher' and 'highest'. If nothing
1208           is given then 'normal' is used. On Unix like systems mkvmerge(1)
1209           will use the nice(2) function. Therefore only the super user can
1210           use 'higher' and 'highest'. On Windows all values are useable for
1211           every user.
1212
1213           Selecting 'lowest' also causes mkvmerge(1) to select idle I/O
1214           priority in addition to the lowest possible process priority.
1215
1216       --command-line-charset character-set
1217           Sets the character set to convert strings given on the command line
1218           from. It defaults to the character set given by system's current
1219           locale. This settings applies to arguments of the following
1220           options: --title, --track-name and --attachment-description.
1221
1222       --output-charset character-set
1223           Sets the character set to which strings are converted that are to
1224           be output. It defaults to the character set given by system's
1225           current locale.
1226
1227       -r, --redirect-output file-name
1228           Writes all messages to the file file-name instead of to the
1229           console. While this can be done easily with output redirection
1230           there are cases in which this option is needed: when the terminal
1231           reinterprets the output before writing it to a file. The character
1232           set set with --output-charset is honored.
1233
1234       --flush-on-close
1235           Tells the program to flush all data cached in memory to storage
1236           when closing files opened for writing. This can be used to prevent
1237           data loss on power outages or to circumvent certain problems in the
1238           operating system or drivers. The downside is that multiplexing will
1239           take longer as mkvmerge will wait until all data has been written
1240           to the storage before exiting. See issues #2469 and #2480 on the
1241           MKVToolNix bug tracker for in-depth discussions on the pros and
1242           cons.
1243
1244       --ui-language code
1245           Forces the translations for the language code to be used (e.g.
1246           'de_DE' for the German translations). Entering 'list' as the code
1247           will cause the program to output a list of available translations.
1248
1249       --abort-on-warnings
1250           Tells the program to abort after the first warning is emitted. The
1251           program's exit code will be 1.
1252
1253       --debug topic
1254           Turn on debugging for a specific feature. This option is only
1255           useful for developers.
1256
1257       --engage feature
1258           Turn on experimental features. A list of available features can be
1259           requested with mkvmerge --engage list. These features are not meant
1260           to be used in normal situations.
1261
1262       --gui-mode
1263           Turns on GUI mode. In this mode specially-formatted lines may be
1264           output that can tell a controlling GUI what's happening. These
1265           messages follow the format '#GUI#message'. The message may be
1266           followed by key/value pairs as in
1267           '#GUI#message#key1=value1#key2=value2...'. Neither the messages nor
1268           the keys are ever translated and always output in English.
1269
1270       @options-file.json
1271           Reads additional command line arguments from the file options-file.
1272           See the section about option files for further information.
1273
1274       --capabilities
1275           Lists information about optional features that have been compiled
1276           in and exit. The first line output will be the version information.
1277           All following lines contain exactly one word whose presence
1278           indicates that the feature has been compiled in. These features
1279           are:
1280
1281           ·   'FLAC' -- reading raw FLAC files and handling FLAC tracks in
1282               other containers, e.g.  Ogg(TM) or Matroska(TM).
1283
1284       -h, --help
1285           Show usage information and exit.
1286
1287       -V, --version
1288           Show version information and exit.
1289

USAGE

1291       For each file the user can select which tracks mkvmerge(1) should take.
1292       They are all put into the file specified with -o. A list of known (and
1293       supported) source formats can be obtained with the -l option.
1294
1295           Important
1296           The order of command line options is important. Please read the
1297           section "Option order" if you're new to the program.
1298

OPTION ORDER

1300       The order in which options are entered is important for some options.
1301       Options fall into two categories:
1302
1303        1. Options that affect the whole program and are not tied to any input
1304           file. These include but are not limited to --command-line-charset,
1305           --output or --title. These can appear anywhere on the command line.
1306
1307        2. Options that affect a single input file or a single track in an
1308           input file. These options all apply to the following input file on
1309           the command line. All options applying to the same input (or to
1310           tracks from the same input file) file can be written in any order
1311           as long as they all appear before that input file's name. Examples
1312           for options applying to an input file are --no-chapters or
1313           --chapter-charset. Examples for options applying to a single track
1314           are --default-duration or --language.
1315
1316       The options are processed from left to right. If an option appears
1317       multiple times within the same scope then the last occurence will be
1318       used. Therefore the title will be set to "Something else" in the
1319       following example:
1320
1321           $ mkvmerge -o output.mkv --title 'This and that' input.avi --title 'Something else'
1322
1323       The following example shows that using the --language option twice is
1324       OK because they're used in different scopes. Even though they apply to
1325       the same track ID they apply to different input files and therefore
1326       have different scopes:
1327
1328           $ mkvmerge -o output.mkv --language 0:fre français.ogg --language 0:deu deutsch.ogg
1329

EXAMPLES

1331       Let's assume you have a file called MyMovie.avi and the audio track in
1332       a separate file, e.g. 'MyMovie.wav'. First you want to encode the audio
1333       to OggVorbis(TM):
1334
1335           $ oggenc -q4 -oMyMovie.ogg MyMovie.wav
1336
1337       After a couple of minutes you can join video and audio:
1338
1339           $ mkvmerge -o MyMovie-with-sound.mkv MyMovie.avi MyMovie.ogg
1340
1341       If your AVI already contains an audio track then it will be copied as
1342       well (if mkvmerge(1) supports the audio format). To avoid that simply
1343       do
1344
1345           $ mkvmerge -o MyMovie-with-sound.mkv -A MyMovie.avi MyMovie.ogg
1346
1347       After some minutes of consideration you rip another audio track, e.g.
1348       the director's comments or another language to 'MyMovie-add-audio.wav'.
1349       Encode it again and join it up with the other file:
1350
1351           $ oggenc -q4 -oMyMovie-add-audio.ogg MyMovie-add-audio.wav
1352           $ mkvmerge -o MM-complete.mkv MyMovie-with-sound.mkv MyMovie-add-audio.ogg
1353
1354       The same result can be achieved with
1355
1356           $ mkvmerge -o MM-complete.mkv -A MyMovie.avi MyMovie.ogg MyMovie-add-audio.ogg
1357
1358       Now fire up mplayer(TM) and enjoy. If you have multiple audio tracks
1359       (or even video tracks) then you can tell mplayer(TM) which track to
1360       play with the '-vid' and '-aid' options. These are 0-based and do not
1361       distinguish between video and audio.
1362
1363       If you need an audio track synchronized you can do that easily. First
1364       find out which track ID the Vorbis track has with
1365
1366           $ mkvmerge --identify outofsync.ogg
1367
1368       Now you can use that ID in the following command line:
1369
1370           $ mkvmerge -o goodsync.mkv -A source.avi -y 12345:200 outofsync.ogg
1371
1372       This would add 200ms of silence at the beginning of the audio track
1373       with the ID 12345 taken from 'outofsync.ogg'.
1374
1375       Some movies start synced correctly but slowly drift out of sync. For
1376       these kind of movies you can specify a delay factor that is applied to
1377       all timestamps -- no data is added or removed. So if you make that
1378       factor too big or too small you'll get bad results. An example is that
1379       an episode I transcoded was 0.2 seconds out of sync at the end of the
1380       movie which was 77340 frames long. At 29.97fps 0.2 seconds correspond
1381       to approx.  6 frames. So I did
1382
1383           $ mkvmerge -o goodsync.mkv -y 23456:0,77346/77340 outofsync.mkv
1384
1385       The result was fine.
1386
1387       The sync options can also be used for subtitles in the same manner.
1388
1389       For text subtitles you can either use some Windows software (like
1390       SubRipper(TM)) or the subrip(TM) package found in transcode(1)'s
1391       sources in the 'contrib/subrip' directory. The general process is:
1392
1393        1. extract a raw subtitle stream from the source:
1394
1395               $ tccat -i /path/to/copied/dvd/ -T 1 -L | tcextract -x ps1 -t vob -a 0x20 | subtitle2pgm -o mymovie
1396
1397        2. convert the resulting PGM images to text with gocr:
1398
1399               $ pgm2txt mymovie
1400
1401        3. spell-check the resulting text files:
1402
1403               $ ispell -d american *txt
1404
1405        4. convert the text files to a SRT file:
1406
1407               $ srttool -s -w -i mymovie.srtx -o mymovie.srt
1408
1409       The resulting file can be used as another input file for mkvmerge(1):
1410
1411           $ mkvmerge -o mymovie.mkv mymovie.avi mymovie.srt
1412
1413       If you want to specify the language for a given track then this is
1414       easily done. First find out the ISO639-2 code for your language.
1415       mkvmerge(1) can list all of those codes for you:
1416
1417           $ mkvmerge --list-languages
1418
1419       Search the list for the languages you need. Let's assume you have put
1420       two audio tracks into a Matroska(TM) file and want to set their
1421       language codes and that their track IDs are 2 and 3. This can be done
1422       with
1423
1424           $ mkvmerge -o with-lang-codes.mkv --language 2:ger --language 3:dut without-lang-codes.mkv
1425
1426       As you can see you can use the --language switch multiple times.
1427
1428       Maybe you'd also like to have the player use the Dutch language as the
1429       default language. You also have extra subtitles, e.g. in English and
1430       French, and want to have the player display the French ones by default.
1431       This can be done with
1432
1433           $ 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
1434
1435       If you do not see the language or default track flags that you've
1436       specified in mkvinfo(1)'s output then please read the section about
1437       default values.
1438
1439       Turn off the compression for an input file.
1440
1441           $ mkvmerge -o no-compression.mkv --compression -1:none MyMovie.avi --compression -1:none mymovie.srt
1442

TRACK IDS

1444   Regular track IDs
1445       Some of the options for mkvmerge(1) need a track ID to specify which
1446       track they should be applied to. Those track IDs are printed by the
1447       readers when demuxing the current input file, or if mkvmerge(1) is
1448       called with the --identify option. An example for such output:
1449
1450           $ mkvmerge -i v.mkv
1451           File 'v.mkv': container: Matroska(TM)
1452           Track ID 0: video (V_MS/VFW/FOURCC, DIV3)
1453           Track ID 1: audio (A_MPEG/L3)
1454
1455       Do not confuse the track IDs that are assigned to the tracks that are
1456       placed in the output MKV file with the track IDs of the input files.
1457       Only the input file track IDs are used for options needing these
1458       values.
1459
1460       Also note that each input file has its own set of track IDs. Therefore
1461       the track IDs for file 'file1.ext' as reported by 'mkvmerge --identify'
1462       do not change no matter how many other input files are there or in
1463       which position 'file1.ext' is used.
1464
1465       Track IDs are assigned like this:
1466
1467       ·   AVI files: The video track has the ID 0. The audio tracks get IDs
1468           in ascending order starting at 1.
1469
1470       ·   AAC, AC-3, MP3, SRT and WAV files: The one 'track' in that file
1471           gets the ID 0.
1472
1473       ·   Most other files: The track IDs are assigned in order the tracks
1474           are found in the file starting at 0.
1475
1476       The options that use the track IDs are the ones whose description
1477       contains 'TID'. The following options use track IDs as well:
1478       --audio-tracks, --video-tracks, --subtitle-tracks, --button-tracks and
1479       --track-tags.
1480
1481   Special track IDs
1482       There are several IDs that have special meaning and do not occur in the
1483       identification output.
1484
1485       The special track ID '-1' is a wild card and applies the given switch
1486       to all tracks that are read from an input file.
1487
1488       The special track ID '-2' refers to the chapters in a source file.
1489       Currently only the --sync option uses this special ID. As an
1490       alternative to --sync -2:...  the option --chapter-sync ...  can be
1491       used.
1492

TEXT FILES AND CHARACTER SET CONVERSIONS

1494           Note
1495           This section applies to all programs in MKVToolNix even if it only
1496           mentions mkvmerge(1).
1497
1498   Introduction
1499       All text in a Matroska(TM) file is encoded in UTF-8. This means that
1500       mkvmerge(1) has to convert every text file it reads as well as every
1501       text given on the command line from one character set into UTF-8. In
1502       return this also means that mkvmerge(1)'s output has to be converted
1503       back to that character set from UTF-8, e.g. if a non-English
1504       translation is used with --ui-language or for text originating from a
1505       Matroska(TM) file.
1506
1507       mkvmerge(1) does this conversion automatically based on the presence of
1508       a byte order marker (short: BOM) or the system's current locale. How
1509       the character set is inferred from the locale depends on the operating
1510       system that mkvmerge(1) is run on.
1511
1512   Byte order markers (BOM)
1513       Text files that start with a BOM are already encoded in one
1514       representation of UTF.  mkvmerge(1) supports the following five modes:
1515       UTF-8, UTF-16 Little and Big Endian, UTF-32 Little and Big Endian. Text
1516       files with a BOM are automatically converted to UTF-8. Any of the
1517       parameters that would otherwise set the character set for such a file
1518       (e.g.  --sub-charset) is silently ignored.
1519
1520   Linux and Unix-like systems including Mac OS
1521       On Unix-like systems mkvmerge(1) uses the setlocale(3) system call
1522       which in turn uses the environment variables LANG, LC_ALL and LC_CYPE.
1523       The resulting character set is often one of UTF-8 or the ISO-8859-*
1524       family and is used for all text file operations and for encoding
1525       strings on the command line and for output to the console.
1526
1527   Windows
1528       On Windows the default character set used for converting text files is
1529       determined by a call to the GetACP() system call.
1530
1531       Reading the command line is done with the GetCommandLineW() function
1532       which already returns a Unicode string. Therefore the option
1533       --command-line-charset is ignored on Windows.
1534
1535       Output to the console consists of three scenarios:
1536
1537        1. If the output is redirected with the option --redirect-output then
1538           the default charset is UTF-8. This can be changed with
1539           --output-charset.
1540
1541           If the output is redirected with cmd.exe itself, e.g. with mkvinfo
1542           file.mkv > info.txt, then the charset is always UTF-8 and cannot be
1543           changed.
1544
1545           Otherwise (when writing directly to the console) the Windows
1546           function WriteConsoleW() is used and the option --output-charset is
1547           ignored. The console should be able to output all Unicode
1548           characters for which the corresponding language support is
1549           installed (e.g. Chinese characters might not be displayed on
1550           English Windows versions).
1551
1552   Command line options
1553       The following options exist that allow specifying the character sets:
1554
1555       ·   --sub-charset for text subtitle files and for text subtitle tracks
1556           stored in container formats for which the character set cannot be
1557           determined unambiguously (e.g. Ogg files),
1558
1559       ·   --chapter-charset for chapter text files and for chapters and file
1560           titles stored in container formats for which the character set
1561           cannot be determined unambiguously (e.g. Ogg files for chapter
1562           information, track and file titles etc; MP4 files for chapter
1563           information),
1564
1565       ·   --command-line-charset for all strings on the command line,
1566
1567       ·   --output-charset for all strings written to the console or to a
1568           file if the output has been redirected with the --redirect-output
1569           option. On non-Windows systems the default for the output charset
1570           is the system's current charset. On Windows it defaults to UTF-8
1571           both for redirecting with --redirect-output and with cmd.exe
1572           itself, e.g.  mkvinfo file.mkv > info.txt.
1573

OPTION FILES

1575       An option file is a file mkvmerge(1) can read additional command line
1576       arguments from. This can be used in order to circumvent certain
1577       limitations of the shell or the operating system when executing
1578       external programs like a limited command line length.
1579
1580       An option file contains JSON-formatted data. Its content must be a
1581       valid JSON array consisting solely of JSON strings. The file's encoding
1582       must be UTF-8. The file should not start with a byte order marker
1583       (BOM), but if one exists, it will be skipped.
1584
1585       The rules for escaping special characters inside JSON are the ones in
1586       the official JSON specification, RFC 7159[4].
1587
1588       The command line 'mkvmerge -o "my file.mkv" -A "a movie.avi" sound.ogg'
1589       could be converted into the following JSON option file called e.g.
1590       'options.json':
1591
1592           [
1593             "-o",
1594             "c:\\Matroska\\my file.mkv",
1595             "--title",
1596             "#65",
1597             "-A",
1598             "a movie.avi",
1599             "sound.ogg"
1600           ]
1601

SUBTITLES

1603       There are several text and bitmap subtitle formats that can be embedded
1604       into Matroska(TM). Text subtitles must be recoded to UTF-8 so that they
1605       can be displayed correctly by a player (see the section about text
1606       files and character sets for an explanation how mkvmerge(1) converts
1607       between character sets). Kate subtitles are already encoded in UTF-8
1608       and do not have to be re-encoded.
1609
1610       The following subtitle formats are supported at the moment:
1611
1612       ·   Subtitle Ripper (SRT) files
1613
1614       ·   Substation Alpha (SSA) / Advanced Substation Alpha scripts (ASS)
1615
1616       ·   Universal Subtitle Format (USF) files
1617
1618       ·   OggKate streams
1619
1620       ·   VobSub bitmap subtitle files
1621
1622       ·   PGS bitmap subtitle files as found on BluRay discs
1623

FILE LINKING

1625       Matroska(TM) supports file linking which simply says that a specific
1626       file is the predecessor or successor of the current file. To be
1627       precise, it's not really the files that are linked but the Matroska(TM)
1628       segments. As most files will probably only contain one Matroska(TM)
1629       segment the following explanations use the term 'file linking' although
1630       'segment linking' would be more appropriate.
1631
1632       Each segment is identified by a unique 128 bit wide segment UID. This
1633       UID is automatically generated by mkvmerge(1). The linking is done
1634       primarily via putting the segment UIDs (short: SID) of the
1635       previous/next file into the segment header information.  mkvinfo(1)
1636       prints these SIDs if it finds them.
1637
1638       If a file is split into several smaller ones and linking is used then
1639       the timestamps will not start at 0 again but will continue where the
1640       last file has left off. This way the absolute time is kept even if the
1641       previous files are not available (e.g. when streaming). If no linking
1642       is used then the timestamps should start at 0 for each file. By default
1643       mkvmerge(1) does not use file linking. If you want that you can turn it
1644       on with the --link option. This option is only useful if splitting is
1645       activated as well.
1646
1647       Regardless of whether splitting is active or not the user can tell
1648       mkvmerge(1) to link the produced files to specific SIDs. This is
1649       achieved with the options --link-to-previous and --link-to-next. These
1650       options accept a segment SID in the format that mkvinfo(1) outputs: 16
1651       hexadecimal numbers between 0x00 and 0xff prefixed with '0x' each, e.g.
1652       '0x41 0xda 0x73 0x66 0xd9 0xcf 0xb2 0x1e 0xae 0x78 0xeb 0xb4 0x5e 0xca
1653       0xb3 0x93'. Alternatively a shorter form can be used: 16 hexadecimal
1654       numbers between 0x00 and 0xff without the '0x' prefixes and without the
1655       spaces, e.g. '41da7366d9cfb21eae78ebb45ecab393'.
1656
1657       If splitting is used then the first file is linked to the SID given
1658       with --link-to-previous and the last file is linked to the SID given
1659       with --link-to-next. If splitting is not used then the one output file
1660       will be linked to both of the two SIDs.
1661

DEFAULT VALUES

1663       The Matroska(TM) specification states that some elements have a default
1664       value. Usually an element is not written to the file if its value is
1665       equal to its default value in order to save space. The elements that
1666       the user might miss in mkvinfo(1)'s output are the language and the
1667       default track flag elements. The default value for the language is
1668       English ('eng'), and the default value for the default track flag is
1669       true. Therefore if you used --language 0:eng for a track then it will
1670       not show up in mkvinfo(1)'s output.
1671

ATTACHMENTS

1673       Maybe you also want to keep some photos along with your Matroska(TM)
1674       file, or you're using SSA subtitles and need a special TrueType(TM)
1675       font that's really rare. In these cases you can attach those files to
1676       the Matroska(TM) file. They will not be just appended to the file but
1677       embedded in it. A player can then show those files (the 'photos' case)
1678       or use them to render the subtitles (the 'TrueType(TM) fonts' case).
1679
1680       Here's an example how to attach a photo and a TrueType(TM) font to the
1681       output file:
1682
1683           $ mkvmerge -o output.mkv -A video.avi sound.ogg \
1684             --attachment-description "Me and the band behind the stage in a small get-together" \
1685             --attachment-mime-type image/jpeg \
1686             --attach-file me_and_the_band.jpg \
1687             --attachment-description "The real rare and unbelievably good looking font" \
1688             --attachment-mime-type application/octet-stream \
1689             --attach-file really_cool_font.ttf
1690
1691       If a Matroska(TM) containing attachments file is used as an input file
1692       then mkvmerge(1) will copy the attachments into the new file. The
1693       selection which attachments are copied and which are not can be changed
1694       with the options --attachments and --no-attachments.
1695

CHAPTERS

1697       The Matroska(TM) chapter system is more powerful than the old known
1698       system used by OGM files. The full specifications can be found at the
1699       Matroska(TM) website[1].
1700
1701       mkvmerge(1) supports two kinds of chapter files as its input. The first
1702       format, called 'simple chapter format', is the same format that the OGM
1703       tools expect. The second format is a XML based chapter format which
1704       supports all of Matroska(TM)'s chapter functionality.
1705
1706   The simple chapter format
1707       This formmat consists of pairs of lines that start with 'CHAPTERxx='
1708       and 'CHAPTERxxNAME=' respectively. The first one contains the start
1709       timestamp while the second one contains the title. Here's an example:
1710
1711           CHAPTER01=00:00:00.000
1712           CHAPTER01NAME=Intro
1713           CHAPTER02=00:02:30.000
1714           CHAPTER02NAME=Baby prepares to rock
1715           CHAPTER03=00:02:42.300
1716           CHAPTER03NAME=Baby rocks the house
1717
1718       mkvmerge(1) will transform every pair or lines into one Matroska(TM)
1719       ChapterAtom. It does not set any ChapterTrackNumber which means that
1720       the chapters all apply to all tracks in the file.
1721
1722       As this is a text file character set conversion may need to be done.
1723       See the section about text files and character sets for an explanation
1724       how mkvmerge(1) converts between character sets.
1725
1726   The XML based chapter format
1727       The XML based chapter format looks like this example:
1728
1729           <?xml version="1.0" encoding="ISO-8859-1"?>
1730           <!DOCTYPE Chapters SYSTEM "matroskachapters.dtd">
1731           <Chapters>
1732             <EditionEntry>
1733               <ChapterAtom>
1734                 <ChapterTimeStart>00:00:30.000</ChapterTimeStart>
1735                 <ChapterTimeEnd>00:01:20.000</ChapterTimeEnd>
1736                 <ChapterDisplay>
1737                   <ChapterString>A short chapter</ChapterString>
1738                   <ChapterLanguage>eng</ChapterLanguage>
1739                 </ChapterDisplay>
1740                 <ChapterAtom>
1741                   <ChapterTimeStart>00:00:46.000</ChapterTimeStart>
1742                   <ChapterTimeEnd>00:01:10.000</ChapterTimeEnd>
1743                   <ChapterDisplay>
1744                     <ChapterString>A part of that short chapter</ChapterString>
1745                     <ChapterLanguage>eng</ChapterLanguage>
1746                   </ChapterDisplay>
1747                 </ChapterAtom>
1748               </ChapterAtom>
1749             </EditionEntry>
1750           </Chapters>
1751
1752       With this format three things are possible that are not possible with
1753       the simple chapter format:
1754
1755        1. The timestamp for the end of the chapter can be set,
1756
1757        2. chapters can be nested,
1758
1759        3. the language and country can be set.
1760
1761       The mkvtoolnix distribution contains some sample files in the doc
1762       subdirectory which can be used as a basis.
1763
1764       The following lists the supported XML tags, their data types and, where
1765       appropriate, the valid range for their values:
1766
1767           Chapters (master)
1768             EditionEntry (master)
1769               EditionUID (unsigned integer, valid range: 1 <= value)
1770               EditionFlagHidden (unsigned integer, valid range: 0 <= value <= 1)
1771               EditionFlagDefault (unsigned integer, valid range: 0 <= value <= 1)
1772               EditionFlagOrdered (unsigned integer, valid range: 0 <= value <= 1)
1773               ChapterAtom (master)
1774                 ChapterAtom (master)
1775                 ChapterUID (unsigned integer, valid range: 1 <= value)
1776                 ChapterTimeStart (unsigned integer)
1777                 ChapterTimeEnd (unsigned integer)
1778                 ChapterFlagHidden (unsigned integer, valid range: 0 <= value <= 1)
1779                 ChapterFlagEnabled (unsigned integer, valid range: 0 <= value <= 1)
1780                 ChapterSegmentUID (binary, valid range: 1 <= length in bytes)
1781                 ChapterSegmentEditionUID (unsigned integer, valid range: 1 <= value)
1782                 ChapterPhysicalEquiv (unsigned integer)
1783                 ChapterTrack (master)
1784                   ChapterTrackNumber (unsigned integer, valid range: 1 <= value)
1785                 ChapterDisplay (master)
1786                   ChapterString (UTF-8 string)
1787                   ChapterLanguage (UTF-8 string)
1788                   ChapterCountry (UTF-8 string)
1789                 ChapterProcess (master)
1790                   ChapterProcessCodecID (unsigned integer)
1791                   ChapterProcessPrivate (binary)
1792                   ChapterProcessCommand (master)
1793                     ChapterProcessTime (unsigned integer)
1794                     ChapterProcessData (binary)
1795
1796   General notes
1797       When splitting files mkvmerge(1) will correctly adjust the chapters as
1798       well. This means that each file only includes the chapter entries that
1799       apply to it, and that the timestamps will be offset to match the new
1800       timestamps of each output file.
1801
1802       mkvmerge(1) is able to copy chapters from Matroska(TM) source files
1803       unless this is explicitly disabled with the --no-chapters option. The
1804       chapters from all sources (Matroska(TM) files, Ogg files, MP4 files,
1805       chapter text files) are usually not merged but end up in separate
1806       ChapterEditions. Only if chapters are read from several Matroska(TM) or
1807       XML files that share the same edition UIDs will chapters be merged into
1808       a single ChapterEdition. If such a merge is desired in other situations
1809       as well then the user has to extract the chapters from all sources with
1810       mkvextract(1) first, merge the XML files manually and mux them
1811       afterwards.
1812

TAGS

1814   Introduction
1815       Matroska(TM)'s tag system is similar to that of other containers: a set
1816       of KEY=VALUE pairs. However, in Matroska(TM) these tags can also be
1817       nested, and both the KEY and the VALUE are elements of their own. The
1818       example file example-tags-2.xml shows how to use this system.
1819
1820   Scope of the tags
1821       Matroska(TM) tags do not automatically apply to the complete file. They
1822       can, but they also may apply to different parts of the file: to one or
1823       more tracks, to one or more chapters, or even to a combination of both.
1824       The the Matroska(TM) specification[5] gives more details about this
1825       fact.
1826
1827       One important fact is that tags are linked to tracks or chapters with
1828       the Targets Matroska(TM) tag element, and that the UIDs used for this
1829       linking are not the track IDs mkvmerge(1) uses everywhere. Instead the
1830       numbers used are the UIDs which mkvmerge(1) calculates automatically
1831       (if the track is taken from a file format other than Matroska(TM)) or
1832       which are copied from the source file if the track's source file is a
1833       Matroska(TM) file. Therefore it is difficult to know which UIDs to use
1834       in the tag file before the file is handed over to mkvmerge(1).
1835
1836       mkvmerge(1) knows two options with which you can add tags to
1837       Matroska(TM) files: The --global-tags and the --tags options. The
1838       difference is that the former option, --global-tags, will make the tags
1839       apply to the complete file by removing any of those Targets elements
1840       mentioned above. The latter option, --tags, automatically inserts the
1841       UID that mkvmerge(1) generates for the tag specified with the TID part
1842       of the --tags option.
1843
1844   Example
1845       Let's say that you want to add tags to a video track read from an AVI.
1846       mkvmerge --identify file.avi tells you that the video track's ID (do
1847       not mix this ID with the UID!) is 0. So you create your tag file, leave
1848       out all Targets elements and call mkvmerge(1):
1849
1850           $ mkvmerge -o file.mkv --tags 0:tags.xml file.avi
1851
1852   Tag file format
1853       mkvmerge(1) supports a XML based tag file format. The format is very
1854       closely modeled after the Matroska(TM) specification[5]. Both the
1855       binary and the source distributions of MKVToolNix come with a sample
1856       file called example-tags-2.xml which simply lists all known tags and
1857       which can be used as a basis for real life tag files.
1858
1859       The basics are:
1860
1861       ·   The outermost element must be <Tags>.
1862
1863       ·   One logical tag is contained inside one pair of <Tag> XML tags.
1864
1865       ·   White spaces directly before and after tag contents are ignored.
1866
1867   Data types
1868       The new Matroska(TM) tagging system only knows two data types, a UTF-8
1869       string and a binary type. The first is used for the tag's name and the
1870       <String> element while the binary type is used for the <Binary>
1871       element.
1872
1873       As binary data itself would not fit into a XML file mkvmerge(1)
1874       supports two other methods of storing binary data. If the contents of a
1875       XML tag starts with '@' then the following text is treated as a file
1876       name. The corresponding file's content is copied into the Matroska(TM)
1877       element.
1878
1879       Otherwise the data is expected to be Base64 encoded. This is an
1880       encoding that transforms binary data into a limited set of ASCII
1881       characters and is used e.g. in email programs.  mkvextract(1) will
1882       output Base64 encoded data for binary elements.
1883
1884       The deprecated tagging system knows some more data types which can be
1885       found in the official Matroska(TM) tag specs. As mkvmerge(1) does not
1886       support this system anymore these types aren't described here.
1887
1888   Known tags for the XML file format
1889       The following lists the supported XML tags, their data types and, where
1890       appropriate, the valid range for their values:
1891
1892           Tags (master)
1893             Tag (master)
1894               Targets (master)
1895                 TargetTypeValue (unsigned integer)
1896                 TargetType (UTF-8 string)
1897                 TrackUID (unsigned integer)
1898                 EditionUID (unsigned integer)
1899                 ChapterUID (unsigned integer)
1900                 AttachmentUID (unsigned integer)
1901               Simple (master)
1902                 Simple (master)
1903                 Name (UTF-8 string)
1904                 TagLanguage (UTF-8 string)
1905                 DefaultLanguage (unsigned integer)
1906                 String (UTF-8 string)
1907                 Binary (binary)
1908

THE SEGMENT INFO XML FILES

1910       With a segment info XML file it is possible to set certain values in
1911       the "segment information" header field of a Matroska(TM) file. All of
1912       these values cannot be set via other command line options.
1913
1914       Other "segment information" header fields can be set via command line
1915       options but not via the XML file. This includes e.g. the --title and
1916       the --timestamp-scale options.
1917
1918       There are other elements that can be set neither via command line
1919       options nor via the XML files. These include the following elements:
1920       DateUTC (also known as the "muxing date"), MuxingApp, WritingApp and
1921       Duration. They're always set by mkvmerge(1) itself.
1922
1923       The following lists the supported XML tags, their data types and, where
1924       appropriate, the valid range for their values:
1925
1926           Info (master)
1927             SegmentUID (binary, valid range: length in bytes == 16)
1928             SegmentFilename (UTF-8 string)
1929             PreviousSegmentUID (binary, valid range: length in bytes == 16)
1930             PreviousSegmentFilename (UTF-8 string)
1931             NextSegmentUID (binary, valid range: length in bytes == 16)
1932             NextSegmentFilename (UTF-8 string)
1933             SegmentFamily (binary, valid range: length in bytes == 16)
1934             ChapterTranslate (master)
1935               ChapterTranslateEditionUID (unsigned integer)
1936               ChapterTranslateCodec (unsigned integer)
1937               ChapterTranslateID (binary)
1938

MATROSKA(TM) FILE LAYOUT

1940       The Matroska(TM) file layout is quite flexible.  mkvmerge(1) will
1941       render a file in a predefined way. The resulting file looks like this:
1942
1943       [EBML head] [segment {meta seek #1} [segment information] [track
1944       information] {attachments} {chapters} [cluster 1] {cluster 2} ...
1945       {cluster n} {cues} {meta seek #2} {tags}]
1946
1947       The elements in curly braces are optional and depend on the contents
1948       and options used. A couple of notes:
1949
1950       ·   meta seek #1 includes only a small number of level 1 elements, and
1951           only if they actually exist: attachments, chapters, cues, tags,
1952           meta seek #2. Older versions of mkvmerge(1) used to put the
1953           clusters into this meta seek element as well. Therefore some
1954           imprecise guessing was necessary to reserve enough space. It often
1955           failed. Now only the clusters are stored in meta seek #2, and meta
1956           seek #1 refers to the meta seek element #2.
1957
1958       ·   Attachment, chapter and tag elements are only present if they were
1959           added.
1960
1961       The shortest possible Matroska(TM) file would look like this:
1962
1963       [EBML head] [segment [segment information] [track information] [cluster
1964       1]]
1965
1966       This might be the case for audio-only files.
1967

EXTERNAL TIMESTAMP FILES

1969       mkvmerge(1) allows the user to chose the timestamps for a specific
1970       track himself. This can be used in order to create files with variable
1971       frame rate video or include gaps in audio. A frame in this case is the
1972       unit that mkvmerge(1) creates separately per Matroska(TM) block. For
1973       video this is exactly one frame, for audio this is one packet of the
1974       specific audio type. E.g. for AC-3 this would be a packet containing
1975       1536 samples.
1976
1977       Timestamp files that are used when tracks are appended to each other
1978       must only be specified for the first part in a chain of tracks. For
1979       example if you append two files, v1.avi and v2.avi, and want to use
1980       timestamps then your command line must look something like this:
1981
1982           $ mkvmerge ... --timestamps 0:my_timestamps.txt v1.avi +v2.avi
1983
1984       There are four formats that are recognized by mkvmerge(1). The first
1985       line always contains the version number. Empty lines, lines containing
1986       only whitespace and lines beginning with '#' are ignored.
1987
1988   Timestamp file format v1
1989       This format starts with the version line. The second line declares the
1990       default number of frames per second. All following lines contain three
1991       numbers separated by commas: the start frame (0 is the first frame),
1992       the end frame and the number of frames in this range. The FPS is a
1993       floating point number with the dot '.' as the decimal point. The ranges
1994       can contain gaps for which the default FPS is used. An example:
1995
1996           # timestamp format v1
1997           assume 27.930
1998           800,1000,25
1999           1500,1700,30
2000
2001   Timestamp file format v2
2002       In this format each line contains a timestamp for the corresponding
2003       frame. This timestamp must be given in millisecond precision. It can be
2004       a floating point number, but it doesn't have to be. You have to give at
2005       least as many timestamp lines as there are frames in the track. The
2006       timestamps in this file must be sorted. Example for 25fps:
2007
2008           # timestamp format v2
2009           0
2010           40
2011           80
2012
2013   Timestamp file format v3
2014       In this format each line contains a duration in seconds followed by an
2015       optional number of frames per second. Both can be floating point
2016       numbers. If the number of frames per second is not present the default
2017       one is used. For audio you should let the codec calculate the frame
2018       timestamps itself. For that you should be using 0.0 as the number of
2019       frames per second. You can also create gaps in the stream by using the
2020       'gap' keyword followed by the duration of the gap. Example for an audio
2021       file:
2022
2023           # timestamp format v3
2024           assume 0.0
2025           25.325
2026           7.530,38.236
2027           gap, 10.050
2028           2.000,38.236
2029
2030   Timestamp file format v4
2031       This format is identical to the v2 format. The only difference is that
2032       the timestamps do not have to be sorted. This format should almost
2033       never be used.
2034

EXIT CODES

2036       mkvmerge(1) exits with one of three exit codes:
2037
2038       ·   0 -- This exit codes means that muxing has completed successfully.
2039
2040       ·   1 -- In this case mkvmerge(1) has output at least one warning, but
2041           muxing did continue. A warning is prefixed with the text
2042           'Warning:'. Depending on the issues involved the resulting file
2043           might be ok or not. The user is urged to check both the warning and
2044           the resulting file.
2045
2046       ·   2 -- This exit code is used after an error occurred.  mkvmerge(1)
2047           aborts right after outputting the error message. Error messages
2048           range from wrong command line arguments over read/write errors to
2049           broken files.
2050

ENVIRONMENT VARIABLES

2052       mkvmerge(1) uses the default variables that determine the system's
2053       locale (e.g.  LANG and the LC_* family). Additional variables:
2054
2055       MKVMERGE_DEBUG, MKVTOOLNIX_DEBUG and its short form MTX_DEBUG
2056           The content is treated as if it had been passed via the --debug
2057           option.
2058
2059       MKVMERGE_ENGAGE, MKVTOOLNIX_ENGAGE and its short form MTX_ENGAGE
2060           The content is treated as if it had been passed via the --engage
2061           option.
2062

SEE ALSO

2064       mkvinfo(1), mkvextract(1), mkvpropedit(1), mkvtoolnix-gui(1)
2065

WWW

2067       The latest version can always be found at the MKVToolNix homepage[6].
2068

AUTHOR

2070       Moritz Bunkus <moritz@bunkus.org>
2071           Developer
2072

NOTES

2074        1. the Matroska(TM) website
2075           http://www.matroska.org/
2076
2077        2. the IANA homepage
2078           http://www.iana.org/assignments/media-types/
2079
2080        3. mkvmerge-identification-output-schema-v11.json
2081           https://mkvtoolnix.download/doc/mkvmerge-identification-output-schema-v11.json
2082
2083        4. RFC 7159
2084           https://tools.ietf.org/html/rfc7159
2085
2086        5. the Matroska(TM) specification
2087           http://matroska.org/technical/specs/index.html
2088
2089        6. the MKVToolNix homepage
2090           https://mkvtoolnix.download/
2091
2092
2093
2094MKVToolNix 34.0.0                 2019-05-18                       MKVMERGE(1)
Impressum