mkvpropedit(1) 再MUXすることなく、既存のMatroska(TM)ファイルのプロパティを修正する

書式

mkvpropedit [options] {source-filename} {actions}

説明

このプログラムは、既存のMatroska(TM)ファイルを解析し、そのプロパティのいくつかを修正します。そして、それらの修正を既存のファイルに書き込みます。プロパティの中で変更可能なのは、セグメント情報エレメント(例えばタイトル)と、トラックヘッダ(例えば言語コードや'デフォルトトラック'フラグ、トラック名)です。

オプション:

-l, --list-property-names

既知の編集可能なプロパティの名前、型(文字列、整数、真偽値等)、短い説明を一覧表示します。その後、プログラムは終了します。よって、source-filenameパラメータを指定する必要はありません。

-p, --parse-mode mode

解析モードを設定します。'mode'パラメータは'fast'(デフォルト)と'full'のどちらかを指定できます。'fast'モードはファイル全体を解析するのではなく、メタシークエレメントを使ってソースファイル内の必要なエレメントを探します。99%の場合これで十分です。しかし、メタシークエレメントを含まないファイルや破損したファイルに対しては'full'解析モードを指定する必要があるかもしれません。'full'スキャンには数分かかることがありますが、'fast'スキャンには数秒しかかかりません。

Actions that deal with track and segment info properties:

-e, --edit selector

このオプション以降のadd、set、deleteアクションが適用されるMatroska(TM)ファイルセクション(セグメント情報または特定のトラックのヘッダ)を指定します。このオプションは、複数のエレメントを修正するために、複数回指定することができます。

デフォルトでは、mkvpropedit(1)はセグメント情報のセクションを編集します。

文法の完全な説明は、エディットセレクタのセクションを参照してください。

-a, --add name=value

nameで指定された名前のプロパティをvalueで指定した値で追加します。プロパティは、既にその名前のプロパティが存在する場合も追加されます。ほとんどのプロパティは一意的で、複数回追加できないことに注意してください。

-s, --set name=value

見付けた全ての、プロパティ名がnameであるプロパティの値を、valueに設定します。そのようなプロパティが存在しないときは、プロパティは追加されます。

-d, --delete name

見付けた全ての、プロパティ名がnameであるプロパティを削除します。いくつかのプロパティは必須で、削除できないことに注意してください。

Actions that deal with tags and chapters:

-t, --tags selector:filename

ファイル名からのタグを、このファイル中のタグに追加、あるいは置換します。もしファイル名が空白なら、タグを削除します。mkvpropedit(1)は、mkvmerge(1)が読み込むのと同じXMLタグフォーマットを読み込みます。

セレクタは、allglobal、またはtrackのうちどれか一つを指定してください。allを指定すると、mkvpropedit(1)はファイル中の全てのタグを置換あるいは削除します。globalを指定すると、グローバルタグだけが置換あるいは削除されます。

