---
website: https://mkvtoolnix.download
obj: application
flatpak-id: org.bunkus.mkvtoolnix-gui
---

# MKVToolnix
MKVToolNix is a set of tools to create, alter and inspect [Matroska](../../files/media/Matroska.md) files under [Linux](../../linux/Linux.md), other Unixes and [Windows](../../windows/Windows.md).

## MKVToolnix-GUI
MKVToolnix has a GUI for remuxing and getting information about [Matroska](../../files/media/Matroska.md) files. Most of the tasks can also be done with the command line (See below).

![Screenshot](./mkvtoolnix.avif)

## mkvmerge
This program takes the input from several media files and joins their streams (all of them or just a selection) into a [Matroska](../../files/media/Matroska.md) file.
Usage: `mkvmerge [global options] {-o out} [options1] {file1} [[options2] {file2}] [@options-file.json]`

Instead of specifying the options on the command line, you can put them in a [JSON](../../files/JSON.md) file and use it with `mkvmerge @options-file.json`. The file is an array of options.

### Options
The order of the options is important and decide on which source file actions are applied to.

#### Global Options
| Option                   | Description                                                      |
| ------------------------ | ---------------------------------------------------------------- |
| `-v, --verbose`          | Increase verbosity.                                              |
| `-q, --quiet`            | Suppress status output.                                          |
| `-o, --output file-name` | Write to the file `file-name`                                    |
| `--title title`          | Sets the general title for the output file, e.g. the movie name. |

#### Chapters
| Option                 | Description                                       |
| ---------------------- | ------------------------------------------------- |
| `--chapters file-name` | Read chapter information from the file file-name. |

The chapter file can be in simple or a [XML](../../files/XML.md) based chapter format.

Simple format:
```
CHAPTER01=00:00:00.000
CHAPTER01NAME=Intro
CHAPTER02=00:02:30.000
CHAPTER02NAME=Alice prepares to rock
CHAPTER03=00:02:42.300
CHAPTER03NAME=Alice rocks the house
```

[XML](../../files/XML.md) based format:
```xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE Chapters SYSTEM "matroskachapters.dtd">
<Chapters>
  <EditionEntry>
    <ChapterAtom>
      <ChapterTimeStart>00:00:30.000</ChapterTimeStart>
      <ChapterTimeEnd>00:01:20.000</ChapterTimeEnd>
      <ChapterDisplay>
        <ChapterString>A short chapter</ChapterString>
        <ChapterLanguage>eng</ChapterLanguage>
      </ChapterDisplay>
      <ChapterAtom>
        <ChapterTimeStart>00:00:46.000</ChapterTimeStart>
        <ChapterTimeEnd>00:01:10.000</ChapterTimeEnd>
        <ChapterDisplay>
          <ChapterString>A part of that short chapter</ChapterString>
          <ChapterLanguage>eng</ChapterLanguage>
        </ChapterDisplay>
      </ChapterAtom>
    </ChapterAtom>
  </EditionEntry>
</Chapters>
```

#### Output Options
| Option                                  | Description                                                                                                                                                                                                                                                                                                                                                                                                                      |
| --------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--track-order FID1:TID1,FID2:TID2,...` | This option changes the order in which the tracks for an input file are created. The argument is a comma separated list of pairs IDs. Each pair contains first the file ID (FID1) which is simply the number of the file on the command line starting at 0. The second is a track ID (TID1) from that file. If some track IDs are omitted then those tracks are created after the ones given with this option have been created. |
| `--no-date`                             | By default mkvmerge sets the "date" segment information field to the time & date when multiplexing started. With this option that field is not written at all.                                                                                                                                                                                                                                                                   |
| `--stop-after-video-ends`               | Stops processing after the primary video track ends, discarding any remaining packets of other tracks.                                                                                                                                                                                                                                                                                                                           |

#### Attachment Options
| Option                                                  | Description                                                                                                                                                               |
| ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--attachment-description description`                  | Plain text description of the following attachment. Applies to the next `--attach-file` or `--attach-file-once` option.                                                   |
| `--attachment-mime-type MIME type`                      | [MIME](../../files/MIME.md) type of the following attachment.                                                                                                             |
| `--attachment-name name`                                | Sets the name that will be stored in the output file for this attachment.                                                                                                 |
| `--attach-file file-name, --attach-file-once file-name` | Creates a file attachment inside the [Matroska](../../files/media/Matroska.md) file. The [MIME](../../files/MIME.md) type must have been set before this option can used. |

