mkvextract -- Matroska(tm) 파일에서 다른 파일로 트랙 추출

Table of contents

1. 개요

mkvextract {모드} {소스-파일명} 옵션 추출-스펙

2. 설명

이 프로그램은 Matroska(tm) 파일에서 다른 유용한 형식으로 특정 부분을 추출합니다. 첫번째 인수인 modemkvextract(1) 에게 추출할 것을 알려 줍니다. 현재 tracks, tags, attachments, chapters, CUE sheets, timecodes and cues의 추출을 지원합니다. 두 번째 인수는 소스 파일의 이름인데 반드시 Matroska(tm) 파일이어야 합니다. 다음의 모든 인수들은 옵션과 추출 사양입니다; 두 가지 모두 선택한 모드에 따라 다릅니다.

2.1. 공통 옵션

다음 옵션은 모든 모드에서 사용 가능하고 이 부분에서 단 한번만 설명합니다.

Option Description
-f, --parse-fully

분석 모드를 '전부'로 설정합니다. 기본 모드는 전체 파일을 분석하지 않지만 소스 파일의 필요한 요소를 찾기 위해 메타 탐색 요소를 사용합니다. 이것은 99% 가량의 모든 경우에 충분합니다. 그러나 메타 탐색 요소를 포함하지 않거나 손상된 파일에서 사용자는 이 모드를 사용해야 할 지 모릅니다. 빠른 스캔은 몇 초밖에 안 걸리지만, 파일 전체 스캔은 이 삼분 걸릴 수 있습니다.

--command-line-charset 문자셋

명령행에 주어진 문자열을 변환할 문자셋을 정합니다. 기본값은 현재 시스템 로케일에 따른 문자셋입니다.

--output-charset 문자셋

출력할 문자열을 변환할 문자셋을 정합니다. 기본값은 현재 시스템 로케일에 따른 문자셋입니다.

-r, --redirect-output 파일명

모든 메시지를 콘솔 화면 대신 파일명 파일에 기록합니다. 이것은 출력 방향 전환으로 쉽게 할 수 있지만 이 옵션이 필요한 경우가 있습니다: 터미널이 파일에 출력하기 전에 출력을 재해석할 때. 문자셋 설정은 --output-charset 을 준수합니다.

--ui-language 코드

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 토픽

특정 기능에 대해 디버깅을 켭니다. 이 기능은 개발자에게만 유용합니다.

--engage 기능

실험적인 기능을 켭니다. 이용 가능한 기능 목록은 mkvextract --engage list로 요청할 수 있습니다. 이 기능들은 보통 상황에서는 사용하면 안 됩니다.

--gui-mode

GUI 모드를 켭니다. 이 모드에서는 GUI 동작시 무슨 일이 일어나는지 알려줄 수 있는 특별하게 형식화된 줄을 출력할 것입니다. 이 메시지들은 '#GUI#message' 형식을 따릅니다. 이 메시지 뒤에 '#GUI#message#key1=value1#key2=value2…' 형태의 키/값 쌍이 붙을 수 있습니다. 메시지나 키값들은 결코 번역되지 않고 항상 영어로 출력됩니다.

-v, --verbose

읽어들인 모든 중요한 Matroska(tm) 요소를 자세하게 보여 줍니다.

-h, --help

사용법에 관한 정보를 표시하고 종료합니다.

-V, --version

버전 정보를 표시하고 종료합니다.

--check-for-updates

http://mkvtoolnix-releases.bunkus.org/latest-release.xml URL을 다운로드하여 새로운 버전이 나왔는지 온라인에서 확인합니다. key=value 스타일의 네 줄이 출력될 것입니다: 정보를 검색하는 주소 (key version_check_url), 현재 실행 중인 버전 (key running_version), 가장 최근에 나온 버전 (key available_version), 다운로드 URL (key download_url).

이후에 프로그램은 이용 가능한 새 버전이 없으면 0, 새 버전이 있으면 1, 오류 발생시(업데이트 정보를 가져올 수 없는 경우)는 2의 종료 코드를 가지고 있습니다.

