mkvpropedit -- Modify properties of existing Matroska(tm) files without a complete remux

# 1. 概要

mkvpropedit options {source-filename} {actions}

# 2. 摘要說明

This program analyses an existing Matroska(tm) 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).

選項:

Option | Description
--- | ---
-l, --list-property-names | Lists all known and editable property names, their type (string, integer, boolean etc) and a short description. The program exits afterwards. Therefore the source-filename parameter does not have to be supplied.
-p, --parse-mode 模式 | Sets the parse mode. The parameter 'mode' can either be 'fast' (which is also the default) or 'full'. The 'fast' 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 set the 'full' parse mode. A full scan of a file can take a couple of minutes while a fast scan only takes seconds.

Actions that deal with track and segment info properties:

Option | Description
--- | ---
-e, --edit 選擇 | Sets the Matroska(tm) 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. By default mkvpropedit(1) will edit the segment information section.

完整的語法描述詳細資訊請參閱下列 編輯選擇器 。

-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 名稱=數值 | Sets all occurrences of the property name to the value value. If no such property exists then it will be added.
-d, --delete 名稱 | Deletes all occurrences of the property name. Note that some properties are required and cannot be deleted.

Actions that deal with tags and chapters:

Option | Description
--- | ---
-t, --tags 選擇:檔名 | Add or replace tags in the file with the ones from filename or remove them if filename is empty. mkvpropedit(1) reads the same XML tag format that mkvmerge(1) reads as well. The selector must be one of the words all, global or track. For all mkvpropedit(1) will replace or remove all tags in a file. With global only global tags will be replaced or removed.

With track mkvpropedit(1) will replace tags for a specific track. Additionally the tags read from filename will be assigned to the same track. The track is specified in the same way edit selectors are specified (see below), e.g. --tags track:a1:new-audio-tags.xml.

--add-track-statistics-tags | Calculates statistics for all tracks in a file and adds new statistics tags for them. If the file already contains such tags then they'll be updated.
--delete-track-statistics-tags | Deletes all existing track statistics tags from a file. If the file doesn't contain track statistics tags then it won't be modified.
-c, --chapters 檔名 | Add or replace chapters in the file with the ones from filename or remove them if filename is empty. mkvpropedit(1) reads the same XML and simple chapter formats that mkvmerge(1) reads as well.

附件處理執行選項:

Option | Description
--- | ---
--add-attachment 檔名 | 從 檔名 增加新的附件。 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. If the option --attachment-mime-type has been used prior to this option then its value is used as the new attachment's MIME type. Otherwise it is auto-detected from the content of filename.

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.

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.

--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. The selector can have one of four forms. They're explained below in the section attachment selectors.

If the option --attachment-name has been used prior to this option then its value is set as the new name for each modified attachment. Otherwise the names aren't changed.

If the option --attachment-mime-type has been used prior to this option then its value is set as the new MIME type for each modified attachment. Otherwise the MIME types aren't changed.

If the option --attachment-description has been used prior to this option then its value is set as the new description for each modified attachment. Otherwise the descriptions aren't changed.

If the option --attachment-uid has been used prior to this option then its value is set as the new UID for each modified attachment. Otherwise the UIDs aren't changed.

--update-attachment 選擇 | 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. The selector can have one of four forms. They're explained below in the section attachment selectors.

If the option --attachment-name has been used prior to this option then its value is set as the new name for each modified attachment. Otherwise the names aren't changed.

If the option --attachment-mime-type has been used prior to this option then its value is set as the new MIME type for each modified attachment. Otherwise the MIME types aren't changed.

If the option --attachment-description has been used prior to this option then its value is set as the new description for each modified attachment. Otherwise the descriptions aren't changed.

If the option --attachment-uid has been used prior to this option then its value is set as the new UID for each modified attachment. Otherwise the UIDs aren't changed.

--delete-attachment 選擇 | Deletes one or more attachments that match selector. The selector can have one of four forms. They're explained below in the section attachment selectors.

附件執行選項:

Option | Description
--- | ---
--attachment-name 名稱 | Sets the name to use for the following --add-attachment or --replace-attachment operation.
--attachment-mime-type MIME 類型 | Sets the MIME type to use for the following --add-attachment or --replace-attachment operation.
--attachment-description 描述 | Sets the description to use for the following --add-attachment or --replace-attachment operation.