#### Input File Options
| Option                                     | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| ------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `-a, --audio-tracks [!]n,m,...`            | Copy the audio tracks `n`, `m` etc. The numbers are track IDs which can be obtained with the `--identify` switch. Instead of track IDs you can also provide ISO 639-2 language codes. This will only work for source files that provide language tags for their tracks. They're not simply the track numbers. Default: copy all audio tracks. If the IDs are prefixed with `!` then the meaning is reversed: copy all tracks of this kind but the ones listed after the `!`.       |
| `-d, --video-tracks [!]n,m,...`            | Copy the video tracks `n`, `m` etc. The numbers are track IDs which can be obtained with the `--identify` switch. They're not simply the track numbers. Default: copy all video tracks. Instead of track IDs you can also provide ISO 639-2 language codes. This will only work for source files that provide language tags for their tracks. If the IDs are prefixed with `!` then the meaning is reversed: copy all tracks of this kind but the ones listed after the `!`.       |
| `-s, --subtitle-tracks [!]n,m,...`         | Copy the subtitle tracks `n`, `m` etc. The numbers are track IDs which can be obtained with the `--identify` switch. They're not simply the track numbers. Default: copy all subtitle tracks. Instead of track IDs you can also provide ISO 639-2 language codes. This will only work for source files that provide language tags for their tracks. If the IDs are prefixed with `!` then the meaning is reversed: copy all tracks of this kind but the ones listed after the `!`. |
| `--track-tags [!]n,m,...`                  | Copy the tags for tracks `n`, `m` etc. The numbers are track IDs which can be obtained with the `--identify` switch. They're not simply the track numbers. Default: copy tags for all tracks. If the IDs are prefixed with `!` then the meaning is reversed: copy everything but the IDs listed after the `!`.                                                                                                                                                                     |
| `-m, --attachments [!]n[:all/first],m[:all | first],...`                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | Copy the attachments with the IDs n, m etc to all or only the first output file. Each ID can be followed by either `:all` (which is the default if neither is entered) or `:first`. If splitting is active then those attachments whose IDs are specified with `:all` are copied to all of the resulting output files while the others are only copied into the first output file. If splitting is not active then both variants have the same effect. The default is to copy all attachments to all output files. If the IDs are prefixed with `!` then the meaning is reversed: copy everything but the IDs listed after the `!`. |
| `-A, --no-audio`                           | Don't copy any audio track from this file.                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `-D, --no-video`                           | Don't copy any video track from this file.                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `-S, --no-subtitles`                       | Don't copy any subtitle track from this file.                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `-T, --no-track-tags`                      | Don't copy any track specific tags from this file.                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `--no-chapters`                            | Don't copy chapters from this file.                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `-M, --no-attachments`                     | Don't copy attachments from this file.                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `--no-global-tags`                         | Don't copy global tags from this file.                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `-y, --sync TID:d[,o[/p]]`                 | Adjust the timestamps of the track with the id `TID` by `d` ms. The track IDs are the same as the ones given with `--identify`. `o/p`: adjust the timestamps by `o/p` to fix linear drifts. `p` defaults to 1 if omitted. Both `o` and `p` can be floating point numbers.                                                                                                                                                                                                          |
| `--default-track-flag TID[:bool]`          | Sets the "default track" flag for the given track if the optional argument `bool` is set to 1 or if it isn't present. The flag will be set if the source container doesn't provide that information and the user doesn't specify it via this option.                                                                                                                                                                                                                               |
| `--track-name TID:name`                    | Sets the track name for the given track to `name`.                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `--language TID:language`                  | Sets the language for the given track. Both ISO 639-2 language codes and ISO 639-1 country codes are allowed. The country codes will be converted to language codes automatically. All languages including their ISO 639-2 codes can be listed with the `--list-languages` option.                                                                                                                                                                                                 |

#### Video Input File Options
| Option                                    | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `--display-dimensions TID:widthxheight`   | [Matroska](../../files/media/Matroska.md) files contain two values that set the display properties that a player should scale the image on playback to: display width and display height. These values can be set with this option, e.g. `1:640x480`.                                                                                                                                                                                                                                            |
| `--aspect-ratio TID:ratio/(width/height)` | [Matroska](../../files/media/Matroska.md) files contain two values that set the display properties that a player should scale the image on playback to: display width and display height. With this option mkvmerge will automatically calculate the display width and display height based on the image's original width and height and the aspect ratio given with this option. The ratio can be given either as a floating point number `ratio` or as a fraction `width/height`, e.g. `16/9`. |

#### Other Options
| Option                               | Description                                                                                                                                                                                   |
| ------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `-i, --identify file-name`           | 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. |
| `-J file-name`                       | This is a convenient alias for `--identification-format json --identify file-name`.                                                                                                           |
| `-F, --identification-format format` | Determines the output format used by the `--identify` option. The following formats are supported: `text` (the default) and `json`.                                                           |
| `--list-languages`                   | Lists all languages and their ISO 639-2 code which can be used with the `--language` option.                                                                                                  |

## mkvinfo
This program lists all elements contained in a [Matroska](../../files/media/Matroska.md). The output can be limited to a list of tracks in the file including information about the codecs used.
Usage: `mkvinfo [options] {source-filename}`