이 옵션은 libcurl을 지원하도록 프로그램을 만든 경우에만 이용 가능합니다.

@옵션 파일

options-file 파일에서 추가적인 명령행 인수를 읽습니다. 공백이 아닌 첫번째 문자가 해쉬 표시('#')인 줄은 주석으로 간주하여 무시합니다. 줄의 앞과 끝의 공백은 제거될 것입니다. 각 줄에는 반드시 한 개의 옵션을 포함해야 합니다.

예를 들어 '#'이 붙은 비주석 줄을 시작할 필요가 있는 경우에는 몇몇 확장 문자를 사용할 수 있습니다. 규칙은 확장 텍스트에 대한 부분에 기술되어 있습니다.

명령행 'mkvextract tracks 소스.mkv --raw 1:대상.raw'은 다음 옵션 파일로 변환될 수 있습니다:

# 소스.mkv에서 트랙 추출
tracks
소스.mkv
# 트랙을 원시 데이터로 출력
--raw
1:대상.raw

2.2. 트랙 추출 모드

구문: mkvextract tracks 소스파일명 [옵션] TID1:대상파일명1 [TID2:대상파일명2 ...]

다음 명령행 옵션은 '트랙' 추출 모드에서 각 트랙에 대해 사용할 수 있습니다. 이 옵션들은 적용이 되야 하는 트랙 사양(아래 참고) 의 앞쪽에 나타나야 합니다.

Option Description
-c 문자셋

다음 자막 트랙을 변환할 문자셋을 설정합니다. 다음 트랙 ID가 텍스트 자막 트랙을 대상으로 하는 경우에만 유효합니다. 기본값은 UTF-8.

--blockadd 수준

이 수준까지만 BlockAddition을 유지합니다. 기본값은 모든 수준을 유지하는 것입니다. 이 옵션은 WAVPACK4같은 특정한 코덱에만 효과가 있습니다.

--cuesheet

mkvextract(1)로 시트를 챕터 정보에서 추출하고 다음 트랙의 데이터를 파일명이 트랙의 출력 이름이고 확장자가 '.cue' 인 파일에 태그로 기록합니다.

--raw

컨테이너에서 원시 데이터를 파일로 추출합니다. --fullraw 플래그와 다르게 이 플래그는 CodecPrivate 요소의 내용이 그 파일에 기록되지 않습니다. 이 모드는 모든 CodecIDs와 동작합니다. 그 외에 mkvextract(1)가 지원하지 않는 CodecIDs에서도 동작이 됩니다. 다만 그 결과로 나오는 파일은 아마도 사용하지 못할 것입니다.

--fullraw

Extracts the raw data into a file without any container data around it. The contents of the CodecPrivate element will be written to the file first if the track contains such a header element. This mode works with all CodecIDs, even the ones that mkvextract(1) doesn't support otherwise, but the resulting files might not be usable.

TID:outname

Causes extraction of the track with the ID TID into the file outname if such a track exists in the source file. This option can be given multiple times. The track IDs are the same as the ones output by mkvmerge(1)'s --identify option.

Each output name should be used only once. The exception are RealAudio and RealVideo tracks. If you use the same name for different tracks then those tracks will be saved in the same file. Example:

$ mkvextract tracks input.mkv 1:output-two-tracks.rm 2:output-two-tracks.rm

2.3. 태그 추출 모드

Syntax: mkvextract tags source-filename [options]

The extracted tags are written to the console unless the output is redirected (see the section about output redirection for details).

2.4. 첨부 파일 추출 모드

Syntax: mkvextract attachments source-filename [options] AID1:outname1 [AID2:outname2 ...]

Option Description
AID:outname

Causes extraction of the attachment with the ID AID into the file outname if such an attachment exists in the source file. If the outname is left empty then the name of the attachment inside the source Matroska(tm) file is used instead. This option can be given multiple times. The attachment IDs are the same as the ones output by mkvmerge(1)'s --identify option.

