). Once finalized, copy the Voice ID from ElevenLabs and link it here.
voiceover_artist_id = "VOICEOVER_ARTIST_ID"
Tutorial Walkthrough
📋 Step 1: Connect to VideoDB
Make sure you have the API key in the environment.
from videodb import connect
# Connect to VideoDB using your API key
conn = connect()
🎬 Step 2: Upload the Trailer
Upload the trailer video to VideoDB for further processing. This creates the base video asset that we shall use later in this tutorial.
video = conn.upload(url='https://www.youtube.com/watch?v=WQmGwmc-XUY')
🔍 Step 3: Analyze Scenes and Generate Scene Descriptions
Start by analyzing the scenes within the trailer using VideoDB's scene indexing capabilities. This will provide context for generating the narration script.
video.index_scenes()
Let's view the description of first scene from the video
The image captures a fiery blaze, a dynamic dance of flames in vivid shades of orange, gold, and red. Light flickers intensely, radiance expanding, contracting with the fire's rhythm. No specific source is visible; the fire dominates entirely, filling the frame with energetic movement. The luminosity suggests a fierce heat, powerful enough to demand respect and caution. Each tongue of flame is seemingly alive, almost writhing against a darker, indistinct background. This could be a natural fire or a controlled blaze—there’s no context to indicate its origin. Amidst the searing heat, the flames create a mesmeric, albeit destructive, spectacle.
🔊 Step 4: Generate Narration Script with LLM
Here, we use OpenAI’s GPT to build context around the scene descriptions above, and generate a fitting narration script for the visuals.
# Generate narration script with ChatGPT
import openai
client = openai.OpenAI()
script_prompt ="Craft a dynamic narration script for this trailer, incorporating scene descriptions to enhance storytelling. Ensure that the narration aligns seamlessly with the timestamps provided in the scene index. Don't include any annotations in output script"
# If you have ElevenLab's paid plan remove the :2500 limit on
# voiceover script.
# voiceover_script = voiceover_script[:2500]
You can refine the narration script prompt to ensure synchronization with timestamps in the scene index, optimizing the storytelling experience.
🎙️ Step 5: Generate Narration Audio with elevenlabs.io
Note: for this step, you will need a specific voice ID that fits perfectly with the vibe of your trailer. In our example, we have used this voice that resembles the vocal quality and style that of Sam Elliott. You can find a voice suitable for your trailer in the
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 at the End
To incorporate adding a movie poster as a bonus section at the end of the trailer using VideoDB, you can follow these steps (you’ll find the code snippet for the same below):
We first import the necessary module for handling Image Assets.
Then, we upload the movie poster image to VideoDB.
Next, we create an Image Asset with the uploaded poster image, specifying its dimensions and duration.
Finally, we add the movie poster as an overlay at the end of the video timeline.