videodb
VideoDB Documentation
videodb
VideoDB Documentation
Dynamic Video Stream Guide

icon picker
Guide : TextAsset

Overview

This guide gives you an introduction to TextAssets and how you can use them to overlay text elements on your videos.
We will also explore the configurations available for the TextAssets class, such as:

Setup

📦 Installing packages

%pip install videodb

🔑 API Keys

Before proceeding, ensure that you have access to .
light
Get your API key from . ( Free for first 50 uploads, No credit card required ) 🎉
import os

os.environ["VIDEO_DB_API_KEY"] = ""


🌐 Connect to VideoDB

from videodb import connect

conn = connect()
coll = conn.get_collection()

🎥 Upload Video

VideoDB uses video as a base to create a timeline. Click here to learn more about how function.
video = coll.upload(url="https://www.youtube.com/watch?v=4dW1ybhA5bM")
info
You can upload from your local file system too by passing file_path in upload()
Since this guide is focused on exploring the TextAsset object, we’ll be using to avoid any distractions. You can, of course, apply this to a VideoAsset of your choice.

Creating Assets

Now, we will create some assets that we are going to use in our Video Timeline
VideoAsset - A Video that will be used as a base for Video Timeline
TextAsset - A Text Element that will overlayed on our Video Timeline
info
Checkout

🎥 VideoAsset

from videodb.asset import VideoAsset

# Create a VideoAsset from Video
video_asset = VideoAsset(
asset_id = video.id,
start = 0,
end = 20
)

🔠 TextAsset : Default Styling

To Create a TextAsset, use TextAsset with following params
text : The text that needs to be displayed
duration (optional): The duration for which the text element needs to be displayed
from videodb.asset import TextAsset

text_asset_1 = TextAsset(
text="THIS IS A SENTENCE",
duration=5,
)


Mask group (8).png

🔡 TextAsset - Custom Styling

To Create a TextAsset, with custom styling you can pass an additional parameter
style (optional): Accepts a TextStyle Instance, which contains styling configuration of a TextAsset
info
View API Reference for TextStyle


1. Font Styling

from videodb.asset import TextAsset, TextStyle

text_asset_2 = TextAsset(
text="THIS IS A SENTENCE",
duration=5,
style=TextStyle(
font = "Inter",
fontsize = 50,
fontcolor = "#FFCFA5",
bordercolor = "#C14103",
borderw = "2"
)
)

Mask group.png

2. Background box

from videodb.asset import TextAsset, TextStyle

text_asset_3 = TextAsset(
text="THIS IS A SENTENCE",
duration=5,
style=TextStyle(
box = True,
boxcolor = "#FFCFA5",
boxborderw = 10,
boxw = 0,
boxh = 0,
text_align = "3"
)
)

Mask group (1).png


3. Shadows

from videodb.asset import TextAsset, TextStyle

text_asset_4 = TextAsset(
text="THIS IS A SENTENCE",
duration=5,
style=TextStyle(
shadowcolor="#0AA910",
shadowx="2",
shadowy="3",
text_align = "3"
box = False,
)
)

Mask group (2).png

4. Position and Alignment

from videodb.asset import TextAsset, TextStyle

text_asset_3 = TextAsset(
text="THIS IS A SENTENCE",
duration=5,
style=TextStyle(
x = 0,
y = 0,
y_align = "text",
text_align = "T+C"
)
)

image.png
image.png

🎼 Create a timeline using

from videodb.timeline import Timeline

# Initialize a Timeline
timeline = Timeline(conn)

# Add Our base VideoAsset inline
timeline.add_inline(video_asset)

# TextAsset with default Styling
timeline.add_overlay(0, text_asset_1)

# TextAsset with Custom Font Styling
timeline.add_overlay(5, text_asset_2)
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.