convert_video
Convert video files to different formats using FFmpeg capabilities. Specify input and output paths, with optional FFmpeg settings for customized conversions.
Instructions
Convert a video file to a different format
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| inputPath | Yes | Path to the input video file | |
| options | No | Additional FFmpeg options (optional) | |
| outputPath | Yes | Path for the output video file |
Implementation Reference
- src/tools/handlers.ts:22-39 (handler)Executes the convert_video tool: validates paths, ensures output directory, builds FFmpeg command with input, options, output, runs it, and returns completion message with result.case "convert_video": { const inputPath = validatePath(String(args?.inputPath), true); const outputPath = validatePath(String(args?.outputPath)); const options = String(args?.options || ""); await ensureDirectoryExists(outputPath); const command = `-i "${inputPath}" ${options} "${outputPath}" -y`; const result = await runFFmpegCommand(command); return { content: [{ type: "text", text: `Video conversion completed: ${inputPath} → ${outputPath}\n\n${result}` }] }; } case "extract_audio": {
- src/tools/definitions.ts:20-41 (schema)Defines the input schema for the convert_video tool, specifying required inputPath and outputPath parameters, and optional FFmpeg options.{ name: "convert_video", description: "Convert a video file to a different format", inputSchema: { type: "object", properties: { inputPath: { type: "string", description: "Path to the input video file" }, outputPath: { type: "string", description: "Path for the output video file" }, options: { type: "string", description: "Additional FFmpeg options (optional)" } }, required: ["inputPath", "outputPath"] } },
- src/index.ts:46-50 (registration)Registers all tools, including convert_video, by providing the toolDefinitions in response to ListTools requests.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: toolDefinitions }; });
- src/index.ts:56-68 (registration)Registers the general tool call handler which routes 'convert_video' calls to the specific handler function based on the tool name.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}` }] }; } });