Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 68 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@

<!-- PROJECT SHIELDS -->
<!--
*** Reference links are enclosed in brackets [ ] instead of parentheses ( ).
*** https://www.markdownguide.org/basic-syntax/#reference-style-links
-->

[![PyPI version][pypi-shield]][pypi-url]
[![Stargazers][stars-shield]][stars-url]
[![Issues][issues-shield]][issues-url]
[![Website][website-shield]][website-url]


<!-- PROJECT LOGO -->
<br />
<p align="center">
Expand All @@ -34,38 +33,46 @@
</p>

<!-- ABOUT THE PROJECT -->

# 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.

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.

<!-- Documentation -->
<!-- ## Documentation
The documentation for the package can be found [here](https://videodb.io/) -->

<!-- Installation -->

## Installation

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

```
pip install videodb
```


<!-- USAGE EXAMPLES -->

## Quick Start

### Creating a Connection
Get API key from [VideoDB console](https://console.videodb.io). Free for first 50 uploads. _(No credit card required)_

Get an API key from the [VideoDB console](https://console.videodb.io). Free for first 50 uploads _(No credit card required)_.

```python
import videodb
conn = videodb.connect(api_key="YOUR_API_KEY")
```
## Working with a single Video

## Working with a Single Video

---

⬆️ **Uploading a 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.
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 a `local file path`. A default collection is created when you create your first connection.

`upload` method returns a `Video` object.

Expand All @@ -78,60 +85,62 @@ video_f = conn.upload(file_path="./my_video.mp4")

```

### 📺 Viewing your video
### 📺 View your Video

Your video is instantly available for viewing 720p resolution ⚡️
Once uploaded, your video is immediately available for viewing in 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
- 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/notebook

```python
video.generate_stream()
video.play()
```

### ⛓️ Stream Sections of videos
### ⛓️ 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
You 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 first `10 seconds` and the clip between the `120th` and the `140th` second.

```python
stream_link = video.generate_stream(timeline=[[0,10], [120,140]])
stream_link = video.generate_stream(timeline=[[0,10], [120,140]])
play_stream(stream_link)
```

### 🔍 Searching inside a video
### 🔍 Search Inside a Video

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

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._
```python
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.
`Videodb` is launching more indexing options in upcoming versions. As of now you can try the `semantic` index - Index by spoken words.

In the future you'll be able to index videos using:

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

### Viewing Search Results :
### Viewing Search Results

`video.search()` will return a `SearchResults` object, which contains the sections/shots of videos which semantically match your search query
`video.search()` returns a `SearchResults` object, which contains the sections or as we call them, `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)
- `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 Videos

---

`VideoDB` can store and search inside multiple videos with ease. By default, videos are uploaded to your default collection.
`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
### 🔄 Using Collection to Upload Multiple Videos

```python
# Get the default collection
Expand All @@ -142,17 +151,17 @@ 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
- `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 provided `video_id`.
- `coll.delete_video(video_id)`: Deletes the video from the Collection.

### 📂 Search Inside Collection

You 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.

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.
```python
# Index all videos in collection
for video in coll.get_videos():
Expand All @@ -162,49 +171,57 @@ for video in coll.get_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.

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**
**Get the Transcript**

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

**Add Subtitle to a video**
**Add Subtitles to a video**

It returns a new stream instantly with subtitles added to the video.

It returns a new stream instantly with subtitle added into the video.
```python
new_stream = video.add_subtitle()
play_stream(new_stream)
```
**Get Thumbnail of Video:**

**Get Thumbnail of a Video:**

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

**Delete a video:**

`video.delete()`: Delete a video.
`video.delete()`: Deletes the video.

Checkout more examples and tutorials 👉 [Build with VideoDB](https://docs.videodb.io/build-with-videodb-35) to explore what you can
build with `VideoDB`
Checkout more examples and tutorials 👉 [Build with VideoDB](https://docs.videodb.io/build-with-videodb-35) to explore what you can build with `VideoDB`.

---

<!-- ROADMAP -->

## 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.
- Give prompt support to edit videos.
- See the [open issues](https://github.com/video-db/videodb-python/issues) for a list of proposed features (and known issues).

---

<!-- CONTRIBUTING -->

## 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**.
Expand All @@ -219,9 +236,10 @@ Contributions are what make the open source community such an amazing place to b

<!-- MARKDOWN LINKS & IMAGES -->
<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->

[pypi-shield]: https://img.shields.io/pypi/v/videodb?style=for-the-badge
[pypi-url]: https://pypi.org/project/videodb/
[python-shield]:https://img.shields.io/pypi/pyversions/videodb?style=for-the-badge
[python-shield]: https://img.shields.io/pypi/pyversions/videodb?style=for-the-badge
[stars-shield]: https://img.shields.io/github/stars/video-db/videodb-python.svg?style=for-the-badge
[stars-url]: https://github.com/video-db/videodb-python/stargazers
[issues-shield]: https://img.shields.io/github/issues/video-db/videodb-python.svg?style=for-the-badge
Expand Down