logo
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Readme
Files and versions

117 lines
3.9 KiB

3 years ago
# Operator: video-decoder
Author: JunJie Jiang
## Overview
## Interface
```python
3 years ago
__init__(self, start_time=None, end_time=None, sample_type=None, args=None)
3 years ago
3 years ago
Args:
3 years ago
- start_time: float
3 years ago
3 years ago
- end_time: float
3 years ago
decode video from start_time to end_time
- sample_type: str
3 years ago
uniform_temporal_subsample
3 years ago
time_step_sample
3 years ago
- args: dict
3 years ago
sample_type is `uniform_temporal_subsample`
3 years ago
num_samples: int
3 years ago
sample_type is `time_step_sample`
time_step: int
3 years ago
```
3 years ago
```python
__call__(self, video_path: str)
```
Args:
- video_path:
support local path and http/https url.
Returns:
3 years ago
- towhee.types.VideoFrame
3 years ago
## Requirements
av
## How it works
```python
from towhee import pipe, ops, DataCollection
p = (
pipe.input('video_file')
.flat_map('video_file', 'frame', ops.video_decode.ffmpeg(start_time=10.0, end_time=15.0, sample_type='time_step_sample', args={'time_step': 1}))
.output('frame')
)
DataCollection(p('./video.mp4')).show(limit=1)
```
3 years ago
3 years ago
```python
from towhee import ops
3 years ago
d = ops.video_decode.ffmpeg(start_time=10.0, end_time=20.0, sample_type='uniform_temporal_subsample', args={'num_samples': 10})
for frame in d(video_path):
print(frame)
3 years ago
print('#' * 50)
d = ops.video_decode.ffmpeg(start_time=10.0, end_time=20.0, sample_type='time_step_sample', args={'time_step': 1})
for frame in d(video_path):
print(frame)
3 years ago
result:
3 years ago
VideoFrame shape: (360, 480, 3), mode: RGB, timestamp: 10010, key_frame: 1
VideoFrame shape: (360, 480, 3), mode: RGB, timestamp: 11078, key_frame: 0
VideoFrame shape: (360, 480, 3), mode: RGB, timestamp: 12145, key_frame: 0
VideoFrame shape: (360, 480, 3), mode: RGB, timestamp: 13280, key_frame: 0
VideoFrame shape: (360, 480, 3), mode: RGB, timestamp: 14348, key_frame: 0
VideoFrame shape: (360, 480, 3), mode: RGB, timestamp: 15482, key_frame: 0
VideoFrame shape: (360, 480, 3), mode: RGB, timestamp: 16550, key_frame: 0
VideoFrame shape: (360, 480, 3), mode: RGB, timestamp: 17684, key_frame: 0
VideoFrame shape: (360, 480, 3), mode: RGB, timestamp: 18752, key_frame: 0
VideoFrame shape: (360, 480, 3), mode: RGB, timestamp: 19887, key_frame: 0
##################################################
VideoFrame shape: (360, 480, 3), mode: RGB, timestamp: 10010, key_frame: 1
VideoFrame shape: (360, 480, 3), mode: RGB, timestamp: 11011, key_frame: 0
VideoFrame shape: (360, 480, 3), mode: RGB, timestamp: 12012, key_frame: 0
VideoFrame shape: (360, 480, 3), mode: RGB, timestamp: 13013, key_frame: 0
VideoFrame shape: (360, 480, 3), mode: RGB, timestamp: 14014, key_frame: 0
VideoFrame shape: (360, 480, 3), mode: RGB, timestamp: 15015, key_frame: 1
VideoFrame shape: (360, 480, 3), mode: RGB, timestamp: 16015, key_frame: 0
VideoFrame shape: (360, 480, 3), mode: RGB, timestamp: 17017, key_frame: 0
VideoFrame shape: (360, 480, 3), mode: RGB, timestamp: 18018, key_frame: 0
VideoFrame shape: (360, 480, 3), mode: RGB, timestamp: 19019, key_frame: 0
3 years ago
## Reference
3 years ago
# More Resources
- [Scalar Quantization and Product Quantization - Zilliz blog](https://zilliz.com/learn/scalar-quantization-and-product-quantization): A hands-on dive into scalar quantization (integer quantization) and product quantization with Python.
- [Multimodal RAG with Milvus and GPT-4o](https://zilliz.com/event/multimodal-rag-with-milvus-and-gpt-4o/success): Join us for a webinar for a demo of multimodal RAG with Milvus and GPT-4o
- [Building a Video Analysis System with Milvus Vector Database - Zilliz blog](https://zilliz.com/blog/milvus-helps-analyze-videos-intelligently): Learn how Milvus powers the AI analysis of video content.
- [Multimodal RAG with Milvus and GPT-4o](https://zilliz.com/event/multimodal-rag-with-milvus-and-gpt-4o): Join us for a webinar for a demo of multimodal RAG with Milvus and GPT-4o
- [4 Steps to Building a Video Search System - Zilliz blog](https://zilliz.com/blog/building-video-search-system-with-milvus): Searching for videos by image with Milvus