Skip to main content
Glama

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 Cline

setup 交互式地:

  1. 将你的 OpenRouter 密钥 保存到 .env

  2. ai-medialens MCP 服务器注册到 Cline 的全局配置中

Related MCP server: mcp-multivision-server

支持的输入(按扩展名自动检测)

类型

扩展名

OpenRouter 内容部分

视频

.mp4 .mpeg .mov .webm

video_url (base64)

音频

.wav .mp3 .aiff .aac .ogg .flac .m4a

input_audio

PDF

.pdf

file (base64)

图片

.jpg .jpeg .png .gif .webp

image_url (base64)

用法

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-run

MCP(从 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 密钥解析顺序

  1. -k/--key 标志

  2. OR_KEY 环境变量

  3. OPENROUTER_API_KEY 环境变量

  4. 脚本旁边的 .env 文件(参见 .env.example)

ffmpeg 与时间范围裁剪

--start/--end本地裁剪媒体后再上传(OpenRouter 没有 原生的范围参数)。ffmpeg 按以下顺序解析:

  1. 捆绑的 bin\ffmpeg.exe(如果你将其放在那里)

  2. 缓存的副本位于 %LOCALAPPDATA%\ai-medialens\bin\ffmpeg.exe

  3. PATH 中的 ffmpeg

  4. 自动下载(约 80 MB 静态构建,一次性,Windows)

注意:裁剪使用 -c copy(快速,但会在关键帧处切割;精确切割需要 重新编码)。

模型

默认:qwen/qwen3.7-flash($0.03/M 输入,$0.13/M 输出)——目前 OpenRouter 上支持完整视频输入的最便宜模型。

其他支持视频的不错选项(通过 --list-models video 验证当前价格):

模型

输入 /M

输出 /M

qwen/qwen3.7-flash(默认)

$0.03

$0.13

z-ai/glm-5.3-flash

$0.075

$0.25

qwen/qwen3.8-27b

$0.425

$2.55

任何 OpenRouter 模型 slug 都可以通过 -m / model= 使用——包括 新发布的模型。

PDF 解析引擎

PDF 可以在本地解析,也可以由 OpenRouter 在服务器端解析:

引擎

行为

成本

(默认)

从嵌入的文本层进行服务器端文本提取

免费

--pdf-engine local

通过 PyMuPDF 进行本地解析pip install pymupdf)——无速率限制。数字 PDF:本地提取文本。扫描 PDF:页面渲染为图像,视觉模型自行执行 OCR

免费

--pdf-engine mistral-ocr

对页面图像进行服务器端真实 OCR——可读取扫描/纯图像 PDF

按页计费

--pdf-engine native

将原始 PDF 转发给具有原生文件输入的模型

免费

推荐使用 local:它永远不会触及 OpenRouter 的解析器速率限制,并且 以零额外成本处理数字和扫描 PDF。

语音转文本(STT)

使用 OpenRouter 专用的 /audio/transcriptions 端点(Whisper 类 模型)。默认模型:openai/whisper-large-v3-turbo。其他选项: openai/gpt-4o-transcribeopenai/gpt-4o-mini-transcribemicrosoft/mai-transcribe-1.5openai/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,永远不会被提交。

F
license - not found
Not graded
quality - not tested
B
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

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

View all related MCP servers

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.

View all MCP Connectors

Latest Blog Posts

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