videodb
VideoDB Documentation
videodb
VideoDB Documentation
Quick Start Guide

icon picker
Ref: TextAsset

TextAsset API Reference

Overlaying Text elements on a video is very useful in multiple scenarios. VideoDB’s Asset class let’s you define a text asset with rich style with many fonts, colors and positions to add into your stream in real time.
This document provides an API Reference to interface with the TextStyle class.
empty-flag
Checkout to dive deep into the outputs of these parameters

Import

Import TextStyle from videodb.asset
from videodb import connect
from videodb.asset import TextAsset, TextStyle


Usage

Here's how you might typically use the TextStyle class in your application:

from videodb import connect
from videodb.asset import TextAsset, TextStyle

conn = connect()
coll = conn.get_collection()
video = coll.get_video("MY_VIDEO_ID")

text_asset = TextAsset(
text="THIS IS A TEXT Asset",
duration=5,
style=TextStyle(
font = "Inter",
fontsize = 50,
fontcolor = "#FFCFA5",
)
)




TextStyle


font

The font family used for the text.
Default: "Sans"
Type: str
info
Checkout List of Supported Fonts

fontsize

The size of the text
Default: 24
Type: int

fontcolor

The color of the font.
Default: black
Type: str
info
See also Color Format & recognized colors

alpha

Transparency level of the text.
The value can be a number between 0.0 and 1.0
Default: 1.0 (fully opaque)
Type: float

borderw

The width of the border around the text.
Default: 0
Type: float

bordercolor

The color of the text border.
Default: black
Type: str

x

The horizontal position of the text, can be a expression(str) or fixed value(float)
They are relative to the left border of Video
Default: "(w -tw )/2"
Type: int or str
info
To learn more about expressions, checkout Using Expression in Position


y

The horizontal position of the text, can be a expression(str) or fixed value(float)
They are relative to the left border of Video
Default: "(h -th )/2"
Type: int or str

info
To learn more about expressions, checkout Using Expression in Position

box

Whether to draw a background box around the text.
Default: True
Type: bool

boxw

The width of the background box.
Default: 0
Type: float

boxh

The height of the background box.
Default: 0
Type: float

boxcolor

The color of the background box.
Default: white
Type: str
info
See also Color Format & recognized colors

boxborderw

The width of the border to be drawn around the box using boxcolor
Default: 10
Type: float

text_align

The alignment of the text within its box.
Default: T+L
Type: str
This accepts a parameter which can be Horizonatal Flag , Vertical flag or Combination of both:
Horizontal-Flag : L , C or M
Vertical-Flag : T , M or B
Vertical-Flag + Horizontal-Flag
image.png

y_align

Specify what the y value is referred to.
Default: text
Type: str

Possible values are:
text
baseline
font
image.png

shadowx

Horizontal shadow offset.
Default: 0
Type: float

shadowy

Vertical shadow offset.
Default: 0
Type: float

shadowcolor

The color of the shadow behind the text.
Default: black
Type: str


tabsize

The size of a tab character in spaces.
Default: 4
Type: int

line_spacing

Set the line spacing in pixel
Default: 0
Type: int

Using Expression in Position

Expressions can be used to set positions of TextAsset .
To Create a expression, you need to use variables and bind them using mathematical expression
info
See List of available variables

Example:
Consider this expression : ( w - tw ) /2
Above expression uses variables w & tw and bind them using a simple mathematical expression.

Variable Available in Position Expressions

w : Width of Video
h : Height of Video
tw : Width of TextAsset
th : Height of TextAsset
sar : Video’s aspect ratio.
rand(min, max) : Returns a random number included between min and max

Color Format

TextStyle accepts colors in various formats, detailed in the ffmpeg-utils "Color" section. This includes support for both named colors and RGB(A) hex codes.

Recognized colors

The following names of colors are recognized along with their hexadecimal values:
AliceBlue: 0xF0F8FF
AntiqueWhite: 0xFAEBD7
Aqua: 0x00FFFF
Aquamarine: 0x7FFFD4
Azure: 0xF0FFFF
Beige: 0xF5F5DC
Bisque: 0xFFE4C4
Black: 0x000000
BlanchedAlmond: 0xFFEBCD
Blue: 0x0000FF
BlueViolet: 0x8A2BE2
Brown: 0xA52A2A
BurlyWood: 0xDEB887
CadetBlue: 0x5F9EA0
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.