videodb
VideoDB Documentation
videodb
VideoDB Documentation
Examples and Tutorials

icon picker
Fun with Keyword Search

😅 Want to generate videos like this for fun?
Load content from console.videodb.io?
Loading external content may reveal information to 3rd parties. Learn more
Allow

💬 Overview

In this tutorial, let’s explore the powerful functionality of Keyword Search in VideoDB. This feature enables users to efficiently locate any keyword or phrase within their video assets, streamlining the process of content discovery.
image.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"] = ""


Steps

🌐 Step 1: Connect to VideoDB

Establish a session for uploading videos. Import the necessary modules from VideoDB library to access functionalities.
from videodb import connect

conn = connect()
coll = conn.get_collection()

🎥 Step 2: Upload Video

Upload the video to your VideoDB collection. You can upload the video asset from your local device or from a YouTube URL to upload the video from its source. This works as the base video for all the Keyword Search queries.
video = coll.upload(url="https://www.youtube.com/watch?v=Uvufun6xer8")
video.play()
info
You can upload from your local file system too by passing file_path in upload()
For this tutorial, we’ll run a Keyword Search on the following video:

🔊 Step 3: Index Spoken Words

Index the spoken words in your video to enable accurate keyword search.
video.index_spoken_words()

🔎 Step 4: Search for any keyword

Utilize the keyword search by using video.search() method with following parameters.
pass search query in query parameter
pass SearchType.keyword in search_type
Note: You will need to import SearchType first to enable this function
from videodb import SearchType

results = video.search(query='metaverse', search_type=SearchType.keyword)


👀 Step 5: Preview and Share

Preview your video with a compilation of all the clips matching your search query. You can access the stream link alongside the preview to share the Keyword Search result with others.
results.play()
Load content from console.videodb.io?
Loading external content may reveal information to 3rd parties. Learn more
Allow

🔎 Bonus : Refining Keyword Search results by adding padding.

Some keyword search results/ compilations may appear slightly choppy, or the cuts may feel abrupt. We can solve this issue by using VideoDB’s padding controls. Here’s how it works:
Compiled Timeline_Keyword-with padding.png

The resulting shots can be made smoother by including a little more context from before and after the matching timestamps. That’s exactly what padding controls enable:
Create a timeline, by using the Timeline() function.
Create VideoAsset of each result shot using VideoAsset() with following parameters
asset_id : Video ID of the Video to which result belongs to [base video]
start: To adjust the beginning of the resulting shot, we subtract the padding duration from the original start timestamp. This ensures the resulting shot starts earlier in relation to the base video.
end: Likewise, we extend the resulting shot's end timestamp by adding the padding duration. This gives the resulting shot additional context from the base video.
Finally, we will add these freshly created assets in our Timeline by using Timeline.add_inline()
from videodb.timeline import Timeline
from videodb.asset import VideoAsset

timeline = Timeline(conn)

# Add padding
padding = 0.4

# Compile Video
for shot in results.shots:
asset = VideoAsset(
asset_id=shot.video_id, start=shot.start-padding, end=shot.end+padding
)
timeline.add_inline(asset)

▶️ Here’s the result for the same video, but improved using padding control.


🎉 Conclusion

Keyword Search in VideoDB empowers users to extract valuable insights from their video assets with ease. For more information and advanced features, explore the and join the VideoDB community on or for support and collaboration.

More Examples

Checkout these fun experiments with Keyword search 👇
So basically it’s “basically”

2. The untold story of “generative”AI

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.