1. 概要
2. 说明
此程序可分析现有 Matroska(tm) 文件,并修改其部分属性。然后它将将变更写入现有文件。可修改的属性包括剪辑信息元素(如标题)和轨道头部(如语言代码、'默认轨' 标记或轨道名称)。
选项:
Option | Description |
---|---|
-l, --list-property-names |
列出所有已知的可编辑的属性名称、它们的类型(字符串型、整数型、布尔型等等)及简短说明。程序随后将退出执行。因此不必提供 source-filename 参数。 |
-p, --parse-mode 模式 |
设置解析模式。参数 '模式' 可以为 'fast(快速)'(此项为默认值)或 'full(完整)'。'fast(快速)'模式不解析整个文件,而是使用元定位元素确定源文件中所需元素的位置。99% 的情况下这就足够了。但如果碰到不含元定位元素或者元定位元素损坏的文件,用户可能得考虑 'full(完整)' 解析模式。完整扫描文件可能要花费几分钟,而快速扫描只需要几秒钟。 |
Actions that deal with track and segment info properties:
Option | Description |
---|---|
-e, --edit 选择器 |
设置后续的 添加、设置 或 删除 操作所针对的 Matroska(tm) 文件区域(即剪辑信息或某个轨道的头部)。此选项可多次使用,以同时修改多个元素。 默认情况下,mkvpropedit(1) 将编辑剪辑信息区段。 关于完整的语法说明请参见关于 编辑选择器 的段落。 |
-a, --add 名称=数值 |
添加名为 名称、值为 数值 的属性。即使已存在这样的属性,也将执行添加属性操作。注意大多数属性是唯一的,不能出现多个。 |
-s, --set 名称=数值 |
设置所有名为 名称 的属性的数值为 数值。如果不存在这样的属性,则将添加该属性。 |
-d, --delete 名称 |
删除所有名为 名称 的属性。注意部分属性是必需的,不能删除。 |
Actions that deal with tags and chapters:
Option | Description |
---|---|
-t, --tags 选择器:文件名 |
用 文件名 中的标签添加或替换文件中的标签,或者如果 文件名 为空则移除标签。mkvpropedit(1) 读取的 XML 标签格式与 mkvmerge(1) 所读取的相同。 选择器 必须是 all、global 或 track 之一。对于all 选择器,mkvpropedit(1) 将替换或移除文件中的所有标签。对于 global 选择器,将只替换或移除全局标签。 对于 track 选择器,mkvpropedit(1) 将替换特定轨道的标签。读取自 文件名 的其他标签将分配给相同轨道。轨道与 编辑选择器 以相同格式指定 (参见下文),如 --tags track:a1:新音频标签.xml。 |
-c, --chapters 文件名 |
用 文件名 中的标签添加或替换文件中的章节,或者如果 文件名 为空则移除章节。mkvpropedit(1) 读取的 XML 及简单章节格式与 mkvmerge(1) 所读取的相同。 |
Actions for handling attachments:
Option | Description |
---|---|
--add-attachment filename |
Adds a new attachment from filename. 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. |
--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 exlained below in the section attachment selectors. If the option --attachment-name has been used prior to this option then its value is used as the replaced attachment's name. Otherwise the name is not changed. If the option --attachment-mime-type has been used prior to this option then its value is used as the replaced attachment's MIME type. Otherwise the MIME type is not changed. If the option --attachment-description has been used prior to this option then its value is used as the replaced attachment's description. Otherwise no description is not changed. |
--delete-attachment selector |
Deletes one or more attachments that match selector. The selector can have one of four forms. They're exlained below in the section attachment selectors. |
Options for attachment actions:
Option | Description |
---|---|
--attachment-name 名称 |
Sets the name to use for the following --add-attachment or --replace-attachment operation. |
--attachment-mime-type mime-type |
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 |
---|---|
--command-line-charset 字符集 |
设定在命令行给出的字符串的字符集,用于转为其他字符集。默认为系统当前区域设置中所给定的字符集。 |
--output-charset 字符集 |
设置输出的字符串应被转换到何种字符集。默认为系统当前区域设置中所给定的字符集。 |
-r, --redirect-output 文件名 |
将所有信息写入文件 文件名 而不是输出到命令行。 尽管该操作可以用输出重定向轻松实现,但在某些情况下还需要靠它:如当终端在写入文件之前重新解释(覆盖输出)时。将优先使用通过 --output-charset 设定的字符集。 |
--ui-language 语言代码 |
强制使用语言代码为 语言代码 的翻译(如 'de_DE' 对应德文翻译)。使用 LANG, LC_MESSAGES 及 LC_ALL 这些环境变量更好。如果在 语言代码 处输入 'list',mkvextract(1) 将输出可用翻译列表。 |
--debug 主题 |
为特定功能开启调试。该选项仅对开发者有用。 |
--engage 功能 |
开启实验性功能。可用功能列表可通过 mkvpropedit --engage list 得到。这些功能在正常情况下不应该使用。 |
-v, --verbose |
使输出信息更详尽,且每当读取到重要的 Matroska(tm) 元素时就将其显示。 |
-h, --help |
显示用法信息并退出。 |
-V, --version |
显示版本信息并退出。 |
--check-for-updates |
联机下载 URL http://mkvtoolnix-releases.bunkus.org/latest-release.xml 检查新版本。将以 键=值 的样式输出四行: 检索信息的 URL(键 version_check_url),当前运行的版本(键 running_version),最新版本(键 available_version)及其下载 URL(键 download_url)。 若无更新版本可用,程序将以退出码 0 退出,若有更新版本可用,退出码为 1,若出现错误(如无法检索更新信息),退出码则为 2。 此选项仅当程序附带 libcurl 支持编译时可用。 |
@选项文件 |
从文件 选项文件 中读取额外的命令行参数。首个非空白字符为井号 ('#') 的行将被当作注释对待,在处理过程中将被忽略。各行开头与结尾的空白将被除去。各行必须恰好仅含一个选项。 有些字符可以转义,如当您需要使用 '#' 作为一个不是评论的行的开头。规则在关于转义文本的段落有描述。 命令行 'mkvpropedit 源.mkv --edit track:a2 --set name=注释' 可以转换为下述选项文件: # Modify source.mkv source.mkv # Edit the second audio track --edit track:a2 # and set the title to 'Comments' --set name=Comments |
3. 编辑选择器
--edit 选项设置后续的 添加, 设置 或 删除 操作所影响的 Matroska(tm) 文件区域(剪辑信息或者特定轨道的头部)。在出现另一个 --edit 选项之前,此选项将一直有效。此选项的参数就叫做编辑选择器。
默认情况下,mkvpropedit(1) 将编辑剪辑信息区段。
3.1. 剪辑信息
可以通过这三个词中的任意一个选择剪辑信息: 'info'、'segment_info' 或 'segmentinfo'。剪辑信息包含的属性包括剪辑标题、剪辑 UID 等。
3.2. 轨道头部
可用于选择轨道头部的选择器稍显复杂:所有以 'track:' 开头的变体。轨道头部属性包括如语言代码、'默认轨' 标记、轨道名称等属性。
Option | Description |
---|---|
track:n |
如果参数 n 为数字,则将选择第 n 条轨道。轨道顺序与 mkvmerge(1) 的 --identify 选项所输出的相同。 编号从 1 开始。 |
track:tn |
如果参数以字母 t 后接 n 开头,则将选择选定轨道类型中的第 n 条轨道。轨道类型参数 t 必须为下述四个字母中的一个: 'a' 代表音频轨道,'b' 代表按钮轨道,'s' 代表字幕轨道,'v' 代表视频轨道。轨道顺序与 mkvmerge(1) 的 --identify 选项所输出的相同。 编号从 1 开始。 |
track:=uid |
如果参数以 '=' 后接 uid 开头,则将选择轨道 UID 元素等于此 uid 的轨道。轨道 UID 可通过 mkvinfo(1) 获取。 |
track:@数字 |
如果参数以 '@' 后接 数字 开头,则选择轨道号元素等于 数字 的轨道。轨道号可以通过 mkvinfo(1) 获取。 |
3.3. 注
由于轨道编辑选择器的特性,一些选择器所匹配的轨道头部可能是相同的。在此情况下,这些编辑选择器的所有操作将被按照在命令行给出的顺序合并运行。
4. Attachment selectors
An attachment selector is used with the two actions --replace-attachment and --delete-attachment. It can have one of the following four forms:
-
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.
-
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.
-
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.
-
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. 示例
下面的示例将编辑一个名为 '电影.mkv' 的文件。示例中将设置剪辑标题并修改一条音频轨和一条字幕轨的语言代码。附注,本示例可以简写,即省去 --edit 选项,因为在第一个 --edit 选项之前的所有选项默认编辑的就是剪辑信息元素。
$ mkvpropedit 影片.mkv --edit info --set "title=一部影片" --edit track:a1 --set language=fre --edit track:a2 --set language=ita
第二个示例,将 '默认轨标记' 从第一条字幕轨移除并设置到第二条字幕轨上。注意 mkvpropedit(1) 与 mkvmerge(1) 不同,不会在将另一个轨道的 '默认轨标记'设为 '1' 的时候自动将其他轨道的标记设为 '0'。
$ mkvpropedit 影片.mkv --edit track:s1 --set flag-default=0 --edit track:s2 --set flag-default=1
像这样替换文件中第二个字幕轨的标签:
$ mkvpropedit 影片.mkv --tags track:s2:新字幕标签.xml
移除所有标签需要将文件名留空:
$ mkvpropedit 影片.mkv --tags all:
像这样替换文件中的章节:
$ mkvpropedit 影片.mkv --chapters 新章节.xml
移除所有章节需要将文件名留空:
$ mkvpropedit 影片.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
Replacing one attached font (Comit.ttf) file with another one (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
Deleting the second attached file, whatever it may be:
$ mkvpropedit movie.mkv --delete-attachment 2
Deleting all attached fonts by MIME type:
$ mkvpropedit movie.mkv --delete-attachment mime-type:application/x-truetype-font
6. 退出代码
mkvpropedit(1) 退出时会返回以下三个退出代码中的一个:
-
0 -- 此退出代码说明已成功完成修改。
-
1 -- 这种情况下 mkvpropedit(1) 至少输出了一条警告信息,但修改并未因之中止。 警告信息以文字 '警告:' 为前缀。根据问题的不同,生成的文件可能是好的,也可能不是。 强烈建议用户检查警告信息以及生成的文件。
-
2 -- 此退出代码用于错误发生之后。 mkvpropedit(1) 在输出错误信息后即中断处理。错误信息可能是错误的命令行参数,也可能是损坏文件的读取/写入错误。
7. 文本中特殊字符的转义
有时文本中的特殊字符必须或应该转义。转义规则很简单: 用反斜杠后接一字符替换需要转义的各字符。
规则为: ' ' (空格) 变为 '\s'、'"' (双引号) 变为 '\2'、':' 变为 '\c'、'#' 变为 '\h',而 '\' (单个反斜杠) 自己则变为 '\\'。
8. 环境变量
mkvpropedit(1) 会使用决定系统区域设置的默认变量 (如 LANG 与 LC_* 族)。其他变量包括:
Option | Description |
---|---|
MKVTOOLNIX_DEBUG 及其缩写形式 MTX_DEBUG |
内容将被当作通过 --debug 选项传递的参数对待。 |
MKVTOOLNIX_ENGAGE 及其缩写形式 MTX_ENGAGE |
内容将被当作通过 --engage 选项传递的参数对待。 |
MKVTOOLNIX_OPTIONS 及其缩写形式 MTX_OPTIONS |
内容将在空白处切割。最终得到的字符串部分将按命令行选项的格式处理。如果您需要传递特殊字符 (如空白) 则需要转义 (参见关于转义文本中特殊字符的段落)。 |
9. 参阅
mkvmerge(1), mkvinfo(1), mkvextract(1), mmg(1)
10. 网络
最新版本总可以在 MKVToolNix 主页 找到。