使用说明
MCP视频
一种MCP(模型上下文协议)服务器,使LLM能够通过提取帧和转录音频来分析视频内容。
特性
- 帧提取:从视频中提取关键帧作为base64编码图像
- 视频元数据:获取持续时间、分辨率、编解码器、文件大小等
- 可配置的:调整帧间隔、质量、分辨率和时间范围
- 多种格式:MP4、WebM、MOV、AVI、MKV、GIF等
当前状态
第一阶段(MVP)-完成:
- [x]
get_video_info-获取视频元数据 - [x]
extract_frames-按间隔提取帧
第二阶段(即将推出):
- [ ]
transcribe_audio-使用Whisper进行音频转录 - [ ]
analyze_video-组合框架+转录
先决条件
- Node.js>=18
- 系统上安装了ffmpeg
安装ffmpeg
# macOS
brew install ffmpeg
# Ubuntu/Debian
sudo apt install ffmpeg
# Windows (with chocolatey)
choco install ffmpeg
安装
# Clone or navigate to the repository
cd mcp-video
# Install dependencies
npm install
# Build
npm run build
Claude代码的配置
添加到MCP设置文件中:
地点: ~/.claude/mcp_servers/mcp-video.json (如果不存在则创建)
或者添加到您的克劳德代码设置中:
{
"mcpServers": {
"mcp-video": {
"command": "node",
"args": ["/Users/YOUR_USERNAME/Documentos/repositories/mcp-video/dist/index.js"]
}
}
}
替换 YOUR_USERNAME 使用您的实际用户名。
可用工具
get_video_info
获取视频文件的元数据。
输入:
{
path: string // Path to video file
}
输出:
{
"filename": "video.mp4",
"duration": "02:30",
"duration_seconds": 150,
"resolution": "1920x1080",
"fps": 30,
"codec": "h264",
"audio_codec": "aac",
"file_size": "45.2 MB",
"has_audio": true
}
extract_frames
以指定的时间间隔从视频中提取帧。
输入:
{
path: string; // Path to video file (required)
interval?: number; // Seconds between frames (default: 2)
max_frames?: number; // Max frames to extract (default: 30)
quality?: number; // JPEG quality 1-100 (default: 75)
width?: number; // Frame width in pixels (default: 800)
start_time?: number; // Start from this second
end_time?: number; // End at this second
}
输出:
- 视频元数据为文本
- base64编码的JPEG图像数组
使用示例
配置后,您可以在Claude Code中使用它:
"What's the duration and resolution of /path/to/video.mp4?"
→ Uses get_video_info
"Show me frames from /path/to/video.mp4 every 5 seconds"
→ Uses extract_frames with interval=5
"Extract the first 10 frames from /path/to/video.mp4"
→ Uses extract_frames with max_frames=10
"Get frames from 10 to 30 seconds of the video"
→ Uses extract_frames with start_time=10, end_time=30
支持的视频格式
| 格式 | 扩展 | 支持 |
|---|---|---|
| MP4 | .MP4 | 已满 |
| WebM | .WebM | 完整 |
| MOV | .MOV | 完整 |
| AVI | .AVI | 完整 |
| MKV | .MKV | 已满 |
| GIF | .GIF | 仅限帧 |
| M4V | .M4V | 满 |
| FLV | .FLV | 满 |
| WMV | .WMV | 已满 |
| MPEG | .MPEG、.mpg | 完整 |
发展
# Run in development mode (with hot reload)
npm run dev
# Build for production
npm run build
# Type check
npm run typecheck
# Run tests
npm test
项目结构
mcp-video/
├── src/
│ ├── index.ts # Entry point
│ ├── server.ts # MCP server setup
│ ├── tools/
│ │ ├── get-video-info.ts # Metadata tool
│ │ └── extract-frames.ts # Frame extraction tool
│ ├── processors/
│ │ └── ffmpeg-processor.ts # FFmpeg wrapper
│ ├── utils/
│ │ ├── validators.ts # Input validation
│ │ └── file-handler.ts # File operations
│ └── types/
│ └── index.ts # TypeScript types
├── dist/ # Compiled JavaScript
├── package.json
├── tsconfig.json
├── PLANNING.md # Detailed architecture
└── README.md
文档
看 规划.md 了解详细的架构、未来路线图和实施计划。
许可证
麻省理工学院