videodb
VideoDB Documentation
videodb
VideoDB Documentation
Examples and Tutorials

icon picker
Dubbing - Replace Soundtrack with New Audio

Overview

Dubbing videos is a great strategy for your existing content. This guide is here to help you explore localizing content or simply enjoy remixing your favorite videos into new versions.The focus is on how to easily replace the soundtrack if you already have the dubbed content.
If you are looking for AI solutions for dubbing the soundtrack, please wait for Part 2 of this tutorial.

🔗 Prerequisites

Ensure you have VideoDB installed in your environment. If not, simply run !pip install videodb in your terminal.
You'll also need a VideoDB API_KEY, which can be obtained from the VideoDB .

📺 Source Your Videos

First, identify the original video and the new audio track you wish to overlay. For this tutorial, we're using an English video and a Hindi audio track:
# Original video in English
english_audio = 'https://www.youtube.com/watch?v=0e3GPea1Tyg'

# New audio track in Hindi
hindi_audio = 'https://www.youtube.com/watch?v=IoDVfXFq5cU'

🌐 Connect to VideoDB

Connect to VideoDB using your API key. This establishes a session for uploading and manipulating video and audio files:
from videodb import connect
conn = connect(api_key="YOUR_API_KEY")

📁 Upload and Prepare Media

Upload both the original video and the new audio track to VideoDB. Specify the `media_type` for the audio to ensure only the soundtrack is used:
from videodb import MediaType

# Upload the original video
video = conn.upload(url=english_audio)

# Upload and extract audio from the new track
audio = conn.upload(url=hindi_audio, media_type=MediaType.audio)

⚙️ Create and Customize Your Timeline

Create a new timeline and add your video. Then, overlay the new audio track, replacing the original audio. Checkout for more information on it.
from videodb.asset import VideoAsset, AudioAsset
from videodb.timeline import Timeline

# create a new timeline
timeline = Timeline(conn)

#create video asset with full length
video_asset = VideoAsset(asset_id=video.id)

# add original video inline
timeline.add_inline(video_asset)
# create an audio asset from 0 sec to the full length of the video
hindi_audio_asset = AudioAsset(asset_id=audio.id, disable_other_tracks=True)

# add overlay starting from 0 sec in the timeline as we want to replace the full track.
timeline.add_overlay(0, hindi_audio_asset)

# generate the stream from timeline
hindi_dub_stream = timeline.generate_stream()

🧰 Review and Share Your Dubbed Video

Finally, generate a stream of your newly dubbed video and share the link for others to view:
from videodb import play_stream
play_stream(hindi_dub_stream)
Load content from console.videodb.io?
Loading external content may reveal information to 3rd parties. Learn more
Allow

🎛️ Generating Dubbed Audio with AI

If you don't have a ready-made audio track, consider using AI solutions like to generate dubbed audio in various languages and voices.

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.