videodb
VideoDB Documentation
videodb
VideoDB Documentation
Examples and Tutorials

icon picker
Add Intro/Outro to Videos

💬 Overview

Imagine a virtual DJ mixing deck where you can seamlessly blend multiple videos into one epic timeline. Whether you're adding flashy intros, snazzy outros, or even splicing in some behind-the-scenes footage, this feature lets you take your video content to the next level!
In this tutorial, let’s dive into how you can seamlessly integrate multiple videos onto a single timeline. Users can easily enhance their video content by appending intros, outros, or supplementary segments. The workflow is straightforward and scalable.
intro outro (2).png

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"] = ""

Implementation

🌐 Step 1: Connect to VideoDB

Connect to VideoDB using your API key to establish a session for uploading and manipulating video files. Import the necessary modules from VideoDB library to access functionalities.
from videodb import connect

# Connect to VideoDB using your API key
conn = connect()

🎥 Step 2: Upload Videos

First, we upload an introductory video ("intro.mp4") and an outro video ("outro.mp4") into the collection, followed by the base video ("sugar_craving.mp4"). This approach allows us to efficiently reuse the intro and outro videos for other projects by simply changing the base video, thereby saving time and streamlining the video creation process.
You can upload the video asset from your local device or from a YouTube URL to upload the video from its source.
coll = conn.get_collection()

intro = coll.upload(url="https://github.com/video-db/videodb-cookbook-assets/raw/main/videos/intro.mp4")
outro = coll.upload(url="https://github.com/video-db/videodb-cookbook-assets/raw/main/videos/outro.mp4")
base = coll.upload(url="https://github.com/video-db/videodb-cookbook-assets/raw/main/videos/sugar_craving.mp4")

🎼 Step 3: Create assets

Adjust parameters for all the video assets according to your preference, such as start and end times.
from videodb.asset import VideoAsset

intro_asset = VideoAsset(asset_id=intro.id, start=0, end=3)
base_asset = VideoAsset(asset_id=base.id, start=0, end=90)
outro_asset = VideoAsset(asset_id=outro.id, start=0, end=3)

▶️ Step 4: Create timeline

Combine all video assets onto a single timeline using VideoDB's timeline feature.
from videodb.timeline import Timeline

timeline = Timeline(conn)

timeline.add_inline(intro_asset)
timeline.add_inline(base_asset)
timeline.add_inline(outro_asset)

▶️ Step 5: Play the generated video stream

from videodb import play_stream

stream = timeline.generate_stream()
play_stream(stream)
Preview the video to ensure it functions correctly. Once satisfied, generate a stream of the video and share the link for others to view and enjoy this wholesome creation!
Output:

🎉 Conclusion

You can now efficiently manipulate and assemble video elements, resulting in professional-quality compositions.
Join the VideoDB community on or for support and collaboration. In the meanwhile, check out the other exciting outputs generated using this tutorial and share yours in our too! We’d love to feature you ⚡️
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.