video.add_subtitle(SubtitleStyle()) function supports many parameters for styling your captions or subtitles according to your brand and guidelines. You can create your own
This document provides an API Reference to the parameters of SubtitleStyle function.
Checkout to dive deep into the outputs of these parameters
Import
Import SubtitleStyle from VideoDB module
from videodb import SubtitleStyle, connect
conn = connect()
coll = conn.get_collection()
video = coll.get_video("MY_VIDEO_ID")
video.add_subtitle(
SubtitleStyle(
font_name = <>,
font_size = <>,
spacing = <>,
....
....
)
)
SubtitleStyle
This function supports following parameters for styling 👇
font_name
The name of the font to use for the subtitles.
font_size
The size of the subtitle text in points.
primary_colour
The color of the main subtitle text in &HBBGGRR or&HAABBGGRR format. Checkout for the details. Default: "&H00FFFFFF" (white)
secondary_colour
The color used for secondary effects like karaoke
Default: "&H000000FF" (red) Checkout for the format details.
outline_colour
The color of the text outline.
Default: "&H00000000" (black) Checkout for the format details.
back_colour
The background color of the subtitle box
Default: "&H00000000" (black) Checkout for the format details.
bold
Indicates if the subtitle text is bold.
italic
Indicates if the subtitle text is italicized.
underline
Indicates if the subtitle text is underlined.
strike_out
Indicates if the subtitle text has a strikethrough.
scale_x
The horizontal scale of the subtitle text in percentage.
Default: 1.0 (100%, no scaling)
scale_y
The vertical scale of the subtitle text in percentage.
Default: 1.0 (100%, no scaling)
spacing
Space between characters in pixels.
angle
The rotation angle of the subtitle text in degrees.
border_style
The style of the border around the text
Default: SubtitleBorderStyle.outline Type: int or SubtitleBorderStyle
This field accepts following value.
SubtitleBorderStyle.no_border or 1 SubtitleBorderStyle.opaque_box or 3 SubtitleBorderStyle.outline or 4
Usage:
from videodb import SubtitleStyle, SubtitleBorderStyle, connect
conn = connect()
coll = conn.get_collection()
video = coll.get_video("MY_VIDEO_ID")
video.add_subtitle(
SubtitleStyle(
border_style = SubtitleBorderStyle.outline
)
)
outline
The width (px) of the outline around the text.
shadow
The depth of the shadow behind the text in pixels.
alignment
The position of the subtitle text on the screen, typically an enumerated type following the SSA/ASS standard.
Default: SubtitleAlignment.bottom_center Type: SubtitleAlignment or int This field accepts following value.
SubtitleAlignment.bottom_left or 1 SubtitleAlignment.bottom_center or 2 SubtitleAlignment.bottom_right or 3 SubtitleAlignment.middle_left or 8, 9 SubtitleAlignment.middle_center or 10 SubtitleAlignment.middle_right or 11 SubtitleAlignment.top_left or 4,5 SubtitleAlignment.top_center or 6 SubtitleAlignment.top_right or 7
Usage:
from videodb import SubtitleStyle, SubtitleAlignment, connect
conn = connect()
coll = conn.get_collection()
video = coll.get_video("MY_VIDEO_ID")
video.add_subtitle(
SubtitleStyle(
alignment = SubtitleAlignment.middle_center
)
)
margin_l
The left margin in pixels.
margin_r
The right margin in pixels.
margin_v
The vertical margin (both top and bottom) in pixels.
Color Format
SubtitleStyle accepts colors in the &HBBGGRR hexadecimal format, where the sequence represents the blue, green, and red components,
&H prefix is required in this color format.
And when transparency is needed, an alpha value is placed at the beginning, yielding &HAABBGGRR.
Supported Fonts
Currently VideoDB supports following Fonts 👇
Checkout to dive deep into the outputs of these parameters.