Skip to main content
Glama

Extract Video Frames

Turn local videos into a small, configurable set of PNG screenshots for slide references, illustrated notes, and visual review. Use the same extraction engine from JavaScript, the command line, or an MCP client.

Requires Node.js 22.18+. FFmpeg is supplied by the JavaScript dependency mcp-ffmpeg-runtime, declared as latest and refreshed when preparing each new release. The resolved dependency is saved with the release for reproducible retries. At first media use in each process, that runtime checks its current FFmpeg build and reuses or updates its binary cache. Subsequent extraction passes reuse the resolved command. System FFmpeg and FFprobe are not required. Runtime settings such as FFMPEG_CACHE_DIR, FFMPEG_CHANNEL, FFMPEG_OFFLINE, and FFMPEG_PREFER_LOCAL are handled by mcp-ffmpeg-runtime. Offline or local preference can opt out of downloading the current build. FFmpeg has its own licenses.

CLI

npx -y --prefer-online mcp-extract-video-frames@latest recording.mp4 --frame-max-count 40
npx -y --prefer-online mcp-extract-video-frames@latest --help

The command returns JSON containing the output directory, manifest path, saved count, selection settings, cache status, and FFmpeg log path. Images are prepared for later inspection; extraction does not interpret their content.

Related MCP server: local-video-scenes-mcp

JavaScript

npm install mcp-extract-video-frames
import { extractFrames } from 'mcp-extract-video-frames';

const result = await extractFrames('/recordings/lecture.mp4', {
  frameMode: 'changes',
  frameMaxCount: 80,
  frameMaxHeight: 1080,
});
console.log(result.directory, result.manifest, result.count);

Optional outputDir selects an explicit output directory. Otherwise artifacts are stored in an identifiable folder under the operating system temporary directory. Pass an AbortSignal as signal to cancel extraction.

MCP

{
  "mcpServers": {
    "extract-video-frames": {
      "command": "npx",
      "args": ["-y", "--prefer-online", "mcp-extract-video-frames@latest"]
    }
  }
}

Clients requiring a Windows executable path can use npx.cmd. The extract_frames tool takes an absolute file path and the same frame settings as the JavaScript API. Each setting describes its configured default in discovery. With no file argument, the CLI starts MCP over stdio; mcp is also an explicit subcommand. Local installations delegate to their installed CLI. An npx-managed MCP installation resolves the current published CLI for tool calls.

Selection and defaults

Option

Default

Purpose

frameMode

changes

Adaptive visual selection, or interval for evenly distributed images

frameIntervalSeconds

0

Candidate spacing; 0 chooses automatically

frameMaxCount

120

Maximum images across the whole retained video

frameMaxHeight

1080

Maximum PNG height, without upscaling

frameChangeThreshold

4.5

Nearby grayscale similarity threshold; higher treats more images as duplicates

Adaptive selection allocates a budget across the complete video, favoring visual activity and local changes. Static footage can produce a single image. The limit is an upper bound, not a cutoff that discards the end of the video. Interval mode spreads its limited selection over the full candidate timeline.

Candidate scanning is bounded to about 20,000 frames. A short change between samples can be missed; moving overlays can produce extra images. Selection is a visual heuristic, not semantic slide recognition or a guarantee of completeness. The source is decoded during scanning, and selected images are rendered in a separate pass. Sparse output does not imply sparse decoding.

Configuration

Invocation settings override process environment, then the selected env file, then built-in defaults. An optional .env in the working directory is loaded by default. Use --env-file /path/to/.env, EXTRACT_VIDEO_FRAMES_ENV_FILE, or the library's envFile option to select another file. Explicit missing files are errors.

Variable

Default

EXTRACT_VIDEO_FRAMES_FRAME_MODE

changes

EXTRACT_VIDEO_FRAMES_FRAME_INTERVAL_SECONDS

0

EXTRACT_VIDEO_FRAMES_FRAME_MAX_COUNT

120

EXTRACT_VIDEO_FRAMES_FRAME_MAX_HEIGHT

1080

EXTRACT_VIDEO_FRAMES_FRAME_CHANGE_THRESHOLD

4.5

EXTRACT_VIDEO_FRAMES_DISCOVERY_CACHE_TTL_MS

600000

Timestamps and output

PNG names use frame-HH-MM-SS-mmm-NNNN.png. The manifest preserves precise source seconds, sampled compact seconds, selection settings, and source identity. These are recording-relative timestamps, not meeting wall-clock times. Sources are not modified, and matching completed runs are reused while their images still exist. Missing images cause regeneration. Operating system temporary files can be removed at any time; copy selected images into permanent notes when needed.

For integrations that remove parts of a recording, pass an optional timeline:

const timeline = {
  originalSeconds: 100,
  compactSeconds: 40,
  segments: [
    { originalStart: 0, originalEnd: 20, compactStart: 0, compactEnd: 20 },
    { originalStart: 80, originalEnd: 100, compactStart: 20, compactEnd: 40 },
  ],
};

Frames are extracted from retained source intervals; filenames and sourceSeconds refer to the original recording. compactSeconds records the corresponding time after removal. CLI users can supply a timeline JSON with --timeline-file.

An existing output directory from a different run is rejected. An active or stale .lock blocks writes; check that no extraction is running before removing a stale lock. Failed runs are not cached as complete. Read ffmpeg.log for media errors.

License

MIT.

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