Skip to content
videodb
VideoDB Documentation
  • Pages
    • Welcome to VideoDB Docs
    • Quick Start Guide
      • Video Indexing Guide
      • Semantic Search
      • How Accurate is Your Search?
      • Collections
      • Public Collections
      • Callback Details
      • Ref: Subtitle Styles
      • Language Support
      • icon picker
        Guide: Subtitles
    • Examples and Tutorials
      • Dubbing - Replace Soundtrack with New Audio
      • VideoDB x TwelveLabs: Real-Time Video Understanding
      • Beep curse words in real-time
      • Remove Unwanted Content from videos
      • Instant Clips of Your Favorite Characters
      • Insert Dynamic Ads in real-time
      • Adding Brand Elements with VideoDB
      • Eleven Labs x VideoDB: Adding AI Generated voiceovers to silent footage
      • Elevating Trailers with Automated Narration
      • Add Intro/Outro to Videos
      • Audio overlay + Video + Timeline
      • Building Dynamic Video Streams with VideoDB: Integrating Custom Data and APIs
      • AI Generated Ad Films for Product Videography: Wellsaid, Open AI & VideoDB
      • Fun with Keyword Search
      • AWS Rekognition and VideoDB - Effortlessly Remove Inappropriate Content from Video
      • Overlay a Word-Counter on Video Stream
      • Generate Automated Video Outputs with Text Prompts | DALL-E + ElevenLabs + OpenAI + VideoDB
    • Visual Search and Indexing
      • Scene Extraction Algorithms
      • Custom Annotations
      • Scene-Level Metadata: Smarter Video Search & Retrieval
      • Advanced Visual Search Pipelines
      • Playground for Scene Extractions
      • Deep Dive into Prompt Engineering : Mastering Video Scene Indexing
    • Multimodal Search
      • Multimodal Search: Quickstart
      • Conference Slide Scraper with VideoDB
    • Real‑Time Video Pipeline
    • Meeting Recording SDK
    • Generative Media Quickstart
      • Generative Media Pricing
    • Realtime Video Editor SDK
      • Fit & Position: Aspect Ratio Control
      • Trimming vs Timing: Two Independent Timelines
      • Advanced Clip Control: The Composition Layer
      • Caption & Subtitles: Auto-Generated Speech Synchronization
      • Notebooks
    • Transcoding Quickstart
    • director-light
      Director - Video Agent Framework
      • Agent Creation Playbook
      • How I Built a CRM-integrated Sales Assistant Agent in 1 Hour
      • Make Your Video Sound Studio Quality with Voice Cloning
      • Setup Director Locally
    • github
      Open Source Tools
      • llama
        LlamaIndex VideoDB Retriever
      • PromptClip: Use Power of LLM to Create Clips
      • StreamRAG: Connect ChatGPT to VideoDB
    • zapier
      Zapier Integration
      • Auto-Dub Videos & Save to Google Drive
      • Create & Add Intelligent Video Highlights to Notion
      • Create GenAI Video Engine - Notion Ideas to Youtube
      • Automatically Detect Profanity in Videos with AI - Update on Slack
      • Generate and Store YouTube Video Summaries in Notion
      • Automate Subtitle Generation for Video Libraries
      • Solve customers queries with Video Answers
    • n8n
      N8N Workflows
      • AI-Powered Meeting Intelligence: Recording to Insights Automation
      • AI Powered Dubbing Workflow for Video Content
      • Automate Subtitle Generation for Video Libraries
      • Automate Interview Evaluations with AI
      • Turn Meeting Recordings into Actionable Summaries
      • Auto-Sync Sales Calls to HubSpot CRM with AI
      • Instant Notion Summaries for Your Youtube Playlist
    • mcp
      VideoDB MCP Server
    • Edge of Knowledge
      • Building Intelligent Machines
        • Part 1 - Define Intelligence
        • Part 2 - Observe and Respond
        • Part 3 - Training a Model
      • Society of Machines
        • Society of Machines
        • Autonomy - Do we have the choice?
        • Emergence - An Intelligence of the collective
      • From Language Models to World Models: The Next Frontier in AI
      • The Future Series
      • How VideoDB Solves Complex Visual Analysis Tasks
    • videodb
      Building World's First Video Database
      • Multimedia: From MP3/MP4 to the Future with VideoDB
      • Dynamic Video Streams
      • Why do we need a Video Database Now?
      • What's a Video Database ?
      • Enhancing AI-Driven Multimedia Applications
      • Misalignment of Today's Web
      • Beyond Traditional Video Infrastructure
      • Research Grants
    • Customer Love
    • Team
      • videodb
        Internship: Build the Future of AI-Powered Video Infrastructure
      • Ashutosh Trivedi
        • Playlists
        • Talks - Solving Logical Puzzles with Natural Language Processing - PyCon India 2015
      • Ashish
      • Shivani Desai
      • Gaurav Tyagi
      • Rohit Garg
      • VideoDB Acquires Devzery: Expanding Our AI Infra Stack with Developer-First Testing Automation

