MKVEXTRACT(1) | User Commands | MKVEXTRACT(1) |
NAME¶
mkvextract - extract tracks from Matroska files into other filesSYNOPSIS¶
mkvextract {source-filename} {mode1} [options] [extraction-spec1] [mode2] [options] [extraction-spec2] [...]
DESCRIPTION¶
This program extracts specific parts from a Matroska file to other useful formats. The first argument is the name of the source file which must be a Matroska file.All other arguments either switch to a certain extraction mode, change options for the currently active mode or specify what to extract into which file. Multiple modes can be used in the same invocation of mkvextract allowing the extraction of multiple things in a single pass. Most options can only be used in certain modes with a few options applying to all modes.
Currently supported is the extraction of tracks, tags, attachments, chapters, CUE sheets, timestamps and cues.
Common options¶
The following options are available in all modes and only described once in this section.-f, --parse-fully
--command-line-charset character-set
--output-charset character-set
-r, --redirect-output file-name
--flush-on-close
--ui-language code
--abort-on-warnings
--debug topic
--engage feature
--gui-mode
-v, --verbose
-h, --help
-V, --version
@options-file.json
Track extraction mode¶
Syntax: mkvextract source-filename tracks [options] TID1:dest-filename1 [TID2: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.
-c character-set
--blockadd level
--cuesheet
--raw
--fullraw
TID:outname
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 input.mkv tracks 0:video.h264 2:output-two-vobsub-tracks.idx 3:output-two-vobsub-tracks.idx
Attachments extraction mode¶
Syntax: mkvextract source-filename attachments [options] AID1:outname1 [AID2:outname2 ...]AID:outname
Chapters extraction mode¶
Syntax: mkvextract source-filename chapters [options] output-filename.xml-s, --simple
--simple-language 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 chapters are written to specified output file. By default the XML format understood by mkvmerge(1) is used. If no chapters are found in the file, the output file is not created.
Tags extraction mode¶
Syntax: mkvextract source-filename tags [options] output-filename.xmlThe tags are written to specified output file in the XML format understood by mkvmerge(1). If no tags are found in the file, the output file is not created.
Cue sheet extraction mode¶
Syntax: mkvextract source-filename cuesheet [options] output-filename.cueThe cue sheet is written to specified output file. If no chapters or tags are found in the file, the output file is not created.
Timestamp extraction mode¶
Syntax: mkvextract source-filename timestamps_v2 [options] TID1:dest-filename1 [TID2:dest-filename2 ...]TID:outname
Example:
$ mkvextract input.mkv timestamps_v2 1:ts-track1.txt 2:ts-track2.txt
Cues extraction mode¶
Syntax: mkvextract source-filename cues [options] TID1:dest-filename1 [TID2:dest-filename2 ...]TID:dest-filename
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:
timestamp=00:00:13.305000000 duration=- cluster_position=757741 relative_position=11
The possible keys are:
timestamp
duration
cluster_position
Note
Inside the Matroska file the CueClusterPosition is relative to the segment's data start offset. The value output by mkvextract(1)'s cue extraction mode, however, contains that offset already and is an absolute offset from the beginning of the file.
relative_position
Note
Inside the Matroska file the CueRelativePosition is relative to the cluster's data start offset. The value output by mkvextract(1)'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 input.mkv cues 1:cues-track1.txt 2:cues-track2.txt
EXAMPLES¶
Extracting both chapters and tags in their respective XML formats at the same time:$ mkvextract movie.mkv chapters movie-chapters.xml tags movie-tags.xml
Extracting a couple of tracks and their respective timestamps at the same time:
$ mkvextract "Another Movie.mkv" tracks 0:video.h265 "1:main audio.aac" "2:director's comments.aac" timestamps_v2 "0:timestamps video.txt" "1:timestamps main audio.txt" "2:timestamps director's comments.txt"
Extracting chapters in the Ogg/OGM format and re-encoding a text subtitle track to another character set:
$ mkvextract "My Movie.mkv" chapters --simple "My Chapters.txt" tracks -c MS-ANSI "2:My Subtitles.srt"
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(1) 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:A_AAC/MPEG2/*, A_AAC/MPEG4/*, A_AAC
A_AC3, A_EAC3
A_ALAC
A_DTS
A_FLAC
A_MPEG/L2
A_MPEG/L3
A_OPUS
A_PCM/INT/LIT, A_PCM/INT/BIG
A_REAL/*
A_TRUEHD, A_MLP
A_TTA1
A_VORBIS
A_WAVPACK4
S_HDMV/PGS
S_HDMV/TEXTST
S_KATE
S_TEXT/SSA, S_TEXT/ASS, S_SSA, S_ASS
S_TEXT/UTF8, S_TEXT/ASCII
S_VOBSUB
S_TEXT/USF
S_TEXT/WEBVTT
V_MPEG1, V_MPEG2
V_MPEG4/ISO/AVC
V_MPEG4/ISO/HEVC
V_MS/VFW/FOURCC
V_REAL/*
V_THEORA
V_VP8, V_VP9
Tags
Attachments
Chapters
Timestamps
EXIT CODES¶
mkvextract(1) exits with one of three exit codes:ENVIRONMENT VARIABLES¶
mkvextract(1) 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_DEBUG
MKVEXTRACT_ENGAGE, MKVTOOLNIX_ENGAGE and its short form MTX_ENGAGE
SEE ALSO¶
mkvmerge(1), mkvinfo(1), mkvpropedit(1), mkvtoolnix-gui(1)WWW¶
The latest version can always be found at the MKVToolNix homepage[1].AUTHOR¶
Moritz Bunkus <moritz@bunkus.org>NOTES¶
- 1.
- the MKVToolNix homepage
2019-02-09 | MKVToolNix 31.0.0 |