Videodb Python client
Project description
VideoDB Python Client
Video Database for your AI Applications
Explore the docs »
View Demo
·
Report Bug
·
Request Feature
VideoDB Python Client
The VideoDB Python client is a python package that allows you to interact with the VideoDB. VideoDB is a serverless DB that lets you manage video as intelligent data, not files. It is secure, scalable & optimized for AI- applications and LLM integrations.
Documentation
The documentation for the package can be found here
Installation
To install the package, run the following command in your terminal:
pip install videodb
Usage
Creating a Connection
To create a connection to the VideoDB, you need to create a Connection
object by passing in your VideoDB API key as a parameter to the connect function or alternatively you can set the API key in VIDEO_DB_API_KEY
environment variable. You can find your API key in the VideoDB console.
import videodb
# create a connection to the VideoDB
conn = videodb.connect(api_key="YOUR_API_KEY")
# upload to the default collection using the video url returns a Video object
video = conn.upload(url="https://www.youtube.com/")
# upload to the default collection using the local file path returns a Video object
video = conn.upload(file_path="path/to/video.mp4")
# get the stream url for the video
stream_url = video.get_stream()
Getting a Collection
To get a collection, use the get_collection
method on the established database connection object. This method returns a Collection
object.
import videodb
# create a connection to the VideoDB
conn = videodb.connect(api_key="YOUR_API_KEY")
# get the default collection
collection = conn.get_collection()
# Upload a video to the collection returns a Video object
video = collection.upload(url="https://www.youtube.com/")
# async upload
collection.upload(url="https://www.youtube.com/", callback_url="https://yourdomain.com/callback")
# get all the videos in the collection returns a list of Video objects
videos = collection.get_videos()
# get a video from the collection returns a Video object
video = collection.get_video("video_id")
# delete the video from the collection
collection.delete_video("video_id")
Multi Modal Indexing
Spoken words indexing
import videodb
# create a connection to the VideoDB and get the default collection
conn = videodb.connect(api_key="YOUR_API_KEY")
collection = conn.get_collection()
# get the video from the collection
video = collection.get_video("video_id")
# index the video for symantic search
video.index_spoken_words()
# search relevant moment in video and stream resultant video clip instantly.
# returns a SearchResults object
# for searching the video, the video must be indexed please use index_spoken_words() before searching
# optional parameters:
# - type: Optional[str] to specify the type of search. default is "semantic"
# - result_threshold: Optional[int] to specify the number of results to return. default is 5
# - score_threshold: Optional[float] to specify the score threshold for the results. default is 0.2
result = video.search("what is videodb?")
# get stream url of the result
stream_url = result.compile()
# get shots of the result returns a list of Shot objects
shots = result.get_shots()
# get stream url of the shot
short_stream_url = shots[0].compile()
# search relevant moment in collections and stream resultant video clip instantly.
# returns a SearchResults object
result = collection.search("what is videodb?")
# get stream url of the result
stream_url = result.compile()
# get shots of the result returns a list of Shot objects
shots = result.get_shots()
# get stream url of the shot
short_stream_url = shots[0].get_stream()
Video Object Methods
import videodb
# create a connection to the VideoDB, get the default collection and get a video
conn = videodb.connect(api_key="YOUR_API_KEY")
collection = conn.get_collection()
video = collection.get_video("video_id")
# get the stream url of the dynamically curated video based on the given timeline sequence
# optional parameters:
# - timeline: Optional[list[tuple[int, int]] to specify the start and end time of the video
stream_url = video.get_stream(timeline=[(0, 10), (30, 40)])
# get thumbnail of the video
thumbnail = video.get_thumbnail()
# get transcript of the video
# optional parameters:
# - force: Optional[bool] to force get the transcript. default is False
transcript = video.get_transcript()
# get transcript text of the video
# optional parameters:
# - force: Optional[bool] to force get the transcript text. default is False
transcript_text = video.get_transcript_text()
# add subtitle to the video and get the stream url of the video with subtitle
stream_url = video.add_subtitle()
# delete the video from the collection
video.delete()
Roadmap
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.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
License
Distributed under the MIT License. See LICENSE
for more information.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.