Skip to content

Subtitles and Chapters

Alex H edited this page Jun 4, 2023 · 4 revisions

Subtitles

Uh... there are a lot of subtitle processing functions in the SubFile class.
It would probably take a lot of time to explain them here again so go read the docstrings.

Basic Usage

from vsmuxtools import SubFile, GJM_GANDHI_PRESET, GlobSearch, dummy_video

# Might be worth noting that none of this touches the original input file
# A copy to the work directory is always the first step
# You can simply chain everything like this as they all return the SubFile object again
subtitle = SubFile(R"test.ass") \
    .resample("random video.mkv") \
    .restyle(GJM_GANDHI_PRESET) \
    .syncpoint_merge("opsync", "opening.ass") \
    .clean_styles()

# Also possible to resample with a dummy video
subtitle.resample(dummy_video(width=1920, height=1080))

# You can do a basic merge of more 2+ files like this
subtitle = SubFile([R"dialogue.ass", R"signs.ass"])

# ... or with a GlobSearch
subtitle = SubFile(GlobSearch("*_en.ass", allow_multiple=True, dir="./subs/english"))

All of those subtitle variables are a SubFile object.
To get the filepath you simply do subtitle.file.

Chapters

As usual, check the docstrings for all the available functions you can use in Chapters.

Note that this doesn't include the src_file part because it's not in muxtools.
For that, check this.

from vsmuxtools import Chapters, src_file

# If you pass a src_file it will try parsing it from the BDMV playlists if it detects a BDMV file stucture
# ofc it will also account for the trims
JPBD = src_file(R"F:\BDMV\Main Disc\BDMV\STREAM\00002.m2ts", trim=(24, 500))
chapters = Chapters(JPBD)

# then you could set the names like
chapters.set_names(["Prologue", "Opening", "Part A", "Part B", "Ending"])

# You can also manually define chapters like this: (obviously frame numbers)
chapters = Chapters([(0, "Prologue"), (2110, "Opening"), (4268, "Episode"), (32981, "Ending")])
Clone this wiki locally