This page documents miscellaneous APIs useful for working with subtitles. These can't be clearly placed into any of the other main categories and there's too few of each kind to warrant a separate category.
Synopsis: aegisub.cancel()
Immediately end execution of the current script, rolling back any changes that have been made in it.
This function never returns.
Synopsis: width, height, descent, ext_lead = aegisub.text_extents(style, text)
Obtain system font metrics and determine the rendered size in pixels of the given text when using the style.
@style
(table
)@text
(string
)\n
or \r\n
) nor should it contain
formatting codes of any kind. Formatting codes are not interpreted and
will be taken as verbatim text.width
(number
)height
(number
)descent
(number
)ext_lead
(number
)You should only feed plain text strings without line breaks into this function. It cannot handle any kind of formatting codes or text layout. Rather, it is intended as a helper to create text layouts by determining rendered sizes of bits and pieces of a longer text, which can then be laid out by the script.
Synopsis: translation = aegisub.gettext(untranslated)
Get the translation for a string. This is mostly only intended for scripts bundled with Aegisub (as there's no way for you to add your own translations), but if you happen to be using strings that are present in Aegisub it may be useful.
Note that in the bundled macros this is always aliased to tr
for the sake
of the string extractor.
Automation 4 Lua offers two functions designed to be able to work with frame-based timing without having to consider whether the video source is VFR or CFR.
The primary purpose of these functions is to be able to generate per-frame effects, i.e. get the timestamps of a number of sequential frames and calculate coordinates, sizes etc. for an object for each of those frames.
One thing to remember when using these functions is that, considering a one-dimensional time line, a time stamp is a point on the time line, while a video frame spans a range of the time line, from its beginning time to its ending time. The ending time of a frame is the beginning time of the next. The beginning time of a frame is included in the range while the ending time is excluded from the range.
Synopsis: frame = aegisub.frame_from_ms(ms)
Use loaded frame rate data to convert an absolute time given in milliseconds into a frame number.
@ms
(number
)frame
(number
)nil
if there is no
frame rate data loaded.If the time is in the middle of the frame it is rounded down to the frame number that contains the given time.
Synopsis: ms = aegisub.ms_from_frame(frame)
Use loaded frame rate data to convert a frame number of the video into an absolute time in milliseconds.
@frame
(number
)ms
(number
)nil
if
there is no frame rate data loaded.Because beginning times of frames can have better precision than one millisecond this function rounds up and returns the first whole millisecond that is guaranteed to be within the frame.
Synopsis: xres, yres, ar, artype = aegisub.video_size()
Get information about the resolution and aspect-ratio of the loaded video, if any.
xres
(number
)nil
if there is no video loaded.yres
(number
)nil
if there is no video loaded.ar
(number
)artype
is 4.artype
(number
)There are 5 values that artype
can take:
xres
/yres
.ar
return value contains.Synopsis keyframes = aegisub.keyframes()
Get a list of what video frames are keyframes.
keyframes
(table
)Synopsis path = aegisub.decode_path(encoded_path)
Convert a path beginning with a path specifier to an absolute path.
@encoded_path
(string
)@path
(string
)encoded_path
began with a valid path
specifier, an absolute path. If it began with an
invalid path specifier (such as if ?video was used when no video is open),
a string that is unlikely to be useful in any way. Any other strings are
passed through untouched.Synopsis properties = aegisub.project_properties()
Get a table containing information about what files the user currently has open. The exact contents of this table are deliberately undocumented, and may change without warning.
Overview: | Automation Manager • Running macros • Using export filters • Standard macros |
---|---|
Karaoke Templater reference: | Declaring
templates • Execution
order • Modifiers • Inline-variables ($-variables)
Code lines and blocks • Execution envirionment |
Lua API reference: | Registration • Subtitles object • Progress reporting • Dialogs • Misc. APIs |
Lua Modules: | karaskel.lua • util • unicode • cleantags.lua • clipboard • re |
Karaskel concepts: | Style tables • Dialogue line tables • Syllable tables • Inline effects • Furigana |