其他選項:

Option | Description
--- | ---
--disable-language-ietf | Normally when the user requests changes to the 'language' track header property, mkvpropedit(1) will apply the same change to the new LanguageIETF track header element in addition to the legacy Language element. If this option is used, the change is only applied to the legacy Language element.

This option does not affect changes requested via the 'language-ietf' track header property.

--command-line-charset 字元集 | 設定在命令列顯示的字串字元集，以轉換為其他字元集。預設為目前系統所在位置指定的字元集。
--output-charset 字元集 | 設定要轉換為輸出字串的字元集。預設為目前系統所在位置指定的字元集。
-r, --redirect-output 檔名 | 將所有訊息寫入到檔案 檔名 而不是命令列。儘管使用輸出重新導向可以輕鬆完成此操作，但在某些情況下需要使用此選項: 當終端在將輸出寫入文件之前重新解釋（覆蓋）輸出時。 優先使用通過 --output-charset 設定字元集。
--ui-language 語言碼 | 強制使用語言 編碼 對應的的翻譯(例如 'zh_TW' 為臺灣正體中文翻譯)。 在編碼欄位中輸入'list' 讓程式輸出時使用可用的對應翻譯清單。
--abort-on-warnings | 發出第一個警告後，終止程式。程式的結束碼為 1 。
--debug 主題 | 針對特定功能開啟除錯。此選項適用於開發者。
--engage 功能 | 開啟實驗中功能。 透過mkvpropedit --engage list啟用可用的列表。這些功能不會在正常情況下使用。
--gui-mode | 開啟 GUI 模式。在這種模式中，可能會輸出特殊格式的行數，可以呈現控制的 GUI 發生什麼事。這些訊息會以 '#GUI#訊息'呈現。訊息可能包含機碼/值，例如 '#GUI#訊息#機碼1=值1#機碼2=值2…'。 無論是訊息或是機碼都不會轉為譯文，而且永遠使用 *英語* 輸出。
-v, --verbose | 輸出時盡量詳細，並在讀取時顯示所有 Matroska(tm) 重要的元件。
-h, --help | 顯示使用方式並退出。
-V, --version | 顯示版本資訊並離開。
@options-file.json | 從檔案選項檔讀取其他命令列引數。有關此類檔案支援格式的完整說明，請參閱 mkvmerge(1) 文件中的 "選項檔案" 章節。

# 3. 編輯選擇器

