speed_up
Increase video playback speed with configurable FPS and speed factor using FFmpeg MCP Server. Specify input/output files and adjust parameters for precise control.
Instructions
Speed up a video
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| input_file | Yes | Path to input file | |
| max_fps | No | Max FPS for the output file | |
| output_file | No | Path to output file, output to the same directory if not specified | |
| speed_factor | No | Speed factor for the output file, default to 2x sped up |
Implementation Reference
- main.ts:31-79 (handler)The asynchronous handler function for the 'speed_up' tool. It processes input arguments, constructs the output file path if needed, executes ffmpeg to speed up the video using setpts, fps, and atempo filters, logs the output, and returns a success or error response.async (args) => { const output_file = args.output_file || getOutputFilePath(args.input_file, path.extname(args.input_file)) const result = x(ffmpeg, [ `-i`, args.input_file, `-filter:v`, `setpts=${1 / args.speed_factor}*PTS,fps=fps=${args.max_fps}`, `-af`, `atempo=${args.speed_factor}`, `-y`, output_file, ]) let output = "" for await (const line of result) { output += line await server.server.sendLoggingMessage({ level: "debug", data: { line, }, }) } if (result.exitCode !== 0) { return { content: [ { type: "text", text: `Error: ${output}`, }, ], isError: true, } } return { content: [ { type: "text", text: `Successfully sped up video to: ${output_file}`, }, ], } },
- tools.ts:4-28 (schema)The schema definition for the 'speed_up' tool, including name, description, and Zod-validated input schema for input_file, output_file (optional), max_fps, and speed_factor.speed_up: { name: "speed_up", description: "Speed up a video", input: { input_file: z.string().describe("Path to input file"), output_file: z .string() .describe( "Path to output file, output to the same directory if not specified", ) .optional(), max_fps: z .number() .min(1) .max(60) .default(30) .describe("Max FPS for the output file"), speed_factor: z .number() .min(0.1) .max(10) .default(2) .describe("Speed factor for the output file, default to 2x sped up"), }, },
- main.ts:27-80 (registration)The registration of the 'speed_up' tool on the MCP server using server.tool(), passing the name, description, input schema from tools.ts, and the inline handler function.server.tool( tools.speed_up.name, tools.speed_up.description, tools.speed_up.input, async (args) => { const output_file = args.output_file || getOutputFilePath(args.input_file, path.extname(args.input_file)) const result = x(ffmpeg, [ `-i`, args.input_file, `-filter:v`, `setpts=${1 / args.speed_factor}*PTS,fps=fps=${args.max_fps}`, `-af`, `atempo=${args.speed_factor}`, `-y`, output_file, ]) let output = "" for await (const line of result) { output += line await server.server.sendLoggingMessage({ level: "debug", data: { line, }, }) } if (result.exitCode !== 0) { return { content: [ { type: "text", text: `Error: ${output}`, }, ], isError: true, } } return { content: [ { type: "text", text: `Successfully sped up video to: ${output_file}`, }, ], } }, )
- main.ts:9-13 (helper)Helper function used in the speed_up handler to generate a default output file path in the same directory as the input with '_output' suffix.const getOutputFilePath = (input: string, ext: string) => { const input_dir = path.dirname(input) const input_filename = path.basename(input, path.extname(input)) return path.join(input_dir, `${input_filename}_output${ext}`) }