video-speed-tool / video_speed.py
smellslikeml
added video_speed_tool
b18e3fd
raw
history blame contribute delete
731 Bytes
import ffmpeg
from transformers import Tool
class VideoSpeedTool(Tool):
name = "video_speed_tool"
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.
"""
inputs = ["text", "text", "text"]
outputs = ["text"]
def __call__(self, input_path: str, output_path: str, speed_factor: float):
stream = ffmpeg.input(input_path)
stream = ffmpeg.setpts(stream, "1/{}*PTS".format(float(speed_factor)))
stream = ffmpeg.output(stream, output_path)
ffmpeg.run(stream)
return output_path