muxtools.misc.chapters
Chapters
Chapters(chapter_source: PathLike | GlobSearch | LooseChapter | list[LooseChapter], timesource: TimeSourceT = Fraction(24000, 1001), timescale: TimeScaleT = TimeScale.MKV, _print: bool = True)
Convenience class for chapters
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chapter_source
|
PathLike | GlobSearch | LooseChapter | list[LooseChapter]
|
Input either txt with ogm chapters, xml or (a list of) self defined chapters. |
required |
timesource
|
TimeSourceT
|
The source of timestamps/timecodes. For details check the docstring on the type. |
Fraction(24000, 1001)
|
timescale
|
TimeScaleT
|
Unit of time (in seconds) in terms of which frame timestamps are represented. For details check the docstring on the type. |
MKV
|
_print
|
bool
|
Prints chapters after parsing and after trimming. |
True
|
Source code in
muxtools/misc/chapters.py
trim
Trims the chapters
Source code in
muxtools/misc/chapters.py
set_names
Renames the chapters
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
names
|
list[str | None]
|
List of names |
required |
Source code in
muxtools/misc/chapters.py
add
Adds a chapter at the specified index
Source code in
muxtools/misc/chapters.py
shift_chapter
Used to shift a single chapter by x frames
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chapter
|
int
|
Chapter number (starting at 0) |
0
|
shift_amount
|
int
|
Frames to shift by |
0
|
Source code in
muxtools/misc/chapters.py
shift
Shifts all chapters by x frames.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shift_amount
|
int
|
Frames to shift by |
required |
Source code in
muxtools/misc/chapters.py
print
Prettier print for these because default timedelta formatting sucks
Source code in
muxtools/misc/chapters.py
to_file
Outputs the chapters to an OGM file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
out
|
PathLike | None
|
Can be either a directory or a full file path |
None
|
minus_one_ms_hack
|
bool
|
If True, every chapter will be shifted by -1ms to avoid issues with some players |
True
|
Source code in
muxtools/misc/chapters.py
from_sub
staticmethod
from_sub(file: PathLike | SubFile, timesource: TimeSourceT = None, timescale: TimeScaleT = None, use_actor_field: bool = False, markers: str | list[str] = ['chapter', 'chptr'], _print: bool = True, encoding: str = 'utf_8_sig') -> 'Chapters'
Extract chapters from an ass file or a SubFile.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file
|
PathLike | SubFile
|
Input ass file or SubFile |
required |
timesource
|
TimeSourceT
|
The source of timestamps/timecodes. For details check the docstring on the type. |
None
|
timescale
|
TimeScaleT
|
Unit of time (in seconds) in terms of which frame timestamps are represented. For details check the docstring on the type. |
None
|
use_actor_field
|
bool
|
Uses the actor field instead of the effect field for identification. |
False
|
markers
|
str | list[str]
|
Markers to check for. |
['chapter', 'chptr']
|
_print
|
bool
|
Prints the chapters after parsing |
True
|
encoding
|
str
|
Encoding used to read the ass file if need be |
'utf_8_sig'
|
Source code in
muxtools/misc/chapters.py
from_mkv
staticmethod
from_mkv(file: PathLike, timesource: TimeSourceT = None, timescale: TimeScaleT = None, _print: bool = True, quiet: bool = True) -> 'Chapters'
Extract chapters from mkv.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file
|
PathLike
|
Input mkv file |
required |
timesource
|
TimeSourceT
|
The source of timestamps/timecodes. For details check the docstring on the type. |
None
|
timescale
|
TimeScaleT
|
Unit of time (in seconds) in terms of which frame timestamps are represented. For details check the docstring on the type. |
None
|
_print
|
bool
|
Prints the chapters after parsing |
True
|