trackを指定すると、mkvpropedit(1)は特定のトラックのタグを置換します。また、filenameから読み込まれたタグは、同じトラックに割り当てられます。edit selectorsが指定されるのと同じ様に(下を参照してください)、トラックは指定されます。(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 filename

ファイル名からのチャプタを、このファイル中のタグに追加、あるいは置換します。もしファイル名が空白なら、チャプタを削除します。mkvpropedit(1)は、mkvmerge(1)が読み込むのと同じXMLまたはシンプルチャプタフォーマットを読み込みます。

Actions for handling attachments:

--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.

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 exlained 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 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.

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 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 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:

--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 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.

その他のオプション:

--command-line-charset character-set

コマンドライン文字列の文字コードを指定します。デフォルトは、システムの現在のロケールの文字コードになります。

--output-charset character-set

出力する文字コードを指定します。デフォルトは、システムの現在のロケールの文字コードになります。

-r, --redirect-output file-name

全てのメッセージをコンソールではなくfile-nameで指定したファイルに書き出します。出力リダイレクトによっても同じことが簡単にできますが、このオプションが必要な場合もあります。ターミナルがファイルに書き込む前に出力を処理してしまう場合などです。--output-charsetによって指定された文字コードは尊重されます。

--ui-language code

Forces the translations for the language code to be used (e.g. 'de_DE' for the German translations). Entering 'list' as the code will cause the program to output a list of available translations.

--debug topic

特定の機能のデバッグをオンにします。このオプションは開発者にのみ有用です。

--engage feature

実験的機能をオンにします。利用可能な機能のリストはmkvpropedit --engage listで得られます。これらの機能は通常の状況で利用されることは意図されていません。

--gui-mode

Turns on GUI mode. In this mode specially-formatted lines may be output that can tell a controlling GUI what's happening. These messages follow the format '#GUI#message'. The message may be followed by key/value pairs as in '#GUI#message#key1=value1#key2=value2...'. Neither the messages nor the keys are ever translated and always output in English.

-v, --verbose

出力が冗長になり、Matroska(TM)のエレメントにとって重要なこと全てを、読み込まれるつどに表示していきます。

-h, --help

コマンド書式情報を出力して終了します。

-V, --version

バージョン情報を出力して終了します。

--check-for-updates

Checks online for new releases by downloading the URL m[blue]http://mkvtoolnix-releases.bunkus.org/latest-release.xmlm[]. Four lines will be output in key=value style: the URL from where the information was retrieved (key version_check_url), the currently running version (key running_version), the latest release's version (key available_version) and the download URL (key download_url).

その後プログラムは、新しいリリースが入手可能ではなかった場合は終了コード0で、新しいリリースが入手可能であった場合は終了コード1で、エラーが発生した場合(例:アップデート情報を取得できなかった場合)は終了コード2で、それぞれ終了します。

このオプションは、プログラムがlibcurlのサポートつきでビルドされた場合のみ使用できます。

@options-file

options-fileで指定されたファイルから追加のコマンドラインオプションを読み込みます。行で最初の空白文字でない文字がハッシュマーク('#')である行はコメントとして扱われ、無視されます。行頭、及び行末の空白文字は取り除かれます。各行には一つずつしかオプションを指定できません。

エスケープすることのできる文字もあります。例えば、コメントではない行を'#'で始める必要のある場合です。そのルールは、エスケープ文字についてのセクションで説明されています。

'mkvpropedit source.mkv --edit track:a2 --set name=Comments'というコマンドラインと同じことは、次のようなオプションファイルによって指定できます。

# Modify source.mkv
source.mkv
# Edit the second audio track
--edit
track:a2
# and set the title to 'Comments'
--set
name=Comments

エディットセレクタ

--editオプションは、以降のadd、set及びdeleteアクションが適用されるMatroska(TM)ファイルセクション(セグメント情報または特定のトラックヘッダ)を設定します。これは次の--editオプションが見付かるまでずっと有効です。このオプションへの引数はエディットセレクタと呼ばれます。

デフォルトでは、mkvpropedit(1)はセグメント情報のセクションを編集します。

セグメント情報

セグメント情報は次の3つの単語によって選択されます。'info'、'segment_info'または'segmentinfo'です。これはセグメントタイトルやセグメントUIDなどのプロパティを格納しています。

トラックヘッダ

トラックヘッダはもうちょっとだけ複雑なセレクタで選択されます。全ての場合でセレクタは'track:'で始まります。トラックヘッダプロパティには、言語コード、'デフォルトトラック'フラグやトラック名のようなエレメントがあります。

track:n

パラメータnが数字であれば、n番目のトラックが選択されます。トラックの順番は、mkvmerge(1)に--identifyオプションを指定すると出力されるものと同じです。

Numbering starts at 1.

track:tn

パラメータが一文字の英字tで始まり、次にnが続く場合、あるトラックタイプでn番目のトラックが選択されます。トラックタイプパラメータtは、オーディオトラックを示す'a'、ボタントラックを示す'b'、字幕トラックを示す's'、ビデオトラックを示す'v'の四つのうちの一つでなければなりません。トラックの順番はmkvmerge(1)の--identifyオプションで出力される順番と同じです。

Numbering starts at 1.

track:=uid

パラメータが'='で始まり、次にuidが続く場合は、トラックUIDエレメントがuidのトラックが選択されます。トラックUIDはmkvinfo(1)で取得できます。

track:@number

パラメータが'@'で始まり、次にnumberが続く場合は、トラックナンバーエレメントがnumberと等しいトラックが選択されます。トラックナンバーはmkvinfo(1)で取得できます。

注意

トラックエディットセレクタの性質から、いくつかのセレクタが同じトラックヘッダにマッチすることがあります。このような場合、それらのエディットセレクタへの全てのアクションは一つにまとめられ、コマンドラインに指定された順番に実行されます。

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:

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.

下に'movie.mkv'というファイルを編集する例を示します。この例では、セグメントタイトルを設定し、オーディオトラックと字幕トラックの言語コードを修正します。この例は、最初の--editオプションが見付かる前の全てのオプションはデフォルトで結局セグメント情報エレメントを編集するので、最初の--editオプションを省略して短縮できることに注意してください。

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

二番目の例は、最初の字幕トラックから'デフォルトトラックフラグ'を削除し二番目の字幕トラックに設定します。mkvpropedit(1)はmkvmerge(1)とは違い、'デフォルトトラックフラグ'が違うトラックで'1'に設定されているからといって自動的に他のトラックの'デフォルトトラックフラグ'を'0'に設定はしない、という点に注意してください。

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

ファイル中で2番目の字幕トラックのタグを置換するには、以下のようにします:

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

タグを削除するには、ファイル名を空白にします

$ mkvpropedit movie.mkv --tags all:

ファイル中のチャプタを置換するには、以下のようにします:

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

全てのチャプタを削除するには、ファイル名を空白にします

$ 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

Replacing one attached font (Comic.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

返り値

mkvpropedit(1)は下の3つの返り値を返します。

0 -- この返り値は変更が成功したことを示します。

1 -- この返り値は、一つ以上の警告が出力されましたが、抽出が続行されたことを意味します。警告は '警告:' という文字列を先頭につけて出力されます。出力ファイルが無事であるかどうかは、場合によります。出力ファイルを確認することを強く推奨します。

2 -- この返り値は、エラーが発生し、エラーメッセージを表示した直後にmkvpropedit(1)が終了したことを示します。エラーメッセージは不正なコマンドラインやファイルI/Oエラー、壊れたファイルなど様々です。

テキストファイルと文字コード変換

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.

テキスト中の特殊文字をエスケープする

特殊文字をエスケープしなければならない、あるいはすべき場所が少しだけあります。エスケープのルールは単純です:エスケープする必要のある各文字を、バックスラッシュ(Windows上の日本語フォントでは\記号)の後ろに違う文字が1つついたものと入れ替えます。

ルール:' '(半角スペース)は'\s'に、'"'(ダブルクォーテーション)は'\2'に、':'は'\c'に、'#'は'\h'に、そして'\'それ自体は'\\'になります。

環境変数

mkvpropedit(1)はシステムのロケールを決めるデフォルトの変数(例:LANGLC_*系)を使用します。追加の変数は以下の通りです:

MKVPROPEDIT_DEBUG, MKVTOOLNIX_DEBUG and its short form MTX_DEBUG

その内容は、あたかも--debugオプション経由で渡されたかのように扱われます。

MKVPROPEDIT_ENGAGE, MKVTOOLNIX_ENGAGE and its short form MTX_ENGAGE

その内容は、あたかも--engageオプション経由で渡されたかのように扱われます。

MKVPROPEDIT_OPTIONS, MKVTOOLNIX_OPTIONS and its short form MTX_OPTIONS

その内容は空白で分割されます。得られた一部の文字列は、あたかもそれがコマンドラインオプションとして渡されたかのように扱われます。もし特殊な文字(例:空白)を渡す必要があるなら、それらをエスケープする必要があります(テキスト中の特殊文字のエスケープについてのセクションをご覧ください)。

ウェブ

最新のバージョンは、常時m[blue]MKVToolNixのホームページm[][1]から取得できます。

著者

Bunkus Moritz[FAMILY Given] <[email protected]>

開発者

注記

1.
MKVToolNixのホームページ
https://mkvtoolnix.download/