Skip to content

Commit

Permalink
feat: add video operator to fulfil unstructured data process (#238)
Browse files Browse the repository at this point in the history
Because

- we want to make vdp process all types of unstructured data

This commit

- add video operator to subsample video to video or images for different
use cases
  • Loading branch information
chuang8511 committed Jul 26, 2024
1 parent 8648326 commit a1459d7
Show file tree
Hide file tree
Showing 10 changed files with 606 additions and 1 deletion.
6 changes: 5 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ require (
github.com/gofrs/uuid v4.4.0+incompatible
github.com/gojuno/minimock/v3 v3.3.6
github.com/google/go-github/v62 v62.0.0
github.com/google/uuid v1.6.0
github.com/h2non/filetype v1.1.3
github.com/iFaceless/godub v0.0.0-20200728093528-a30bb4d1a0f1
github.com/instill-ai/protogen-go v0.3.3-alpha.0.20240530065422-d384f728a1e2
Expand All @@ -46,6 +47,7 @@ require (
github.com/slack-go/slack v0.12.5
github.com/stretchr/testify v1.9.0
github.com/tmc/langchaingo v0.1.10
github.com/u2takey/ffmpeg-go v0.5.0
go.uber.org/zap v1.24.0
golang.org/x/image v0.18.0
golang.org/x/oauth2 v0.18.0
Expand All @@ -69,6 +71,7 @@ require (
github.com/antchfx/xpath v1.2.4 // indirect
github.com/apache/arrow/go/v14 v14.0.2 // indirect
github.com/araddon/dateparse v0.0.0-20200409225146-d820a6159ab1 // indirect
github.com/aws/aws-sdk-go v1.55.1 // indirect
github.com/aws/aws-sdk-go-v2 v1.30.1 // indirect
github.com/aws/smithy-go v1.20.3 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
Expand All @@ -92,13 +95,13 @@ require (
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/googleapis/gax-go/v2 v2.12.3 // indirect
github.com/gorilla/websocket v1.5.1 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0 // indirect
github.com/itchyny/timefmt-go v0.1.5 // indirect
github.com/jaytaylor/html2text v0.0.0-20200412013138-3577fbdbcff7 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect
github.com/kennygrant/sanitize v1.2.4 // indirect
github.com/klauspost/compress v1.17.2 // indirect
Expand All @@ -123,6 +126,7 @@ require (
github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf // indirect
github.com/temoto/robotstxt v1.1.2 // indirect
github.com/tink-ab/tempfile v0.0.0-20180226111222-33beb0518f1a // indirect
github.com/u2takey/go-utils v0.3.1 // indirect
github.com/zeebo/xxh3 v1.0.2 // indirect
gitlab.com/golang-commonmark/html v0.0.0-20191124015941-a22733972181 // indirect
gitlab.com/golang-commonmark/linkify v0.0.0-20191026162114-a0c2df6c8f82 // indirect
Expand Down
32 changes: 32 additions & 0 deletions go.sum

Large diffs are not rendered by default.

80 changes: 80 additions & 0 deletions operator/video/v0/README.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
title: "Video"
lang: "en-US"
draft: false
description: "Learn about how to set up a VDP Video component https://github.com/instill-ai/instill-core"
---

The Video component is an operator component that allows users to extract and manipulate video from different sources.
It can carry out the following tasks:

- [Subsample Video](#subsample-video)
- [Subsample Video Frames](#subsample-video-frames)



## Release Stage

`Alpha`



## Configuration

The component configuration is defined and maintained [here](https://github.com/instill-ai/component/blob/main/operator/video/v0/config/definition.json).





## Supported Tasks

### Subsample Video

Subsample video into a new video


| Input | ID | Type | Description |
| :--- | :--- | :--- | :--- |
| Task ID (required) | `task` | string | `TASK_SUBSAMPLE_VIDEO` |
| Video (required) | `video` | string | Base64 encoded video |
| FPS (required) | `fps` | number | Frames per second |
| Start time | `start-time` | string | Start time in seconds, format is hh:mm:ss |
| Duration | `duration` | string | Duration in seconds, format is hh:mm:ss |



| Output | ID | Type | Description |
| :--- | :--- | :--- | :--- |
| Video | `video` | string | Base64 encoded sub-sampled video |






### Subsample Video Frames

Subsample video into frames


| Input | ID | Type | Description |
| :--- | :--- | :--- | :--- |
| Task ID (required) | `task` | string | `TASK_SUBSAMPLE_VIDEO_FRAMES` |
| Video (required) | `video` | string | Base64 encoded video |
| FPS (required) | `fps` | number | Frames per second |
| Start time | `start-time` | string | Start time in seconds, format is hh:mm:ss |
| Duration | `duration` | string | Duration in seconds, format is hh:mm:ss |



| Output | ID | Type | Description |
| :--- | :--- | :--- | :--- |
| Frames | `frames` | array[string] | Base64 encoded sub-sampled frames |







3 changes: 3 additions & 0 deletions operator/video/v0/assets/video.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions operator/video/v0/config/definition.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"availableTasks": [
"TASK_SUBSAMPLE_VIDEO",
"TASK_SUBSAMPLE_VIDEO_FRAMES"
],
"documentationUrl": "https://www.instill.tech/docs/component/operator/video",
"icon": "assets/video.svg",
"id": "video",
"public": true,
"spec": {},
"title": "Video",
"type": "COMPONENT_TYPE_OPERATOR",
"uid": "f0be2fd3-7266-4eeb-88eb-3bbbcc2a6b32",
"version": "0.1.0",
"sourceUrl": "https://github.com/instill-ai/component/blob/main/operator/video/v0",
"description": "Extract and manipulate video from different sources",
"releaseStage": "RELEASE_STAGE_ALPHA"
}
182 changes: 182 additions & 0 deletions operator/video/v0/config/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
{
"TASK_SUBSAMPLE_VIDEO": {
"instillShortDescription": "Subsample video into a new video",
"input": {
"description": "Factor to be used for sub-sampling the video",
"instillEditOnNodeFields": [
"video",
"fps"
],
"instillUIOrder": 0,
"properties": {
"video": {
"description": "Base64 encoded video",
"instillAcceptFormats": [
"video/*"
],
"instillUIOrder": 0,
"instillUpstreamTypes": [
"reference"
],
"title": "Video",
"type": "string"
},
"fps": {
"description": "Frames per second",
"instillAcceptFormats": [
"number",
"integer"
],
"instillUIOrder": 1,
"instillUpstreamTypes": [
"reference",
"value"
],
"title": "FPS",
"type": "number"
},
"start-time": {
"description": "Start time in seconds, format is hh:mm:ss",
"instillAcceptFormats": [
"string"
],
"instillUIOrder": 2,
"instillUpstreamTypes": [
"reference",
"value"
],
"title": "Start time",
"type": "string"
},
"duration": {
"description": "Duration in seconds, format is hh:mm:ss",
"instillAcceptFormats": [
"string"
],
"instillUIOrder": 3,
"instillUpstreamTypes": [
"reference",
"value"
],
"title": "Duration",
"type": "string"
}
},
"required": [
"video",
"fps"
],
"title": "Input",
"type": "object"
},
"output": {
"instillUIOrder": 1,
"properties": {
"video": {
"description": "Base64 encoded sub-sampled video",
"instillFormat": "video/*",
"instillUIOrder": 0,
"title": "Video",
"type": "string"
}
},
"required": [
"video"
],
"title": "Output",
"type": "object"
}
},
"TASK_SUBSAMPLE_VIDEO_FRAMES": {
"instillShortDescription": "Subsample video into frames",
"input": {
"description": "Factor to be used for sub-sampling the video into frame",
"instillEditOnNodeFields": [
"video",
"fps"
],
"instillUIOrder": 0,
"properties": {
"video": {
"description": "Base64 encoded video",
"instillAcceptFormats": [
"video/*"
],
"instillUIOrder": 0,
"instillUpstreamTypes": [
"reference"
],
"title": "Video",
"type": "string"
},
"fps": {
"description": "Frames per second",
"instillAcceptFormats": [
"number",
"integer"
],
"instillUIOrder": 1,
"instillUpstreamTypes": [
"reference",
"value"
],
"title": "FPS",
"type": "number"
},
"start-time": {
"description": "Start time in seconds, format is hh:mm:ss",
"instillAcceptFormats": [
"string"
],
"instillUIOrder": 2,
"instillUpstreamTypes": [
"reference",
"value"
],
"title": "Start time",
"type": "string"
},
"duration": {
"description": "Duration in seconds, format is hh:mm:ss",
"instillAcceptFormats": [
"string"
],
"instillUIOrder": 3,
"instillUpstreamTypes": [
"reference",
"value"
],
"title": "Duration",
"type": "string"
}
},
"required": [
"video",
"fps"
],
"title": "Input",
"type": "object"
},
"output": {
"instillUIOrder": 1,
"properties": {
"frames": {
"description": "Base64 encoded sub-sampled frames",
"instillFormat": "image/*",
"instillUIOrder": 0,
"items": {
"type": "string",
"title": "Frame"
},
"title": "Frames",
"type": "array"
}
},
"required": [
"frames"
],
"title": "Output",
"type": "object"
}
}
}
Loading

0 comments on commit a1459d7

Please sign in to comment.