Spaces:
Sleeping
Sleeping
| import json | |
| import ffmpeg | |
| from transformers import Tool | |
| class VideoCropTool(Tool): | |
| name = "video_crop_tool" | |
| description = """ | |
| This tool crops a video with inputs: | |
| input_path, output_path, | |
| top_x, top_y, | |
| bottom_x, bottom_y. | |
| Output is the output_path. | |
| """ | |
| inputs = ["text", "text", "text", "text", "text", "text"] | |
| outputs = ["text"] | |
| def __call__( | |
| self, | |
| input_path: str, | |
| output_path: str, | |
| top_x: str, | |
| top_y: str, | |
| bottom_x: str, | |
| bottom_y: str, | |
| ): | |
| stream = ffmpeg.input(input_path) | |
| stream = ffmpeg.crop(stream, int(top_y), int(top_x), int(bottom_y) - int(top_y), int(bottom_x) - int(top_x)) | |
| stream = ffmpeg.output(stream, output_path) | |
| ffmpeg.run(stream) | |
| return output_path | |