smellslikeml commited on
Commit
b18e3fd
Β·
1 Parent(s): df72afe

added video_speed_tool

Browse files
Files changed (5) hide show
  1. README.md +1 -1
  2. app.py +4 -0
  3. requirements.txt +3 -0
  4. tool_config.json +6 -0
  5. video_speed.py +19 -0
README.md CHANGED
@@ -1,6 +1,6 @@
1
  ---
2
  title: Video Speed Tool
3
- emoji: 🏒
4
  colorFrom: yellow
5
  colorTo: blue
6
  sdk: gradio
 
1
  ---
2
  title: Video Speed Tool
3
+ emoji: πŸƒ
4
  colorFrom: yellow
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_speed import VideoSpeedTool
3
+
4
+ launch_gradio_demo(VideoSpeedTool)
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 speeds up a video. Inputs are input_path as a string, output_path as a string, speed_factor (float) as a string. Output is the output_path.",
3
+ "name": "video_speed_tool",
4
+ "tool_class": "video_speed.VideoSpeedTool"
5
+ }
6
+
video_speed.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import ffmpeg
2
+ from transformers import Tool
3
+
4
+ class VideoSpeedTool(Tool):
5
+ name = "video_speed_tool"
6
+ description = """
7
+ This tool speeds up a video.
8
+ Inputs are input_path as a string, output_path as a string, speed_factor (float) as a string.
9
+ Output is the output_path.
10
+ """
11
+ inputs = ["text", "text", "text"]
12
+ outputs = ["text"]
13
+
14
+ def __call__(self, input_path: str, output_path: str, speed_factor: float):
15
+ stream = ffmpeg.input(input_path)
16
+ stream = ffmpeg.setpts(stream, "1/{}*PTS".format(float(speed_factor)))
17
+ stream = ffmpeg.output(stream, output_path)
18
+ ffmpeg.run(stream)
19
+ return output_path