Skip to content
videodb
VideoDB Documentation
  • Pages
    • Welcome to VideoDB Docs
    • Quick Start Guide
      • Video Indexing Guide
      • Semantic Search
      • Collections
      • Public Collections
      • Callback Details
      • Ref: Subtitle Styles
      • Language Support
      • Guide: Subtitles
      • How Accurate is Your Search?
    • 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 Visual Indexing
      • How VideoDB Solves Complex Visual Analysis Tasks
      • Multimodal Search: Quickstart
      • Conference Slide Scraper with VideoDB
    • Examples and Tutorials
      • Dubbing - Replace Soundtrack with New Audio
      • VideoDB: Adding AI Generated voiceovers to silent footage
      • 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
      • icon picker
        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
      • Fun with Keyword Search
      • Overlay a Word-Counter on Video Stream
      • Generate Automated Video Outputs with Text Prompts | VideoDB
      • VideoDB x TwelveLabs: Real-Time Video Understanding
      • Multimodal Search
      • How I Built a CRM-integrated Sales Assistant Agent in 1 Hour
      • Make Your Video Sound Studio Quality with Voice Cloning
      • Automated Traffic Violation Reporter
    • Live Video→ Instant Action
    • Generative Media Quickstart
      • Generative Media Pricing
    • Video Editing Automation
      • 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
      • Setup Director Locally
    • Workflows and Integrations
      • 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
    • Meeting Recording SDK
    • github
      Open Source
      • llama
        LlamaIndex VideoDB Retriever
      • PromptClip: Use Power of LLM to Create Clips
      • StreamRAG: Connect ChatGPT to VideoDB
    • mcp
      VideoDB MCP Server
    • videodb
      Give your AI, Eyes and Ears
      • Building Infrastructure that “Sees” and “Edits”
      • Agents with Video Experience
      • 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
      • Beyond Traditional Video Infrastructure
    • Customer Love
    • Join us
      • 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
      • Edge of Knowledge
        • Language Models to World Models: The Next Frontier in AI
        • Society of Machines
          • Society of Machines
          • Autonomy - Do we have the choice?
          • Emergence - An Intelligence of the collective
        • Building Intelligent Machines
          • Part 1 - Define Intelligence
          • Part 2 - Observe and Respond
          • Part 3 - Training a Model
      • Updates
        • VideoDB Acquires Devzery: Expanding Our AI Infra Stack with Developer-First Testing Automation

Elevating Trailers with Automated Narration

Introduction

Narration is the heartbeat of trailers, injecting excitement and intrigue into every frame. With VideoDB, adding narration becomes a seamless, creative process.
In this tutorial, we will:
Analyze a movie trailer to understand its scenes.
Generate a dramatic script using VideoDB’s text generation.
Synthesize a deep, trailer-style voiceover using VideoDB’s voice generation.
Edit the narration into specific time slots to match the video’s pacing.
Overlay a movie poster at the end.
All using a single SDK.

Here’s an example of weaving a thrilling storyline from a reel of unrelated, but valuable cinematic shots:

Setup

📦 Installing VideoDB

%pip install videodb

🔑 API Keys

You only need your VideoDB API Key.
Get your API key from . (Free for first 50 uploads, No credit card required).Get your API key from . ( Free for first 50 uploads, No credit card required ) 🎉

import videodb
import os
from getpass import getpass

# Prompt user for API key securely
api_key = getpass("Please enter your VideoDB API Key: ")
os.environ["VIDEO_DB_API_KEY"] = api_key

🌐 Step 1: Connect to VideoDB

Establish a connection to your VideoDB project.
from videodb import connect

# Connect to VideoDB
conn = connect()
coll = conn.get_collection()

🎬 Step 2: Upload the Trailer

We’ll upload a sample movie trailer (Chase) to VideoDB. This creates the base video asset we will edit.
video = coll.upload(url='https://www.youtube.com/watch?v=WQmGwmc-XUY')

🔍 Step 3: Analyze Scenes

We need to understand the visual pacing of the trailer to write a good script. index_scenes() will generate descriptions and timestamps for every shot.
video_scenes_id = video.index_scenes()

