videodb
VideoDB Documentation
videodb
VideoDB Documentation
Dynamic Video Streams

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
Chartreuse: 0x7FFF00
Chocolate: 0xD2691E
Coral: 0xFF7F50
CornflowerBlue: 0x6495ED
Cornsilk: 0xFFF8DC
Crimson: 0xDC143C
Cyan: 0x00FFFF
DarkBlue: 0x00008B
DarkCyan: 0x008B8B
DarkGoldenRod: 0xB8860B
DarkGray: 0xA9A9A9
DarkGreen: 0x006400
DarkKhaki: 0xBDB76B
DarkMagenta: 0x8B008B
DarkOliveGreen: 0x556B2F
Darkorange: 0xFF8C00
DarkOrchid: 0x9932CC
DarkRed: 0x8B0000
DarkSalmon: 0xE9967A
DarkSeaGreen: 0x8FBC8F
DarkSlateBlue: 0x483D8B
DarkSlateGray: 0x2F4F4F
DarkTurquoise: 0x00CED1
DarkViolet: 0x9400D3
DeepPink: 0xFF1493
DeepSkyBlue: 0x00BFFF
DimGray: 0x696969
DodgerBlue: 0x1E90FF
FireBrick: 0xB22222
FloralWhite: 0xFFFAF0
ForestGreen: 0x228B22
Fuchsia: 0xFF00FF
Gainsboro: 0xDCDCDC
GhostWhite: 0xF8F8FF
Gold: 0xFFD700
GoldenRod: 0xDAA520
Gray: 0x808080
Green: 0x008000
GreenYellow: 0xADFF2F
HoneyDew: 0xF0FFF0
HotPink: 0xFF69B4
IndianRed: 0xCD5C5C
Indigo: 0x4B0082
Ivory: 0xFFFFF0
Khaki: 0xF0E68C
Lavender: 0xE6E6FA
LavenderBlush: 0xFFF0F5
LawnGreen: 0x7CFC00
LemonChiffon: 0xFFFACD
LightBlue: 0xADD8E6
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.