### Options
| Option               | Description                                                           |
| -------------------- | --------------------------------------------------------------------- |
| `-s, --summary`      | Only show a terse summary of what mkvinfo finds and not each element. |
| `-x, --hexdump`      | Show the first 16 bytes of each frame as a hex dump.                  |
| `-X, --full-hexdump` | Show all bytes of each frame as a hex dump.                           |
| `-z, --size`         | Show the size of each element including its header.                   |

## mkvextract
This program extracts specific parts from a [Matroska](../../files/media/Matroska.md) file to other useful formats. The first argument is the name of the source file which must be a [Matroska](../../files/media/Matroska.md) file.
Usage: `mkvextract {source-filename} {mode1} [options] [extraction-spec1] [mode2] [options] [extraction-spec2] […]`

### Extract Tracks
Usage: `mkvextract source-filename tracks [options] [track]:dest-filename1 [[track]:dest-filename2 ...]`
Example: `mkvextract input.mkv tracks 0:video.h264 2:output-two-vobsub-tracks.idx 3:output-two-vobsub-tracks.idx`

### Extract Attachments
Usage: `mkvextract source-filename attachments [options] id:outname1 [id2:outname2 ...]`

### Extract Chapters
Usage: `mkvextract source-filename chapters [options] output-filename.xml`

### Extract Tags
Usage: `mkvextract source-filename tags [options] output-filename.xml`

## mkvpropedit
This program analyses an existing [Matroska](../../files/media/Matroska.md) file and modifies some of its properties. Then it writes those modifications to the existing file. Among the properties that can be changed are the segment information elements (e.g. the title) and the track headers (e.g. the language code, 'default track' flag or the name).
Usage: `mkvpropedit [options] {source-filename} {actions} `

### Options
| Option                      | Description                                                                                                     |
| --------------------------- | --------------------------------------------------------------------------------------------------------------- |
| `-l, --list-property-names` | Lists all known and editable property names, their type (string, integer, boolean etc) and a short description. |

#### Track and segment info properties:
| Option                 | Description                                                                                                                                                                                                                                                                                                                                                                       |
| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `-e, --edit selector`  | Sets the [Matroska](../../files/media/Matroska.md) file section (segment information or a certain track's headers) that all following add, set and delete actions operate on. This option can be used multiple times in order to make modifications to more than one element.<br>This stays valid until the next `--edit` option is found<br>`selector` has the `track:n` format. |
| `-a, --add name=value` | Adds a property `name` with the value `value`. The property will be added even if such a property exists already. Note that most properties are unique and cannot occur more than once.                                                                                                                                                                                           |
| `-s, --set name=value` | Sets all occurrences of the property `name` to the value `value`. If no such property exists then it will be added.                                                                                                                                                                                                                                                               |
| `-d, --delete name`    | Deletes all occurrences of the property `name`. Note that some properties are required and cannot be deleted.                                                                                                                                                                                                                                                                     |

#### Tags and chapters
| Option                         | Description                                                                                                                                                                                                           |
| ------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `-t, --tags selector:filename` | Add or replace tags in the file with the ones from `filename` or remove them if `filename` is empty. mkvpropedit reads the same [XML](../../files/XML.md) tag format that mkvmerge reads as well.                     |
| `-c, --chapters filename`      | Add or replace chapters in the file with the ones from `filename` or remove them if `filename` is empty. mkvpropedit reads the same [XML](../../files/XML.md) and simple chapter formats that mkvmerge reads as well. |

#### Attachments
| Option                                   | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ---------------------------------------- |   |
| `--add-attachment filename`              | Adds a new attachment from filename.<br>If the option `--attachment-name` has been used prior to this option then its value is used as the new attachment's name. Otherwise it is derived from filename<br>If the option `--attachment-mime-type` has been used prior to this option then its value is used as the new attachment's [MIME](../../files/MIME.md) type. Otherwise it is auto-detected from the content of filename.<br>If the option `--attachment-description` has been used prior to this option then its value is used as the new attachment's description. Otherwise no description will be set.<br>If the option `--attachment-uid` has been used prior to this option then its value is used as the new attachment's UID. Otherwise a random UID will be generated automatically. The same options affect the other actions as well. |
| `--replace-attachment selector:filename` | Replaces one or more attachments that match `selector` with the file `filename`. If more than one existing attachment matches `selector` then all of their contents will be replaced by the content of `filename`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `--update-attachment selector`           | Sets the properties of one or more attachments that match `selector`. If more than one existing attachment matches `selector` then all of their properties will be updated.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `--delete-attachment selector`           | Deletes one or more attachments that match `selector`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |

##### Options for Attachment actions
| Option                                 | Description                                                                                                                |
| -------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| `--attachment-name name`               | Sets the name to use for the following `--add-attachment` or `--replace-attachment` operation.                             |
| `--attachment-mime-type mime-type`     | Sets the [MIME](../../files/MIME.md) type to use for the following `--add-attachment` or `--replace-attachment` operation. |
| `--attachment-description description` | Sets the description to use for the following `--add-attachment` or `--replace-attachment operation`.                      |
