设计与多媒体

Video Understanding

用 Gemini 分析视频 URL 或本地文件,输出结构化 JSON:逐字稿、画面描述、摘要、说话人和问答。

它能做什么

一个 Python CLI,把视频 URL(YouTube、Loom、TikTok、X、Vimeo 以及 yt-dlp 支持的 1000+ 站点)或本地文件交给 Google Gemini 多模态模型处理。默认返回 JSON:带 [MM:SS] 时间戳的逐字稿、画面描述、2-3 句摘要、估算时长和说话人识别。加 -q 可以针对视频提问;配合 --session-key 和 --reuse-file-cache 能在同一会话里复用 Gemini File API 句柄,省去重复上传。需要 GEMINI_API_KEY、yt-dlp、ffmpeg 和 Python 3.10+ 加 uv。

什么时候用它

  • 总结或转录聊天里分享的 YouTube 视频
  • 针对 Loom 或 TikTok 视频问具体问题
  • 从本地录屏里抽取说话人、逐字稿和画面信息
  • 在同一个 Slack 会话里对同一视频做多轮追问

技能文档

Video Understanding (Gemini)

Analyze videos using Google Gemini's multimodal video understanding. Supports 1000+ video sources via yt-dlp.

Requirements

  • Python 3.10+ with uv
  • yt-dlpbrew install yt-dlp / pip install yt-dlp
  • ffmpegbrew install ffmpeg (for merging video+audio streams)
  • GEMINI_API_KEY environment variable

Trigger Rule

Use this skill first whenever the user provides a video URL, YouTube link, or video file. The trigger is the video input itself, not whether the user explicitly says "Gemini," "analyze," or "transcribe."

Casual asks like "watch this," "look at this," "what is this?," "you laugh," or "what happens here?" still require this skill.

Gotchas

  • If the skill cannot run because GEMINI_API_KEY or another dependency is missing, report that blocker before falling back to local extraction.
  • Requires yt-dlp and ffmpeg installed (sanity-check with which yt-dlp / which ffmpeg).
  • Gemini File API uploads are reusable for follow-up questions while ACTIVE, but expire after about 48 hours.
  • Gemini explicit CachedContent can speed repeated questions, but has model-specific minimum token counts and storage billing.
  • The analyze script downloads non-YouTube videos locally first unless a valid cached Gemini file handle is reused.
  • YouTube age-restricted or private videos require authentication cookies.

Default Output

Returns structured JSON:

  • transcript — Verbatim transcript with [MM:SS] timestamps
  • description — Visual description (people, setting, UI, text on screen, flow)
  • summary — 2-3 sentence summary
  • duration_seconds — Estimated duration
  • speakers — Identified speakers

Usage

Analyze a video (structured JSON output)

uv run {baseDir}/scripts/analyze_video.py "https://example.com/video.mp4"

Local video files work too:

uv run {baseDir}/scripts/analyze_video.py "/path/to/video.mp4"

Ask a question (adds "answer" field)

uv run {baseDir}/scripts/analyze_video.py "https://example.com/video.mp4" -q "What product is shown?"

Continue questions against the same video

Use a stable --session-key for the conversation or Slack thread. --reuse-file-cache keeps and reuses an ACTIVE Gemini File API handle instead of re-uploading; stale handles automatically fall back to a fresh upload/download.

uv run {baseDir}/scripts/analyze_video.py "https://example.com/video.mp4" --session-key "slack-thread-123" --reuse-file-cache -q "Summarize this"
uv run {baseDir}/scripts/analyze_video.py "https://example.com/video.mp4" --session-key "slack-thread-123" --reuse-file-cache --continue-chat -q "What happens after the pricing screen?"

For long videos with repeated follow-ups, add --use-context-cache to try Gemini explicit CachedContent. If Gemini rejects caching, the script falls back to File API reuse.

uv run {baseDir}/scripts/analyze_video.py "https://example.com/video.mp4" --session-key "slack-thread-123" --reuse-file-cache --use-context-cache --cache-ttl-seconds 3600 -q "Find all UI errors"

