extract_audio
Extract audio from video files to create standalone audio files in formats like MP3 or AAC using FFmpeg processing.
Instructions
Extract audio from a video file
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| inputPath | Yes | Path to the input video file | |
| outputPath | Yes | Path for the output audio file | |
| format | Yes | Audio format (mp3, aac, etc.) |
Implementation Reference
- src/tools/handlers.ts:39-54 (handler)Handler function for the 'extract_audio' tool. Validates inputs, constructs FFmpeg command to extract audio without video (-vn -acodec), runs it, and returns completion message.case "extract_audio": { const inputPath = validatePath(String(args?.inputPath), true); const outputPath = validatePath(String(args?.outputPath)); const format = String(args?.format || "mp3"); await ensureDirectoryExists(outputPath); const command = `-i "${inputPath}" -vn -acodec ${format} "${outputPath}" -y`; const result = await runFFmpegCommand(command); return { content: [{ type: "text", text: `Audio extraction completed: ${inputPath} → ${outputPath}\n\n${result}` }] }; }
- src/tools/definitions.ts:42-63 (schema)Input schema definition for the 'extract_audio' tool, specifying required parameters: inputPath, outputPath, and format.{ name: "extract_audio", description: "Extract audio from a video file", inputSchema: { type: "object", properties: { inputPath: { type: "string", description: "Path to the input video file" }, outputPath: { type: "string", description: "Path for the output audio file" }, format: { type: "string", description: "Audio format (mp3, aac, etc.)" } }, required: ["inputPath", "outputPath", "format"] } },
- src/index.ts:46-50 (registration)Registration of all tools, including 'extract_audio', by returning the toolDefinitions array in response to ListToolsRequest.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: toolDefinitions }; });