Skip to main content

VideoDB Python SDK

Project description

PyPI version Stargazers Issues Website


Logo

VideoDB Python SDK

Video Database for your AI Applications
Explore the docs »

View Demo · Report Bug · Request Feature

VideoDB Python SDK

VideoDB Python SDK allows you to interact with the VideoDB serverless database. Manage videos as intelligent data, not files. It's scalable, cost efficient & optimized for AI applications and LLM integration.

Installation

To install the package, run the following command in your terminal:

pip install videodb

Quick Start

Creating a Connection

Get API key from VideoDB console. Free for first 50 uploads. (No credit card required)

import videodb
conn = videodb.connect(api_key="YOUR_API_KEY")

Working with a single Video


⬆️ Uploading a Video

Now that you have established a connection to VideoDB, you can upload your videos using conn.upload() You can directly upload from youtube, any public url, S3 bucket or local file path. A default collection is created when you create a new connection.

upload method returns a Video object.

# Upload a video by url
video = conn.upload(url="https://www.youtube.com/watch?v=WDv4AWk0J3U")

# Upload a video from file system
video_f = conn.upload(file_path="./my_video.mp4")

📺 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 video.play(). This will open the video in your default browser/notebook
video.generate_stream()
video.play()

⛓️ Stream 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]]) 
play_stream(stream_link)

🔍 Searching inside a video

To search bits inside a video — you have to index the video first. This can be done by a simple command. Indexing may take some time for longer videos.

video.index_spoken_words()
result = video.search("Morning Sunlight")
result.play()
video.get_transcript()

Videodb is launching more indexes in upcoming versions. Currently it offers semantic index - Index by spoken words.

In future you can also index videos using:

  1. Scene - Visual concepts and events.
  2. Faces.
  3. Specific domain Index like Football, Baseball, Drone footage, Cricket etc.

Viewing Search Results :

video.search() 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
  • result.play() Returns a playable url for video (similar to video.play() 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.

🔄 Using Collection to upload multiple Videos

# Get the default collection
coll = conn.get_collection()

# Upload Videos to a collection
coll.upload(url="https://www.youtube.com/watch?v=lsODSDmY4CY")
coll.upload(url="https://www.youtube.com/watch?v=vZ4kOr38JhY")
coll.upload(url="https://www.youtube.com/watch?v=uak_dXHh6s4")
  • 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 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 performing semantic search.

# Index all videos in collection
for video in coll.get_videos():
    video.index_spoken_words()

# search in the collection of videos
results = coll.search(query = "What is Dopamine?")
results.play()

The result here has all the matching bits in a single stream from your collection. You can use these results in your application right away.

🌟 Explore the Video object

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

Access Transcript

# words with timestamps
text_json = video.get_transcript()
text = video.get_transcript_text()
print(text)

Add Subtitle to a video

It returns a new stream instantly with subtitle added into the video.

new_stream = video.add_subtitle()
play_stream(new_stream)

Get Thumbnail of Video:

video.generate_thumbnail(): Returns a thumbnail image of video.

Delete a video:

video.delete(): Delete a video.

Checkout more examples and tutorials 👉 Build with VideoDB to explore what you can build with VideoDB


Roadmap

  • Adding More Indexes : Face, Scene, Security, Events, and Sports
  • Give prompt support to generate thumbnails using GenAI.
  • Give prompt support to access content.
  • Give prompt support to edit videos.
  • See the open issues for a list of proposed features (and known issues).

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

videodb-0.0.2.tar.gz (19.5 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page