Skip to main content
Glama

trim_video

Trim videos to specific start and end times or durations using FFmpeg on the MCP FFmpeg Helper server. Specify input and output paths for precise video editing.

Instructions

Trim a video to a specific duration

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
durationNoDuration (format: HH:MM:SS.mmm or seconds)
endTimeNoEnd time (format: HH:MM:SS.mmm or seconds)
inputPathYesPath to the input video file
outputPathYesPath for the output video file
startTimeNoStart time (format: HH:MM:SS.mmm or seconds)

Implementation Reference

  • The core handler logic for the 'trim_video' tool within the handleToolCall switch statement. It validates input/output paths, constructs an FFmpeg command using -ss for start time, optionally -t for duration or -to for end time, uses -c copy for fast stream copying without re-encoding, ensures output directory exists, executes via runFFmpegCommand, and returns a success message with result.
    case "trim_video": { const inputPath = validatePath(String(args?.inputPath), true); const outputPath = validatePath(String(args?.outputPath)); const startTime = String(args?.startTime || "0"); const duration = String(args?.duration || ""); const endTime = String(args?.endTime || ""); await ensureDirectoryExists(outputPath); let command = `-i "${inputPath}" -ss ${startTime}`; if (duration) { command += ` -t ${duration}`; } else if (endTime) { command += ` -to ${endTime}`; } command += ` -c copy "${outputPath}" -y`; const result = await runFFmpegCommand(command); return { content: [{ type: "text", text: `Video trimming completed: ${inputPath} → ${outputPath}\n\n${result}` }] }; }
  • The input schema definition for the 'trim_video' tool, specifying required inputPath and outputPath, and optional startTime, duration, endTime parameters.
    { name: "trim_video", description: "Trim a video to a specific duration", inputSchema: { type: "object", properties: { inputPath: { type: "string", description: "Path to the input video file" }, outputPath: { type: "string", description: "Path for the output video file" }, startTime: { type: "string", description: "Start time (format: HH:MM:SS.mmm or seconds)" }, duration: { type: "string", description: "Duration (format: HH:MM:SS.mmm or seconds)" }, endTime: { type: "string", description: "End time (format: HH:MM:SS.mmm or seconds)" } }, required: ["inputPath", "outputPath"] } },
  • src/index.ts:46-50 (registration)
    Registration of all tools including 'trim_video' via the ListToolsRequestHandler, which returns the toolDefinitions array containing the trim_video schema.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: toolDefinitions }; });
  • src/index.ts:56-68 (registration)
    Registration of the generic tool call handler which dispatches to handleToolCall based on tool name, enabling execution of 'trim_video'.
    server.setRequestHandler(CallToolRequestSchema, async (request) => { try { return await handleToolCall(request.params.name, request.params.arguments); } catch (error: any) { console.error("Tool execution error:", error.message); return { content: [{ type: "text", text: `Error: ${error.message}` }] }; } });

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/sworddut/mcp-ffmpeg-helper'

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