8000 GitHub - gauravkrp/videodb-python at v0.0.1
[go: up one dir, main page]

Skip to content

gauravkrp/videodb-python

Repository files navigation

PyPI version Stargazers Issues Website


Logo

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 which is a serverless database that lets you manage video as intelligent data, not files. It is secure, scalable & optimized for AI- applications and LLM integrations.

Installation

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

pip install videodb

Quick Start

Creating a Connection

To create a new connection you need to get API key from VideoDB console. 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.

import videodb

# create a new 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.

  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

License

Distributed under the MIT License. See LICENSE for more information.

About

VideoDB Python SDK

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%
0