Skip to main content

Quick Example

from videodb.editor import (
    TextAsset, Font, Background,
    Alignment, HorizontalAlignment, VerticalAlignment, TextAlignment
)

text_asset = TextAsset(
    text="BREAKING NEWS",
    font=Font(family="Inter", size=48, color="#FFFFFF"),
    background=Background(
        color="#FF0000",
        width=400,
        height=80,
        text_alignment=TextAlignment.center
    ),
    alignment=Alignment(
        horizontal=HorizontalAlignment.center,
        vertical=VerticalAlignment.center
    )
)

TextAsset Parameters

ParameterTypeDescription
textstrThe text to display
fontFontFont styling (family, size, color, opacity)
backgroundBackgroundBackground box styling
alignmentAlignmentPosition on screen
borderBorderBorder styling
shadowShadowShadow styling
tabsizeintTab size for text formatting
line_spacingfloatSpacing between lines
widthintWidth of text box in pixels
heightintHeight of text box in pixels

Font

Controls text appearance.
ParameterTypeDefaultDescription
familystr"Sans"Font family name
sizeint24Font size in pixels
colorstr"#000000"Text color (hex)
opacityfloat1.0Text opacity (0.0 to 1.0)
from videodb.editor import Font

font = Font(
    family="Inter",
    size=56,
    color="#FFFFFF"
)
Supported fonts: Sans, Inter, Roboto, Open Sans, Lato, Montserrat, Oswald, Raleway, Poppins, Ubuntu, Clear Sans, Arial, Times New Roman, Courier New, Georgia, Verdana

Background

Controls the background box behind text.
ParameterTypeDefaultDescription
colorstr"#FFFFFF"Background color (hex)
opacityfloat1.0Background opacity (0.0 to 1.0)
widthintautoBox width in pixels
heightintautoBox height in pixels
border_widthfloat0Border thickness
text_alignmentTextAlignmentcenterText alignment within box
from videodb.editor import Background, TextAlignment

background = Background(
    color="#000000",
    width=600,
    height=120,
    border_width=2.0,
    text_alignment=TextAlignment.center
)

Alignment

Controls where the text appears on screen.
ParameterTypeDescription
horizontalHorizontalAlignmentleft, center, right
verticalVerticalAlignmenttop, center, bottom
from videodb.editor import Alignment, HorizontalAlignment, VerticalAlignment

# Center of screen
alignment = Alignment(
    horizontal=HorizontalAlignment.center,
    vertical=VerticalAlignment.center
)

# Bottom-left corner
alignment = Alignment(
    horizontal=HorizontalAlignment.left,
    vertical=VerticalAlignment.bottom
)

Complete Example

from videodb.editor import (
    Timeline, Track, Clip, VideoAsset, TextAsset,
    Font, Background, Alignment,
    HorizontalAlignment, VerticalAlignment, TextAlignment
)

# Create text asset
intro_text = TextAsset(
    text="Let the Match Begin",
    font=Font(family="Clear Sans", size=56, color="#FFFFFF"),
    background=Background(
        width=600,
        height=120,
        color="#000000",
        border_width=2.0,
        text_alignment=TextAlignment.center
    ),
    alignment=Alignment(
        horizontal=HorizontalAlignment.center,
        vertical=VerticalAlignment.center
    )
)

# Add to timeline
timeline = Timeline(conn)

video_clip = Clip(asset=VideoAsset(asset_id=video.id), duration=30)
text_clip = Clip(asset=intro_text, duration=5)

video_track = Track()
video_track.add_clip(clip=video_clip, start=0)

text_track = Track()
text_track.add_clip(clip=text_clip, start=0)

timeline.add_track(video_track)
timeline.add_track(text_track)

stream_url = timeline.generate_stream()

Next Steps