2.5. 챕터 추출 모드

Syntax: mkvextract chapters source-filename [options]

Option Description
-s, --simple

Exports the chapter information in the simple format used in the OGM tools (CHAPTER01=..., CHAPTER01NAME=...). In this mode some information has to be discarded. Default is to output the chapters in XML format.

--simple-language language

If the simple format is enabled then mkvextract(1) will only output a single entry for each chapter atom encountered even if a chapter atom contains more than one chapter name. By default mkvextract(1) will use the first chapter name found for each atom regardless of its language.

Using this option allows the user to determine which chapter names are output if atoms contain more than one chapter name. The language parameter must be an ISO 639-1 or ISO 639-2 code.

The extracted chapters are written to the console unless the output is redirected (see the section about output redirection for details).

2.6. 큐시트 추출 모드

Syntax: mkvextract cuesheet source-filename [options]

The extracted cue sheet is written to the console unless the output is redirected (see the section about output redirection for details).

2.7. 타임코드 추출 모드

Syntax: mkvextract timecodes_v2 source-filename [options] TID1:dest-filename1 [TID2:dest-filename2 ...]

The extracted timecodes are written to the console unless the output is redirected (see the section about output redirection for details).

Option Description
TID:outname

Causes extraction of the timecodes for the track with the ID TID into the file outname if such a track exists in the source file. This option can be given multiple times. The track IDs are the same as the ones output by mkvmerge(1)'s --identify option.

예:

$ mkvextract timecodes_v2 input.mkv 1:tc-track1.txt 2:tc-track2.txt

2.8. 큐 추출 모드

Syntax: mkvextract cues source-filename [options] TID1:dest-filename1 [TID2:dest-filename2 ...]

Option Description
TID:dest-filename

Causes extraction of the cues for the track with the ID TID into the file outname if such a track exists in the source file. This option can be given multiple times. The track IDs are the same as the ones output by mkvmerge(1)'s --identify option and not the numbers contained in the CueTrack element.

The format output is a simple text format: one line per CuePoint element with key=value pairs. If an optional element is not present in a CuePoint (e.g. CueDuration) then a dash will be output as the value.

예:

timecode=00:00:13.305000000 duration=- cluster_position=757741 relative_position=11

The possible keys are:

Option Description
타임코드

The cue point's timecode with nanosecond precision. The format is HH:MM:SS.nnnnnnnnn. This element is always set.

지속 시간

The cue point's duration with nanosecond precision. The format is HH:MM:SS.nnnnnnnnn.

클러스터_위치

The absolute position in bytes inside the Matroska(tm) file where the cluster containing the referenced element starts.

Note:

Inside the Matroska(tm) file the CueClusterPosition is relative to the segment's data start offset. The value output by mkvextract(1)'s cue extraction mode, however, contains that offset already and is an absolute offset from the beginning of the file.

상대적인_위치

The relative position in bytes inside the cluster where the BlockGroup or SimpleBlock element the cue point refers to starts.

Note:

Inside the Matroska(tm) file the CueRelativePosition is relative to the cluster's data start offset. The value output by mkvextract(1)'s cue extraction mode, however, is relative to the cluster's ID. The absolute position inside the file can be calculated by adding cluster_position and relative_position.

예:

$ mkvextract cues input.mkv 1:cues-track1.txt 2:cues-track2.txt

3. 출력 방향 변경

Several extraction modes cause mkvextract(1) to write the extracted data to the console. There are generally two ways of writing this data into a file: one provided by the shell and one provided by mkvextract(1) itself.

The shell's builtin redirection mechanism is used by appending '> output-filename.ext' to the command line. Example:

$ mkvextract tags source.mkv > tags.xml

mkvextract(1)'s own redirection is invoked with the --redirect-output option. Example:

$ mkvextract tags source.mkv --redirect-output tags.xml

Note:

On Windows you should probably use the --redirect-output option because cmd.exe sometimes interpretes special characters before they're written into the output file resulting in broken output.

