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.
Setup
Installing packages
API Keys
Before proceeding, ensure access to VideoDB Get your API key from VideoDB Console. ( Free for first 50 uploads, No credit card required)Steps
Step 1: Connect to VideoDB
Begin by establishing a connection to VideoDB using your API keyStep 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.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.Step 4: Search for any keyword
Utilize the keyword search by usingvideo.search() method with following parameters.
- pass search query in
queryparameter - pass
SearchType.keywordinsearch_type
Note: You will need to import SearchType first to enable this function
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.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: 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’sTrack and Clip pattern, we can create a timeline with padding:
- Create a timeline and track using
Timeline()andTrack() - Create a
VideoAssetwithidandstartparameters (wherestartis adjusted by subtracting padding) - Wrap each asset in a
Clipwith the appropriate duration (adding padding on both ends) - Add clips to the track sequentially using
track.add_clip(start_time, clip)
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.More Examples
Checkout these fun experiments with Keyword search 👇- So basically it’s “basically”
- The untold story of “generative” AI
Next Steps
Explore Full Notebook
Open the complete implementation in Google Colab with all code examples.