Skip to content

About

Provides video and audio metadata reading, format conversion, compression, trimming, merging, audio extraction, frame extraction, subtitle burning, scaling, video overlay, thumbnail generation, and media file search — all powered by FFmpeg. The runtime package bundles platform-native FFmpeg and FFprobe, so users do not need to install FFmpeg separa

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

🎬 FFmpeg MCP

A cross-platform FFmpeg Model Context Protocol server

Python License Platform

Audio/video processing made available to any MCP client through simple tool calls.


✨ Features

FFmpeg MCP exposes a full suite of media-processing capabilities to MCP-compatible clients (Claude Desktop, Cursor, and more):

Category Tools
🔍 Metadata Read duration, streams, codecs, resolution, and bitrate
🔄 Conversion Convert video/audio with optional scaling and codec selection
📦 Compression H.264 CRF-based size reduction with quality presets
✂️ Editing Trim by start/end or duration, merge multiple files
🎵 Audio Extract audio to MP3, AAC, WAV, FLAC, OGG, or Opus
🖼️ Frames Extract frames by interval or count, generate thumbnails
💬 Subtitles Burn SRT/ASS/VTT subtitles with styling
📐 Resize Scale videos with automatic aspect-ratio handling
🎨 Overlay Layer foreground video on background at named positions
📁 Search Find media files in a directory, optionally by name

No FFmpeg installation needed — every package ships a platform-native FFmpeg + FFprobe runtime, resolved automatically.


🚀 Quick Start

Requirements

  • Python 3.10 or later
  • One of the supported platforms

Supported Platforms

Platform Architecture Runtime
Windows x86_64 bundled ffmpeg.exe + ffprobe.exe
Linux (incl. Kylin) x86_64 bundled ffmpeg + ffprobe

Installation

git clone https://github.com/luffy666code/ffmpeg-mcp.git
cd ffmpeg-mcp
pip install -e .

Running

python __main__.py

The server communicates over stdio using the Model Context Protocol, so it connects to any MCP client as a stdio transport server.


🛠️ Tools

Tool Description
ffmpeg_runtime_status Report which FFmpeg/FFprobe runtime is active and its version
ffmpeg_find_media Find video/audio files under a directory, optionally by name
ffmpeg_get_info Read media metadata (duration, streams, codecs, resolution, bitrate)
ffmpeg_convert Convert video/audio format with optional scale and codec selection
ffmpeg_compress Compress a video using H.264 CRF presets
ffmpeg_trim Trim a video by start + end or duration
ffmpeg_merge Merge videos — fast stream-copy, or normalized H.264/AAC re-encode
ffmpeg_extract_audio Extract audio to MP3, AAC, WAV, FLAC, OGG, or Opus
ffmpeg_extract_frames Extract frames at a time interval or as an even count
ffmpeg_add_subtitles Burn SRT/ASS/VTT subtitles with style presets
ffmpeg_scale Resize video; use -2 for one dimension to preserve aspect ratio
ffmpeg_overlay Overlay a foreground video at a named position
ffmpeg_thumbnail Create a JPEG thumbnail at a specified timestamp

🧩 Runtime Resolution

The runtime is located in this priority order:

  1. Environment — FFMPEG_PATH / FFPROBE_PATH explicitly set
  2. Bundled — binaries shipped in run/<platform>/
  3. System PATH — ffmpeg / ffprobe found on $PATH

Configuration

Variable Purpose
FFMPEG_PATH Path to ffmpeg binary
FFPROBE_PATH Path to ffprobe binary
FFMPEG_OUTPUT_DIR Directory for generated outputs (default: output/)

📦 Building the Package

Build a portable package with the platform's bundled FFmpeg runtime:

Windows

package.bat

Linux

package.sh

This uses PyInstaller to produce a single-file executable and bundles the matching FFmpeg/FFprobe binaries, then packages everything into a ZIP.

Self-Test

Verify the server starts and exposes tools correctly:

python self_test.py

📂 Project Structure

ffmpeg-mcp/
├── __main__.py              # Entry point
├── ffmpeg_video_mcp/
│   ├── server.py            # MCP JSON-RPC server
│   ├── tools.py             # Tool implementations & schemas
│   ├── runtime.py           # FFmpeg runtime resolution
│   ├── config.py            # Paths & configuration
│   └── process.py           # Subprocess runner
├── scripts/
│   └── build_package.py     # Cross-platform package builder
├── run/                     # Bundled runtime placeholder dirs
├── package.bat / package.sh # Build scripts
├── self_test.py             # MCP smoke test
└── runtime-manifest.json    # Bundled runtime manifest

🧰 Tools Overview

Example: Get Media Info

{
  "name": "ffmpeg_get_info",
  "arguments": { "file_path": "/path/to/video.mp4" }
}

Example: Compress a Video

{
  "name": "ffmpeg_compress",
  "arguments": { "file_path": "/path/to/video.mp4", "quality": "high" }
}

📄 License

MIT


🙏 Acknowledgements

About

Provides video and audio metadata reading, format conversion, compression, trimming, merging, audio extraction, frame extraction, subtitle burning, scaling, video overlay, thumbnail generation, and media file search — all powered by FFmpeg. The runtime package bundles platform-native FFmpeg and FFprobe, so users do not need to install FFmpeg separa

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages