Video2Agent
by Harm0ny-AI
README.md
<p align="right">
<b>English</b> · <a href="README.zh.md">简体中文</a>
</p>
<p align="center">
<img src="docs/assets/hero-brand.svg" alt="Video2Agent — give your agent video retrieval and understanding across YouTube, Bilibili, Douyin, and local videos" width="100%">
</p>
<p align="center">
<a href="https://github.com/Harm0ny-AI/Video2Agent/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/Harm0ny-AI/Video2Agent/actions/workflows/ci.yml/badge.svg"></a>
<a href="LICENSE"><img alt="License: Apache-2.0" src="https://img.shields.io/badge/license-Apache--2.0-6ee7b7"></a>
<img alt="Python 3.11+" src="https://img.shields.io/badge/python-3.11%2B-3776ab">
<img alt="MCP compatible" src="https://img.shields.io/badge/MCP-compatible-10b981">
<a href="https://github.com/topics/dsh-plugin"><img alt="DSH plugin" src="https://img.shields.io/badge/DSH-plugin-60a5fa"></a>
<img alt="Local-first" src="https://img.shields.io/badge/local--first-8b5cf6">
</p>
<h1 align="center">Give your agent video retrieval and understanding.</h1>
<p align="center">
Turn YouTube, Bilibili, Douyin, and local videos into a searchable agent knowledge base — run as a standard <b>MCP server</b> for Claude, Cursor, Windsurf, Cline, Codex & Cherry Studio, as a native <b>DSH plugin</b>, or from the CLI. Inspect long videos, compare 1–10 clips, and verify every claim with exact source-frame evidence (<b>Video-MME 87.8%</b>, <b>~99% fewer tokens</b>). Local-first; optional cloud ASR/OCR and optional platform logins.
</p>
<p align="center">
<a href="#quick-start-mcp">MCP Quick Start</a> ·
<a href="#built-in-settings-ui">Settings UI</a> ·
<a href="#faster-broader-cheaper">Benchmarks</a> ·
<a href="#what-it-does">What It Does</a> ·
<a href="#quick-start-dsh--cli">DSH & CLI</a> ·
<a href="#how-it-works">How It Works</a> ·
<a href="#docs">Docs</a>
</p>
<p align="center">
<img src="docs/assets/demo/video2agent-demo.gif" alt="Video2Agent demo: paste a video link, index locally, answer with source-frame evidence" width="860">
<br>
<sub>Real recording; waiting sections compressed.</sub>
</p>
<p align="center"><sub><b>1 Connect</b> → <b>2 Index locally</b> → <b>3 Ask with timecoded proof</b></sub></p>
---
<h2 id="quick-start-mcp">Quick Start: MCP Server (Claude / Cursor / Codex / Cherry Studio)</h2>
Use `uvx video2agent mcp` for a zero-install quick start with subtitles and, if configured, cloud speech recognition and OCR. Add this to your MCP client configuration (`claude_desktop_config.json`, `.cursor/mcp.json`, or the equivalent for your client). The server shares the local video library with the CLI and DSH plugin.
[Install in Cursor](https://cursor.com/install-mcp?name=video2agent&config=eyJjb21tYW5kIjoidXZ4IiwiYXJncyI6WyJ2aWRlbzJhZ2VudCIsIm1jcCJdfQ%3D%3D) ([direct link](cursor://anysphere.cursor-deeplink/mcp/install?name=video2agent&config=eyJjb21tYW5kIjoidXZ4IiwiYXJncyI6WyJ2aWRlbzJhZ2VudCIsIm1jcCJdfQ==)) · [Install in VS Code](https://insiders.vscode.dev/redirect/mcp/install?name=video2agent&config=%7B%22command%22%3A%22uvx%22%2C%22args%22%3A%5B%22video2agent%22%2C%22mcp%22%5D%7D)
```json
{
"mcpServers": {
"video2agent": {
"command": "uvx",
"args": ["video2agent", "mcp"]
}
}
}
```
For **Claude Code**:
```bash
claude mcp add video2agent -- uvx video2agent mcp
```
For a persistent install, run `uv tool install video2agent` or `pip install video2agent`. Run `video2agent mcp --print-config` to get a ready-to-paste configuration. With either install, `video2agent ui` offers one-click setup for local speech recognition, local OCR, and the browser component for Douyin login. To install offline speech recognition and OCR together, run `uv tool install "video2agent[asr,ocr]"` or `pip install "video2agent[asr,ocr]"`, then download a speech model in Settings.
### Make Agents Trigger Video Tools Proactively
Many MCP clients lazy-load tool schemas until prompted. Install the companion Agent Skill so **Claude Code**, **Codex**, **Antigravity**, and **DSH** recognize video links, YouTube/Bilibili/Douyin mentions, and video-oriented questions automatically:
```bash
video2agent setup --target all # or claude / codex / antigravity / dsh
```
Search routing defaults to **`auto`** (English queries search YouTube with a quick automatic fallback to Bilibili if unreachable; Chinese queries search Bilibili). Switch the **Default Search Platform** anytime in `video2agent ui` or DSH Settings.
### Built-in Settings UI
Need to configure a cloud API key, download a local Whisper speech model, switch OCR, check FFmpeg, or scan a Bilibili/Douyin QR code? Run:
```bash
video2agent ui
```
In a connected MCP client, use the `open-settings` prompt or ask **“Open Video2Agent settings.”** The bilingual settings page opens in your browser so API keys stay on your machine and outside chat logs.
---
### Why Video2Agent
| Comparison | Caption-only summarizers | Single-grid viewers | **Video2Agent** |
| :--- | :---: | :---: | :---: |
| **Video sources** | Single links only | Single links only | **YouTube + Bilibili + Douyin + local files** |
| **Client support** | Web / single app | Single app | **Any MCP client + DSH plugin + CLI** |
| **Batch comparison** | Not supported | Not supported | **Compare 1–10 videos for consensus & conflicts** |
| **Source-frame proof** | No visual context | No library-wide search | **Search text & timecodes first, then verify exact frames** |
| **Local & token budget** | Text only | Heavy per-query image calls | **Local-first index, ~99% fewer tokens (Video-MME 87.8%)** |
---
## Turn Videos & Favorites Into Knowledge
Online talks, tutorials, demos, and saved playlists pile up fast. Video2Agent reads the video first—captions or ASR transcript, on-screen text (OCR), scene cuts, and key frames—into your own local searchable library. Then your agent can answer:
- **“What does this 45-minute talk cover?”** → timestamped outline + 3×3 contact sheet in seconds;
- **“What did that slide/chart at 12:10 say?”** → exact source frame paired with the text on that same frame;
- **“Which of these tutorials is worth watching?”** → compare 1–10 videos side-by-side for agreements, gaps, and conflicts.
---
## Faster, Broader, Cheaper
One video: **2m09s** to produce an 8-row cheat sheet + 6 source frames (**4** source types vs **1** for text-only, and **~99%** fewer tokens than sending video frames directly to a multimodal model).

## Video-MME Leaderboard
On the [llm-stats](https://llm-stats.com/benchmarks/video-mme) Video-MME board (2026-11, 2,700 questions), the orange row is **Video2Agent\* 87.8** (4.1 Flash Max), alongside frontier models; \* marks a [90-question subset](docs/BENCH-VIDEOMME.md).

## What It Does
### 1. Works across YouTube, Bilibili, Douyin, and local files
- **YouTube (`youtube.com`, `youtu.be`, Shorts, Live)**: works out of the box with no login required; smart single-track caption selection avoids rate limits and automatically cleans up rolling auto-caption duplicates before indexing. Search YouTube directly with `video_discover(platform="youtube")` or `video2agent discover "..." --platform youtube`.
- **Bilibili (`bilibili.com`, `BV`/`av`, `b23.tv`) & Douyin (`douyin.com`, `v.douyin.com`)**: metadata preview, full ingest, cross-platform search, and optional account logins.
- **Local files (`.mp4`, `.mkv`, `.webm`, `.mov`, etc.)**: indexed directly from disk without copying media unnecessarily; optional sidecar `.srt`/`.vtt` subtitles supported.
### 2. Built for MCP Agents & DSH Sessions
- **Text-first, pixels on request**: search transcripts and on-screen text first (`video_search`), browse contact sheets (`video_digest`), read transcript ranges (`video_read`), and pull raw frames + matching frame OCR (`video_evidence` / `video_frames`) only for the moments that need visual verification.
- **11 focused MCP tools**: `video_ingest`, `video_digest`, `video_read`, `video_search`, `video_evidence`, `video_frames`, `video_perceive`, `video_discover`, `video_library`, `video_account`, and `video_settings`.
- **Inline visual results**: contact sheets, evidence frames, and Bilibili login QR codes return natively as images inside supporting MCP clients.
### 3. Batch comparison & motion analysis
- **1–10 videos side-by-side**: compare courses, reviews, interviews, or product demos for consensus, contradictions, and unique points.
- **Motion, cuts & UI recordings (`video_perceive`)**: measure shot boundaries, motion peaks, and looping cadence cleanly without flooding context.
### 4. Honest about gaps
- Every answer carries timecodes (`HH:MM:SS`). Unread OCR stays explicitly unknown rather than guessing zero, out-of-range timestamps return clear errors, and caption quality checks fall back to speech recognition if a subtitle track mismatches the audio.
## Local, Cloud & Accounts
- **Subtitles first.** When a linked video has usable captions, MCP's default `media="auto"` reads them immediately and defers the video download until you request frames or visual evidence. Without usable captions, speech recognition can provide a transcript.
- **Offline recognition is optional.** Run `pip install "video2agent[asr]"` or choose **Enable local speech** (「启用本地识别」) in DSH Settings or `video2agent ui`. Download your preferred speech model in Settings when you're ready (`small` is about 464 MB). Local OCR is also optional (`pip install "video2agent[ocr]"`).
- **Cloud is optional.** Connect any OpenAI-compatible ASR/OCR provider (SiliconFlow preset included with a free tier) in `video2agent ui` or via `SILICONFLOW_API_KEY`. Only requested audio or explicit evidence frames are sent. API keys are stored via Windows DPAPI, macOS Keychain, or a `0600` secret file on Linux—never in plain JSON configs or chat logs.
- **Logins are optional.** YouTube and local files require no login. Optional Bilibili QR login unlocks CC/AI subtitles and read-only favorites/history; optional Douyin browser login (`pip install "video2agent[browser]"`) reads your profile, works, favorites, and liked lists.
<h2 id="quick-start-dsh--cli">Quick Start: DSH Plugin & CLI</h2>
**Requirements** · Python 3.11+. The core install downloads about 24 MB and uses under 100 MB of disk space, without OpenCV or Whisper bundled. Video2Agent sets up FFmpeg and FFprobe on demand when media processing first needs them. You can also install them yourself.
```bash
# Install CLI + MCP server
pip install video2agent
# Open the visual Settings UI (Environment check, API keys, models, accounts)
video2agent ui
# Or install as a native DSH plugin
dsh plugin --profile web add dsh-video2agent
```
### Install from source
```bash
git clone https://github.com/Harm0ny-AI/Video2Agent.git
cd Video2Agent
python -m venv .venv
# Windows: .venv\Scripts\activate macOS/Linux: source .venv/bin/activate
pip install -e .
video2agent doctor
video2agent ui --no-open
video2agent ingest "https://youtu.be/jNQXAC9IVRw"
video2agent search "elephants"
```
## How It Works

- **Text first, pixels on request.** Search hits text and OCR first; images load only when checking visual details.
- **Shared state across surfaces.** CLI commands, MCP servers, `video2agent ui`, and the DSH plugin share the exact same local index and credentials under `~/.video2agent`.
- **Bounded context.** Compact digests, capped frame sheets, and cached reads keep multi-video investigations fast and token-efficient.
## Screenshots
**Detailed analysis of a single video**

**Account login cards**

Dark social cards and marketplace assets live in [`docs/assets/`](docs/assets).
## Docs
- [Architecture and invariants](docs/ARCHITECTURE.md)
- [Benchmark method and per-task results](docs/BENCH-VIDEOMME.md)
- [Limits and known failure modes](docs/LIMITS.md)
- [Plugin benchmark: routes, latency, polling](docs/PLUGIN-BENCH.md)
- [Long-video runs](docs/LONG-VIDEO-BENCH.md)
- [Bilibili subtitles and login](docs/BILIBILI-SUBTITLES.md)
- [CLI command reference](docs/ARCHITECTURE.md) · `video2agent --help`
## DSH Marketplace
Also available as a native DSH plugin (`dsh-video2agent`, category `vision`) on the [DSH Plugin Marketplace](https://awesome-dsh-plugin.com/p/Harm0ny-AI/DSH-Video2Agent--packages-dsh-video2agent/).
## Contributing
Issues and PRs are welcome. Start with `CONTRIBUTING.md`; before opening a PR, run:
```bash
python -m unittest discover -s tests -q
ruff check src tests --select E,F,I --ignore E501
node tests/test_plugin_card.mjs
node tests/test_plugin_manifest.mjs
node tests/test_plugin_host_settings.mjs
node tests/test_plugin_campaign.mjs
node tests/test_plugin_dock_state.mjs
```
## License
Apache-2.0. Third-party notices are in [THIRD_PARTY_LICENSES.md](THIRD_PARTY_LICENSES.md).
<p align="center"><sub>If Video2Agent saved you from scrubbing another timeline, a ⭐ helps more agents discover it.</sub></p>
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues