movis.subtitle.write_ass_file#

movis.subtitle.write_ass_file(start_times: Sequence[float], end_times: Sequence[float], texts: Sequence[str], dst_ass_file: str | PathLike, size: tuple[int, int] = (1920, 1080), characters: Sequence[str] | None = None, styles: Sequence[ASSStyleType] | None = None) None[source]#

Writes an ASS (Advanced SubStation Alpha) subtitle file.

Args:
start_times:

A list of start times in seconds for each subtitle entry.

end_times:

A list of end times in seconds for each subtitle entry.

texts:

A list of text strings corresponding to each subtitle entry.

dst_ass_file:

The destination path for the generated ASS file.

size:

The resolution of the video, defaults to (1920, 1080).

characters:

A list of character names for each subtitle entry. Defaults to None.

styles:

A list of styles for each subtitle entry. Defaults to None.

Examples:
>>> import movis as mv
>>> mv.write_ass_file(
...     start_times=[0.0, 1.0, 3.0],
...     end_times=[1.0, 3.0, 4.0],
...     texts=['Subtitle1', 'Subtitle2', 'Subtitle3'],
...     styles=[mv.ASSStyleType(font_size=96)],  # Set default font size
...     dst_ass_file='subtitle1.ass')
>>> mv.write_ass_file(
...    start_times=[0.0, 1.0, 3.0],
...    end_times=[1.0, 3.0, 4.0],
...    texts=['text by Alice', 'text by Bob', 'text by Alice'],
...    characters=['Alice', 'Bob', 'Alice'],
...    styles=[
...        mv.ASSStyleType(name='Alice', primary_color=mv.rgb_to_ass_color('red')),
...        mv.ASSStyleType(name='Bob', primary_color=mv.rgb_to_ass_color('blue'))],
...    dst_ass_file='subtitle2.ass')