4. Text files and character set conversions

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.

5. 출력 파일 형식

The decision about the output format is based on the track type, not on the extension used for the output file name. The following track types are supported at the moment:

Option Description
V_MPEG4/ISO/AVC

H.264 / AVC video tracks are written to H.264 elementary streams which can be processed further with e.g. MP4Box(tm) from the GPAC(tm) package.

V_MS/VFW/FOURCC

Fixed FPS video tracks with this CodecID are written to AVI files.

V_REAL/*

RealVideo(tm) tracks are written to RealMedia(tm) files.

V_THEORA

Theora(tm) streams will be written within an Ogg(tm) container

V_VP8, V_VP9

VP8 / VP9 tracks are written to IVF files.

A_MPEG/L2

MPEG-1 Audio Layer II streams will be extracted to raw MP2 files.

A_MPEG/L3, A_AC3

These will be extracted to raw MP3 and AC-3 files.

A_PCM/INT/LIT

Raw PCM data will be written to a WAV file.

A_AAC/MPEG2/*, A_AAC/MPEG4/*, A_AAC

All AAC files will be written into an AAC file with ADTS headers before each packet. The ADTS headers will not contain the deprecated emphasis field.

A_VORBIS

Vorbis audio will be written into an OggVorbis(tm) file.

A_REAL/*

RealAudio(tm) tracks are written to RealMedia(tm) files.

A_TTA1

TrueAudio(tm) tracks are written to TTA files. Please note that due to Matroska(tm)'s limited timecode precision the extracted file's header will be different regarding two fields: data_length (the total number of samples in the file) and the CRC.

A_ALAC

ALAC tracks are written to CAF files.

A_FLAC

FLAC tracks are written to raw FLAC files.

A_WAVPACK4

WavPack(tm) tracks are written to WV files.

A_OPUS

Opus(tm) tracks are written to OggOpus(tm) files.

S_TEXT/UTF8

Simple text subtitles will be written as SRT files.

S_TEXT/SSA, S_TEXT/ASS

SSA and ASS text subtitles will be written as SSA/ASS files respectively.

S_KATE

Kate(tm) streams will be written within an Ogg(tm) container.

S_VOBSUB

VobSub(tm) subtitles will be written as SUB files along with the respective index files, as IDX files.

S_TEXT/USF

USF text subtitles will be written as USF files.

S_HDMV/PGS

PGS subtitles will be written as SUP files.

태그

Tags are converted to a XML format. This format is the same that mkvmerge(1) supports for reading tags.

첨부 파일

Attachments are written to they output file as they are. No conversion whatsoever is done.

챕터

Chapters are converted to a XML format. This format is the same that mkvmerge(1) supports for reading chapters. Alternatively a stripped-down version can be output in the simple OGM style format.

타임코드

Timecodes are first sorted and then output as a timecode v2 format compliant file ready to be fed to mkvmerge(1). The extraction to other formats (v1, v3 and v4) is not supported.

6. 종료 코드

mkvextract(1) exits with one of three exit codes:

7. Escaping special chars in text

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.

The rules are: ' ' (a space) becomes '\s', '"' (double quotes) becomes '\2', ':' becomes '\c', '#' becomes '\h' and '\' (a single backslash) itself becomes '\\'.

8. Environment variables

mkvextract(1) uses the default variables that determine the system's locale (e.g. LANG and the LC_* family). Additional variables:

Option Description
MKVEXTRACT_DEBUG, MKVTOOLNIX_DEBUG and its short form MTX_DEBUG

The content is treated as if it had been passed via the --debug option.

MKVEXTRACT_ENGAGE, MKVTOOLNIX_ENGAGE and its short form MTX_ENGAGE

The content is treated as if it had been passed via the --engage option.

MKVEXTRACT_OPTIONS, MKVTOOLNIX_OPTIONS and its short form MTX_OPTIONS

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 the section about escaping special characters in text).

9. 더 보기

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

10. WWW

The latest version can always be found at the MKVToolNix homepage.