Skip to main content
Glama
misbahsy

Video & Audio Editing MCP Server

by misbahsy

set_video_codec

Change the video codec of a file while preserving the audio stream. Specify input and output paths along with the desired codec for efficient video format conversion.

Instructions

Sets the video codec of a video, attempting to copy the audio stream. Args: input_video_path: Path to the source video file. output_video_path: Path to save the video with the new video codec. video_codec: Target video codec (e.g., 'libx264', 'libx265', 'vp9'). Returns: A status message indicating success or failure.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
input_video_pathYes
output_video_pathYes
video_codecYes

Implementation Reference

  • The main handler function for the 'set_video_codec' tool. It uses a helper to run FFmpeg with primary kwargs (video codec change + audio copy) and fallback (re-encode audio if copy fails).
    @mcp.tool()
    def set_video_codec(input_video_path: str, output_video_path: str, video_codec: str) -> str:
        """Sets the video codec of a video, attempting to copy the audio stream.
        Args:
            input_video_path: Path to the source video file.
            output_video_path: Path to save the video with the new video codec.
            video_codec: Target video codec (e.g., 'libx264', 'libx265', 'vp9').
        Returns:
            A status message indicating success or failure.
        """
        primary_kwargs = {'vcodec': video_codec, 'acodec': 'copy'}
        fallback_kwargs = {'vcodec': video_codec} # Re-encode audio
        return _run_ffmpeg_with_fallback(input_video_path, output_video_path, primary_kwargs, fallback_kwargs)
  • Helper function used by set_video_codec and other similar tools to execute FFmpeg commands with fallback logic for stream copying vs. re-encoding.
    def _run_ffmpeg_with_fallback(input_path: str, output_path: str, primary_kwargs: dict, fallback_kwargs: dict) -> str:
        """Helper to run ffmpeg command with primary kwargs, falling back to other kwargs on ffmpeg.Error."""
        try:
            ffmpeg.input(input_path).output(output_path, **primary_kwargs).run(capture_stdout=True, capture_stderr=True)
            return f"Operation successful (primary method) and saved to {output_path}"
        except ffmpeg.Error as e_primary:
            try:
                ffmpeg.input(input_path).output(output_path, **fallback_kwargs).run(capture_stdout=True, capture_stderr=True)
                return f"Operation successful (fallback method) and saved to {output_path}"
            except ffmpeg.Error as e_fallback:
                err_primary_msg = e_primary.stderr.decode('utf8') if e_primary.stderr else str(e_primary)
                err_fallback_msg = e_fallback.stderr.decode('utf8') if e_fallback.stderr else str(e_fallback)
                return f"Error. Primary method failed: {err_primary_msg}. Fallback method also failed: {err_fallback_msg}"
        except FileNotFoundError:
            return f"Error: Input file not found at {input_path}"
        except Exception as e:
            return f"An unexpected error occurred: {str(e)}"
Behavior2/5

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

With no annotations provided, the description carries full burden. It discloses the tool's mutation behavior ('Sets', 'save') and the audio preservation attempt, but lacks critical behavioral details: no mention of permissions needed, whether the operation is destructive to the original file, processing time expectations, error conditions, or what specific 'success or failure' messages might look like.

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 efficiently structured with purpose statement upfront followed by clearly labeled Args and Returns sections. Every sentence earns its place: the first sentence states core functionality, the Args section explains all parameters, and the Returns section clarifies output. No wasted words.

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 a mutation tool with 3 parameters, no annotations, and no output schema, the description covers the basic operation and parameters adequately but lacks important context. It doesn't explain what happens to the original file, what formats are supported, error handling details, or performance characteristics that would help an agent use this tool effectively in complex workflows.

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

Parameters4/5

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

With 0% schema description coverage, the description must compensate for all three parameters. It successfully provides clear semantics for each: 'input_video_path' as source file path, 'output_video_path' as destination path, and 'video_codec' with helpful examples ('libx264', 'libx265', 'vp9'). This adds substantial value beyond the bare schema.

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

Purpose5/5

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

The description clearly states the tool's purpose with specific verbs ('Sets the video codec', 'attempting to copy the audio stream') and identifies the resource ('a video'). It distinguishes from siblings like 'convert_video_format' or 'set_video_audio_track_codec' by focusing specifically on video codec changes while preserving audio.

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

Usage Guidelines3/5

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

The description implies usage context through 'attempting to copy the audio stream' and the parameter descriptions, suggesting this is for re-encoding video while keeping audio intact. However, it doesn't explicitly state when to use this versus alternatives like 'convert_video_format' or 'set_video_audio_track_codec', nor does it mention any prerequisites or exclusions.

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/misbahsy/video-audio-mcp'

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