Package: videodb
VideoDB Python SDKVideo Database for your AI ApplicationsExplore the docs »View Demo·Report Bug·Request FeatureVideoDB Python SDKVideoDB 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.InstallationTo install the package, run the following command in your terminal:pip install videodbQuick StartCreating a ConnectionGet an API key from theVideoDB console. Free for first 50 uploads(No credit card required).importvideodbconn=videodb.connect(api_key="YOUR_API_KEY")Working with a Single Video⬆️ Uploading a VideoNow that you have established a connection to VideoDB, you can upload your videos usingconn.upload().
You can directly upload fromyoutube,any public url,S3 bucketor alocal file path. A default collection is created when you create your first connection.uploadmethod returns aVideoobject.# Upload a video by urlvideo=conn.upload(url="https://www.youtube.com/watch?v=WDv4AWk0J3U")# Upload a video from file systemvideo_f=conn.upload(file_path="./my_video.mp4")📺 View your VideoOnce uploaded, your video is immediately available for viewing in 720p resolution. ⚡️Generate a streamable url for the video using video.generate_stream()Preview the video using video.play(). This will open the video in your default browser/notebookvideo.generate_stream()video.play()⛓️ Stream Specific Sections of VideosYou can easily clip specific sections of a video by passing a timeline of the start and end timestamps (in seconds) as a parameter.
For example, this will generate and play a compilation of the first10 secondsand the clip between the120thand the140thsecond.stream_link=video.generate_stream(timeline=[[0,10],[120,140]])play_stream(stream_link)🔍 Search Inside a VideoTo search bits inside a video, you have toindexthe video first. This can be done by a simple command.P.S. Indexing may take some time for longer videos.video.index_spoken_words()result=video.search("Morning Sunlight")result.play()video.get_transcript()Videodbis launching more indexing options in upcoming versions. As of now you can try thesemanticindex - Index by spoken words.In the future you'll be able to index videos using:Scene- Visual concepts and events.Faces.Specific domain Indexlike Football, Baseball, Drone footage, Cricket etc.Viewing Search Resultsvideo.search()returns aSearchResultsobject, which contains the sections or as we call them,shotsof videos which semantically match your search query.result.get_shots()Returns a list of Shot(s) that matched the search query.result.play()Returns a playable url for the video (similar to video.play(); you can open this link in the browser, or embed it into your website using an iframe).RAG: Search inside Multiple VideosVideoDBcan 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 collectioncoll=conn.get_collection()# Upload Videos to a collectioncoll.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 a Collection object; the default collection.coll.get_videos(): Returns a list of Video objects; all videos in the collections.coll.get_video(video_id): Returns a Video object, corresponding video from the providedvideo_id.coll.delete_video(video_id): Deletes the video from the Collection.📂 Search Inside CollectionYou can simply Index all the videos in a collection and use the search method to find relevant results.
Here we are indexing the spoken content of a collection and performing semantic search.# Index all videos in collectionforvideoincoll.get_videos():video.index_spoken_words()# search in the collection of videosresults=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 objectThere are multiple methods available on a Video Object, that can be helpful for your use-case.Get the Transcript# words with timestampstext_json=video.get_transcript()text=video.get_transcript_text()print(text)Add Subtitles to a videoIt returns a new stream instantly with subtitles added to the video.new_stream=video.add_subtitle()play_stream(new_stream)Get Thumbnail of a Video:video.generate_thumbnail(): Returns a thumbnail image of video.Delete a video:video.delete(): Deletes the video.Checkout more examples and tutorials 👉Build with VideoDBto explore what you can build withVideoDB.RoadmapAdding More Indexes :Face,Scene,Security,Events, andSportsGive prompt support to generate thumbnails using GenAI.Give prompt support to access content.Give prompt support to edit videos.See theopen issuesfor a list of proposed features (and known issues).ContributingContributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make aregreatly appreciated.Fork the ProjectCreate 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