Spaces:
Runtime error
Runtime error
smellslikeml
commited on
Commit
•
b43c9f8
1
Parent(s):
4f5ef96
added video_compression_tool
Browse files- README.md +1 -1
- app.py +4 -0
- requirements.txt +3 -0
- tool_config.json +6 -0
- video_compression.py +21 -0
README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
---
|
2 |
title: Video Compression Tool
|
3 |
-
emoji:
|
4 |
colorFrom: pink
|
5 |
colorTo: blue
|
6 |
sdk: gradio
|
|
|
1 |
---
|
2 |
title: Video Compression Tool
|
3 |
+
emoji: 🤏
|
4 |
colorFrom: pink
|
5 |
colorTo: blue
|
6 |
sdk: gradio
|
app.py
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers.tools.base import launch_gradio_demo
|
2 |
+
from video_compression import VideoCompressionTool
|
3 |
+
|
4 |
+
launch_gradio_demo(VideoCompressionTool)
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
ffmpeg-python
|
2 |
+
huggingface_hub
|
3 |
+
transformers
|
tool_config.json
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"description": "This tool compresses input video/gif to optimized video/gif. Inputs are input_path, output_path. Output is output_path.",
|
3 |
+
"name": "video_compression_tool",
|
4 |
+
"tool_class": "video_compression.VideoCompressionTool"
|
5 |
+
}
|
6 |
+
|
video_compression.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import ffmpeg
|
2 |
+
from transformers import Tool
|
3 |
+
|
4 |
+
class VideoCompressionTool(Tool):
|
5 |
+
name = "video_compression_tool"
|
6 |
+
description = """
|
7 |
+
This tool compresses input video/gif to optimized video/gif.
|
8 |
+
Inputs are input_path, output_path.
|
9 |
+
Output is output_path.
|
10 |
+
"""
|
11 |
+
inputs = ["text", "text"]
|
12 |
+
outputs = ["text"]
|
13 |
+
|
14 |
+
def __call__(self, input_path: str, output_path: str):
|
15 |
+
(
|
16 |
+
ffmpeg.input(input_path)
|
17 |
+
.filter_("split", "[0:v] split [a][b];[a] palettegen [p];[b][p] paletteuse")
|
18 |
+
.output(output_path)
|
19 |
+
.run()
|
20 |
+
)
|
21 |
+
return output_path
|