mkvtoolnix/doc/man/mkvpropedit.xml

553 lines
22 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "/usr/share/xml/docbook/schema/dtd/4.5/docbookx.dtd"
[
<!ENTITY product "mkvpropedit">
<!ENTITY version "5.3.0">
<!ENTITY date "2012-02-09">
<!ENTITY mkvmerge "<citerefentry><refentrytitle>mkvmerge</refentrytitle><manvolnum>1</manvolnum></citerefentry>">
<!ENTITY mkvinfo "<citerefentry><refentrytitle>mkvinfo</refentrytitle><manvolnum>1</manvolnum></citerefentry>">
<!ENTITY mkvextract "<citerefentry><refentrytitle>mkvextract</refentrytitle><manvolnum>1</manvolnum></citerefentry>">
<!ENTITY mkvpropedit "<citerefentry><refentrytitle>mkvpropedit</refentrytitle><manvolnum>1</manvolnum></citerefentry>">
<!ENTITY mmg "<citerefentry><refentrytitle>mmg</refentrytitle><manvolnum>1</manvolnum></citerefentry>">
<!ENTITY matroska "<productname>Matroska</productname>">
<!ENTITY oggvorbis "<productname>OggVorbis</productname>">
<!ENTITY xml "<abbrev>XML</abbrev>">
]>
<refentry lang="en" id="mkvextract">
<refentryinfo>
<productname>&product;</productname>
<date>&date;</date>
<authorgroup>
<author>
<contrib>Developer</contrib>
<firstname>Moritz</firstname>
<surname>Bunkus</surname>
<email>moritz@bunkus.org</email>
</author>
</authorgroup>
</refentryinfo>
<refmeta>
<refentrytitle>&product;</refentrytitle>
<manvolnum>1</manvolnum>
<refmiscinfo class="version">&version;</refmiscinfo>
<refmiscinfo class="date">&date;</refmiscinfo>
<refmiscinfo class="source">MKVToolNix</refmiscinfo>
<refmiscinfo class="manual">User Commands</refmiscinfo>
</refmeta>
<refnamediv>
<refname>&product;</refname>
<refpurpose>Modify properties of existing &matroska; files without a complete remux</refpurpose>
</refnamediv>
<refsynopsisdiv id="mkvpropedit.synopsis">
<title>Synopsis</title>
<cmdsynopsis>
<command>mkvpropedit</command>
<arg>options</arg>
<arg choice="req">source-filename</arg>
<arg choice="req">actions</arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1 id="mkvpropedit.description">
<title>Description</title>
<para>
This program analyses an existing &matroska; 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).
</para>
<para>
Options:
</para>
<variablelist>
<varlistentry id="mkvpropedit.description.list_property_names">
<term><option>-l</option>, <option>--list-property-names</option></term>
<listitem>
<para>
Lists all known and editable property names, their type (string, integer, boolean etc) and a short description. The program exits
afterwards. Therefore the <parameter>source-filename</parameter> parameter does not have to be supplied.
</para>
</listitem>
</varlistentry>
<varlistentry id="mkvpropedit.description.parse_mode">
<term><option>-p</option>, <option>--parse-mode</option> <parameter>mode</parameter></term>
<listitem>
<para>
Sets the parse mode. The parameter '<parameter>mode</parameter>' can either be '<literal>fast</literal>' (which is also the default)
or '<literal>full</literal>'. The '<literal>fast</literal>' 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 '<literal>full</literal>' parse mode. A full scan of a file can take a
couple of minutes while a fast scan only takes seconds.
</para>
</listitem>
</varlistentry>
</variablelist>
<para>
Actions:
</para>
<variablelist>
<varlistentry id="mkvpropedit.description.edit">
<term><option>-e</option>, <option>--edit</option> <parameter>selector</parameter></term>
<listitem>
<para>
Sets the &matroska; file section (segment information or a certain track's headers) that all following <link
linkend="mkvpropedit.description.add">add</link>, <link linkend="mkvpropedit.description.set">set</link> and <link
linkend="mkvpropedit.description.delete">delete</link> actions operate on. This option can be used multiple times in order to make
modifications to more than one element.
</para>
<para>
By default &mkvpropedit; will edit the segment information section.
</para>
<para>
See the section about <link linkend="mkvpropedit.edit_selectors">edit selectors</link> for a full description of the syntax.
</para>
</listitem>
</varlistentry>
<varlistentry id="mkvpropedit.description.add">
<term><option>-a</option>, <option>--add</option> <parameter>name</parameter>=<parameter>value</parameter></term>
<listitem>
<para>
Adds a property <parameter>name</parameter> with the value <parameter>value</parameter>. The property will be added even if such a
property exists already. Note that most properties are unique and cannot occur more than once.
</para>
</listitem>
</varlistentry>
<varlistentry id="mkvpropedit.description.set">
<term><option>-s</option>, <option>--set</option> <parameter>name</parameter>=<parameter>value</parameter></term>
<listitem>
<para>
Sets all occurrences of the property <parameter>name</parameter> to the value <parameter>value</parameter>. If no such property exists
then it will be added.
</para>
</listitem>
</varlistentry>
<varlistentry id="mkvpropedit.description.delete">
<term><option>-d</option>, <option>--delete</option> <parameter>name</parameter></term>
<listitem>
<para>
Deletes all occurrences of the property <parameter>name</parameter>. Note that some properties are required and cannot be deleted.
</para>
</listitem>
</varlistentry>
<varlistentry id="mkvpropedit.description.tags">
<term><option>-t</option>, <option>--tags</option> <parameter>selector</parameter>:<parameter>filename</parameter></term>
<listitem>
<para>
Add or replace tags in the file with the ones from <filename>filename</filename> or remove them if <filename>filename</filename> is
empty. &mkvpropedit; reads the same XML tag format that &mkvmerge; reads as well.
</para>
<para>
The <parameter>selector</parameter> must be one of the words <constant>all</constant>, <constant>global</constant> or
<constant>track</constant>. For <constant>all</constant> &mkvpropedit; will replace or remove all tags in a file. With
<constant>global</constant> only global tags will be replaced or removed.
</para>
<para>
With <constant>track</constant> &mkvpropedit; will replace tags for a specific track. Additionally the tags read from
<filename>filename</filename> will be assigned to the same track. The track is specified in the same way <link
linkend="mkvpropedit.edit_selectors">edit selectors</link> are specified (see below), e.g. <code>--tags
track:a1:new-audio-tags.xml</code>.
</para>
</listitem>
</varlistentry>
<varlistentry id="mkvpropedit.description.chapters">
<term><option>-c</option>, <option>--chapters</option> <parameter>filename</parameter></term>
<listitem>
<para>
Add or replace chapters in the file with the ones from <filename>filename</filename> or remove them if <filename>filename</filename> is
empty. &mkvpropedit; reads the same XML and simple chapter formats that &mkvmerge; reads as well.
</para>
</listitem>
</varlistentry>
</variablelist>
<para>
Other options:
</para>
<variablelist>
<varlistentry id="mkvpropedit.description.command_line_charset">
<term><option>--command-line-charset</option> <parameter>character-set</parameter></term>
<listitem>
<para>
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.
</para>
</listitem>
</varlistentry>
<varlistentry id="mkvpropedit.description.output_charset">
<term><option>--output-charset</option> <parameter>character-set</parameter></term>
<listitem>
<para>
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.
</para>
</listitem>
</varlistentry>
<varlistentry id="mkvpropedit.description.redirect_output">
<term><option>-r</option>, <option>--redirect-output</option> <parameter>file-name</parameter></term>
<listitem>
<para>
Writes all messages to the file <parameter>file-name</parameter> 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 <link
linkend="mkvpropedit.description.output_charset"><option>--output-charset</option></link> is honored.
</para>
</listitem>
</varlistentry>
<varlistentry id="mkvpropedit.description.ui_language">
<term><option>--ui-language</option> <parameter>code</parameter></term>
<listitem>
<para>
Forces the translations for the language <parameter>code</parameter> to be used (e.g. '<literal>de_DE</literal>' for the German
translations). It is preferable to use the environment variables <varname>LANG</varname>, <varname>LC_MESSAGES</varname> and
<varname>LC_ALL</varname> though. Entering '<literal>list</literal>' as the <parameter>code</parameter> will cause &mkvextract; to
output a list of available translations.
</para>
</listitem>
</varlistentry>
<varlistentry id="mkvpropedit.description.debug">
<term><option>--debug</option> <parameter>topic</parameter></term>
<listitem>
<para>
Turn on debugging for a specific feature. This option is only useful for developers.
</para>
</listitem>
</varlistentry>
<varlistentry id="mkvpropedit.description.engage">
<term><option>--engage</option> <parameter>feature</parameter></term>
<listitem>
<para>
Turn on experimental features. A list of available features can be requested with <command>mkvpropedit --engage list</command>. These
features are not meant to be used in normal situations.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-v</option>, <option>--verbose</option></term>
<listitem>
<para>
Be verbose and show all the important &matroska; elements as they're read.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-h</option>, <option>--help</option></term>
<listitem>
<para>
Show usage information and exit.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-V</option>, <option>--version</option></term>
<listitem>
<para>
Show version information and exit.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--check-for-updates</option></term>
<listitem>
<para>
Checks online for new releases by downloading the URL <uri>http://mkvtoolnix-releases.bunkus.org/latest-release.xml</uri>. Four lines
will be output in <literal>key=value</literal> style: the URL from where the information was retrieved (key
<literal>version_check_url</literal>), the currently running version (key <literal>running_version</literal>), the latest release's
version (key <literal>available_version</literal>) and the download URL (key <literal>download_url</literal>).
</para>
<para>
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).
</para>
<para>
This option is only available if the program was built with support for libcurl.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>@</option><parameter>options-file</parameter></term>
<listitem>
<para>
Reads additional command line arguments from the file <parameter>options-file</parameter>. Lines whose first non-whitespace
character is a hash mark ('<literal>#</literal>') are treated as comments and ignored. White spaces at the start and end of a line
will be stripped. Each line must contain exactly one option.
</para>
<para>
Several chars can be escaped, e.g. if you need to start a non-comment line with '#'. The rules are described in <link
linkend="mkvpropedit.escaping">the section about escaping text</link>.
</para>
<para>
The command line '<command>mkvpropedit source.mkv --edit track:a2 --set name=Comments</command>' could be converted into the
following option file:
</para>
<programlisting># Modify source.mkv
source.mkv
# Edit the second audio track
--edit
track:a2
# and set the title to 'Comments'
--set
title=Comments</programlisting>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 id="mkvpropedit.edit_selectors">
<title>Edit selectors</title>
<para>
The <link linkend="mkvpropedit.description.edit"><option>--edit</option></link> option sets the &matroska; file section (segment
information or a certain track's headers) that all following <link linkend="mkvpropedit.description.add">add</link>, <link
linkend="mkvpropedit.description.set">set</link> and <link linkend="mkvpropedit.description.delete">delete</link> actions operate
on. This stays valid until the next <link linkend="mkvpropedit.description.edit"><option>--edit</option></link> option is found. The
argument to this option is called the edit selector.
</para>
<para>
By default &mkvpropedit; will edit the segment information section.
</para>
<refsect2 id="mkvpropedit.edit_selectors.segment_info">
<title>Segment information</title>
<para>
The segment information can be selected with one of these three words: '<literal>info</literal>', '<literal>segment_info</literal>' or
'<literal>segmentinfo</literal>'. It contains properties like the segment title or the segment <abbrev>UID</abbrev>.
</para>
</refsect2>
<refsect2 id="mkvpropedit.edit_selectors.track_headers">
<title>Track headers</title>
<para>
Track headers can be selected with a slightly more complex selector. All variations start with '<literal>track:</literal>'. The track
header properties include elements like the language code, 'default track' flag or the track's name.
</para>
<variablelist>
<varlistentry>
<term><option>track:</option><parameter>n</parameter></term>
<listitem>
<para>
If the parameter <parameter>n</parameter> is a number then the <parameter>n</parameter>th track will be selected. The track order is
the same that &mkvmerge;'s <option>--identify</option> option outputs.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>track:</option><parameter>t</parameter><parameter>n</parameter></term>
<listitem>
<para>
If the parameter starts with a single character <parameter>t</parameter> followed by a <parameter>n</parameter> then the
<parameter>n</parameter>th track of a specific track type will be selected. The track type parameter <parameter>t</parameter> must be
one of these four characters: '<literal>a</literal>' for an audio track, '<literal>b</literal>' for a button track,
'<literal>s</literal>' for a subtitle track and '<literal>v</literal>' for a video track. The track order is the same that
&mkvmerge;'s <option>--identify</option> option outputs.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>track:</option>=<parameter>uid</parameter></term>
<listitem>
<para>
If the parameter starts with a '<literal>=</literal>' followed by a number <parameter>uid</parameter> then the track whose track
<abbrev>UID</abbrev> element equals this <parameter>uid</parameter>. Track <abbrev>UIDs</abbrev> can be obtained with &mkvinfo;.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>track:</option>@<parameter>number</parameter></term>
<listitem>
<para>
If the parameter starts with a '<literal>@</literal>' followed by a number <parameter>number</parameter> then the track whose track
number element equals this <parameter>number</parameter>. Track number can be obtained with &mkvinfo;.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect2>
<refsect2 id="mkvpropedit.edit_selectors.notes">
<title>Notes</title>
<para>
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.
</para>
</refsect2>
</refsect1>
<refsect1 id="mkvpropedit.examples">
<title>Examples</title>
<para>
The following example edits a file called '<literal>movie.mkv</literal>'. 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 <link
linkend="mkvpropedit.description.edit"><option>--edit</option></link> option because editing the segment information element is the
default for all options found before the first <link linkend="mkvpropedit.description.edit"><option>--edit</option></link> option anyway.
</para>
<screen>$ mkvpropedit movie.mkv --edit info --set "title=The movie" --edit track:a1 --set language=fre --edit track:a2 --set language=ita</screen>
<para>
The second example removes the 'default track flag' from the first subtitle track and sets it for the second one. Note that
&mkvpropedit;, unlike &mkvmerge;, does not set the 'default track flag' of other tracks to '0' if it is set to '1' for a different track
automatically.
</para>
<screen>$ mkvpropedit movie.mkv --edit track:s1 --set flag-default=0 --edit track:s2 --set flag-default=1</screen>
<para>
Replacing the tags for the second subtitle track in a file looks like this:
</para>
<screen>$ mkvpropedit movie.mkv --tags track:s2:new-subtitle-tags.xml</screen>
<para>
Removing all tags requires leaving out the file name:
</para>
<screen>$ mkvpropedit movie.mkv --tags all:</screen>
<para>
Replacing the chapters in a file looks like this:
</para>
<screen>$ mkvpropedit movie.mkv --chapters new-chapters.xml</screen>
<para>
Removing all chapters requires leaving out the file name:
</para>
<screen>$ mkvpropedit movie.mkv --chapters ''</screen>
</refsect1>
<refsect1>
<title>Exit codes</title>
<para>
&mkvpropedit; exits with one of three exit codes:
</para>
<itemizedlist>
<listitem>
<para>
<constant>0</constant> -- This exit codes means that the modification has completed successfully.
</para>
</listitem>
<listitem>
<para>
<constant>1</constant> -- In this case &mkvpropedit; has output at least one warning, but the modification did continue. A warning is
prefixed with the text '<literal>Warning:</literal>'. 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.
</para>
</listitem>
<listitem>
<para>
<constant>2</constant> -- This exit code is used after an error occurred. &mkvpropedit; aborts right after outputting the error message.
Error messages range from wrong command line arguments over read/write errors to broken files.
</para>
</listitem>
</itemizedlist>
</refsect1>
<refsect1 id="mkvpropedit.escaping">
<title>Escaping special chars in text</title>
<para>
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.
</para>
<para>
The rules are: ' ' (a space) becomes '\s', '&quot;' (double quotes) becomes '\2', ':' becomes '\c', '#' becomes '\h' and '\' (a single backslash) itself becomes '\\'.
</para>
</refsect1>
<refsect1 id="mkvpropedit.environment_variables">
<title>Environment variables</title>
<para>
&mkvpropedit; uses the default variables that determine the system's locale (e.g. <varname>LANG</varname> and the <varname>LC_*</varname>
family). Additional variables:
</para>
<variablelist>
<varlistentry>
<term><varname>MKVTOOLNIX_DEBUG</varname> and its short form <varname>MTX_DEBUG</varname></term>
<listitem>
<para>The content is treated as if it had been passed via the <link
linkend="mkvpropedit.description.debug"><option>--debug</option></link> option.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>MKVTOOLNIX_ENGAGE</varname> and its short form <varname>MTX_ENGAGE</varname></term>
<listitem>
<para>The content is treated as if it had been passed via the <link
linkend="mkvpropedit.description.engage"><option>--engage</option></link> option.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>MKVTOOLNIX_OPTIONS</varname> and its short form <varname>MTX_OPTIONS</varname></term>
<listitem>
<para>The 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 <link
linkend="mkvpropedit.escaping">the section about escaping special characters in text</link>).</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 id="mkvpropedit.seealso">
<title>See also</title>
<para>
&mkvmerge;, &mkvinfo;, &mkvextract;, &mmg;
</para>
</refsect1>
<refsect1 id="mkvpropedit.www">
<title>WWW</title>
<para>
The latest version can always be found at <ulink url="http://www.bunkus.org/videotools/mkvtoolnix/">the MKVToolNix homepage</ulink>.
</para>
</refsect1>
</refentry>