ai-medialens
AI-MediaLens - OpenRouter 経由の AI エージェント向けメディア解析
Cline が読めないもの(動画、音声、PDF ファイル)のギャップを埋めます。 ファイルを OpenRouter API に直接送信し、マルチモーダルモデルにルーティングします(PDF はあらゆるモデル向けに解析されます)。
Cline 用のMCP サーバー、スタンドアロンのCLI、インポート可能なPython モジュールとして動作します - すべて 1 つのファイルから。
クイックスタート
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: Media Context MCP
対応入力(拡張子で自動検出)
タイプ | 拡張子 | 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.exeにキャッシュされたコピーPATH 上の ffmpeg
自動ダウンロード(約 80 MB の静的ビルド、1 回限り、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 |
-m / model= で任意の OpenRouter モデルスラッグが使用可能です — 新しいリリースも登場次第対応します。
PDF 解析エンジン
PDF はローカルまたは OpenRouter によるサーバーサイドで解析されます:
エンジン | 動作 | コスト |
(デフォルト) | 埋め込みテキストレイヤーからのサーバーサイドのテキスト抽出 | 無料 |
| PyMuPDF によるローカル解析( | 無料 |
| ページ画像に対するサーバーサイドの本格的な OCR — スキャン/画像のみの PDF を読み取ります | ページごとに課金 |
| ネイティブファイル入力対応モデルに生の PDF を転送 | 無料 |
local が推奨です: OpenRouter のパーサーレート制限に達することがなく、デジタル PDF とスキャン 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 のセグメントマクサーはこれを省略します; OpenRouter のパーサーはこれがないストリームを拒否します)
--srtはverbose_jsonセグメント経由でタイムスタンプ付きの SRT 字幕を返し、チャンク間で正しくオフセットされます注:
whisper-large-v3は速度変更された音声で文字化けした出力を生成します;mai-transcribe-1.5はそれを許容します
注意事項
大きなファイルはメモリ内で base64 エンコードされます - 非常に大きな動画はプロバイダーのアップロード制限に達する可能性があります。
シークレットは安全です:
.envは gitignore されており、コミットされることはありません。
This server cannot be deployed
Maintenance
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.
Extract structured insights from videos, podcasts, articles, and PDFs with multi-model AI
Video, audio, and image processing for AI agents: convert, transcribe, upscale - 150+ operations.
Related MCP Servers
- 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
- AlicenseAqualityCmaintenanceEnables AI agents to extract, analyze, and manipulate images, PDFs, video, and audio while conserving context through downscaling, truncation, and frame/page caps.22MIT
- AlicenseNot gradedqualityAmaintenanceProvides local, offline transcription, keyframe extraction, OCR, and pre-publish review of audio, video, and image files, enabling AI agents to see and hear media without cloud or API keys.29 npmApache 2.0