Skip to content
videodb
VideoDB Documentation
  • Pages
    • Welcome to VideoDB Docs
    • Quick Start Guide
      • Video Indexing Guide
      • Semantic Search
      • Collections
      • Public Collections
      • Callback Details
      • Ref: Subtitle Styles
      • Language Support
      • Guide: Subtitles
      • How Accurate is Your Search?
    • Visual Search and Indexing
      • Scene Extraction Algorithms
      • Custom Annotations
      • Scene-Level Metadata: Smarter Video Search & Retrieval
      • Advanced Visual Search Pipelines
      • Playground for Scene Extractions
      • Deep Dive into Prompt Engineering : Mastering Visual Indexing
      • How VideoDB Solves Complex Visual Analysis Tasks
      • Multimodal Search: Quickstart
      • Conference Slide Scraper with VideoDB
    • Examples and Tutorials
      • Dubbing - Replace Soundtrack with New Audio
      • VideoDB: Adding AI Generated voiceovers to silent footage
      • Beep curse words in real-time
      • Remove Unwanted Content from videos
      • Instant Clips of Your Favorite Characters
      • Insert Dynamic Ads in real-time
      • Adding Brand Elements with VideoDB
      • Elevating Trailers with Automated Narration
      • Add Intro/Outro to Videos
      • Audio overlay + Video + Timeline
      • Building Dynamic Video Streams with VideoDB: Integrating Custom Data and APIs
      • AI Generated Ad Films for Product Videography
      • icon picker
        Fun with Keyword Search
      • Overlay a Word-Counter on Video Stream
      • Generate Automated Video Outputs with Text Prompts | VideoDB
      • VideoDB x TwelveLabs: Real-Time Video Understanding
      • Multimodal Search
      • How I Built a CRM-integrated Sales Assistant Agent in 1 Hour
      • Make Your Video Sound Studio Quality with Voice Cloning
      • Automated Traffic Violation Reporter
    • Live Video→ Instant Action
    • Generative Media Quickstart
      • Generative Media Pricing
    • Video Editing Automation
      • Fit & Position: Aspect Ratio Control
      • Trimming vs Timing: Two Independent Timelines
      • Advanced Clip Control: The Composition Layer
      • Caption & Subtitles: Auto-Generated Speech Synchronization
      • Notebooks
    • Transcoding Quickstart
    • director-light
      Director - Video Agent Framework
      • Agent Creation Playbook
      • Setup Director Locally
    • Workflows and Integrations
      • zapier
        Zapier Integration
        • Auto-Dub Videos & Save to Google Drive
        • Create & Add Intelligent Video Highlights to Notion
        • Create GenAI Video Engine - Notion Ideas to Youtube
        • Automatically Detect Profanity in Videos with AI - Update on Slack
        • Generate and Store YouTube Video Summaries in Notion
        • Automate Subtitle Generation for Video Libraries
        • Solve customers queries with Video Answers
      • n8n
        N8N Workflows
        • AI-Powered Meeting Intelligence: Recording to Insights Automation
        • AI Powered Dubbing Workflow for Video Content
        • Automate Subtitle Generation for Video Libraries
        • Automate Interview Evaluations with AI
        • Turn Meeting Recordings into Actionable Summaries
        • Auto-Sync Sales Calls to HubSpot CRM with AI
        • Instant Notion Summaries for Your Youtube Playlist
    • Meeting Recording SDK
    • github
      Open Source
      • llama
        LlamaIndex VideoDB Retriever
      • PromptClip: Use Power of LLM to Create Clips
      • StreamRAG: Connect ChatGPT to VideoDB
    • mcp
      VideoDB MCP Server
    • videodb
      Give your AI, Eyes and Ears
      • Building Infrastructure that “Sees” and “Edits”
      • Agents with Video Experience
      • From MP3/MP4 to the Future with VideoDB
      • Dynamic Video Streams
      • Why do we need a Video Database Now?
      • What's a Video Database ?
      • Enhancing AI-Driven Multimedia Applications
      • Beyond Traditional Video Infrastructure
    • Customer Love
    • Join us
      • videodb
        Internship: Build the Future of AI-Powered Video Infrastructure
      • Ashutosh Trivedi
        • Playlists
        • Talks - Solving Logical Puzzles with Natural Language Processing - PyCon India 2015
      • Ashish
      • Shivani Desai
      • Gaurav Tyagi
      • Rohit Garg
      • Edge of Knowledge
        • Language Models to World Models: The Next Frontier in AI
        • Society of Machines
          • Society of Machines
          • Autonomy - Do we have the choice?
          • Emergence - An Intelligence of the collective
        • Building Intelligent Machines
          • Part 1 - Define Intelligence
          • Part 2 - Observe and Respond
          • Part 3 - Training a Model
      • Updates
        • VideoDB Acquires Devzery: Expanding Our AI Infra Stack with Developer-First Testing Automation

Fun with Keyword Search

From an hour long video, want to create a fun compilation of every moment Mark Zuckerberg says ‘metaverse’?
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 videodb
import os
from getpass import getpass

# Prompt user for API key securely
api_key = getpass("Please enter your VideoDB API Key: ")
os.environ["VIDEO_DB_API_KEY"] = api_key

Steps

🌐 Step 1: Connect to VideoDB

Begin by establishing a connection to VideoDB using your API key
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()

🔎 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:
Using the Editor SDK's Track and Clip pattern, we can create a timeline with padding:
1. Create a timeline and track using Timeline() and Track() 2. Create a VideoAsset with id and start parameters (where start is adjusted by subtracting padding) 3. Wrap each asset in a `Clip` with the appropriate duration (adding padding on both ends) 4. Add clips to the track sequentially using track.add_clip(start_time, clip)
from videodb import play_stream
from videodb.editor import Timeline, Track, Clip, VideoAsset

timeline = Timeline(conn)

# Add padding for smoother cuts
padding = 0.4

# Create main track
track = Track()
seeker = 0

# Compile Video from search results
for shot in results.shots:
start_with_padding = max(0, shot.start - padding)
duration = (shot.end + padding) - start_with_padding
asset = VideoAsset(id=shot.video_id, start=start_with_padding)
clip = Clip(asset=asset, duration=duration)
track.add_clip(seeker, clip)
seeker += duration

timeline.add_track(track)

stream_url = timeline.generate_stream()
play_stream(stream_url)

▶️ 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 ··· in the right corner or using a keyboard shortcut (
CtrlP
) instead.