Spaces:
Runtime error
Runtime error
import ffmpeg | |
from transformers import Tool | |
class VideoStabilizationTool(Tool): | |
name = "video_stabilization_tool" | |
description = """ | |
This tool stabilizes a video. | |
Inputs are input_path, output_path, smoothing, zoom. | |
""" | |
inputs = ["text", "text", "integer", "integer", "integer"] | |
outputs = ["text"] | |
def __call__( | |
self, | |
input_path: str, | |
output_path: str, | |
smoothing: int = 10, | |
zoom: int = 0, | |
shakiness: int = 5, | |
): | |
( | |
ffmpeg.input(input_path) | |
.output("null", vf="vidstabdetect=shakiness={}".format(shakiness), f="null") | |
.overwrite_output() | |
.run(capture_stdout=True, capture_stderr=True) | |
) | |
( | |
ffmpeg.input(input_path) | |
.output( | |
output_path, | |
vf="vidstabtransform=smoothing={}:zoom={}:input={}".format( | |
smoothing, zoom, "transforms.trf" | |
), | |
) | |
.overwrite_output() | |
.run() | |
) | |
return output_path | |