Override prompt entirely

uv run {baseDir}/scripts/analyze_video.py "https://example.com/video.mp4" -p "Custom prompt" --raw

Download only (no analysis)

uv run {baseDir}/scripts/analyze_video.py "https://example.com/video.mp4" --download-only -o video.mp4

Options

FlagDescriptionDefault
-q / --questionQuestion to answer (added to default fields)none
-p / --promptOverride entire prompt (ignores -q)structured JSON
-m / --modelGemini modelgemini-2.5-flash
--fallback-modelOptional fallback model for transient Gemini errorsnone
-o / --outputSave output to filestdout
--keepKeep downloaded video filefalse
--download-onlyDownload only, skip analysisfalse
--max-sizeMax file size in MB500
--rawRaw text output instead of JSONfalse
--reuse-file-cacheKeep/reuse Gemini File API upload handles for follow-upsfalse
--use-context-cacheTry Gemini explicit CachedContent for repeated questionsfalse
--cache-ttl-secondsTTL for explicit CachedContent3600
--cache-dirLocal directory for cache records~/.openclaw/cache/video-understanding
--session-keyConversation/thread key for follow-up reusenone
--continue-chatInclude prior cached outputs as follow-up contextfalse
--purge-cacheDelete cached Gemini handles for this asset/sessionfalse

How It Works

  1. Local video files → Uploaded directly to Gemini File API
  2. YouTube URLs → Passed directly to Gemini (no download needed)
  3. All other URLs → Downloaded via yt-dlp → uploaded to Gemini File API → poll until processed
  4. With --reuse-file-cache, valid Gemini file handles are reused for follow-up questions; expired/deleted handles trigger a fresh upload/download
  5. With --use-context-cache, the script tries Gemini CachedContent and falls back to File API reuse if caching is unavailable
  6. Gemini analyzes video with structured prompt → returns JSON
  7. Temp local files are cleaned up automatically; remote Gemini uploads are deleted unless reuse/cache mode is enabled

Supported Sources

Any URL supported by yt-dlp: Loom, YouTube, TikTok, Vimeo, Twitter/X, Instagram, Dailymotion, Twitch, and 1000+ more.

Tips

  • Use -q for targeted questions on top of the full analysis
  • Use --session-key plus --reuse-file-cache for Slack-thread follow-ups so Loom/local videos are not re-uploaded every turn
  • Use --continue-chat when the follow-up relies on prior wording like "that screen" or "the second speaker"
  • Use --purge-cache when done with a sensitive video to delete the remote Gemini handles
  • YouTube is fastest (no download step)
  • YouTube follow-ups resend the public URL and optional prior context; there is no documented durable YouTube asset handle
  • Transient Gemini 503/high-demand errors are retried; set --fallback-model only when that model has quota on the account
  • Large videos (10min+) work fine — Gemini File API supports up to 2GB (free) / 20GB (paid)
  • The script auto-installs Python dependencies via uv

常见问题

默认返回什么?
一个 JSON 对象:带 [MM:SS] 时间戳的逐字稿、画面描述、2-3 句摘要、估算时长和说话人识别。加 -q 会再追加一个 answer 字段。
支持 YouTube 以外的链接吗?
支持。YouTube URL 直接走 Gemini;其他 yt-dlp 站点(Loom、TikTok、X、Vimeo、Instagram、Twitch、Dailymotion 等)会先下载到本地,再上传到 Gemini File API。
运行需要什么环境?
Python 3.10+ 加 uv、yt-d

相关技能

把 YouTube 视频整理成带章节、时间戳和要点的 Markdown 摘要

59 次安装1 星标

通过 CellCog SDK 生成 YouTube 视频、Shorts、缩略图和脚本。

102 次安装11 星标

汇总过去 30 天 Reddit、X、YouTube 和网页上关于某个话题的真实讨论。

110 次安装

一条提示词生成最长 4 分钟的视频 —— 自动完成脚本、配音、配乐与剪辑。

299 次安装24 星标

压缩任意来源,保留每一条论断、对冲、数值与归属。

239 次安装4 星标