Ass Core
- class pyonfx.ass_core.Meta[source]
Meta object contains informations about the Ass.
More info about each of them can be found on http://docs.aegisub.org/manual/Styles
- scaled_border_and_shadow
Determines if it has to be used script resolution (True) or video resolution (False) to scale border and shadow
- Type
- class pyonfx.ass_core.Style[source]
Style object contains a set of typographic formatting rules that is applied to dialogue lines.
More info about styles can be found on http://docs.aegisub.org/3.2/ASS_Tags/.
- class pyonfx.ass_core.Char[source]
Char object contains informations about a single char of a line in the Ass.
A char is defined by some text between two karaoke tags (k, ko, kf).
- word_i
Char word index (e.g.: In line text
Hello PyonFX users!
, letter “u” will have word_i=2).- Type
- syl_i
Char syl index (e.g.: In line text
{\k0}Hel{\k0}lo {\k0}Pyon{\k0}FX {\k0}users!
, letter “F” will have syl_i=3).- Type
- syl_char_i
Char invidual syl index (e.g.: In line text
{\k0}Hel{\k0}lo {\k0}Pyon{\k0}FX {\k0}users!
, letter “e” of “users” will have syl_char_i=2).- Type
- styleref
Reference to the Style object of this object original line.
- Type
obj
- class pyonfx.ass_core.Syllable[source]
Syllable object contains informations about a single syl of a line in the Ass.
A syl can be defined as some text after a karaoke tag (k, ko, kf) (e.g.: In
{\k0}Hel{\k0}lo {\k0}Pyon{\k0}FX {\k0}users!
, “Pyon” and “FX” are distinct syllables),- word_i
Syllable word index (e.g.: In line text
{\k0}Hel{\k0}lo {\k0}Pyon{\k0}FX {\k0}users!
, syl “Pyon” will have word_i=1).- Type
- styleref
Reference to the Style object of this object original line.
- Type
obj
- class pyonfx.ass_core.Word[source]
Word object contains informations about a single word of a line in the Ass.
A word can be defined as some text with some optional space before or after (e.g.: In the string “What a beautiful world!”, “beautiful” and “world” are both distinct words).
- styleref
Reference to the Style object of this object original line.
- Type
obj
- class pyonfx.ass_core.Line[source]
Line object contains informations about a single line in the Ass.
Note
(*) = This field is available only if
extended
= True- leadin
Time between this line and the previous one (in milliseconds; first line = 1000.1) (*).
- Type
- leadout
Time between this line and the next one (in milliseconds; first line = 1000.1) (*).
- Type
- styleref
Reference to the Style object of this line (*).
- Type
obj
- class pyonfx.ass_core.Ass(path_input='', path_output='Output.ass', keep_original=True, extended=True, vertical_kanji=False)[source]
Contains all the informations about a file in the ASS format and the methods to work with it for both input and output.
Usually you will create an Ass object and use it for input and output (see example section).PyonFX set automatically an absolute path for all the info in the output, so that wherever you will put your generated file, it should always load correctly video and audio.- Parameters
path_input (str) – Path for the input file (either relative to your .py file or absolute).
path_output (str) – Path for the output file (either relative to your .py file or absolute) (DEFAULT: “Output.ass”).
keep_original (bool) – If True, you will find all the lines of the input file commented before the new lines generated.
extended (bool) – Calculate more informations from lines (usually you will not have to touch this).
vertical_kanji (bool) – If True, line text with alignment 4, 5 or 6 will be positioned vertically. Additionally,
line
fields will be re-calculated based on the re-positionedline.chars
.
Example
io = Ass("in.ass") meta, styles, lines = io.get_data()
- write_line(line)[source]
Appends a line to the output list (which is private) that later on will be written to the output file when calling save().
Use it whenever you’ve prepared a line, it will not impact performance since you will not actually write anything until
save()
will be called.- Parameters
line (
Line
) – A line object. If not valid, TypeError is raised.
- save(quiet=False)[source]
Write everything inside the private output list to a file.
- Parameters
quiet (bool) – If True, you will not get printed any message.
- open_aegisub()[source]
Open the output (specified in self.path_output) with Aegisub.
This can be usefull if you don’t have MPV installed or you want to look at your output in detailed.
- Returns
0 if success, -1 if the output couldn’t be opened.
- open_mpv(video_path='', video_start='', full_screen=False)[source]
Open the output (specified in self.path_output) in softsub with the MPV player. To utilize this function, MPV player is required. Additionally if you’re on Windows, MPV must be in the PATH (check https://pyonfx.readthedocs.io/en/latest/quick%20start.html#installation-extra-step).
This is one of the fastest way to reproduce your output in a comfortable way.
- Parameters
video_path (string) – The video file path (absolute) to reproduce. If not specified, meta.video is automatically taken.
video_start (string) – The start time for the video (more info: https://mpv.io/manual/master/#options-start). If not specified, 0 is automatically taken.
full_screen (bool) – If True, it will reproduce the output in full screen. If not specified, False is automatically taken.