.TH MKVMERGE "1" "October 2003" "mkvmerge v0.7.2" "User Commands" .SH NAME mkvmerge \- Merge multimedia streams into a Matroska file .SH SYNOPSIS .B mkvmerge [\fIglobal options\fR] \-o \fIout\fR [\fIoptions1\fR] [[\fIoptions2\fR] ...] [@optionsfile] .SH DESCRIPTION .LP This program takes the input from several media files and joins their streams (all of them or just a selection) into a Matroska file. .UR http://www.matroska.org/ .UE .LP Global options: .TP \fB\-v\fR, \fB\-\-verbose\fR Increase verbosity. .TP \fB\-q\fR, \fB\-\-quiet\fR Suppress status output. .TP \fB\-o\fR, \fB\-\-output\fR \fIout\fR Write to the file '\fIout\fR'. .TP \fB\-\-title\fR <\fItitle\fR> Sets the general title for the output file, e.g. the movie name. .TP \fB\-\-global\-tags\fR <\fIfile\fR> Read global tags from the XML \fIfile\fR. See the section about tags below for details. .TP \fB\-\-command\-line\-charset\fR <\fBcharset\fR> Sets the charset to convert strings given on the command line from. It defaults to the charset given by system's current locale. This settings applies to arguments of the following options: \fB\-\-title\fR, \fB\-\-track\-name\fR and \fB\-\-attachment\-description\fR. .LP Chapter handling: (global options) .TP \fB\-\-chapter\-language\fR <\fBlanguage\fR> Sets the ISO639-2 language code that is written for each chapter entry. Applies only to simple chapter files. Defaults to "eng". See the section about chapters below for details. .TP \fB\-\-chapter\-charset\fR <\fBcharset\fR> Sets the charset that is used for the conversion to UTF-8 for simple chapter files. Defaults to the current system locale. See the section about chapters below for details. .TP \fB\-\-chapters <\fIfile\fR> Read chapter information from the \fIfile\fR. See the section about chapters below for details. .LP General output control (advanced global options): .TP \fB\-\-cluster\-length \fR \fIn[ms]\fR Put at most \fIn\fR data blocks into each cluster. If the number is postfixed with 'ms' then put at most \fIn\fR milliseconds of data into each cluster. The maximum length for a cluster is 65535ms. Programs will only be able to seek to clusters, so creating larger clusters may lead to imprecise seeking and/or processing. .TP \fB\-\-no\-cues\fR Tells \fBmkvmerge\fR not to create and write the cue data which can be compared to an index in an AVI. Matroska files can be played back without the cue data, but seeking will probably be imprecise and slower. Use this only if you're really desperate for space or for testing purposes. See also option \fB\-\-cues\fR which can be specified for each input file. .TP \fB\-\-no\-clusters\-in\-meta\-seek\fR Tells \fBmkvmerge\fR not to create a meta seek element at the end of the file containing all clusters. See also the section about \fBMATROSKA FILE LAYOUT\fR. .TP \fB\-\-disable\-lacing\fR Disables lacing for all tracks. This will increase the file's size, especially if there are many audio tracks. This option is not intended for everyday use. .TP \fB\-\-enable\-durations\fR Write durations for all blocks. This will increase file size and does not offer any additional value for players at the moment. .TP \fB\-\-enable\-timeslices\fR Write time slices for all blocks with more than one frame (laced blocks). This will increase file size and does not offer any additional value for players at the moment. .LP File splitting and linking (more global options): .TP \fB\-\-split\fR <\fId[k|m|g]\fR> or \fB\-\-split\fR <\fIHH:MM:SS\fR|\fIns\fR> Splits the output file after a given size or a given time. For splitting after a specific size the parameter \fId\fR may end with k, m or g to indicate that the size is in KB, MB or GB respectively. For time-based splitting use the form HH:MM:SS or add 's' to the number of seconds \fIn\fR after which the file should be split. .br For this splitting mode the output filename is treated differently than for the normal operation. It may contain a printf like expression '%d' including an optional field width, e.g. '%02d'. If it does then the current file number will be formatted appropriately and inserted at that point in the filename. If there is no such pattern then a pattern of '-%03d' is assumed right before the file's extension: '-o output.mkv' would result in 'output-001.mkv' and so on. If there's no extension then '-%03d' will be appended to the name. .TP \fB\-\-split\-max\-files\fR <\fIn\fR> Create at most \fIn\fR files, even if the last file will be longer or larger than indicated by \fB\-\-split\fR. .TP \fB\-\-dont\-link\fR Do not link files to one another when splitting the output file. See the section \fBFILE LINKING\fR below for details. .TP \fB\-\-link\-to\-previous\fR <\fIUID\fR> Links the first output file to the segment with the given \fIUID\fR. See the section \fBFILE LINKING\fR below for details. .TP \fB\-\-link\-to\-next\fR <\fIUID\fR> Links the last output file to the segment with the given \fIUID\fR. See the section \fBFILE LINKING\fR below for details. .LP Attachment support (more global options): .TP \fB\-\-attachment\-description\fR <\fIdescription\fR> Plain text description of the following attachment. Applies to the next \fB\-\-attach\-file\fR or \fB\-\-attach\-file\-once\fR command. .TP \fB\-\-attachment\-mime\-type\fR <\fIMIME type\fR> MIME type of the following attachment. Applies to the next \fB\-\-attach\-file\fR or \fB\-\-attach\-file\-once\fR command. A list of officially recognized MIME types can be found e.g. at .UR ftp://ftp.isi.edu/in-notes/iana/assignments/media-types/media-types The MIME type is mandatory for an attachment. .TP \fB\-\-attach\-file\fR <\fIfile name\fR> .TP \fB\-\-attach\-file\-once\fR <\fIfile name\fR> Creates a file attachment inside the Matroska file. The MIME type must have been set before this option can used. The difference between the two forms is that during splitting the files attached with \fB\-\-attach\-file\fR are attached to all output files while the ones attached with \fB\-\-attach\-file\-once\fR are only attached to the first file created. If splitting is not used then both do the same. .br \fBmkvextract\fR can be used to extract attached files from a Matroska file. .br \fBNote:\fR If an input file is a Matroska file then the attached files will not be copied to the output file(s). This may change in the future. .LP Options that can be used for each input file: .TP \fB\-a\fR, \fB\-\-atracks\fR <\fIn\fR,\fIm\fR,...> Copy the audio tracks \fIn\fR, \fIm\fR etc. The numbers are track IDs which can be obtained with the \fB\-\-identify\fR switch. They're \fBnot\fR simply the track numbers (see section \fBTRACK IDS\fR). Default: copy all audio tracks. .TP \fB\-d\fR, \fB\-\-vtracks\fR <\fIn\fR,\fIm\fR,...> Copy the video tracks \fIn\fR, \fIm\fR etc. The numbers are track IDs which can be obtained with the \fB\-\-identify\fR switch (see section \fBTRACK IDS\fR). They're \fBnot\fR simply the track numbers. Default: copy all video tracks. .TP \fB\-s\fR, \fB\-\-stracks\fR <\fIn\fR,\fIm\fR,...> Copy the subtitle tracks \fIn\fR, \fIm\fR etc. The numbers are track IDs which can be obtained with the \fB\-\-identify\fR switch (see section \fBTRACK IDS\fR). They're \fBnot\fR simply the track numbers. Default: copy all subtitle tracks. .TP \fB\-A\fR, \fB\-\-noaudio\fR Don't copy any audio track from this file. .TP \fB\-D\fR, \fB\-\-novideo\fR Don't copy any video track from this file. .TP \fB\-S\fR, \fB\-\-nosubs\fR Don't copy any subtitle track from this file. .TP \fB\-\-no\-chapters\fR If the source is a Matroska file then don't copy chapters from it. .TP \fB\-\-no\-attachments\fR If the source is a Matroska file then don't copy attachments from it. .TP \fB\-\-no\-tags\fR If the source is a Matroska file then don't copy tags from it. .TP \fB\-y\fR, \fB\-\-sync\fR <\fITID\fR:\fId\fR[,\fIo\fR[/\fIp\fR]]> Synchronize manually, delay the audio track with the id \fITID\fR by \fId\fR ms. The track IDs are the same as the ones given with \fB\-\-identify\fR (see section \fBTRACK IDS\fR). .br \fId\fR > 0: Pad with silent samples. .br \fId\fR < 0: Remove samples from the beginning. .br \fIo\fR/\fIp\fR: adjust the timestamps by \fIo\fR/\fIp\fR to fix linear drifts. \fIp\fR defaults to 1000 if omitted. Both \fIo\fR and \fIp\fR can be floating point numbers. .br Defaults: no manual sync correction (which is the same as \fId\fR = 0 and \fIo\fR/\fIp\fR = 1.0). .br This option can be used multiple times for an input file applying to several tracks by selecting different track IDs each time. .TP \fB\-\-cues\fR <\fITID\fR:\fInone\fR|\fIiframes\fR|\fIall\fR> Controls for which tracks cue (index) entries are created for the given track (see section \fBTRACK IDS\fR). \fInone\fR inhibits the creation of cue entries. For \fIiframes\fR only blocks with no backward or forward references ( = I frames in video tracks) are put into the cue sheet. \fIall\fR causes \fBmkvmerge\fR to create cue entries for all blocks which will make the file very big. .br The default is \fIiframes\fR for video tracks and \fInone\fR for all others. See also option \fB\-\-no\-cues\fR which inhibits the creation of cue entries regardless of the \fB\-\-cues\fR options used. .br This option can be used multiple times for an input file applying to several tracks by selecting different track IDs each time. .TP \fB\-\-default\-track\fR <\fITID\fR> Sets the 'default' flag for the given track (see section \fBTRACK IDS\fR). If the user does not explicitly select a track himself then the player should prefer the track that has his 'default' flag set. Only one track of each kind (audio, video, subtitles) can have his 'default' flag set. .br This option can be used multiple times for an input file applying to several tracks by selecting different track IDs each time. .TP \fB\-\-track\-name\fR <\fITID\fR:\fIname\fR> Sets the track name for the given track (see section \fBTRACK IDS\fR) to \fIname\fR. .TP \fB\-\-language\fR <\fITID\fR:\fIlanguage\fR> Sets the language for the given track (see section \fBTRACK IDS\fR). Only ISO639-2 codes are allowed. All languages including their ISO639-2 codes can be listed with the \fB\-\-list\-languages\fR option. .br This option can be used multiple times for an input file applying to several tracks by selecting different track IDs each time. .TP \fB\-t\fR, \fB\-\-tags\fR <\fITID\fR:\fIfile\fR> Read tags for the track with the number \fITID\fR from the \fIfile\fR. See the section about tags below for details. .TP \fB\-\-aac\-is\-sbr\fR <\fITID\fR> Tells \fBmkvmerge\fR that the track with the ID \fITID\fR is SBR AAC (also known as HE-AAC or AAC+). This options is needed if a) the source file is an AAC file (NOT for a Matroska file) and b) the AAC file contains SBR AAC data. The reason for this switch is that it is technically impossible to automatically tell normal AAC data from SBR AAC data without decoding a complete AAC frame. As there are several patent issues with AAC decoders I won't implement this decoding stage. So for SBR AAC files this switch is mandatory. The resulting file might not play back correctly or even not at all if the switch was omitted. .br If the source file is a Matroska file then the CodecID should be enough to detect SBR AAC. However, if the CodecID is wrong then this switch can be used to correct that. .TP \fB\-\-timecodes\fR <\fITID\fR:\fIfilename\fR> Read the timecodes to be used for the specific track ID from \fIfilename\fR. These timecodes forcefully override the timecodes that \fBmkvmerge\fR normally calculates. A frame in this case is the unit that \fBmkvmerge\fR creates separately per Matroska block. For video this is exactly one frame, for audio this is one packet of the specific audio type. E.g. for AC3 this would be a packet containing 1536 samples. However, it should only be used for video tracks. .br The format recognized looks like this: First line is the version string: .br \fB# timecode format v1\fR .br Second line gives the default number of frames per second: .br \fBassume 27.930\fR .br All following lines contain three numbers separated by commas: the start frame (0 is the first frame), the end frame and the number of frames in this range. The FPS is a floating point number with the dot '.' as the decimal point. The ranges can contain gaps for which the default FPS is used. Example: .br \fB800,1000,25\fR .br \fB1500,1700,30\fR .br Empty lines, lines containing only whitespace and lines beginning with '#' are ignored. .LP Options that only apply to video tracks: .TP \fB\-f\fR, \fB\-\-fourcc\fR <\fIFourCC\fR> Forces the FourCC to the specified value. Works only for video tracks. .TP \fB\-\-aspect\-ratio\fR <\fIar\fR|\fIw\fR/\fIh\fR> Sets the aspect ratio for the track. The ratio can be given either as a floating point number or as 'width/height', e.g. 16/9. .LP Options that only apply to text subtitle tracks: .TP \fB\-\-sub\-charset\fR <\fITID\fR:\fIcharset\fR> Sets the charset for the conversion to UTF-8 for UTF-8 subtitles for the given track ID. If not specified the charset will be derived from the current locale settings. Note that a charset is not needed for subtitles read from Matroska files as these are always stored in UTF-8. .br This option can be used multiple times for an input file applying to several tracks by selecting different track IDs each time. .LP Options that only apply to VobSub subtitle tracks: .TP \fB\-\-compression\fR <\fITID\fR:\fImethod\fR> Selects the compression method to be used for the VobSub track. Note that the player also has to support this method! Valid values are 'none' and 'zlib'. The default is 'zlib' compression. .LP Other options: .TP \fB\-i\fR, \fB\-\-identify\fR <\fIfilename\fR> Will let mkvmerge probe the single file and report its type, the tracks contained in the file and their track IDs. If this option is used then the only other option allowed is the filename. .TP \fB\-l\fR, \fB\-\-list\-types\fR Lists supported input file types. .TP \fB\-\-list\-languages\fR Lists all languages and their ISO639-2 code which can be used with the \fB\-\-language\fR option. .TP \fB\-h\fR, \fB\-\-help\fR Show usage information. .TP \fB\-V\fR, \fB\-\-version\fR Show version information. .TP \fB@\fR\fIoptionsfile\fR Reads additional command line arguments from the file \fIoptionsfile\fR. Lines whose first non-whitespace character is a hash mark (#) are treated as comments and ignored. White spaces at the start and end of a line will be stripped. If a space is encountered and the line starts with '\-' then the line will be split into exactly two arguments - the string before the space and the string after it. There is no meta character escaping. .br The command line \fBmkvmerge \-o "my file.mkv" -A "a movie.avi" sound.ogg\fR could be converted into the following option file: .br # Write to the file "my file.mkv". .br \-o my file.mkv .br # Only take the video from "a movie.avi". .br \-A a movie.avi .br sound.ogg .SH USAGE .LP For each file the user can select which tracks \fBmkvmerge\fR should take. They are all put into the file specified with '-o'. A list of known (and supported) source formats can be obtained with the '-l' option. .SH EXAMPLES .LP Let's assume you have a file called \fIMyMovie.avi\fP and the audio track in a separate file, e.g. \fIMyMovie.wav\fP. First you want to encode the audio to OGG: .LP $ \fBoggenc -q4 -oMyMovie.ogg MyMovie.wav\fP .LP After a couple of minutes you can join video and audio: .LP $ \fBmkvmerge -o MyMovie-with-sound.mkv MyMovie.avi MyMovie.ogg\fP .LP If your AVI already contains an audio track then it will be copied as well (if \fBmkvmerge\fR supports the audio format). To avoid that simply do .LP $ \fBmkvmerge -o MyMovie-with-sound.mkv -A MyMovie.avi MyMovie.ogg\fP .LP After some minutes of consideration you rip another audio track, e.g. the director's comments or another language to \fIMyMovie-add-audio.wav\fP. Encode it again and join it up with the other file: .LP $ \fBoggenc -q4 -oMyMovie-add-audio.ogg MyMovie-add-audio.wav\fP .br $ \fBmkvmerge -o MM-complete.mkv MyMovie-with-sound.mkv MyMovie-add-audio.ogg\fP .LP The same result can be achieved with .LP $ \fBmkvmerge -o MM-complete.mkv -A MyMovie.avi MyMovie.ogg \\\fP .br \fBMyMovie-add-audio.ogg\fP .LP Now fire up mplayer and enjoy. If you have multiple audio tracks (or even video tracks) then you can tell mplayer which track to play with the \&'\fB-vid\fP' and '\fB-aid\fP' parameters. These are 0-based and do not distinguish between video and audio. .LP If you need an audio track synchronized you can do that easily. First find out which track ID the Vorbis track has with .LP $ \fBmkvmerge --identify outofsync.ogg\fP .LP Now you can use that ID in the following command line: .LP $ \fBmkvmerge -o goodsync.mkv -A source.avi -y 12345:200 outofsync.ogg\fP .LP This would add 200ms of silence at the beginning of the audio track with the ID 12345 taken from \fIoutofsync.ogg\fP. .LP Some movies start synced correctly but slowly drift out of sync. For these kind of movies you can specify a delay factor that is applied to all timestamps - no data is added or removed. So if you make that factor too big or too small you'll get bad results. An example is that an episode I transcoded was 0.2 seconds out of sync at the end of the movie which was 77340 frames long. At 29.97fps 0.2 seconds correspond to approx. 6 frames. So I did .LP $ \fBmkvmerge -o goodsync.mkv -y 23456:0,77346/77340 outofsync.mkv\fP .LP The result was fine. .LP The sync options can also be used for subtitles in the same manner. .LP For text subtitles you can either use some Windows software (like \fBSubRipper\fR) or the \fBsubrip\fR package found in \fBtranscode(1)\fR's sources (in \fBcontrib/subrip\fR). The general process is: .TP 1. extract a raw subtitle stream from the source: .br $ \fBtccat -i /path/to/copied/dvd/ -T 1 -L | \\ .br tcextract -x ps1 -t vob -a 0x20 | \\ .br subtitle2pgm -o mymovie\fP .TP 2. convert the resulting PGM images to text with \fBgocr\fP: .br $ \fBpgm2txt mymovie\fP .TP 3. spell-check the resulting text files: .br $ \fBispell -d american *txt\fP .TP 4. convert the text files to a SRT file: .br $ \fBsrttool -s -w -i mymovie.srtx -o mymovie.srt\fP .LP The resulting file can be used as another input file for \fBmkvmerge\fR: .LP $ \fBmkvmerge -o mymovie.mkv mymovie.avi mymovie.srt\fP .LP If you want to specify the language for a given track then this is easily done. First find out the ISO639-2 code for your language. \fBmkvmerge\fR can list all of those codes for you: .LP $ \fBmkvmerge --list-languages\fR .LP Search the list for the languages you need. Let's assume you have put two audio tracks into a Matroska file and want to set their language codes and that their track IDs are 2 and 3. This can be done with .LP $ \fBmkvmerge -o with-lang-codes.mkv --language 2:ger --language 3:dut without-lang-codes.mkv\fR .LP As you can see you can use the \fB--language\fR switch multiple times. .LP Maybe you'd also like to have the player use the Dutch language as the default language. You also have extra subtitles, e.g. in English and French, and want to have the player display the French ones by default. This can be done with .LP $ \fBmkvmerge -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\fR .LP If you do not see the language or default track flags that you've specified in \fBmkvinfo\fR's output then please read the section about \fBDEFAULT VALUES\fR. .SH TRACK IDS .LP Some of the options for \fBmkvmerge\fR need a track ID to specify which track they should be applied to. Those track IDs are printed by the readers when demuxing the current input file, or if \fBmkvmerge\fR is called with the \fB\-\-identify\fR option. Track IDs are assigned like this: .TP * AVI files: The video track has the ID 0. All audio tracks get the ID 1, 2... .TP * AAC, AC3, MP3, SRT and WAV files: The one 'track' in that file gets the ID 0. .TP * Ogg/OGM files: The track's ID is its serial number as given in the Ogg stream header page. .TP * Matroska files: The track's ID is the track number as reported by \fBmkvinfo\fR or \fBmkvmerge \-\-identify\fR. It is \fBnot\fR the track UID. .LP The special track ID '-1' is a wild card and applies the given switch to all tracks that are read from an input file. This was the behaviour of these switches prior to version 0.4.4. .LP The options that use the track IDs are: \fB\-\-atracks\fR, \fB\-\-vtracks\fR, \fB\-\-stracks\fR, \fB\-\-sync\fR, \fB\-\-default-track\fR, \fB\-\-cues\fR and \fB\-\-language\fR. .SH SUBTITLES .LP There are several text subtitle formats that can be embedded into Matroska. At the moment \fBmkvmerge\fR supports only text subtitle formats. These subtitles must be recoded to UTF-8 so that they can be displayed correctly by a player. .LP \fBmkvmerge\fR does this conversion automatically based on the system's current locale. If the subtitle charset is not the same as the system's current charset then the user can use \fB\-\-sub\-charset\fR switch. If the subtitles are already encoded in UTF-8 then you can use \fB\-\-sub\-charset UTF\-8\fR. .LP The following subtitle formats are supported at the moment: .TP * Subtitle Ripper (SRT) files .TP * Substation Alpha (SSA) / Advanced Substation Alpha scripts (ASS) .SH FILE LINKING .LP Matroska supports file linking which simply says that a specific file is the predecessor or successor of the current file. To be precise, it's not really the files that are linked but the Matroska segments. As most files will probably only contain one Matroska segment I simply say 'file linking' although 'segment linking' would be more appropriate. .LP Each segment is identified by a unique 128 bit wide segment UID. This UID is automatically generated by \fBmkvmerge\fR. The linking is done primarily via putting the segment UIDs of the previous/next file into the segment header information. \fBmkvinfo(1)\fR prints these UIDs if it finds them. .LP If a file is split into several smaller ones and linking is used then the timecodes will not start at 0 again but will continue where the last file has left off. This way the absolute time is kept even if the previous files are not available (e.g. when streaming). If no linking is used then the timecodes should start at 0 for each file. By default \fBmkvmerge\fR uses file linking. If you don't want that you can turn it off with the \'\fB\-\-dont\-link\fR\' option. This option is only useful if splitting is activated as well. .LP Regardless of whether splitting is active or not the user can tell \fBmkvmerge\fR to link the produced files to specific UIDs. This is achieved with the options '\fB\-\-link\-to\-previous\fR' and '\fB\-\-link\-to\-next\fR'. These options accept a segment UID in the format that \fBmkvinfo(1)\fR outputs: 16 hexadecimal numbers between 0x00 and 0xff prefixed with '0x' each, e.g. \fI0x41 0xda 0x73 0x66 0xd9 0xcf 0xb2 0x1e 0xae 0x78 0xeb 0xb4 0x5e 0xca 0xb3 0x93\fR. Alternatively a shorter form can be used: 16 hexadecimal numbers between 0x00 and 0xff without the '0x' prefixes and without the spaces, e.g. \fI41da7366d9cfb21eae78ebb45ecab393\fR. .LP If splitting is used then the first file is linked to the UID given with \'\fB\-\-link\-to\-previous\fR\' and the last file is linked to the UID given with \'\fB\-\-link\-to\-next\fR\'. If splitting is not used then the one output file will be linked to both of the two UIDs. .SH DEFAULT VALUES .LP The Matroska specs say that some elements have a default value. Usually an element is not written to the file if its value is equal to its default value in order to save space. The elements that the user might miss in \fBmkvinfo\fR's output are the \fIlanguage\fR and the \fIdefault track flag\fR. The default value for the \fIlanguage\fR is English (\fIeng\fR), and the default value for the \fIdefault track flag\fR is \fItrue\fR. Therefore if you used \fB--language 0:eng\fR for a track then it will not show up in \fBmkvinfo\fR's output. .SH ATTACHMENTS .LP Maybe you also want to keep some photos along with your Matroska file, or you're using SSA subtitles and need a special TrueType font that's really rare. In these cases you can attach those files to the Matroska file. They will not be just appended to the file but embedded in it. A player can then show those files (the 'photos' case) or use them to render the subtitles (the 'TrueType fonts' case). .LP Here's an example how to attach a photo and a TrueType font to the output file: .br $ \fBmkvmerge -o output.mkv -A video.avi sound.ogg \-\-attachment\-description "Me and the band behind the stage in a small get-together" \-\-attachment\-mime\-type image/jpeg \-\-attach\-file me_and_the_band.jpg \-\-attachment\-description "The real rare and unbelievably good looking font" \-\-attachment\-type application/octet\-stream \-\-attach\-file really_cool_font.ttf .SH CHAPTERS .LP The Matroska chapter system is more powerful than the old known system used by OGMs. The full specs can be found at .UR http://cvs.corecodec.org/cgi-bin/viewcvs.cgi/*checkout*/matroska/doc/website/technical/specs/chapters/index.html .LP \fBmkvmerge\fR supports two kinds of chapter files as its input. The first format, called 'simple chapter format', is the same format that the OGM tools expect. The second format is a XML based chapter format which supports all of Matroska's chapter functionality. .LP \fBThe simple chapter format\fR It looks basically like this: .LP CHAPTER01=00:00:00.000 .br CHAPTER01NAME=Intro .br CHAPTER02=00:02:30.000 .br CHAPTER02NAME=Baby prepares to rock .br CHAPTER03=00:02:42.300 .br CHAPTER03NAME=Baby rocks the house .LP \fBmkvmerge\fR will transform every pair or lines (CHAPTERxx and CHAPTERxxNAME) into one Matroska \fIChapterAtom\fR. It does not set any \fIChapterTrackNumber\fR which means that the chapters all apply to all tracks in the file. .LP The charset used in the file is assumed to be the same charset that the current system's locale returns. If this is not the case then the swith \fI\-\-chapter\-charset\fR should be used. If the file contains a valid BOM (byte order marker) then all UTF styles are converted automatically. In this case \fI\-\-chapter\-charset\fR is simply ignored. You can use \fBmkvinfo\fR or \fBmkvextract\fR to verify that the chapter names have been converted properly. .LP \fBThe XML based chapter format\fR The XML based chapter format looks like this: .LP .br .br .br .br .br 00:00:30.000 .br 00:01:20.000 .br .br A short chapter .br eng .br .br .br 00:00:46.000 .br 00:01:10.000 .br .br A part of that short chapter .br eng .br .br .br .br .br With this format three things are possible that are not possible with the simple chapter format: 1) The timestamp for the end of the chapter can be set, 2) chapters can be nested, 3) the language and country can be set. .LP The mkvtoolnix distribution contains some sample files in the \fIdoc\fR subdirectory which can be used as a basis. .LP \fBGeneral notes\fR .LP When splitting files \fBmkvmerge\fR will correctly adjust the chapters as well. This means that each file only includes the chapter entries that apply to it, and that the timecodes will be offset to match the new timecodes of each output file. .LP \fBmkvmerge\fR is able to copy chapters from Matroska source files unless this is explicitely disabled with the \fI\-\-no\-chapters\fR option. At the moment \fBmkvmerge\fR is limited to one 'buch of chapters' globally. This means that only the first chapter section found in all source files is used. If the user specified chapters on the command line then these take precedence over any chapters found in source files. \fBmkvmerge\fR does not merge chapters. This must be done manually by using \fBmkvextract\fR to extract the chapter information and editing the resulting files. .LP One shortcoming is that \fBmkvmerge\fR cannot parse chapter information found in OGM files. .SH TAGS .LP \fBIntroduction\fR Matroska supports an extensive set of tags. Unlike other containers/formats it does not rely on a free form specification of the type \fIKEY=VALUE\fR but provides a big number of tags that are a subset of several well-known tagging schemes unified in one big tag tree. The full specification can be found at .UR http://cvs.corecodec.org/cgi-bin/viewcvs.cgi/*checkout*/matroska/doc/website/technical/specs/tagging/index.html .LP \fBScope of the tags\fR Matroska tags do not automatically apply to the complete file. They may, however, apply to different parts of the file: to one or more tracks, to one or more chapters, or even to a combination of both. The aforementioned URL gives more details about this fact. .LP One important fact is that tags are linked to tracks or chapters with the \fITargets\fR Matroska tag element, and that the UIDs used for this linking are NOT the track IDs \fBmkvmerge\fR uses everywhere. Instead the numbers used are the UIDs which \fBmkvmerge\fR calculates automatically (if the track is taken from a file format other than Matroska) or which are copied from the source file if the track's source file is a Matroska file. Therefore it is difficult to know which UIDs to use in the tag file before the file is handed over to \fBmkvmerge\fR. .LP \fBmkvmerge\fR knows two options with which you can add tags to Matroska files: The \fB\-\-global\-tags\fR and the \fB\-\-tags\fR options. The difference is that the former option, \fB\-\-global\-tags\fR, will not modify the tags read from the file in any way, while the latter option, \fB\-\-tags\fR, automatically inserts the UID that \fBmkvmerge\fR generates for the tag specified with the \fITID\fR part of the \fB\-\-tags\fR option. Therefore the tag file used with \fB\-\-tags\fR does not need any \fITargets\fR element (in fact they are deleted if the tag file contained any), while the one used with \fB\-\-global\-tags\fR does need them. .LP \fBExample\fR Let's say that you want to add tags to a video track read from an AVI. \fBmkvmerge -i file.avi\fR tells you that the video track's ID (do not mix this ID with the UID!) is 0. So you create your tag file, leave out any \fITargets\fR element and call \fBmkvmerge\fR: .br $ \fBmkvmerge -o file.mkv --tags 0:tags.xml file.avi\fR .LP \fBTag file format\fR \fBmkvmerge\fR supports a XML based tag file format. The format is very easy and closely connected to the Matroska tag specs found at the URL mentioned above. Both the binary and the source \fBmkvtoolnix\fR distributions come with a sample file called \fImatroska-tags.xml\fR which simply lists all known tags and which can be used as a basis for real life tag files. .LP The basics are: .TP * The outermost element must be \fB\fR. .TP * One logical tag is contained inside one pair of \fB\fR XML tags. .TP * White spaces directly before and after tag contents are ignored. .LP \fBData types\fR The data type expected can be found in the official Matroska tag specs. The types \fIinteger\fR, \fIunsigned integer\fR, \fIfloat\fR, \fIstring\fR and \fIUTF-8 string\fR look just like you expect them to: \fI4254\fR, \fI-2\fR, \fI5.0\fR, \fIhello world\fR and \fIhello world\fR. Two data types are treadet differently, however: \fIbinary\fR and \fIdate\fR. .LP As binary data itself would not fit into a XML file \fBmkvmerge\fR supports two other methods of storing binary data. If the contents of a XML tag starts with '@' then the following text is treated as a \fIfile name\fR. The corresponding file's content is copied into the Matroska element. .LP Otherwise the data is expected to be \fIBase64\fR encoded. This is an encoding that transforms binary data into a limited set of ASCII characters and is used e.g. in email programs. \fBmkvtoolnix\fR comes with a utility, \fBbase64tool\fR, that can be used to encode to and decode from Base64. \fBmkvextract\fR will output Base64 encoded data for binary elements. .LP The date format used by both \fBmkvmerge\fR when reading XML tag files and by \fBmkvextract\fR when outputting XML tag data is the \fIISO-8601\fR format. It has the following structure: \fIYYYY\fR-\fIMM\fR-\fIDD\fRT\fIHH\fR:\fIMM\fR:\fISS\fR\fI+TZTZ\fR. \fIYYYY\fR is the year (four digist long), \fIMM\fR the month (two digits long starting with 01), \fIDD\fR the day of the month (two digits long starting with 01), \fIHH\fR the hour of the day (two digits long, range 00 - 23), \fIMM\fR the minute (two digits long, range 00 - 59), \fISS\fR the seconds (two digits long, range 00 - 59). \fI+TZTZ\fR is the time zone, e.g. +0100 or -0200. An example would be 2003-07-30T19:10:16+0200. .SH MATROSKA FILE LAYOUT .LP The Matroska file layout is quite flexible. \fBmkvmerge\fR will render a file in a predefined way. The resulting file looks like this: .LP [EBML head] [segment {meta seek #1} {attachments} {chapters} [segment information] [track information] [cluster 1] {cluster 2} ... {cluster n} {cues} {meta seek #2} {tags}] .LP The elements in curly braces are optional and depend on the contents and options used. Some notes: .TP * meta seek #1 includes only a small number of level 1 elements, and only if they actually exist: attachments, chapters, cues, tags, meta seek #2. Older versions of \fBmkvmerge\fR used to put the clusters into this meta seek element as well. Therefore some imprecise guessing was necessary to reserve enough space. It often failed. Now only the clusters are stored in meta seek #2, and meta seek #1 refers to the meta seek element #2. .TP * Attachment, chapter and tag elements are only present if they were added. .LP The shortest possible Matroska file would look like this: .LP [EBML head] [segment [segment information] [track information] [cluster 1]] .LP This might be the case for audio-only files. .SH NOTES .LP What works: .TP * AVI as the video and audio source (only raw PCM, MP3 and AC3 audio tracks at the moment) .TP * OGG as the source for video, audio (Vorbis, raw PCM, MP3 and AC3 audio) and text streams (subtitles). .TP * WAV as the audio source .TP * AAC audio files (only those with ADTS headers before each packet) .TP * AC3 audio files .TP * DTS audio files .TP * MP3 audio files .TP * RealVideo and RealAudio from RealMedia files .TP * Track selection .TP * Manual audio synchronization by adding silence/removing packets for Vorbis audio and for text streams by adjusting the starting point and duration. .TP * Manual audio synchronization for AAC, AC3, DTS and MP3 audio by duplicating or removing packets at the beginning. .TP * Text subtitles can be read from SRT (SubRipper / subrip) files or taken from other OGM files. .TP * SSA/ASS subtitles from SSA/ASS files .TP * Simple chapters. .TP * Full tags support. .LP What not works: .TP * Manual audio synchronization for PCM sound (who needs it anyway?) .SH AUTHOR .I mkvmerge was written by Moritz Bunkus . .SH SEE ALSO .BR mkvinfo (1), .BR mkvextract (1) .SH WWW The newest version can always be found at .UR http://www.bunkus.org/videotools/mkvtoolnix/ .UE