scale_video
Resize video dimensions to specified width and height using FFmpeg-MCP Server. Input video path, target dimensions, and output path to generate resized video.
Instructions
视频缩放
参数:
width(int) - 目标宽度。
height(int) - 目标高度。
output_path(str) - 输出路径
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| height | Yes | ||
| output_path | No | ||
| video_path | Yes | ||
| width | Yes |
Implementation Reference
- src/ffmpeg_mcp/server.py:122-133 (handler)MCP tool handler for 'scale_video', decorated with @mcp.tool(), delegates to the core implementation in cut_video.scale_video@mcp.tool() def scale_video(video_path, width, height,output_path: str = None): """ 视频缩放 参数: width(int) - 目标宽度。 height(int) - 目标高度。 output_path(str) - 输出路径 """ return cut_video.scale_video(video_path, width, height, output_path)
- src/ffmpeg_mcp/cut_video.py:250-274 (helper)Core implementation of video scaling using FFmpeg's scale filter, handling output path, command construction, execution, and error handling.def scale_video(video_path, width, height = -2,output_path: str = None): """ 视频缩放 参数: width(int) - 目标宽度, 如果是-2,代表保持宽高比,且是2的倍数。 height(int) - 目标高度,如果是-2,代表保持宽高比,且是2的倍数。 output_path(str) - 输出路径 """ try: base, ext = os.path.splitext(video_path) if (output_path == None): if (ext == None or len(ext) == 0): ext = ".mp4" output_path = f"{base}_clip{ext}" cmd = f" -i {video_path} -filter_complex \"scale={width}:{height}\"" cmd = f"{cmd} -y {output_path}" print(cmd) status_code, log = ffmpeg.run_ffmpeg(cmd, timeout=1000) print(log) return {status_code, log, output_path} except Exception as e: print(f"剪辑失败: {str(e)}") return {-1, str(e), ""}