Skip to main content
Glama

FFmpeg Runtime

Run current FFmpeg and FFprobe builds without installing them globally. Use native commands from a terminal, call the JavaScript API, or connect an MCP client for media inspection, conversion, audio extraction, trimming, and screenshots.

Requires Node.js 22.18+ and npm. Windows, macOS, and glibc Linux are supported on x64 and arm64. Linux archive extraction also requires tar with XZ support. Musl Linux and other architectures currently require a compatible local binary with --preferred-runtime local.

Native CLI

npx -y --prefer-online mcp-ffmpeg-runtime@latest ffmpeg -i input.mp4 output.webm
npx -y --prefer-online mcp-ffmpeg-runtime@latest ffprobe -v error -show_streams -of json input.mp4

Everything after ffmpeg or ffprobe is passed as a native argument array without a shell. Standard input, standard output, standard error, and exit status belong to the underlying program. For native help use ffmpeg -h or ffprobe -h.

Wrapper options go before the program name:

npx -y --prefer-online mcp-ffmpeg-runtime@latest --preferred-runtime local ffmpeg -version
npx -y --prefer-online mcp-ffmpeg-runtime@latest --offline ffprobe -version
npx -y --prefer-online mcp-ffmpeg-runtime@latest runtime info

--preferred-runtime local uses which to find the required program in PATH. Only native PE, ELF, or Mach-O executables are accepted. Shell scripts, .cmd, .bat, .sh, and extensionless scripts are skipped, preventing recursion through wrapper scripts. If no native match exists, the normal download/cache path is used. Other preferences ignore system programs.

Preference

Behavior

latest

Default: newest published build, checked at most daily

cached

Use a validated cached build without checking; use latest when none exists

local

Prefer a native executable in PATH; use latest when none exists

npm semver range

Highest available matching release, e.g. 9, 9.1, 9.1.1, ^9.1.1, ~9.1.1

Build ID

Use that specific build; never substitute an unrelated build

Version preferences have independent cache pointers and can coexist. Failed updates may use an existing matching build, but never a version outside the requested range. If no compatible published or cached build exists, the operation fails. --offline remains a strict no-network option; cached may download on a miss.

npx -y --prefer-online mcp-ffmpeg-runtime@latest --preferred-runtime "9.1" ffmpeg -version

Related MCP server: ffmpeg-mcp

MCP

{
  "mcpServers": {
    "ffmpeg-runtime": {
      "command": "npx",
      "args": [
        "-y",
        "--prefer-online",
        "mcp-ffmpeg-runtime@latest",
        "--preferred-runtime",
        "local",
        "mcp"
      ]
    }
  }
}
TIP

To limit the impact of duplicate and orphaned MCP processes in applications such as Codex, Claude Code, etc., we recommend running this server throughmcpLazyProxy.

When mcpLazyProxy starts a new backend with npx -y --prefer-online and an @latest package reference, npm checks the current version. A running backend uses its installed version until its next start.

CLI and MCP use the same tool definitions and functions from the installed package. The MCP server executes tools directly; package updates are checked at launch by external npx. It also works without a proxy.

Omit the preference to use latest. Preference is configured once at server launch; individual tools do not expose it. The CLI and JavaScript API share the same executable resolver.

Tool

Purpose

runtime_info

Executable paths, sources, build identifiers, and versions

ffmpeg

Any native FFmpeg argument array, including codec/filter help

ffprobe

Any native FFprobe argument array

probe_media

Local file metadata as structured JSON

extract_audio

First audio stream; copy by default, or select an encoder

convert_media

Output container and optional audio/video codecs

trim_media

Start and duration, with optional stream copying

extract_frame

One screenshot, optionally limiting its height

Common operations require explicit output paths and preserve existing files unless overwrite is true. Native ffmpeg arguments retain their normal overwrite and network behavior. Stream-copy trimming may align to video keyframes. Copying audio requires an output container compatible with the source codec.

Generic MCP tools capture textual stdout/stderr, with a 16 MiB limit per stream. Write binary or large output to files. Their default execution timeout is 3600 seconds and can be overridden with timeoutSeconds. Use the native CLI for pipes or interactive execution. Discovery never downloads or starts FFmpeg.

