mkvmerge1">
mkvinfo1">
mkvextract1">
mkvpropedit1">
mkvtoolnix-gui1">
Matroska">
OggVorbis">
XML">
]>
&product;&date;DeveloperMoritzBunkusmoritz@bunkus.org&product;1&version;&date;MKVToolNixUser Commands&product;extract tracks from &matroska; files into other filesSynopsismkvextractmodesource-filenameoptionsextraction-specDescription
This program extracts specific parts from a &matroska; file to other useful formats. The first argument, , tells
&mkvextract; what to extract. Currently supported is the extraction of tracks, tags, attachments, chapters, CUE sheets, timecodes and cues. The second argument is the name of the source file. It must be a
&matroska; file. All following arguments are options and extraction specifications; both of which depend on the selected mode.
Common options
The following options are available in all modes and only described once in this section.
,
Sets the parse mode to 'full'. The default mode does not parse the whole file but uses the meta seek elements for locating the
required elements of a source file. In 99% of all cases this is enough. But for files that do not contain meta seek elements or which
are damaged the user might have to use this mode. A full scan of a file can take a couple of minutes while a fast scan only takes
seconds.
character-set
Sets the character set to convert strings given on the command line from. It defaults to the character set given by system's current
locale.
character-set
Sets the character set to which strings are converted that are to be output. It defaults to the character set given by system's
current locale.
, file-name
Writes all messages to the file file-name instead of to the console. While this can be done easily with
output redirection there are cases in which this option is needed: when the terminal reinterprets the output before writing it to a
file. The character set set with is honored.
code
Forces the translations for the language code to be used (e.g. 'de_DE' for the German
translations). Entering 'list' as the code will cause the program to output a list of
available translations.
topic
Turn on debugging for a specific feature. This option is only useful for developers.
feature
Turn on experimental features. A list of available features can be requested with mkvextract --engage list. These
features are not meant to be used in normal situations.
Turns on GUI mode. In this mode specially-formatted lines may be output that can tell a controlling GUI what's happening. These
messages follow the format '#GUI#message'. The message may be followed by key/value pairs as in
'#GUI#message#key1=value1#key2=value2…'. Neither the messages nor the keys are ever translated and always output
in English.
,
Be verbose and show all the important &matroska; elements as they're read.
,
Show usage information and exit.
,
Show version information and exit.
Checks online for new releases by downloading the URL http://mkvtoolnix-releases.bunkus.org/latest-release.xml. Four
lines will be output in key=value style: the URL from where the information was retrieved (key
version_check_url), the currently running version (key running_version), the latest release's
version (key available_version) and the download URL (key download_url).
Afterwards the program exists with an exit code of 0 if no newer release is available, with 1 if a newer release is available and with
2 if an error occured (e.g. if the update information could not be retrieved).
This option is only available if the program was built with support for libcurl.
options-file.json
Reads additional command line arguments from the file options-file. For a full explanation on the supported
formats for such files see the section called "Option files" in the &mkvmerge; man page.
Track extraction mode
Syntax: mkvextract source-filenameoptionsTID1:dest-filename1TID2:dest-filename2 ...
The following command line options are available for each track in the 'tracks' extraction mode. They have to appear
in front of the track specification (see below) they should be applied to.
character-set
Sets the character set to convert the next text subtitle track to. Only valid if the
next track ID targets a text subtitle track. It defaults to UTF-8.
level
Keep only the BlockAdditions up to this level. The default is to keep all levels. This option only affects certain kinds of codecs
like WAVPACK4.
Causes &mkvextract; to extract a CUE sheet from the chapter information and tag data for the following track into a
file whose name is the track's output name with '.cue' appended to it.
Extracts the raw data into a file without any container data around it. Unlike the flag this flag does not cause the contents of the
CodecPrivate element to be written to the file. This mode works with all CodecIDs, even
the ones that &mkvextract; doesn't support otherwise, but the resulting files might not be usable.
Extracts the raw data into a file without any container data around it. The contents of the CodecPrivate
element will be written to the file first if the track contains such a header element. This mode works with all
CodecIDs, even the ones that &mkvextract; doesn't support otherwise, but the resulting files might not be
usable.
TID:outname
Causes extraction of the track with the ID TID into the file
outname if such a track exists in the source file. This option can be
given multiple times. The track IDs are the same as the ones output by
&mkvmerge;'s option.
Each output name should be used only once. The exception are RealAudio and RealVideo tracks. If you use the same name for different
tracks then those tracks will be saved in the same file. Example:
$ mkvextract tracks input.mkv 1:output-two-tracks.rm 2:output-two-tracks.rmTags extraction mode
Syntax: mkvextract source-filenameoptions
The extracted tags are written to the console unless the output is redirected (see the section about output redirection for details).
Attachments extraction mode
Syntax: mkvextract source-filenameoptionsAID1:outname1AID2:outname2 ...AID:outname
Causes extraction of the attachment with the ID AID into the file outname if such an
attachment exists in the source file. If the outname is left empty then the name of the attachment inside the
source &matroska; file is used instead. This option can be given multiple times. The attachment IDs are the same as the ones output
by &mkvmerge;'s option.
Chapters extraction mode
Syntax: mkvextract source-filenameoptions,
Exports the chapter information in the simple format used in the OGM tools
(CHAPTER01=..., CHAPTER01NAME=...). In this mode some information has to be
discarded. Default is to output the chapters in &xml; format.
language
If the simple format is enabled then &mkvextract; will only output a single entry for each chapter atom encountered even if a chapter atom contains more than one chapter name.
By default &mkvextract; will use the first chapter name found for each atom regardless of its language.
Using this option allows the user to determine which chapter names are output if atoms contain more than one chapter name.
The language parameter must be an ISO 639-1 or ISO 639-2 code.
The extracted chapters are written to the console unless the output is redirected (see the section about output redirection for details).
Cue sheet extraction mode
Syntax: mkvextract source-filenameoptions
The extracted cue sheet is written to the console unless the output is redirected (see the section about output redirection for details).
Timecode extraction mode
Syntax: mkvextract source-filenameoptionsTID1:dest-filename1TID2:dest-filename2 ...
The extracted timecodes are written to the console unless the output is redirected (see the section about output redirection for details).
TID:outname
Causes extraction of the timecodes for the track with the ID TID into the file outname
if such a track exists in the source file. This option can be given multiple times. The track IDs are the same as the ones output by
&mkvmerge;'s option.
Example:
$ mkvextract timecodes_v2 input.mkv 1:tc-track1.txt 2:tc-track2.txtCues extraction mode
Syntax: mkvextract source-filenameoptionsTID1:dest-filename1TID2:dest-filename2 ...TID:dest-filename
Causes extraction of the cues for the track with the ID TID into the file outname
if such a track exists in the source file. This option can be given multiple times. The track IDs are the same as the ones output by
&mkvmerge;'s option and not the numbers contained in the CueTrack element.
The format output is a simple text format: one line per CuePoint element with key=value
pairs. If an optional element is not present in a CuePoint (e.g. CueDuration) then a dash
will be output as the value.
Example:
timecode=00:00:13.305000000 duration=- cluster_position=757741 relative_position=11The possible keys are:timecodeThe cue point's timecode with nanosecond precision. The format is HH:MM:SS.nnnnnnnnn. This element is always set.durationThe cue point's duration with nanosecond precision. The format is HH:MM:SS.nnnnnnnnn.cluster_positionThe absolute position in bytes inside the &matroska; file where the cluster containing the referenced element starts.Inside the &matroska; file the CueClusterPosition is relative to the segment's data start offset. The
value output by &mkvextract;'s cue extraction mode, however, contains that offset already and is an absolute offset from the
beginning of the file.relative_positionThe relative position in bytes inside the cluster where the BlockGroup or
SimpleBlock element the cue point refers to starts.Inside the &matroska; file the CueRelativePosition is relative to the cluster's data start
offset. The value output by &mkvextract;'s cue extraction mode, however, is relative to the cluster's ID. The absolute position
inside the file can be calculated by adding cluster_position and relative_position.
Example:
$ mkvextract cues input.mkv 1:cues-track1.txt 2:cues-track2.txtOutput redirection
Several extraction modes cause &mkvextract; to write the extracted data to the console. There are generally two ways of writing this data
into a file: one provided by the shell and one provided by &mkvextract; itself.
The shell's builtin redirection mechanism is used by appending '> output-filename.ext' to the command
line. Example:
$ mkvextract tags source.mkv > tags.xml
&mkvextract;'s own redirection is invoked with the option. Example:
$ mkvextract tags source.mkv --redirect-output tags.xml
On Windows you should probably use the option because
cmd.exe sometimes interpretes special characters before they're written into the output file resulting in broken
output.
Text files and character set conversions
For an in-depth discussion about how all tools in the MKVToolNix suite handle character set conversions, input/output encoding, command
line encoding and console encoding please see the identically-named section in the &mkvmerge; man page.
Output file formats
The decision about the output format is based on the track type, not on the extension used for the output file name. The following track
types are supported at the moment:
V_MPEG4/ISO/AVCH.264 / AVC video tracks are written to H.264 elementary streams which can be
processed further with e.g. MP4Box from the GPAC package.
V_MS/VFW/FOURCC
Fixed FPS video tracks with this CodecID are written to AVI files.
V_REAL/*RealVideo tracks are written to RealMedia files.
V_THEORATheora streams will be written within an Ogg container
V_VP8, V_VP9VP8 / VP9 tracks are written to IVF files.
A_MPEG/L2
MPEG-1 Audio Layer II streams will be extracted to raw MP2 files.
A_MPEG/L3, A_AC3
These will be extracted to raw MP3 and AC-3 files.
A_PCM/INT/LIT
Raw PCM data will be written to a WAV file.
A_AAC/MPEG2/*, A_AAC/MPEG4/*, A_AAC
All AAC files will be written into an AAC file with ADTS headers before each
packet. The ADTS headers will not contain the deprecated emphasis field.
A_VORBIS
Vorbis audio will be written into an &oggvorbis; file.
A_REAL/*RealAudio tracks are written to RealMedia files.
A_TTA1TrueAudio tracks are written to TTA files. Please note that due to &matroska;'s limited
timecode precision the extracted file's header will be different regarding two fields: data_length (the total
number of samples in the file) and the CRC.
A_ALACALAC tracks are written to CAF files.
A_FLACFLAC tracks are written to raw FLAC files.
A_WAVPACK4WavPack tracks are written to WV files.
A_OPUSOpus tracks are written to OggOpus files.
S_TEXT/UTF8
Simple text subtitles will be written as SRT files.
S_TEXT/SSA, S_TEXT/ASSSSA and ASS text subtitles will be written as SSA/ASS files
respectively.
S_KATEKate streams will be written within an Ogg container.
S_VOBSUBVobSub subtitles will be written as SUB files along with the
respective index files, as IDX files.
S_TEXT/USFUSF text subtitles will be written as USF files.
S_HDMV/PGSPGS subtitles will be written as SUP files.
Tags
Tags are converted to a &xml; format. This format is the same that &mkvmerge; supports for reading tags.
Attachments
Attachments are written to they output file as they are. No conversion whatsoever is done.
Chapters
Chapters are converted to a &xml; format. This format is the same that &mkvmerge; supports for reading chapters. Alternatively a
stripped-down version can be output in the simple OGM style format.
Timecodes
Timecodes are first sorted and then output as a timecode v2 format compliant file ready to be fed to &mkvmerge;. The extraction to
other formats (v1, v3 and v4) is not supported.
Exit codes
&mkvextract; exits with one of three exit codes:
0 -- This exit codes means that extraction has completed successfully.
1 -- In this case &mkvextract; has output at least one warning, but extraction did continue. A warning is
prefixed with the text 'Warning:'. Depending on the issues involved the resulting files might be ok or not. The
user is urged to check both the warning and the resulting files.
2 -- This exit code is used after an error occurred. &mkvextract; aborts right after outputting the error message.
Error messages range from wrong command line arguments over read/write errors to broken files.
Escaping special chars in text
There are a few places in which special characters in text must or should be escaped. The rules for escaping are simple: each character
that needs escaping is replaced with a backslash followed by another character.
The rules are: ' ' (a space) becomes '\s', '"' (double quotes) becomes '\2', ':' becomes '\c', '#' becomes '\h' and '\' (a single backslash) itself becomes '\\'.
Environment variables
&mkvextract; uses the default variables that determine the system's locale (e.g. LANG and the LC_*
family). Additional variables:
MKVEXTRACT_DEBUG, MKVTOOLNIX_DEBUG and its short form MTX_DEBUGThe content is treated as if it had been passed via the option.MKVEXTRACT_ENGAGE, MKVTOOLNIX_ENGAGE and its short form MTX_ENGAGEThe content is treated as if it had been passed via the option.MKVEXTRACT_OPTIONS, MKVTOOLNIX_OPTIONS and its short form MTX_OPTIONSThe content is split on white space. The resulting partial strings are treated as if it had been passed as command line
options. If you need to pass special characters (e.g. spaces) then you have to escape them (see the section about escaping special characters in text).See also
&mkvmerge;, &mkvinfo;, &mkvpropedit;, &mtxgui;
WWW
The latest version can always be found at the MKVToolNix homepage.