Let's view the description of first scene from the video
video_scenes = video.get_scene_index(video_scenes_id)

import json
print(json.dumps(video_scenes[0], indent=2))
Output:
{
"description": "The scene is engulfed in a vast, tumultuous blaze, with vibrant yellow and fiery orange flames swirling and dancing across the entire frame. The intense heat radiating from the inferno creates a mesmerizing, dynamic spectacle, casting a reddish-brown glow that fills the atmosphere. Darker, smoky elements are intermittently visible through the brilliant light, suggesting objects being consumed within the heart of this powerful, destructive force. The fire is alive, constantly shifting and reaching, conveying both destructive power and captivating motion.",
"end": 1.043,
"metadata": {},
"scene_metadata": {},
"start": 0.0
}

🔊 Step 4: Generate Narration Script

We’ll use VideoDB’s generate_text to write a dramatic script. We feed the scene descriptions into the prompt to ensure the narration matches the visual action.
# Construct prompt with scene context
scene_context = "\n".join([f"- {scene['description']}" for scene in video_scenes])

prompt = f"""
Craft a dynamic, dramatic narration script for a movie trailer based on these visual descriptions:
{scene_context}

Requirements:
- Style: Intense, gritty, like a blockbuster action movie trailer.
- Output: ROnly provide the script for direct voice generation, no stage directions or narration.
"""

script_response = coll.generate_text(
prompt=prompt,
model_name="pro"
)

print("--- Generated Script ---")
print(script_response)
You can refine the narration script prompt to ensure synchronization with timestamps in the scene index, optimizing the storytelling experience.

🎙️ Step 5: Generate Voiceover Audio

Now we synthesize the audio.
# Generate speech directly as an Audio Asset
audio = coll.generate_voice(
text=voiceover_script['output'],
voice_name="Brian"
)

print(f"Generated Audio ID: {audio.id}")

🎥 Step 6: Edit the Timeline

Now we combine the video and audio.
from videodb.editor import Timeline, Track, Clip, VideoAsset, AudioAsset

timeline = Timeline(conn)

# --- 1. Main Video Track ---
main_track = Track()
video_asset = VideoAsset(id=video.id, volume=0.5)
video_clip = Clip(asset=video_asset, duration=float(video.length))
main_track.add_clip(0, video_clip)
timeline.add_track(main_track)

# --- 2. Narration Track---
audio_track = Track()
audio_asset1 = AudioAsset(id=audio.id, start=0, volume=2.0)
audio_clip1 = Clip(asset=audio_asset1, duration=float(audio.length))
audio_track.add_clip(4, audio_clip1)

timeline.add_track(audio_track)

🪄 Step 8: Review and Share

Preview the trailer with the integrated narration to ensure it aligns with your vision. Once satisfied, share the trailer with others to experience the enhanced storytelling.
from videodb import play_stream

stream_url = timeline.generate_stream()
play_stream(stream_url)

🎬 Bonus - Add Movie Poster

Let’s add a “Coming Soon” style movie poster at the very end of the trailer. We’ll upload an image URL and overlay it on the video.
from videodb import MediaType

# Upload movie poster
poster_url = "https://img.freepik.com/free-photo/darkly-atmospheric-retail-environment-rendering_23-2151153755.jpg"
image = coll.upload(url=poster_url, media_type=MediaType.image)

from videodb.editor import ImageAsset

# Create an overlay track for the poster
image_track = Track()

# Show poster at the 10 seconds of the trailer
image_asset = ImageAsset(id=image.id)
image_clip = Clip(
asset=image_asset,
duration=10.0,
fit="contain"
)

image_track.add_clip(float(video.length) - 10, image_clip)
timeline.add_track(image_track)

stream_url = timeline.generate_stream()
play_stream(stream_url)

🎉 Conclusion

You’ve successfully built a sophisticated video editing workflow:
Analysis: Automated scene understanding.
 
Want to print your doc?
This is not the way.
Try clicking the ··· in the right corner or using a keyboard shortcut (
CtrlP
) instead.