muxtools.helpers.extract
MKVExtract
A helper for mkvextract to extract tracks and attachments without conversion.
Creates the mkvextract helper for a Matroska or WebM file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fileIn
|
PathLike
|
File to extract from. |
required |
output
|
PathLike
|
Default output directory. The directory will be created if it does not exist. |
None
|
Source code in
muxtools/helpers/extract.py
video_track
video_track(track: int = 0, output: PathLike = None, quiet: bool = True, **kwargs: Any) -> VideoTrack
Extract a video track from the file.
The track name, language, default/forced flags and custom tags are inherited unless overridden.
Timestamps are extracted automatically to preserve variable frame rate and container timing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
track
|
int
|
Relative video track number, starting at 0. |
0
|
output
|
PathLike
|
Custom output. Can be an existing directory or a file.
The file extension will be set automatically. |
None
|
quiet
|
bool
|
Suppresses the output. The stdout will still be printed on failure regardless of this setting. |
True
|
kwargs
|
Any
|
Any other parameters to pass to Pass
|
{}
|
Returns:
| Type | Description |
|---|---|
VideoTrack
|
The extracted video as a |
Source code in
muxtools/helpers/extract.py
audio_track
audio_track(track: int = 0, output: PathLike = None, quiet: bool = True, **kwargs: Any) -> AudioTrack
Extract an audio track from the file without conversion.
The track name, language, default/forced flags and custom tags are inherited unless overridden.
The format has to be supported by AudioFormat. Existing container timing is preserved.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
track
|
int
|
Relative audio track number, starting at 0. |
0
|
output
|
PathLike
|
Custom output. Can be an existing directory or a file.
The file extension will be set automatically. |
None
|
quiet
|
bool
|
Suppresses the output. The stdout will still be printed on failure regardless of this setting. |
True
|
kwargs
|
Any
|
Any other parameters to pass to
|
{}
|
Returns:
| Type | Description |
|---|---|
AudioTrack
|
The extracted audio as an |
Source code in
muxtools/helpers/extract.py
sub_track
Extract a subtitle track from the file without conversion. SRT will stay SRT.
The track name, language, default/forced flags and custom tags are inherited unless overridden.
Existing subtitle timing is preserved. VobSub returns an .idx file with its .sub companion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
track
|
int
|
Relative subtitle track number, starting at 0. |
0
|
output
|
PathLike
|
Custom output. Can be an existing directory or a file.
The file extension will be set automatically. |
None
|
quiet
|
bool
|
Suppresses the output. The stdout will still be printed on failure regardless of this setting. |
True
|
kwargs
|
Any
|
Any other parameters to pass to
|
{}
|
Returns:
| Type | Description |
|---|---|
SubTrack
|
The extracted subtitle as a |
Source code in
muxtools/helpers/extract.py
attachment
attachment(track: int = 0, output: PathLike = None, quiet: bool = True, *, name: str | None = None, mimetype: str | None = None) -> Attachment
Extract an attachment from the file.
The original attachment name and MIME type are inherited unless overridden.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
track
|
int
|
Relative attachment number, starting at 0. |
0
|
output
|
PathLike
|
Custom output. Can be an existing directory or a file.
Generated filenames are based on the original attachment name. |
None
|
quiet
|
bool
|
Suppresses the output. The stdout will still be printed on failure regardless of this setting. |
True
|
name
|
str | None
|
Name of the attachment when muxing. |
None
|
mimetype
|
str | None
|
MIME type of the returned attachment. |
None
|
Returns:
| Type | Description |
|---|---|
Attachment
|
The extracted attachment as an |
Source code in
muxtools/helpers/extract.py
attachments
Extract all attachments from the file in one pass.
Original attachment names and MIME types are preserved.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output
|
PathLike
|
Output directory. The directory will be created if it does not exist. |
None
|
quiet
|
bool
|
Suppresses the output. The stdout will still be printed on failure regardless of this setting. |
True
|
Returns:
| Type | Description |
|---|---|
list[Attachment]
|
A list of An empty list is returned if the file has no attachments. |