Skip to main content
Glama
misbahsy

Video & Audio Editing MCP Server

by misbahsy

change_video_speed

Adjust video playback speed and audio to create faster or slower versions. Specify input/output paths and speed factor for precise customization.

Instructions

Changes the playback speed of a video (and its audio).

Args: video_path: Path to the input video file. output_video_path: Path to save the speed-adjusted video file. speed_factor: The factor by which to change the speed (e.g., 2.0 for 2x speed, 0.5 for half speed). Must be positive.

Returns: A status message indicating success or failure.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
output_video_pathYes
speed_factorYes
video_pathYes

Implementation Reference

  • The handler function for the 'change_video_speed' MCP tool. Adjusts video speed using setpts filter on video stream and chains multiple atempo filters on audio to support speed factors outside the single atempo limit (0.5-2.0). Handles input validation and ffmpeg errors with fallbacks.
    def change_video_speed(video_path: str, output_video_path: str, speed_factor: float) -> str:
        """Changes the playback speed of a video (and its audio).
    
        Args:
            video_path: Path to the input video file.
            output_video_path: Path to save the speed-adjusted video file.
            speed_factor: The factor by which to change the speed (e.g., 2.0 for 2x speed, 0.5 for half speed).
                          Must be positive.
        
        Returns:
            A status message indicating success or failure.
        """
        if speed_factor <= 0:
            return "Error: Speed factor must be positive."
        if not os.path.exists(video_path):
            return f"Error: Input video file not found at {video_path}"
    
        try:
            # Process atempo values (audio speed) - requires special handling for values outside 0.5-2.0 range
            atempo_value = speed_factor
            atempo_filters = []
            
            # Handle audio speed outside atempo's range (0.5-2.0)
            if speed_factor < 0.5:
                # For speed < 0.5, use multiple atempo=0.5 filters
                while atempo_value < 0.5:
                    atempo_filters.append("atempo=0.5")
                    atempo_value *= 2  # After applying atempo=0.5, the remaining factor doubles
                # Add the remaining factor if needed
                if atempo_value < 0.99:  # A bit of buffer for floating point comparison
                    atempo_filters.append(f"atempo={atempo_value}")
            elif speed_factor > 2.0:
                # For speed > 2.0, use multiple atempo=2.0 filters
                while atempo_value > 2.0:
                    atempo_filters.append("atempo=2.0")
                    atempo_value /= 2  # After applying atempo=2.0, the remaining factor halves
                # Add the remaining factor if needed
                if atempo_value > 1.01:  # A bit of buffer for floating point comparison
                    atempo_filters.append(f"atempo={atempo_value}")
            else:
                # For speed factors within range, just use one atempo filter
                atempo_filters.append(f"atempo={speed_factor}")
            
            # Apply separate filters to video and audio streams
            input_stream = ffmpeg.input(video_path)
            video = input_stream.video.setpts(f"{1.0/speed_factor}*PTS")
            
            # Chain multiple audio filters if needed
            audio = input_stream.audio
            for filter_str in atempo_filters:
                audio = audio.filter("atempo", speed_factor if filter_str == f"atempo={speed_factor}" else 
                                   0.5 if filter_str == "atempo=0.5" else 
                                   2.0 if filter_str == "atempo=2.0" else 
                                   float(filter_str.replace("atempo=", "")))
            
            # Combine processed streams and output
            output = ffmpeg.output(video, audio, output_video_path)
            output.run(capture_stdout=True, capture_stderr=True)
            
            return f"Video speed changed by factor {speed_factor} and saved to {output_video_path}"
        except ffmpeg.Error as e:
            error_message = e.stderr.decode('utf8') if e.stderr else str(e)
            return f"Error changing video speed: {error_message}"
        except Exception as e:
            return f"An unexpected error occurred while changing video speed: {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 but lacks critical behavioral details. It states the tool changes speed and returns a status message, but doesn't disclose whether it's destructive (modifies files), requires specific permissions, has rate limits, or what specific failure modes might occur. The mention of audio being affected is helpful but insufficient for a mutation tool.

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?

The description is well-structured with clear sections (Args, Returns) and front-loaded purpose. Every sentence adds value: the first states the core function, and subsequent lines document parameters and return value. It could be slightly more concise by integrating the 'Args' label more naturally, but overall it's efficient.

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 (3 parameters, mutation operation) and lack of annotations/output schema, the description is partially complete. It covers parameters well and states the return type, but misses behavioral context like file system impacts, error handling, or format limitations. For a video processing tool with no structured safety hints, this leaves gaps.

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

Parameters5/5

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

The description adds significant meaning beyond the input schema, which has 0% description coverage. It clearly explains each parameter: 'video_path' as input file path, 'output_video_path' as save location, and 'speed_factor' with examples (2.0 for 2x, 0.5 for half) and constraint (must be positive). This fully compensates for the schema's lack of descriptions.

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 verb ('Changes') and resource ('playback speed of a video'), and distinguishes it from siblings by focusing on speed adjustment rather than format conversion, overlays, trimming, or other video editing functions. It explicitly mentions audio is also affected, which adds specificity.

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?

The description provides no guidance on when to use this tool versus alternatives like 'trim_video' for time-based adjustments or 'set_video_frame_rate' for frame rate changes. It doesn't mention prerequisites (e.g., file existence, permissions) or exclusions (e.g., unsupported formats). Usage is implied only by the tool name and purpose.

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