ai-medialens
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@ai-medialensAnalyze the video at ./clip.mp4 and describe what happens."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
# AI-MediaLens - Media analysis for AI agents via OpenRouter
Fills the gap of what Cline can't read: video, audio, and PDF files. Sends files directly to the OpenRouter API, which routes them to multimodal models (and parses PDFs for any model).
Works as an MCP server for Cline, a standalone CLI, and an importable Python module - all from one file.
Quick start
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 interactively:
Saves your OpenRouter key to
.envRegisters the
ai-medialensMCP server into Cline's global config
Related MCP server: mcp-multivision-server
Supported inputs (auto-detected by extension)
Type | Extensions | OpenRouter content part |
Video |
|
|
Audio |
|
|
|
| |
Image |
|
|
Usage
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 (from Cline)
Cline calls the tools natively:
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 }As a Python module
from openrouter_media import analyze
text = analyze("video.mp4", "Transcribe all speech.")
resp = analyze("doc.pdf", "Summarize.", raw=True)API key resolution order
-k/--keyflagOR_KEYenvironment variableOPENROUTER_API_KEYenvironment variable.envfile next to the script (see .env.example)
ffmpeg & time-range trimming
--start/--end trim the media locally before upload (OpenRouter has no
native range parameter). ffmpeg is resolved in this order:
Bundled
bin\ffmpeg.exe(if you placed one there)Cached copy at
%LOCALAPPDATA%\ai-medialens\bin\ffmpeg.exeffmpeg on PATH
Auto-download (~80 MB static build, one time, Windows)
Note: trimming uses -c copy (fast, but cuts at keyframes; exact cuts would
require re-encoding).
Models
Default: qwen/qwen3.7-flash ($0.03/M in, $0.13/M out) — currently the
cheapest OpenRouter model with full video input support.
Other good video-capable options (verify current prices via
--list-models video):
Model | In /M | Out /M |
| $0.03 | $0.13 |
| $0.075 | $0.25 |
| $0.425 | $2.55 |
Any OpenRouter model slug works via -m / model= — including newer
releases as they appear.
PDF parsing engines
PDFs are parsed either locally or server-side by OpenRouter:
Engine | Behavior | Cost |
(default) | Server-side text extraction from embedded text layer | Free |
| Local parsing via PyMuPDF ( | Free |
| Server-side real OCR over page images — reads scanned/image-only PDFs | Billed per page |
| Forward raw PDF to models with native file input | Free |
local is recommended: it never hits OpenRouter's parser rate limits and
handles both digital and scanned PDFs at zero extra cost.
Speech-to-text (STT)
Uses OpenRouter's dedicated /audio/transcriptions endpoint (Whisper-class
models). Default model: openai/whisper-large-v3-turbo. Other options:
openai/gpt-4o-transcribe, openai/gpt-4o-mini-transcribe,
microsoft/mai-transcribe-1.5, openai/whisper-large-v3.
Pipeline hardening (lessons from a production YouTube→subtitles system):
Any audio/video input → ffmpeg converts to Opus 32kbps/16kHz/mono (8× smaller than WAV, accepted by all providers); video tracks stripped
Long media auto-split into 6-minute chunks (OpenRouter has a ~60s upstream timeout per request)
Each chunk re-muxed to add the missing Ogg EOS page (ffmpeg's segment muxer omits it; OpenRouter's parser rejects streams without it)
--srtreturns timestamped SRT subtitles viaverbose_jsonsegments, correctly offset across chunksNote:
whisper-large-v3produces garbled output on sped-up audio;mai-transcribe-1.5tolerates it
Notes
Large files are base64-encoded in-memory - very large videos may hit provider upload limits.
Secrets are safe:
.envis gitignored and never committed.
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
- AlicenseAqualityCmaintenanceGive your AI assistant eyes and ears — analyze any video, audio, or image, entirely on your machine.2120 npm2Apache 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
- AlicenseAqualityAmaintenanceEnables text-only AI coding agents to analyze images and videos via vision-capable models (Gemini, Grok, OpenRouter), returning text descriptions for reasoning.213 npmMIT