Video Analysis
Use this skill to turn an authorized video file or direct video URL into a timestamped, auditable report. Remote models do not receive the raw MP4/WebM stream. This workflow decodes the video locally, extracts timestamped JPEG frames and speech transcription, and—only when explicitly configured—sends frames to a selected vision provider and text evidence to a selected synthesis provider.
Authorized inputs only
Accept any of:
- A local video file that the user is authorized to analyze.
- A public, direct
http://orhttps://media URL, such as a public.mp4or.webmresource. - With
--allow-platform, a public video-platform page (for example a Bilibili or YouTube watch link). The skill fetches the single public video withyt-dlpand then processes it locally.
Platform-page fetching is deliberately narrow and these limits are not to be weakened:
- Public, anonymously accessible videos only. Never send cookies, passwords, or authenticated headers; never log in; never access member-only, private, friend-only, or age-gated content.
- No DRM circumvention. DRM-protected streams are refused with an honest error, not decrypted.
- Single video per run (
--no-playlist); no batch scraping, playlists, or channels. - The user remains responsible for the platform's terms of service and for being authorized to analyze the content.
If a platform video requires login or membership, do not work around it: ask the user for an authorized original file, a direct public export, or the platform's official API/export route.
The URL fetcher blocks local, private, link-local, reserved, and metadata-service addresses. Do not weaken these checks.
Workflow
Run the preflight check before installing or running the pipeline:
python "$HOME/.claude/skills/video-analysis/scripts/preflight.py" --jsonOn Windows, use the full path if
$HOMEis not expanded by the active shell.Explain any missing prerequisites instead of silently installing packages or adding secrets. The pipeline needs
ffmpegandffprobe; full transcription requiresfaster-whisper; remote semantic stages require the officialopenaiPython SDK plus the provider-specific environment key selected by the user; platform-page fetching with--allow-platformrequiresyt-dlp.Choose providers. Remote stages are disabled by default, but a user-supplied OpenAI-compatible endpoint is the simplest configuration: an API key, a base URL, and a model name are enough. Pass
--custom-base-urland--custom-modelplus the key via theCUSTOM_API_KEYenvironment variable (or--custom-api-key-envif the key already lives in another variable). When all three are present and no provider flags are given, the pipeline auto-selects the custom provider for both vision and synthesis. Any model that accepts image input works; the pipeline verifies this with a single test image before sending frame batches, and a text-only model degrades to an honest local report instead of failing.Otherwise choose providers explicitly:
--vision-provider {none,openai,xai,custom}controls frame interpretation.customtargets a user-supplied OpenAI-compatible endpoint with an explicit model name; the model must support image input.--synthesis-provider {none,openai,xai,deepseek,custom}controls the text report. DeepSeek hosted API is text-only and never receives images.- API keys come only from environment variables:
OPENAI_API_KEY,XAI_API_KEY,DEEPSEEK_API_KEY, orCUSTOM_API_KEY(name configurable via--custom-api-key-env).
Run the analyzer. Start from a local file when possible:
python scripts/analyze_video.py --input "C:\videos\demo.mp4" --output-dir "C:\video-results\demo" --frame-interval 3 --vision-provider openai --synthesis-provider deepseek --keep-artifactsFor an authorized direct URL:
python scripts/analyze_video.py --url "https://media.example.com/public-demo.mp4" --output-dir "./video-results/public-demo" --max-download-bytes 262144000 --vision-provider xai --synthesis-provider openaiFor a public video-platform page (single public video, no login/cookies; requires
yt-dlp):python scripts/analyze_video.py --url "https://www.bilibili.com/video/BVxxxxxxxxxx/" --output-dir "./video-results/platform-demo" --allow-platform --language zh --skip-visionFor a custom OpenAI-compatible endpoint (key, endpoint, and model supplied by the user). If the user gives you the API key directly, set it inline on the command instead of persisting it anywhere, and never echo it into the report:
CUSTOM_API_KEY="<key the user supplied>" python scripts/analyze_video.py --input "C:\videos\demo.mp4" --output-dir "C:\video-results\demo" --custom-base-url https://api.relay.example/v1 --custom-model gpt5.6-luna--custom-modelapplies to both stages; with the key set, the custom provider is auto-selected for vision and synthesis. To use different models per stage, spell them out with--vision-provider custom --vision-model <name> --synthesis-provider custom --synthesis-model <name>.In PowerShell, use
$env:CUSTOM_API_KEY="<key>"; python scripts/analyze_video.py ...instead. Use--custom-api-key-env OTHER_VARif the key already lives in a differently named environment variable. The model must accept image input for the vision stage; the pipeline verifies this with a single test image before sending frame batches.Read
analysis.jsonandreport.mdfrom the output directory. Cite time ranges when describing the video. If the report lists missing modalities, state that limitation rather than inventing content.
Runtime behavior
ffprobechecks duration and streams before processing.- With
--allow-platform, a URL that serves HTML instead of direct media is fetched as a single public video viayt-dlp(--no-playlist, size and duration caps applied, no cookies or login ever). Login-gated, member-only, private, or DRM-protected content is refused with a clear limitation instead of being bypassed. The report's provenance records that the media came from platform extraction. ffmpegproduces a 16 kHz mono WAV and bounded JPEG key frames. Default sampling is every 3 seconds, which is suitable for typical short videos; use 1–2 seconds for UI/PPT tutorials and 3–5 seconds for talking-head videos.faster-whispercreates timestamped transcript segments. ASR failures are reportable but nonfatal: the pipeline writes an emptytranscript.jsonand continues with any available visual evidence.- When
--vision-provider openaior--vision-provider xaiis selected, the officialopenaiPython SDK sends batches of JPEG frames as Base64 data URLs to the selected model. Each returned observation is forced back to the locally generated source timestamp. - When
--vision-provider customis selected, the user-supplied OpenAI-compatible endpoint receives the same JPEG frames via Chat Completionsimage_urlcontent parts. Before batching, the pipeline submits one test image to confirm the named model actually accepts image input; if the endpoint rejects it, frame interpretation is aborted with a clear limitation instead of failing every batch. - When a custom base URL, model name (
--custom-modelor per-stage models), and the custom API key are all supplied without explicit provider flags, both stages auto-select the custom provider; the auto-selection is disclosed in the report limitations and provenance. - When
--synthesis-provider openai,xai,deepseek, orcustomis selected, only the text timeline evidence is sent to that provider. DeepSeek and custom synthesis never receive images. - A selected provider failure degrades to the deterministic local report. It never silently switches to another vendor or sends artifacts elsewhere.
- The pipeline aligns transcript and visual observations into five-minute timeline windows and generates a final JSON report plus readable Markdown.
- The default maximum video duration is 10 minutes. For a longer authorized source, increase
--max-durationdeliberately and use--segment-seconds 300; the report remains split into time windows. Do not attempt frame-by-frame processing.
Offline and staged verification
Use both skip flags to verify decoding and outputs without model credentials or an ASR model:
python scripts/analyze_video.py
--input sample.mp4
--output-dir ./video-results/offline-check
--skip-asr --skip-vision
This is an offline media-pipeline check, not a video understanding result. It creates media.json, frames.json, timeline.json, analysis.json, and report.md, and marks audio and visual interpretation as unavailable.
Output contract
The output directory contains:
media.json— ffprobe metadata and source information.transcript.json— ASR segments with timestamps, when ASR ran.frames.json— key-frame paths and estimated source timestamps.vision.json— provider frame observations and batch errors, when vision ran.timeline.json— merged time windows.analysis.json— title, summary, chapters, key moments, limitations, and provenance.report.md— user-readable report.
Temporary downloaded media, WAV audio, and frames are removed unless --keep-artifacts is supplied. A caller-supplied local source video is never deleted.
Failure handling
- Treat blocked URL, download, platform-fetch refusal (login/member/DRM),
ffprobe, ASR, Vision, and synthesis errors as separate reportable failures. - Keep successfully produced JSON artifacts when a later stage fails.
- Do not claim an end-to-end analysis succeeded when a modality was skipped, unavailable, or failed.
- Before a real external URL run, tell the user that it downloads media and may use ASR compute plus credits from the explicitly selected OpenAI, xAI, DeepSeek, or custom providers.