JavaScript

import { resolveBinary, runFfmpeg, probeMedia } from "mcp-ffmpeg-runtime";

const options = { preferredRuntime: "local" };
const { command } = await resolveBinary("ffmpeg", options);
const metadata = await probeMedia("/recordings/input.mp4", options);
await runFfmpeg(
  ["-nostdin", "-i", "/recordings/input.mp4", "/output/audio.mp3"],
  options,
);

runFfprobe, ensureRuntime, getBuilds, and settings are also exported. getBuilds({ platform, arch, channel }) returns a normalized catalog with release versions, immutable build IDs, archive URLs and checksum references. Selection resolves the selected archives to SHA-256 values before any download. Runtime options are cacheDir, channel, offline, and preferredRuntime. Execution accepts signal and timeoutSeconds. Nonzero execution throws an error with exitCode, stdout, and stderr. ensureRuntime explicitly installs or validates a downloaded pair; use resolveBinary to apply the local preference for a particular program.

Builds and cache

One catalog module reads public paginated build histories. The default release channel selects the highest published release version by FFmpeg-Builds on Windows/Linux and the latest release build on Martin Riedl's server for macOS. Two-component FFmpeg release labels such as 9.1 are normalized to 9.1.0 for npm semver matching. Builds can include provider commits after that release; use a build ID to select a specific provider build. History retention varies by provider. Select --channel snapshot for development snapshots. "Latest" means the newest build available from that provider for the selected platform/channel; a provider may lag upstream FFmpeg. Both binaries come from the same build.

With a valid cached runtime, provider metadata is checked at most once every 24 hours for each platform and channel. The check time is shared on disk across processes; cache hits do not extend it. Missing or damaged binaries trigger an immediate lookup and repair. Unchanged builds reuse their cached files after integrity verification. New archives are checked against provider SHA-256 checksums and installed atomically under a lock. Existing build directories remain available to running processes. Updates do not require a new npm release of this wrapper.

If a provider check or update download fails, a verified existing runtime remains usable. The failed attempt is also remembered for 24 hours to avoid repeated requests during outages or rate limiting. The JavaScript result exposes updateCheckError, checkedAt, and lastCheckAt. Without a valid cached runtime, the operation reports the provider/download error.

env-paths('ffmpeg-runtime') supplies the platform cache directory:

  • Windows: %LOCALAPPDATA%/ffmpeg-runtime-nodejs/Cache

  • macOS: ~/Library/Caches/ffmpeg-runtime-nodejs

  • Linux: $XDG_CACHE_HOME/ffmpeg-runtime-nodejs or ~/.cache/ffmpeg-runtime-nodejs

The npm/npx cache holds this package; the runtime cache separately holds downloaded binaries. No install script downloads them. Use --offline to use an existing validated runtime without any release check. Offline mode fails clearly if no valid cached build is available. If --preferred-runtime local finds a native binary, no provider request or binary download occurs.

Environment variable

Default

CLI equivalent

FFMPEG_PREFERRED_RUNTIME

latest

--preferred-runtime VALUE

FFMPEG_CACHE_DIR

Platform cache

--cache-dir PATH

FFMPEG_CHANNEL

release

--channel release|snapshot

FFMPEG_OFFLINE

false

--offline

FFMPEG_OFFLINE accepts true or false. JavaScript options override environment settings; CLI wrapper flags override the corresponding environment values.

License

This wrapper is MIT licensed. Downloaded FFmpeg/FFprobe builds have their own licenses, including GPL components. They are fetched from the providers and are not included in this npm package. Consult the corresponding provider's build information, source, and license terms when distributing binaries or outputs. This project is independent of FFmpeg and the build providers.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      C
      maintenance
      Enables comprehensive video and audio processing using FFmpeg, supporting tasks like metadata extraction, clipping, scaling, and adding transitions or overlays. It provides a high-performance interface for building media processing microservices via FastMCP.
      12
      12
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Gives coding agents a local FFmpeg video-editing engine exposed over MCP, enabling them to probe, cut, join, reframe, caption, normalize audio, and verify the resulting media without cloud services or API keys. Every operation returns structured JSON and self-checks its own output against delivery specs.
      MIT