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:
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
{ "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}
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 contextscene_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: Only provide the script for direct voice generation, no stage directions or narration."""script_response = coll.generate_text( prompt=prompt, model_name="pro")script_text = script_response["output"]print("--- Generated Script ---")print(script_text)
You can refine the narration script prompt to ensure synchronization with timestamps in the scene index, optimizing the storytelling experience.
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_streamstream_url = timeline.generate_stream()play_stream(stream_url)
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 posterposter_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 posterimage_track = Track()# Show poster at the 10 seconds of the trailerimage_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)
You’ve successfully built a sophisticated video editing workflow:
Analysis: Automated scene understanding.
Generation: AI Scripting and Voice synthesis.
Composition: Non-linear editing with multi-track audio and image overlays.
Here’s another interesting experiment to generate automatic voiceovers for silent footages. In this example, we’ve added the classic David Attenborough styled documentary narration to this footage of the underwater world. Check out the complete tutorial here
Explore Full Notebook
Open the complete implementation in Google Colab with all code examples.