VideoDB Documentation
VideoDB Documentation
This notebook is designed to help you get started with VideoDB. Check at the end for deep dive into advance concepts like Programmable streams.


🔧 Installing VideoDB in your environment

VideoDB is available as
!pip install videodb

🔗 Setting Up a connection to db

To connect to VideoDB, simply get the API and create a connection. This can be done by either providing your VideoDB API key directly to the constructor or by setting the VIDEO_DB_API_KEY environment variable with your API key.
Get your API key from . ( Free for first 50 uploads, No credit card required ) 🎉
import videodb
conn = videodb.connect(api_key="YOUR_API_KEY")

Working with Single Video

⬆️ Uploading a video

Now that you have established a connection to VideoDB , you can upload your videos using conn.upload()
You can upload your media by a url or from your local file system
upload method returns a Video object.
# Upload a video by url
video = conn.upload(url="")

# Upload a video from file system
video_f = conn.upload(file_path="./my_video.mp4")
VideoDB simplifies your upload by supporting links from Youtube, S3 or any Public URL with video

Pro Tip

If you wish to upload only the audio from a video file, just specify in the "media_type" field. For instance, you can obtain audio from a YouTube video by doing so.
from videodb import MediaType

audio = conn.upload(url="",
The types of media that can be uploaded are defined in the MediaType class.

📺 Viewing your video

Your video is instantly available for viewing 720p resolution ⚡️
Generate a streamable url for video using video.generate_stream()
Preview the video using This will open the video in your default browser/notebook
Note: if you are viewing this notebook on github, you won't be able to see iframe player, because of security restrictions. Please open the printed link of player in your browser
Load content from
Loading external content may reveal information to 3rd parties. Learn more

⛓️ Stream Specific Sections of videos

You can easily clip specific sections of a video by passing timeline of start and end sections. It accepts seconds. For example Here’s we are streaming only first 10 seconds and then 120 to 140 second of a video
stream_link = video.generate_stream(timeline=[(0,10), (120,140)])

🗂️ Indexing a Video

To search bits inside a video, you have to first index the video. This can be done by a invoking the index function on the video object. VideoDB offers two type of indexes currently.
index_spoken_words: Indexes spoken words in the video. It automatically generate the transcript and makes it ready for search. Checkout to index different language content.
index_scenes: Indexes visual concepts and events of the video. Perfect for building security monitoring, drone, and other camera footage. Refer
# best for podcasts, elearning, news, etc.
# best for camera feeds, moderation usecases etc.
video.index_scenes(prompt="<your prompt to describe the scenes>")
In future you can also index videos using:
Faces : Upload image of the person and find them in a video.
Specific domain Index like Football, Baseball, Drone footage, Cricket etc.
⏱️ Indexing may take some time for longer videos, structure it as a batch job with callback in your application.

🔍 Search Inside a Video

Search the segments inside a video. While searching you have options to choose the type of search and index. VideoDB offers following types of search :
SearchType.semantic Perfect for question answer kind of queries. This is also the default type of search.
SearchType.keyword It matches the exact occurrence of word or sentence you pass in the query parameter of the search function. keyword search is only available to use with single videos.
IndexType.scene It search the visual information of the video, Index the video using index_scenes function.
IndexType.spoken_word It search the spoken information of the video, Index the video using index_spoken_words function.
from videodb import SearchType
from videodb import IndexType

result = = "What are the benefits of morning sunlight?",
search_type = SearchType.semantic,
index_type =IndexType.spoken_word)

Viewing Search Results : will return a SearchResults object, which contains the sections/shots of videos which semantically match your search query
result.get_shots() - Returns a list of Shot that matched search query - Returns a playable url for video (similar to you can open this link in browser, or embed it into your website using iframe)

RAG: Search Inside Multiple Videos

VideoDB can store and search inside multiple videos with ease. By default, videos are uploaded to your default collection and you have freedom to create and manage more collections, checkout our doc for more details.
If you are an existing llamaIndex user, trying to build RAG pipeline on your video data. You can also use VideoDB retriever. Checkout llama docs ⬇️
🔄 Using Collection to upload multiple Videos
# Get the default collection
coll = conn.get_collection()

# Upload Videos to a collection

conn.get_collection() : Returns Collection object, the default collection
coll.get_videos() : Returns list of Video, all videos in collections
coll.get_video(video_id): Returns Video, respective video object from given video_id
coll.delete_video(video_id): Deletes the video from Collection

📂 Search inside multiple videos in a collection

You can simply index all the videos in a collection and use search method on collection to find relevant results. Here we are indexing spoken content of a collection and searching
# Index all videos in collection
for video in coll.get_videos():

Semantic Search in the collection
# search in the collection of videos
results = = "What is Dopamine?")

Let’s try one more search:
results = = "What's the benefit of morning sunlight?")
The result here has all the matching bits in a single video stream from your collection. You can use these results in your application right away.
As you can see VideoDB fundamentally removes the limitation of files and gives you power to access and stream videos in a very seamless way. Stay tuned for exciting features in our upcoming version and keep building awesome stuff with VideoDB 🤘

🌟 Explore more with Video object

There are multiple methods available on a Video Object, that can be helpful for your use-case.

Access Transcript

# get text of the spoken content
text_json = video.get_transcript()
text = video.get_transcript_text()

Add Subtitle to a video
It returns a new stream instantly with subtitle added into the video. Subtitle functions has many styling parameters like font, size, background color etc. Check and for details.
new_stream = video.add_subtitle()
Get Thumbnail of Video :
video.generate_thumbnail() : Returns a thumbnail image of video.
Delete a video :
video.delete() : Delete a video.

👉🏼 Checkout to understand how you can modify the video streams in real-time. This opens doors for many usecases that were never possible with videos.⚡️
👉🏼 Checkout more examples and tutorials 👉 to explore what you can build with VideoDB

Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
) instead.