Skip to main content
Glama

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
NameRequiredDescriptionDefault
heightYes
output_pathNo
video_pathYes
widthYes

Implementation Reference

  • 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)
  • 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), ""}

Tool Definition Quality

Score is being calculated. Check back soon.

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/video-creator/ffmpeg-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server