Skip to main content
Glama
misbahsy

Video & Audio Editing MCP Server

by misbahsy

convert_video_format

Convert a video file to a desired format by specifying input and output paths. Use this tool for efficient video format transformation across formats like MP4, MOV, or AVI. Works with FFmpeg for reliable processing.

Instructions

Converts a video file to the specified target format, attempting to copy codecs first. Args: input_video_path: Path to the source video file. output_video_path: Path to save the converted video file. target_format: Desired output video format (e.g., 'mp4', 'mov', 'avi'). Returns: A status message indicating success or failure.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
input_video_pathYes
output_video_pathYes
target_formatYes

Implementation Reference

  • The main execution function (handler) for the convert_video_format tool. It defines the input schema via type hints and implements the logic using FFmpeg with codec copy preference, calling a helper for execution.
    def convert_video_format(input_video_path: str, output_video_path: str, target_format: str) -> str: """Converts a video file to the specified target format, attempting to copy codecs first. Args: input_video_path: Path to the source video file. output_video_path: Path to save the converted video file. target_format: Desired output video format (e.g., 'mp4', 'mov', 'avi'). Returns: A status message indicating success or failure. """ primary_kwargs = {'format': target_format, 'vcodec': 'copy', 'acodec': 'copy'} fallback_kwargs = {'format': target_format} # Re-encode both streams return _run_ffmpeg_with_fallback(input_video_path, output_video_path, primary_kwargs, fallback_kwargs)
  • Supporting helper function that implements the FFmpeg execution logic with fallback from stream-copy to re-encoding, used by convert_video_format and similar tools.
    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:351-351 (registration)
    The @mcp.tool() decorator registers the convert_video_format function as an MCP tool with FastMCP.
    def convert_video_format(input_video_path: str, output_video_path: str, target_format: str) -> str:
  • The function signature and docstring define the input schema and description for the MCP tool, used by FastMCP to generate JSON schema.
    def convert_video_format(input_video_path: str, output_video_path: str, target_format: str) -> str: """Converts a video file to the specified target format, attempting to copy codecs first. Args: input_video_path: Path to the source video file. output_video_path: Path to save the converted video file. target_format: Desired output video format (e.g., 'mp4', 'mov', 'avi'). Returns: A status message indicating success or failure.

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