Skip to main content
Glama
ZizoTheDev

FFmpeg MCP Server

extract_audio

Extract audio from video files in MP3 format using FFmpeg MCP Server. Input video file path, specify output (optional), and generate audio efficiently for media processing needs.

Instructions

Extract audio as mp3 from a video

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
input_fileYesPath to input file
output_fileNoPath to output file, output to the same directory if not specified

Implementation Reference

  • main.ts:86-120 (handler)
    The async handler function that uses ffmpeg to extract audio from a video file and save it as MP3. Handles output path, executes the command via 'x' from tinyexec, logs errors, and returns success/error messages.
    async (args) => {
      const output_file =
        args.output_file || getOutputFilePath(args.input_file, ".mp3")
    
      const result = await x(ffmpeg, [
        `-i`,
        args.input_file,
        `-vn`,
        `-acodec`,
        `mp3`,
        `-y`,
        output_file,
      ])
    
      if (result.exitCode !== 0) {
        return {
          content: [
            {
              type: "text",
              text: `Error: ${result.stderr}`,
            },
          ],
          isError: true,
        }
      }
    
      return {
        content: [
          {
            type: "text",
            text: `Successfully extracted audio to: ${output_file}`,
          },
        ],
      }
    },
  • main.ts:82-121 (registration)
    Registration of the 'extract_audio' tool on the MCP server using server.tool(), providing name, description, input schema, and inline handler.
    server.tool(
      tools.extract_audio.name,
      tools.extract_audio.description,
      tools.extract_audio.input,
      async (args) => {
        const output_file =
          args.output_file || getOutputFilePath(args.input_file, ".mp3")
    
        const result = await x(ffmpeg, [
          `-i`,
          args.input_file,
          `-vn`,
          `-acodec`,
          `mp3`,
          `-y`,
          output_file,
        ])
    
        if (result.exitCode !== 0) {
          return {
            content: [
              {
                type: "text",
                text: `Error: ${result.stderr}`,
              },
            ],
            isError: true,
          }
        }
    
        return {
          content: [
            {
              type: "text",
              text: `Successfully extracted audio to: ${output_file}`,
            },
          ],
        }
      },
    )
  • Schema definition for the extract_audio tool, including Zod input schema for input_file (required string) and optional output_file.
    extract_audio: {
      name: "extract_audio",
      description: "Extract audio as mp3 from 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(),
      },
    },
  • main.ts:9-13 (helper)
    Helper function to generate default output file path in the same directory as input, appending '_output' + extension.
    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}`)
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It mentions the output format (mp3) but lacks details on behavioral traits like error handling, performance constraints, or whether the operation is destructive to the input file. This leaves significant gaps for an agent to understand the tool's behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that clearly states the tool's purpose without any wasted words. It is appropriately sized and front-loaded, making it easy to understand at a glance.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (2 parameters, no output schema, no annotations), the description is minimally adequate. It covers the basic purpose but lacks details on behavioral aspects and usage context, leaving room for improvement in completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both parameters thoroughly. The description adds no additional meaning beyond what the schema provides, such as format details or usage examples, resulting in a baseline score of 3.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('extract audio') and the resource ('from a video'), specifying the output format as mp3. However, it doesn't differentiate from the sibling tool 'speed_up', which appears to be a different operation, so it doesn't fully distinguish from siblings.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. The description only states what it does, with no context about prerequisites, limitations, or comparison to the sibling tool 'speed_up'.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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

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