Skip to main content
Glama
misbahsy

Video & Audio Editing MCP Server

by misbahsy

set_video_audio_track_channels

Modify the number of audio channels in a video track (e.g., mono to stereo) while preserving the video stream, ensuring compatibility or adjusting audio layout for specific playback needs.

Instructions

Sets the number of audio channels of a video's audio track, attempting to copy the video stream. Args: input_video_path: Path to the source video file. output_video_path: Path to save the video with the new audio channel layout. audio_channels: Number of audio channels (1 for mono, 2 for stereo). Returns: A status message indicating success or failure.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
audio_channelsYes
input_video_pathYes
output_video_pathYes

Implementation Reference

  • Main handler function for the 'set_video_audio_track_channels' MCP tool. Uses FFmpeg to set audio channels ('ac') on video, preferring video stream copy ('vcodec':'copy'), falling back to full re-encode.
    @mcp.tool()
    def set_video_audio_track_channels(input_video_path: str, output_video_path: str, audio_channels: int) -> str:
        """Sets the number of audio channels of a video's audio track, attempting to copy the video stream.
        Args:
            input_video_path: Path to the source video file.
            output_video_path: Path to save the video with the new audio channel layout.
            audio_channels: Number of audio channels (1 for mono, 2 for stereo).
        Returns:
            A status message indicating success or failure.
        """
        primary_kwargs = {'ac': audio_channels, 'vcodec': 'copy'} # ac for audio channels
        fallback_kwargs = {'ac': audio_channels} # Re-encode video
        return _run_ffmpeg_with_fallback(input_video_path, output_video_path, primary_kwargs, fallback_kwargs)
  • Supporting helper function that executes the FFmpeg command with primary parameters first (e.g., stream copying), falling back to re-encoding if it fails. Used by the handler.
    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)}"
  • server.py:469-481 (registration)
    The @mcp.tool() decorator registers this function as an MCP tool named 'set_video_audio_track_channels'.
    @mcp.tool()
    def set_video_audio_track_channels(input_video_path: str, output_video_path: str, audio_channels: int) -> str:
        """Sets the number of audio channels of a video's audio track, attempting to copy the video stream.
        Args:
            input_video_path: Path to the source video file.
            output_video_path: Path to save the video with the new audio channel layout.
            audio_channels: Number of audio channels (1 for mono, 2 for stereo).
        Returns:
            A status message indicating success or failure.
        """
        primary_kwargs = {'ac': audio_channels, 'vcodec': 'copy'} # ac for audio channels
        fallback_kwargs = {'ac': audio_channels} # Re-encode video
        return _run_ffmpeg_with_fallback(input_video_path, output_video_path, primary_kwargs, fallback_kwargs)
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 mentions 'attempting to copy the video stream' which suggests partial behavioral context about preservation, but doesn't disclose important traits like whether this is a destructive operation, what happens if the operation fails, what permissions are needed, or any rate limits. The description is insufficient for a mutation tool with zero annotation coverage.

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

Conciseness4/5

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

Well-structured with purpose statement followed by clear Args and Returns sections. Every sentence earns its place, though the 'attempting to copy the video stream' phrase could be more precise. The description is appropriately sized for a 3-parameter tool with no annotations.

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?

For a mutation tool with no annotations and no output schema, the description provides basic parameter semantics and purpose but lacks important behavioral context. It doesn't explain what 'attempting to copy the video stream' means operationally, what happens on failure, or what the status message contains. Given the complexity of video processing and zero annotation coverage, this is minimally adequate but has clear gaps.

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. It provides clear semantic meaning for all 3 parameters: 'input_video_path: Path to the source video file', 'output_video_path: Path to save the video with the new audio channel layout', and 'audio_channels: Number of audio channels (1 for mono, 2 for stereo)'. The audio_channels explanation with examples (1 for mono, 2 for stereo) adds significant value beyond what the bare schema provides.

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 number of audio channels', 'attempting to copy the video stream') and identifies the resource ('a video's audio track'). It distinguishes from sibling tools like 'set_audio_channels' by specifying it operates on video audio tracks rather than standalone audio files.

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 explicit guidance on when to use this tool versus alternatives like 'set_audio_channels' or 'convert_audio_properties'. The description mentions 'attempting to copy the video stream' which hints at preservation behavior but doesn't provide clear usage context or prerequisites for successful operation.

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