Empowering AI Agents to actually see and hear YouTube videos.
Adaptive Scene Extraction β’ Audio-Visual Timeline Alignment β’ Dual-Mode AI Engine β’ MCP Server & Agent Skill
Almost every existing "YouTube AI" tool relies solely on scraping speech transcripts.
For coding tutorials, tech keynotes, architecture discussions, and product reviews, transcripts only contain half the story:
- β Presenters rarely read out their code line-by-line: "As you can see here, we change this line..." (An audio-only AI has no idea what changed).
- β Architecture diagrams & charts are invisible: High-level designs shown on slides are completely lost.
- β Terminal errors & UI interactions are ignored: Button clicks, console outputs, and debug logs are visual events.
- β Naive 1-FPS frame dumpers blow token budgets: A 10-minute video at 1 FPS yields 600 images (~600,000 vision tokens), overwhelming context windows and generating massive API bills.
YouTube Vision Skill solves this completely.
YouTube Vision Skill treats YouTube videos as true multimodal streams:
- Smart Media Pipeline: Uses
yt-dlpto download bandwidth-optimized streams (480p/720p) with native time-slice trimming (start_time,end_time) so you never download hours of video just to inspect a 2-minute section. - Adaptive Scene Extraction: Zero dumb 1-FPS dumping. Uses visual difference algorithms (HSV histogram distance + FFmpeg scene filters) with temporal guardrails (min interval 1.5s, max interval 30s) to only capture frames when the screen actually changes (slide switch, IDE file change, terminal output). Compresses to WebP for 70-80% token savings over PNG.
- Zero-Cost Subtitle & Whisper Pipeline: Automatically checks for official human subtitles first (instant, free). If unavailable, falls back to sub-second timestamped transcription via Groq Whisper Large v3 or local faster-whisper.
- Timeline Alignment: Synchronizes extracted WebP frames with the exact spoken dialogue on a structured timeline.
- Dual-Mode AI Engine:
- Mode 1 (Frame + Audio Pipeline): Feeds interleaved WebP frames and speech context into OpenAI (GPT-4o), Anthropic (Claude 3.5 Sonnet), or Local VLMs (Ollama Qwen2-VL / Llama 3.2-Vision).
- Mode 2 (Native Video API): Leverages Google Gemini 2.5 Flash / Pro File API for end-to-end native video understanding.
- Built for Agents: Ready out-of-the-box as an MCP Server (Model Context Protocol), Agent Skill (
SKILL.md), Python SDK, and interactive CLI.
flowchart TD
User["AI Agent / User (Claude, Cursor, Antigravity, CLI)"] -->|MCP / SDK / CLI| Orch["YouTube Vision Orchestrator"]
subgraph Pipeline["Smart Media Pipeline"]
Orch -->|yt-dlp with Time Slice| Downloader["Smart Downloader (480p/720p)"]
Downloader --> VideoStream["Video Stream (MP4)"]
Downloader --> AudioStream["Audio Stream (MP3)"]
end
subgraph Visual["Adaptive Visual Processing"]
VideoStream --> SceneDetector["Adaptive Scene Detector (OpenCV / FFmpeg)"]
SceneDetector -->|Threshold gt 0.25 + Guardrails| WebPCompress["WebP Compression (Max 1280px, Q80)"]
WebPCompress --> Frames["Key Scene Frames (.webp)"]
end
subgraph Audio["Audio & Speech Processing"]
AudioStream --> Transcriber["Audio Transcriber"]
Transcriber -->|Priority 1| OfficialSubs["Official Human Subtitles"]
Transcriber -->|Priority 2 Fallback| GroqWhisper["Groq Whisper Large v3"]
Transcriber -->|Priority 3 Fallback| LocalWhisper["faster-whisper / Auto Captions"]
OfficialSubs --> Transcript["Timestamped Dialogue"]
GroqWhisper --> Transcript
LocalWhisper --> Transcript
end
Frames --> Aligner["Timeline Aligner (Context Engine)"]
Transcript --> Aligner
Aligner --> AlignedTimeline["Multimodal Timeline: [{ timestamp, frame_webp, speech_text }]"]
subgraph Inference["Dual-Mode AI Engine"]
AlignedTimeline -->|Mode 1: Interleaved Frames + Audio| VLM["Vision LLMs: OpenAI GPT-4o / Claude 3.5 / Ollama"]
VideoStream -->|Mode 2: Native Video File API| Gemini["Google Gemini 2.5 Flash / Pro"]
end
VLM --> Output["Structured Multimodal Analysis (Code OCR, UI Insights, Verification)"]
Gemini --> Output
| Feature | Naive Transcript Scraper | Naive 1-FPS Frame Dumper | YouTube Vision Skill |
|---|---|---|---|
| Reads On-Screen Code / IDE | β No | β Yes | π Yes (Crisp Monospace OCR) |
| Captures Architecture Slides | β No | β Yes | π Yes (Only when slide changes) |
| 10-Min Video Vision Tokens | 0 tokens | ~600,000 tokens (Costly) | β‘ ~15,000 - 35,000 tokens (85% savings) |
| Time-Slice Trimming | β Full download | β Full download | β‘ Yes (yt-dlp download_ranges) |
| Speech-to-Visual Alignment | β None | β Manual | π Automatic Timeline Alignment |
| Model Context Protocol (MCP) | β No | β No | π Native MCP Server Included |
| Local Offline LLM Support | β No | π Yes (via Ollama Qwen2-VL) |
# Clone the repository
git clone https://github.com/your-username/youtube-vision-skill.git
cd youtube-vision-skill
# Install dependencies (FFmpeg is automatically handled via imageio-ffmpeg!)
pip install -e ".[all]"Copy .env.example to .env and insert your desired API keys:
cp .env.example .env# Optional: Mode 2 Native Gemini
GEMINI_API_KEY=your_gemini_key
# Optional: Mode 1 Whisper transcription fallback (Groq is ultra-fast & free tier available)
GROQ_API_KEY=your_groq_key
# Optional: Mode 1 Vision LLMs
OPENAI_API_KEY=your_openai_key
# or ANTHROPIC_API_KEY=your_anthropic_key
# or OLLAMA_BASE_URL=http://localhost:11434/v1# 1. Watch and analyze a video clip (with speech + visual understanding)
youtube-vision watch "https://www.youtube.com/watch?v=dQw4w9WgXcQ" --start "01:00" --end "03:30"
# 2. Focus on a specific technical question
youtube-vision watch "https://youtu.be/..." --focus "Extract the Docker Compose file shown"
# 3. Extract high-resolution frames around a specific timestamp for code reading
youtube-vision extract "https://youtu.be/..." --timestamp "04:12" --duration 10
# 4. Search for a specific topic or keyword across the video
youtube-vision search "https://youtu.be/..." --query "FastAPI dependency injection"
# 5. Start the MCP Server
youtube-vision mcpConnect YouTube Vision Skill directly to Claude Desktop, Cursor, or Antigravity.
Add this to your claude_desktop_config.json:
{
"mcpServers": {
"youtube-vision": {
"command": "python",
"args": ["-m", "youtube_vision.server.mcp_server"],
"cwd": "/path/to/youtube-vision-skill",
"env": {
"GEMINI_API_KEY": "your_gemini_key",
"GROQ_API_KEY": "your_groq_key",
"OPENAI_API_KEY": "your_openai_key"
}
}
}
}Now you can prompt Claude:
"Claude, can you watch
https://www.youtube.com/watch?v=...from minute 02:15 to 04:30 and tell me what code the instructor typed in themain.pyfile?"
Claude will invoke watch_video_overview and extract_visual_details autonomously!
from youtube_vision import YouTubeVisionOrchestrator
orchestrator = YouTubeVisionOrchestrator()
# Analyze a video segment
result = orchestrator.watch_video_overview(
url="https://www.youtube.com/watch?v=your_video_id",
start_time="02:00",
end_time="04:30",
mode="auto",
focus_prompt="What database schema is shown on the whiteboard?"
)
print(result["summary"])
# Extract high-res WebP frame at exact second
details = orchestrator.extract_visual_details(
url="https://www.youtube.com/watch?v=your_video_id",
timestamp="03:45",
high_res=True
)
print("Saved high-res frame to:", details["primary_frame"])| Tool Name | Purpose | When the Agent Uses It |
|---|---|---|
watch_video_overview |
Full or clipped multimodal analysis | Getting the big picture, understanding slide decks, or watching a multi-minute tutorial section. |
extract_visual_details |
High-res frame extraction (1080p WebP) | Reading small monospace code in IDEs, terminal command outputs, or inspecting fine UI details. |
search_in_video |
Semantic/keyword time anchor search | Finding the exact minute a concept was mentioned before diving deeper with visual tools. |
youtube-vision-skill/
βββ .env.example # Configuration template with provider keys
βββ pyproject.toml # Package dependencies & CLI entrypoints
βββ SKILL.md # Agent Skill specification file
βββ README.md # Project documentation
βββ src/
β βββ youtube_vision/
β βββ __init__.py # Public API exports
β βββ config.py # Settings with env overrides
β βββ cli.py # CLI commands (watch, extract, search, mcp)
β βββ core/
β β βββ models.py # Pydantic data schemas
β β βββ ffmpeg_utils.py # Cross-platform FFmpeg locator & runner
β β βββ downloader.py # yt-dlp with time-slice trimming & 720p cap
β β βββ scene_detector.py# Adaptive Scene Extraction (OpenCV / FFmpeg)
β β βββ audio_transcriber.py # Official Subs -> Groq Whisper fallback
β β βββ timeline.py # Audio-Visual timeline alignment
β β βββ orchestrator.py # Central workflow coordinator
β βββ engines/
β β βββ base.py # Abstract Vision Engine
β β βββ frame_audio.py # Mode 1: Interleaved Frames + Audio (GPT-4o/Claude/Ollama)
β β βββ native_gemini.py # Mode 2: Native Gemini Video API
β βββ server/
β βββ __init__.py
β βββ mcp_server.py # FastMCP Server implementation
βββ tests/
βββ test_models.py # Timestamp parser and model tests
βββ test_scene_detector.py # Synthetic video adaptive scene test
βββ test_timeline.py # Alignment & search tests
Contributions are welcome!
- Fork the repository
- Create your feature branch (
git checkout -b feature/awesome-feature) - Commit your changes (
git commit -m 'Add awesome feature') - Run tests:
pytest - Push to the branch (
git push origin feature/awesome-feature) - Open a Pull Request
Distributed under the MIT License. See LICENSE for details.
