MCP视频解析器
一个强大的视频分析系统,使用模型上下文协议(MCP)使用AI视觉模型处理、分析和查询视频内容。
🎬 特性
- AI驱动的视频分析:使用视觉LLM(Llava)自动提取和分析帧
- 自然语言查询:使用会话查询搜索视频
- 基于时间的搜索:按相对时间(“上周”)或特定日期查询视频
- 基于位置的组织:按位置组织视频(棚屋、车库等)
- 音频转录:提取并搜索视频记录
- 聊天集成:与Mistral/Llama进行自然对话,同时保持视频背景
- 场景检测:基于视觉变化的智能帧提取
- MCP协议:与Claude和其他MCP客户进行基于标准的集成
🚀 快速开始
先决条件
- Python 3.10+
- 没有 已安装并正在运行
- ffmpeg(用于视频处理)
安装
- 克隆存储库:
git clone https://github.com/michaelbaker-dev/mcpVideoParser.git
cd mcpVideoParser- 安装依赖项:
pip install -r requirements.txt- 拉取所需的Olama型号:
ollama pull llava:latest # For vision analysis
ollama pull mistral:latest # For chat interactions- 启动MCP服务器:
python mcp_video_server.py --http --host localhost --port 8000基本用法
- 处理视频:
python process_new_video.py /path/to/video.mp4 --location garage- 启动聊天客户端:
python standalone_client/mcp_http_client.py --chat-llm mistral:latest- 查询示例:
- “显示最新视频”
- “昨天车库里发生了什么事?”
- “查找汽车视频”
- “给我一个上周所有视频的摘要”
🏗️ 建筑
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Video Files │────▶│ Video Processor │────▶│ Frame Analysis │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│ │
▼ ▼
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ MCP Server │◀────│ Storage Manager │◀────│ Ollama LLM │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│
▼
┌─────────────────┐
│ HTTP Client │
└─────────────────┘🛠️ 配置
编辑 config/default_config.json 自定义:
- 帧提取率:要分析多少帧
- 场景检测灵敏度:何时捕捉场景变化
- 存储设置:在哪里存储视频和数据
- LLM模型:哪些模型用于视觉和聊天
看 配置指南 了解详情。
🔧 MCP工具
服务器公开了这些MCP工具:
process_video-处理和分析视频文件query_location_time-按位置和时间查询视频search_videos-搜索视频内容和文字记录get_video_summary-获取AI生成的视频摘要ask_video-询问有关特定视频的问题analyze_moment-分析视频中的特定时间戳get_video_stats-获取系统统计信息get_video_guide-获取使用说明
🛠️ 实用程序脚本
视频清理
清除系统中的所有视频并重置为新状态:
# Dry run to see what would be deleted
python clean_videos.py --dry-run
# Clean processed files and database (keeps originals)
python clean_videos.py
# Clean everything including original video files
python clean_videos.py --clean-originals
# Skip confirmation and backup
python clean_videos.py --yes --no-backup此脚本将:
- 从数据库中删除所有视频条目
- 删除所有已处理的帧和转录本
- 从基于位置的结构中删除所有视频
- 可选择删除原始视频文件
- 在清理之前创建数据库备份(除非
--no-backup)
视频处理
处理单个视频:
# Process a video with automatic location detection
python process_new_video.py /path/to/video.mp4
# Process with specific location
python process_new_video.py /path/to/video.mp4 --location garage📖 文档
🚦 发展
运行测试
# All tests
python -m pytest tests/ -v
# Unit tests only
python -m pytest tests/unit/ -v
# Integration tests (requires Ollama)
python -m pytest tests/integration/ -v项目结构
mcp-video-server/
├── src/
│ ├── llm/ # LLM client implementations
│ ├── processors/ # Video processing logic
│ ├── storage/ # Database and file management
│ ├── tools/ # MCP tool definitions
│ └── utils/ # Utilities and helpers
├── standalone_client/ # HTTP client implementation
├── config/ # Configuration files
├── tests/ # Test suite
└── video_data/ # Video storage (git-ignored)🤝 贡献
我们欢迎捐款!请看 贡献.md 作为指导方针。
📝 路线图
- ✅ 基本视频处理和分析
- ✅ MCP服务器实现
- ✅ 自然语言查询
- ✅ 聊天与上下文集成
- 🚧 增强的时间解析(请参见 智能查询PLAN.md)
- 🚧 多摄像头支持
- 🚧 实时处理
- 🚧 web界面
🐛 故障排除
常见问题
- Ollama没有跑:
ollama serve # Start Ollama- 缺少模型:
ollama pull llava:latest
ollama pull mistral:latest- 端口已在使用中:
# Change port in command
python mcp_video_server.py --http --port 8001📄 许可证
MIT许可证-请参阅 许可证 了解详情。
🙏 致谢
💬 支持
______________________________________________________________________
版本: 0.1.1\ 作者:迈克尔·贝克\ 状态:Beta-可能发生重大变化