Guide: Subtitles

Adding Subtitles

This guide gives you an introduction to adding Subtitle Styles by showing you visual outputs of the configurations available for the SubtitleStyle class, such as
Typography and Style
Color and Effects
Positioning and Margins
Text Transformation
Borders and Shadow

🛠️ Setup

📦 Installing packages

%pip install videodb

🔑 API Keys

Before proceeding, ensure 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

Upload a base video to add subtitle. For this guide, we’ll use following video
video = coll.upload(url="https://www.youtube.com/watch?v=il39Ks4mV9g")
video.play()
info
You can upload from your local file system too by passing file_path in upload()

🔊 Index Spoken Words

First, we need to index the video using video.index_spoken_words() function.This ensures the availability of the transcript. Without this step VideoDB wouldn’t be able to add captions to any video.
video.index_spoken_words()

📝 Default Subtitles

To add subtitles to your video you can use video.add_subtitle() .
This method returns a , that you can play using play_stream() method
from videodb import play_stream
# Add Subtitle to Video
stream_url = video.add_subtitle()

# Play stream
play_stream(stream_url)

💅 Custom Styled Subtitles

To customise the style of subtitle, pass SubtitleStytle() with configured styles to video.add_subtitle()
info
View API Reference for SubtitleStyle class 💅

1. Typography and Style

Configure Typography of the Subtitle by passing following parameters to SubtitleStyle() class
font_name : The name of the font to use for the subtitles.
font_size : The size(px) of the font
spacing : Spacing(px) between characters
bold : Set to True for bold text
italic : Set to True for italic text
underline : Set to True for underlined text
strike_out : Set to True for strike-through text
from videodb import SubtitleStyle, play_stream

stream_url = video.add_subtitle(
SubtitleStyle(
font_name = "Roboto",
font_size = 12,
spacing = 0,
bold = False,
italic = False,
underline = False,
strike_out = False
)
)
play_stream(stream_url)

1 (1).png

2. Color and Effects

Configure color of Subtitle by passing following parameters to SubtitleStyle() class
primary_colour : The color of the main subtitle text.
secondary_colour : The color used for karaoke or secondary effects.
outline_colour : The color of the outline of the text.
back_colour : The color of the subtitle background.
info
Format of Color
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.
from videodb import SubtitleStyle

stream_url = video.add_subtitle(
SubtitleStyle(
primary_colour = "&H00A5CFFF",
secondary_colour = "&H00FFFF00",
outline_colour = "&H000341C1",
back_colour = "&H803B3B3B",
)
)
play_stream(stream_url)


2.png


3. Position and Margins

Configure alignment and position of Subtitle by passing following parameters to SubtitleStyle() class
alignment : Alignment of subtitle. Accepts a value a type SubtitleAlignment
margin_l : Sets margin area on left side of Subtitle box
margin_r : Sets margin area on right side of Subtitle box
margin_v : Sets margin area of top and bottom of Subtitle box
info
View API Reference to know more about SubtitleAlignment

from videodb import SubtitleStyle, SubtitleAlignment

stream_url = video.add_subtitle(
SubtitleStyle(
alignment = SubtitleAlignment.middle_center,
margin_l = 10,
margin_r = 10,
margin_v = 20,
)
)
play_stream(stream_url)

3.png


4. Text Transformation

Transform the text size and spacing by passing following parameters to SubtitleStyle() class
scale_x : Factor for scaling of the font horizontally
scale_y : Factor for scaling of the font vertically
angle : Rotation angle(degress) of the text
from videodb import SubtitleStyle

stream_url = video.add_subtitle(
SubtitleStyle(
scale_x = 1.5,
scale_y = 3,
angle = 0,
)
)

play_stream(stream_url)

4 (1).png

5. Borders and Shadow

Add border style, outline and shadow by passing following parameters to SubtitleStyle() class
border_style : Border style of subtitle. Accepts a value a type SubtitleBorderStyle
outline : The width(px) of the outline around the text.
shadow : The depth(px) of the shadow behind the text
info
View API Reference to know more about SubtitleBorderStyle

from videodb import SubtitleStyle, SubtitleBorderStyle

stream_url = video.add_subtitle(
style=SubtitleStyle(
shadow=2,
back_colour="&H00000000",
border_style=SubtitleBorderStyle.no_border,
)
)
play_stream(stream_url)


5.png


👨‍💻 Next Steps

Check out the other resources and tutorials using Subtitle and Subtitle Styling 💅.

If you have any questions or feedback. Feel free to reach out to us 🙌🏼



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.