create_video_from_images
Convert a sequence of images into a video using FFmpeg. Specify input patterns, output path, framerate, codec, and pixel format for customized video creation.
Instructions
Create a video from a sequence of images
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| codec | No | Video codec to use (default: libx264) | |
| extraOptions | No | Additional FFmpeg options | |
| framerate | No | Frames per second (default: 25) | |
| inputPattern | Yes | Pattern for input images (e.g., 'img%03d.jpg' or 'folder/*.png') | |
| outputPath | Yes | Path for the output video file | |
| pixelFormat | No | Pixel format (default: yuv420p) |
Implementation Reference
- src/tools/handlers.ts:56-77 (handler)Handler logic for the 'create_video_from_images' tool. Parses arguments, validates input, constructs an FFmpeg command to create a video from images using the specified pattern, framerate, codec, etc., executes it via runFFmpegCommand, and returns the result.case "create_video_from_images": { const inputPattern = String(args?.inputPattern); const outputPath = validatePath(String(args?.outputPath)); const framerate = Number(args?.framerate || 25); const codec = String(args?.codec || "libx264"); const pixelFormat = String(args?.pixelFormat || "yuv420p"); const extraOptions = String(args?.extraOptions || ""); if (!inputPattern) { throw new Error("Input pattern is required"); } await ensureDirectoryExists(outputPath); const command = `-framerate ${framerate} -i "${inputPattern}" -c:v ${codec} -pix_fmt ${pixelFormat} ${extraOptions} "${outputPath}" -y`; const result = await runFFmpegCommand(command); return { content: [{ type: "text", text: `Video creation completed: ${inputPattern} → ${outputPath}\n\n${result}` }] };
- src/tools/definitions.ts:64-96 (schema)Input schema and metadata definition for the 'create_video_from_images' tool, specifying parameters like inputPattern, outputPath, framerate, codec, etc.{ name: "create_video_from_images", description: "Create a video from a sequence of images", inputSchema: { type: "object", properties: { inputPattern: { type: "string", description: "Pattern for input images (e.g., 'img%03d.jpg' or 'folder/*.png')" }, outputPath: { type: "string", description: "Path for the output video file" }, framerate: { type: "number", description: "Frames per second (default: 25)" }, codec: { type: "string", description: "Video codec to use (default: libx264)" }, pixelFormat: { type: "string", description: "Pixel format (default: yuv420p)" }, extraOptions: { type: "string", description: "Additional FFmpeg options" } }, required: ["inputPattern", "outputPath"] }
- src/index.ts:46-50 (registration)Registers the list of available tools, including 'create_video_from_images', by returning toolDefinitions in response to ListToolsRequest.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: toolDefinitions }; });
- src/index.ts:56-68 (registration)Registers the tool execution handler for MCP CallToolRequest, which delegates to handleToolCall dispatching to the specific tool handler like create_video_from_images.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}` }] }; } });