视频帧提取工具

一个通过MCP协议与AI助手集成的本地视频帧提取工具,支持OCR文本识别、智能采样和视频剪辑功能。

  • by eequaled
  • JavaScript
  • 本地部署
  • 3 星标
  • 更新于
在 GitHub 查看 eequaled/frames-mcp

使用说明

🎞️ 视频帧MCP

1-衬垫: 给你的AI代理眼睛:从本地视频中为Claude、Cursor和Windsurf提取视觉背景。

这是一个 MCP(模型上下文协议) 将AI编码助手与 ffmpeg,使他们能够直接从聊天中处理视频文件。

https://github.com/user-attachments/assets/8493da1c-1c2a-42d4-87ee-40cead242eb2


✨ 特性

工具 说明
extract_frame 提取单个图像(返回base64& OCR文本;路径可选)
extract_multiple_frames 批量提取帧(返回base64;目录可选)
get_video_info 获取持续时间、分辨率、FPS、编解码器和帧数
extract_clip 剪切视频片段(需要路径)

🧠 智能功能

  • 内置OCR(extract_frame):服务器使用以下命令自动运行光学字符识别 tesseract.js 在提取的帧上,将文本直接返回给您的人工智能。非常适合阅读视频中的错误消息或幻灯片内容。
  • 智能采样(extract_multiple_frames):不要每秒都转储一帧,破坏你的令牌上下文。请求 totalFrames: 10,服务器将完美地分割视频,返回10个均匀分布的帧,捕捉整个时间线。
  • 瞬态模式:如果省略帧的输出路径,服务器会将其保存到系统临时文件夹中,将其读取为base64,并立即删除。零杂乱。

🔒 100%本地和私人

你的视频文件永远不会离开你的机器。帧提取、OCR和剪切完全在本地进行。这使得它对企业环境、保密协议和私人录音是安全的。


⚙️ 运作原理

所有处理都会发生 本地在您的计算机上 使用 ffmpeg, ffprobe,以及 tesseract.js OCR。服务器通过以下方式进行通信 标准 传输——标准MCP协议。你的AI发送一个工具调用,服务器运行命令,并返回结果(以及文本,如果适用)。

  • extract_frame → ffmpeg -ss <timestamp> -i video.mp4 -frames:v 1 output.jpg + OCR处理
  • extract_multiple_frames → ffmpeg -vf fps=N/duration video.mp4 output_%04d.jpg
  • get_video_info → ffprobe -print_format json -show_streams -show_format video.mp4
  • extract_clip → ffmpeg -ss <start> -to <end> -c copy video.mp4 clip.mp4

为什么使用 -c copy? 它完全跳过了重新编码,使剪辑提取近乎即时。折衷之处在于,剪切与最近的关键帧对齐,因此它们可能会在精确的帧上略微偏离。


📋 需求

安装ffmpeg

平台 命令
视窗 winget install ffmpeg 或 choco install ffmpeg
macOS brew install ffmpeg
Ubuntu/Debian sudo apt install ffmpeg
Fedora/RHEL sudo dnf install ffmpeg

验证它是否有效: ffmpeg -version


🚀 安装

npx -y @eequaled/frames-mcp

(或者,您可以从源代码克隆和构建)。

这 npx 命令会自动从NPM获取最新版本。


🛠️ 配置代码段

对于使用 config.json 结构(Cursor、Claude、Roo Code、Cline、Windsurf),在您的 mcpServers 对象:

{
  "mcpServers": {
    "video-frames": {
      "command": "npx",
      "args": ["-y", "@eequaled/frames-mcp"]
    }
  }
}

[!重要] 如果你从GitHub克隆而不是使用 npx,将命令更改为 node args指向 绝对路径 您当地的 dist/index.js.


🔌 客户端设置

光标

  1. 打开 设置 → 特性 → 主控程序
  2. 点击 +添加新的MCP服务器
  3. 填写:
    • 名字: video-frames
    • 类型: command
    • 命令: npx -y @eequaled/frames-mcp
  4. 保存并等待 绿点 (已连接)

克劳德桌面版

编辑您的配置文件:

  • 视窗: %APPDATA%\Claude\claude_desktop_config.json
  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
{
  "mcpServers": {
    "video-frames": {
      "command": "npx",
      "args": ["-y", "@eequaled/frames-mcp"]
    }
  }
}

Roo代码(VS代码扩展名)

打开Roo Code MCP设置面板,或直接编辑文件:

%APPDATA%\Code\User\globalStorage\roovscode.roo-cline\settings\cline_mcp_settings.json
{
  "mcpServers": {
    "video-frames": {
      "command": "npx",
      "args": ["-y", "@eequaled/frames-mcp"]
    }
  }
}

Cline(VS代码扩展)

编辑临床MCP设置文件:

%APPDATA%\Code\User\globalStorage\saoudrizwan.claude-dev\settings\cline_mcp_settings.json
{
  "mcpServers": {
    "video-frames": {
      "command": "npx",
      "args": ["-y", "@eequaled/frames-mcp"]
    }
  }
}

帆板运动

打开 设置 → 主控程序 → 添加服务器 并填写:

{
  "command": "npx",
  "args": ["-y", "@eequaled/frames-mcp"]
}

CLI/其他平台

任何MCP兼容工具(Open Interpreter、自定义脚本等)都可以使用以下方式连接:

参数 值
运输 stdio
命令 npx
参数 ["-y", "@eequaled/frames-mcp"]

您也可以直接在终端中进行测试:

# Smoke test — should print the running message
npx -y @eequaled/frames-mcp

# Send a raw JSON-RPC list request
echo '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' | npx -y @eequaled/frames-mcp

💬 示例提示

连接后,在您的AI聊天中尝试以下操作:

What's the duration and resolution of /path/to/video.mp4?
Extract the frame at 1:30 from /path/to/video.mp4 and save it to /output/thumb.jpg
Check this video and tell me the moment the error message appears.
Summarize the UI changes in this screen recording.
Extract the text from the slide at 02:45.

提示: 总是使用 绝对路径 (例如。, C:\Videos\movie.mp4 或 /home/user/movie.mp4).相对路径不会可靠地解析。


🧠 为什么这很有用

结合您的人工智能的视觉能力,此MCP可以解锁:

  • 视频内容分析 --提取帧→ AI描述或总结场景内容
  • 缩略图生成 --随时拉出最好看的相框
  • 快速视频检查 --无需打开视频播放器即可获取元数据
  • 剪辑提取 --按需剪切精彩片段或短片
  • GIF/视频管道 --夹一段并用管子将其进一步加工

🛠️ 支持的视频格式

mp4, mkv, avi, mov, webm, flv, wmv, m4v --以及ffmpeg可以解码的任何其他内容。


🤖 AI代理集成

该项目包括 llms.txt file——专门为AI代理编写的机器可读文档。如果你想让人工智能助手代表你设置、配置或使用此MCP服务器,只需将其指向该文件:

“阅读 llms.txt 在这个仓库中,将视频帧MCP添加到我的设置中。"

该文件包含代理所需的一切:先决条件、安装步骤、每个客户端的配置代码段、包含所有参数的完整工具规范以及重要注意事项(如始终使用绝对路径)。