AgentSkillsCN

video-understand

借助智能多供应商回退机制,实现视频理解与转录。适用场景如下:(1) 转录视频或音频内容;(2) 理解包含视觉元素与场景的视频内容;(3) 通过 URL 分析 YouTube 视频;(4) 从本地视频文件中提取信息;(5) 获取视频内容的时间戳、摘要,或解答有关视频内容的问题。系统会根据已配置的 API 密钥,自动选择最合适的供应商——在 ASR 专用供应商之外,优先选用具备完整视频理解能力的模型(如 Gemini 或 OpenRouter)。同时支持按各供应商分别指定模型。

SKILL.md
--- frontmatter
name: video-understand
description: |
  Video understanding and transcription with intelligent multi-provider fallback. Use when: (1) Transcribing video or audio content, (2) Understanding video content including visual elements and scenes, (3) Analyzing YouTube videos by URL, (4) Extracting information from local video files, (5) Getting timestamps, summaries, or answering questions about video content. Automatically selects the best available provider based on configured API keys - prefers full video understanding (Gemini/OpenRouter) over ASR-only providers. Supports model selection per provider.

Video Understanding

Multi-provider video understanding with automatic fallback and model selection.

Quick Start

bash
# Check available providers
python3 scripts/check_providers.py

# Process a video (auto-selects best provider)
python3 scripts/process_video.py "https://youtube.com/watch?v=..."
python3 scripts/process_video.py /path/to/video.mp4

# Custom prompt
python3 scripts/process_video.py video.mp4 -p "List all products shown with timestamps"

# Use specific provider/model
python3 scripts/process_video.py video.mp4 --provider openrouter -m google/gemini-3-pro-preview

# List available models
python3 scripts/process_video.py --list-models

Provider Hierarchy

Automatically selects the best available provider:

PriorityProviderCapabilityEnv VarDefault Model
1GeminiFull videoGEMINI_API_KEYgemini-3-flash-preview
2Vertex AIFull videoGOOGLE_APPLICATION_CREDENTIALSgemini-3-flash-preview
3OpenRouterFull videoOPENROUTER_API_KEYgoogle/gemini-3-flash-preview
4FFMPEGFrames + ASRNone (requires ffmpeg + whisper)scene
5OpenAIASR onlyOPENAI_API_KEYwhisper-1
6AssemblyAIASR + analysisASSEMBLYAI_API_KEYbest
7DeepgramASRDEEPGRAM_API_KEYnova-2
8GroqASR (fast)GROQ_API_KEYwhisper-large-v3-turbo
9Local WhisperASR (offline)Nonebase

Full video = visual + audio analysis. Frames + ASR = extracted screenshots + audio transcription (free, offline). ASR = audio transcription only.

CLI Options

code
python3 scripts/process_video.py [OPTIONS] SOURCE

Arguments:
  SOURCE              YouTube URL, video URL, or local file path

Options:
  -p, --prompt TEXT   Custom prompt for video understanding
  --provider NAME     Force specific provider
  -m, --model NAME    Force specific model
  --asr-only          Force ASR-only mode (skip visual analysis)
  -o, --output FILE   Write JSON to file instead of stdout
  -q, --quiet         Suppress progress messages
  --list-models       Show available models per provider
  --list-providers    Show available providers as JSON

Model Selection

Each provider supports multiple models. Use --list-models to see options:

bash
python3 scripts/process_video.py --list-models

OpenRouter models:

  • google/gemini-3-flash-preview (default) - Fast, free tier
  • google/gemini-3-pro-preview - Higher quality

Gemini models:

  • gemini-3-flash-preview (default) - Latest, fast
  • gemini-3-pro-preview - Highest quality
  • gemini-2.5-flash - Stable production fallback

Local Whisper models:

  • tiny, base (default), small, medium, large, large-v3

FFMPEG modes (frame extraction strategy):

  • scene (default) - Extract frames when scene changes (smart, efficient)
  • keyframe - Extract I-frames only (fastest)
  • interval - Extract frames at regular intervals (predictable)

Quick Reference

TaskReference
Setup & API keyssetup-guide.md
Use Gemini for videogemini.md
Use OpenRouteropenrouter.md
FFMPEG frames (free)ffmpeg-frames.md
ASR providersasr-providers.md
Output JSON schemaoutput-format.md
Video sources & downloadingvideo-sources.md

Verify Setup

bash
python3 scripts/setup.py  # Check dependencies and API keys

Output Format

All providers return consistent JSON:

json
{
  "source": {
    "type": "youtube|url|local",
    "path": "...",
    "duration_seconds": 120.5,
    "size_mb": 15.2
  },
  "provider": "openrouter",
  "model": "google/gemini-3-flash-preview",
  "capability": "full_video",
  "response": "...",
  "transcript": [{"start": 0.0, "end": 2.5, "text": "..."}],
  "text": "Full transcript..."
}

Features

  • Automatic provider selection based on available API keys
  • Model selection per provider with sensible defaults
  • Robust path handling for macOS special characters and unicode
  • Progress output (use -q for quiet mode)
  • File size warnings for API limits
  • Auto-conversion of video formats when needed
  • YouTube URL support (direct or via download)

Requirements

For full video understanding:

bash
pip install google-generativeai  # Gemini
pip install openai               # OpenRouter

For ASR fallback:

bash
brew install yt-dlp ffmpeg       # Video tools
pip install openai               # OpenAI Whisper
pip install groq                 # Groq Whisper
pip install assemblyai           # AssemblyAI
pip install deepgram-sdk         # Deepgram
pip install openai-whisper       # Local Whisper