The --edit option sets the Matroska(tm) file section (segment information or a certain track's headers) that all following add, set and delete actions operate on. This stays valid until the next --edit option is found. The argument to this option is called the edit selector.

By default mkvpropedit(1) will edit the segment information section.

## 3.1. 剪輯訊息

The segment information can be selected with one of these three words: 'info', 'segment_info' or 'segmentinfo'. It contains properties like the segment title or the segment UID.

## 3.2. 軌道表頭

Track headers can be selected with a slightly more complex selector. All variations start with 'track:'. The track header properties include elements like the language code, 'default track' flag or the track's name.

Option | Description
--- | ---
track:n | If the parameter n is a number then the nth track will be selected. The track order is the same that mkvmerge(1)'s --identify option outputs. 從 1 開始編號。
track:t n | If the parameter starts with a single character t followed by a n then the nth track of a specific track type will be selected. The track type parameter t must be one of these four characters: 'a' for an audio track, 'b' for a button track, 's' for a subtitle track and 'v' for a video track. The track order is the same that mkvmerge(1)'s --identify option outputs.

從 1 開始編號。

track:=uid | If the parameter starts with a '=' followed by a number uid, the track whose track UID element equals the given uid will be selected. Track UIDs can be obtained with mkvinfo(1).
track:@編號 | If the parameter starts with a '@' followed by a number number, the track whose track number element equals this number will be selected. Track numbers can be obtained with mkvinfo(1).

## 3.3. 備註

Due to the nature of the track edit selectors it is possible that several selectors actually match the same track headers. In such cases all actions for those edit selectors will be combined and executed in the order in which they're given on the command line.

# 4. 附件選擇

An attachment selector is used with the two actions --replace-attachment and --delete-attachment. It can have one of the following four forms:

1. Selection by attachment ID. In this form the selector is simply a number, the attachment's ID as output by mkvmerge(1)'s identification command.

2. Selection by attachment UID (unique ID). In this form the selector is the equal sign = followed by a number, the attachment's unique ID as output by mkvmerge(1)'s verbose identification command.

3. Selection by attachment name. In this form the selector is the literal word name: followed by the existing attachment's name. If this selector is used with --replace-attachment then colons within the name to match must be escaped as \c.

4. Selection by MIME type. In this form the selector is the literal word mime-type: followed by the existing attachment's MIME type. If this selector is used with --replace-attachment then colons within the MIME type to match must be escaped as \c.

# 5. 範例

The following example edits a file called 'movie.mkv'. It sets the segment title and modifies the language code of an audio and a subtitle track. Note that this example can be shortened by leaving out the first --edit option because editing the segment information element is the default for all options found before the first --edit option anyway.

    $ mkvpropedit movie.mkv --edit info --set "title=The movie" --edit track:a1 --set language=fre --edit track:a2 --set language=ita

The second example removes the 'default track flag' from the first subtitle track and sets it for the second one. Note that mkvpropedit(1), unlike mkvmerge(1), does not set the 'default track flag' of other tracks to '0' if it is set to '1' for a different track automatically.

    $ mkvpropedit movie.mkv --edit track:s1 --set flag-default=0 --edit track:s2 --set flag-default=1

Replacing the tags for the second subtitle track in a file looks like this:

    $ mkvpropedit movie.mkv --tags track:s2:new-subtitle-tags.xml

Removing all tags requires leaving out the file name:

    $ mkvpropedit movie.mkv --tags all:

Replacing the chapters in a file looks like this:

    $ mkvpropedit movie.mkv --chapters new-chapters.xml

Removing all chapters requires leaving out the file name:

    $ mkvpropedit movie.mkv --chapters ''

Adding a font file (Arial.ttf) as an attachment:

    $ mkvpropedit movie.mkv --add-attachment Arial.ttf

Adding a font file (89719823.ttf) as an attachment and providing some information as it really is just Arial:

    $ mkvpropedit movie.mkv --attachment-name Arial.ttf --attachment-description 'The Arial font as a TrueType font' --attachment-mime-type application/x-truetype-font --add-attachment 89719823.ttf

將一個附加字型 (Comic.ttf) 檔取代成另一個 (Arial.ttf):

    $ mkvpropedit movie.mkv --attachment-name Arial.ttf --attachment-description 'The Arial font as a TrueType font' --replace-attachment name:Comic.ttf:Arial.ttf

刪除第二個附加檔，無論可能是什麼:

    $ mkvpropedit movie.mkv --delete-attachment 2

依 MIME 類型刪除所有附加的字型:

    $ mkvpropedit movie.mkv --delete-attachment mime-type:application/x-truetype-font

# 6. 結束代碼

使用三個之一的結束代碼結束 mkvpropedit(1) ：

- 0 -- 此結束代碼表示修正已成功完成。

- 1 -- 在此情況下 mkvpropedit(1) 輸出時至少有一則警告，但編輯動作仍然進行。警告訊息會在前端出現 'Warning:' 字樣。依據問題的程度，生成的檔案也許可用。建議使用者檢視警告訊息與輸出檔。

- 2 -- 此結束代碼用於發生錯誤後。 mkvpropedit(1) 在輸出錯誤訊息後立即中止動作。錯誤訊息的範圍包含從錯誤命令列參數的讀/寫至檔案損壞。

# 7. 文字檔案與字元集轉換

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.

# 8. 環境變數

mkvpropedit(1) 使用決定系統的地區設定的變數 (例如： LANG 與 LC_* 系列)。 附加變數：

Option | Description
--- | ---
MKVPROPEDIT_DEBUG, MKVTOOLNIX_DEBUG 與其的簡短形式 MTX_DEBUG | 視為通過 --debug 選項傳遞的內容。
MKVPROPEDIT_ENGAGE, MKVTOOLNIX_ENGAGE 與其簡短形式 MTX_ENGAGE | 視為通過 --engage 選項傳遞的內容。

# 9. 參閱

mkvmerge(1), mkvinfo(1), mkvextract(1), mkvtoolnix-gui(1)

# 10. 網路

永遠可在 MKVToolNix 首頁 找到最新版。