ai-medialens
AI-MediaLens - 通过 OpenRouter 为 AI 代理提供媒体分析
填补了 Cline 无法读取的内容空白:视频、音频和 PDF 文件。 直接将文件发送到 OpenRouter API,该 API 会将文件路由到多模态 模型(并为任何模型解析 PDF)。
可作为 MCP 服务器 用于 Cline、独立的 CLI,以及可导入的 Python 模块 - 全部来自一个文件。
快速开始
git clone https://github.com/Alihkhawaher/ai-medialens.git
cd ai-medialens
pip install mcp # only needed for MCP mode
python openrouter_media.py setup # configure API key + register in Clinesetup 交互式地:
将你的 OpenRouter 密钥 保存到
.env将
ai-medialensMCP 服务器注册到 Cline 的全局配置中
Related MCP server: mcp-multivision-server
支持的输入(按扩展名自动检测)
类型 | 扩展名 | OpenRouter 内容部分 |
视频 |
|
|
音频 |
|
|
|
| |
图片 |
|
|
用法
CLI
# Full file
python openrouter_media.py video.mp4 -p "Transcribe all spoken Arabic word-for-word"
# Only seconds 5-20 (trimmed locally; ffmpeg auto-downloaded on first use)
python openrouter_media.py video.mp4 -p "What happens here?" --start 5 --end 20
# Different model / explicit key
python openrouter_media.py doc.pdf -p "Summarize" -m z-ai/glm-5.3-flash -k sk-or-v1-...
# Scanned PDF -> real OCR (billed per page by OpenRouter)
python openrouter_media.py scan.pdf -p "Extract all text" --pdf-engine mistral-ocr
# Speech-to-text (works on video files too - audio track extracted locally)
python openrouter_media.py lecture.mp4 --stt --language ar
# SRT subtitles with timestamps
python openrouter_media.py lecture.mp4 --stt --srt > lecture.srt
# Find models that accept video input, with prices
python openrouter_media.py --list-models video
# Preview request shape without sending (no API cost)
python openrouter_media.py video.mp4 -p "test" --dry-runMCP(从 Cline 使用)
Cline 原生调用这些工具:
use_mcp_tool: server=ai-medialens, tool=analyze_media
arguments: { "path": "...", "prompt": "...", "start": "5", "end": "20" }
use_mcp_tool: server=ai-medialens, tool=transcribe_audio
arguments: { "path": "...", "language": "ar", "srt": false }作为 Python 模块
from openrouter_media import analyze
text = analyze("video.mp4", "Transcribe all speech.")
resp = analyze("doc.pdf", "Summarize.", raw=True)API 密钥解析顺序
-k/--key标志OR_KEY环境变量OPENROUTER_API_KEY环境变量脚本旁边的
.env文件(参见 .env.example)
ffmpeg 与时间范围裁剪
--start/--end 在本地裁剪媒体后再上传(OpenRouter 没有
原生的范围参数)。ffmpeg 按以下顺序解析:
捆绑的
bin\ffmpeg.exe(如果你将其放在那里)缓存的副本位于
%LOCALAPPDATA%\ai-medialens\bin\ffmpeg.exePATH 中的 ffmpeg
自动下载(约 80 MB 静态构建,一次性,Windows)
注意:裁剪使用 -c copy(快速,但会在关键帧处切割;精确切割需要
重新编码)。
模型
默认:qwen/qwen3.7-flash($0.03/M 输入,$0.13/M 输出)——目前
OpenRouter 上支持完整视频输入的最便宜模型。
其他支持视频的不错选项(通过 --list-models video 验证当前价格):
模型 | 输入 /M | 输出 /M |
| $0.03 | $0.13 |
| $0.075 | $0.25 |
| $0.425 | $2.55 |
任何 OpenRouter 模型 slug 都可以通过 -m / model= 使用——包括
新发布的模型。
PDF 解析引擎
PDF 可以在本地解析,也可以由 OpenRouter 在服务器端解析:
引擎 | 行为 | 成本 |
(默认) | 从嵌入的文本层进行服务器端文本提取 | 免费 |
| 通过 PyMuPDF 进行本地解析( | 免费 |
| 对页面图像进行服务器端真实 OCR——可读取扫描/纯图像 PDF | 按页计费 |
| 将原始 PDF 转发给具有原生文件输入的模型 | 免费 |
推荐使用 local:它永远不会触及 OpenRouter 的解析器速率限制,并且
以零额外成本处理数字和扫描 PDF。
语音转文本(STT)
使用 OpenRouter 专用的 /audio/transcriptions 端点(Whisper 类
模型)。默认模型:openai/whisper-large-v3-turbo。其他选项:
openai/gpt-4o-transcribe、openai/gpt-4o-mini-transcribe、
microsoft/mai-transcribe-1.5、openai/whisper-large-v3。
流水线加固(来自生产级 YouTube→字幕系统的经验教训):
任何音频/视频输入 → ffmpeg 转换为 Opus 32kbps/16kHz/单声道 (比 WAV 小 8 倍,所有提供商都接受);视频轨道被剥离
长媒体自动拆分为 6 分钟块(OpenRouter 每个请求有约 60 秒 的上游超时)
每个块重新封装以添加缺失的 Ogg EOS 页面(ffmpeg 的 segment muxer 会省略它;OpenRouter 的解析器会拒绝没有它的流)
--srt通过verbose_json段返回带时间戳的 SRT 字幕, 并跨块正确偏移注意:
whisper-large-v3在加速音频上会产生乱码输出;mai-transcribe-1.5可以容忍这种情况
注意事项
大文件在内存中进行 base64 编码——非常大的视频可能会达到 提供商的上传限制。
密钥是安全的:
.env已被 gitignore,永远不会被提交。
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseAqualityAmaintenanceGive your AI assistant eyes and ears — analyze any video, audio, or image, entirely on your machine.2612Apache 2.0
- AlicenseAqualityBmaintenanceProvides image and video analysis capabilities for LLMs, with local preprocessing (ffmpeg/OpenCV) and any OpenAI-compatible vision model for understanding and Q&A.4MIT
- AlicenseNot gradedqualityBmaintenanceEnables text-only coding models to read images, PDFs, presentations, spreadsheets, and other non-text files through a single analyze_media tool, combining local document extraction, OCR, and optional vision models with clear evidence labeling.1MIT
- AlicenseNot gradedqualityAmaintenanceEnables text-only AI coding agents to analyze images and videos via vision-capable models (Gemini, Grok, OpenRouter), returning text descriptions for reasoning.36MIT
Related MCP Connectors
Multimodal video analysis MCP — transcription, vision, and OCR for any video URL.
OCR, transcription, file extraction, and image generation for AI agents via MCP.
Transform video, audio and images, and generate media from prompts. FFmpeg, captions, models.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Alihkhawaher/ai-medialens'
If you have feedback or need assistance with the MCP directory API, please join our Discord server