Communitygithub.com

flmaximwang/AgentSkill-WatchingVideo

Transcribes and summarizes video/audio content (Bilibili/YouTube/local files) into text, chapters, or key points.

What is AgentSkill-WatchingVideo?

This skill enables an AI agent to process video or audio content from platforms like Bilibili, YouTube, or local files (mp4/mp3). It first checks for available subtitles (CC/AI) from the platform. If subtitles are available and the agent has cookies for authenticated access, it downloads them directly for near-instant results. Otherwise, it falls back to local Automatic Speech Recognition (ASR) using `mlx-whisper`, optimized for Apple Silicon (M-series) hardware. The skill handles transcription, produces summaries or structured outputs such as chapters, key points, threads, or blog posts based on user preferences, and integrates with Obsidian for note-taking (e.g., investment notes). It relies on a toolchain including `yt-dlp`, `mlx-whisper`, and `ffmpeg`, all installed via `uv`. The skill is backed by real-world testing, documenting pitfalls like anonymous Bilibili access lacking subtitles, rate-limiting on search endpoints, and macOS TCC permission issues. It supports Bilibili (BV/av links), YouTube (youtu.be links), and local media files.

Works with~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/flmaximwang/AgentSkill-WatchingVideo/tree/HEAD/skills/video-transcript-summarization

Ask in your favorite AI

Open a new chat with this agent skill pre-loaded.

Documentation

Video/Audio → Transcription → Summary

Convert videos (Bilibili/YouTube) or local audio/video files into text, then output summaries/chapters/key points in the format requested by the user. Core: First check for available subtitles, then decide whether to use ASR.

When to Use

  • User provides a video/audio link or file (BV number/av number, Bilibili or youtu.be link, local mp4/mp3) requesting "summarize / what was said / transcribe / extract key points"
  • Archive a creator's video content into notes (e.g., investment videos → use with obsidian-investment-notes)
  • Need verbatim transcripts or timestamped chapters as input for subsequent analysis, backtesting, or review
  • Default output is a summary; if user specifies a format (chapters/thread/blog/introduction), output accordingly

Toolchain (one-time install, binaries go to ~/.local/bin)

uv tool install yt-dlp          # Download + platform parsing (includes wbi signing, more stable than hand-written API)
uv tool install mlx-whisper     # Apple Silicon local ASR (M-series)
export PATH="$HOME/.local/bin:$PATH"
export PATH="$PATH:$(ls -d $HOME/.hermes/tools/ffmpeg-* | head -1)"   # mlx_whisper depends on ffmpeg for audio decoding

The ffmpeg directory name includes a version number that changes, use ls -d ~/.hermes/tools/ffmpeg-* dynamically, do not hardcode.

Route to Text: Choose First, Then Act

RouteWhen to UseCost
A SubtitlesPlatform has CC/AI subtitles and can provide login cookieSeconds, cheapest
B Local ASRDefault fallback, zero login requiredFirst model download 708M; M1 measured: tiny ≈35×, large-v3-turbo ≈18× real-time

Tested: Bilibili cannot get subtitles anonymously (--list-subs only lists danmaku), but audio streams can be downloaded anonymously → without cookies, default to Route B, do not waste time on subtitles.

Steps

  1. Probe metadata + subtitle list: yt-dlp --list-subs <URL>
    • If Available subtitles table (containing zh-CN/ai-zh) appears = Route A possible; only danmaku = no CC/AI subtitles obtainable anonymously.
  2. Route A download subtitles: yt-dlp --write-subs --sub-langs "ai-zh,zh-CN" --skip-download -o subs <URL>
    • If login required, add --cookies-from-browser chrome (or --cookies cookies.txt).
  3. Route B get audio (download only audio stream, very small):
    yt-dlp -f "30232/bestaudio" --no-playlist -o audio.m4a <URL>   # Bilibili 30232 ≈76k m4a; YouTube use -f bestaudio
    
    Measured: Bilibili 129s video audio only 1.17 MiB, downloaded in 1.7s (4.9 MiB/s) — audio size about 0.5 MB/min, long videos are fine.
  4. Transcribe:
    mlx_whisper audio.m4a --model mlx-community/whisper-large-v3-turbo \
      --language zh --initial-prompt "以下是普通话的句子,请输出简体中文。" \
      --output-format txt --output-dir out
    
    • Chinese output must use large-v3-turbo (tiny only for pipeline verification). Measured: turbo: 129.4s audio → 7.2s wall clock (≈18× real-time, includes model loading), model 708M downloaded once and reused.
    • For timestamped chapters, replace --output-format with srt (tested: 129s audio produces 16 subtitles with timestamps); pure text use txt.
    • For long audio, split into segments (≈30 min each) then transcribe segment by segment, avoid a single long run.
  5. Summarize: Default output summary; when user specifies, produce timestamped chapters / key points list / thread / blog.
    • If transcript >50K characters, chunk first (≈40K with 2K overlap), summarize each chunk, then merge.
  6. Save: Investment videos additionally extract fields like "target / signal / position / stop-loss / time"; note formatting follows obsidian-investment-notes (signal day, source, frontmatter v2 as defined there).

Pitfalls (tested)

  • Bilibili anonymous has no subtitles: x/player/v2 returns [] for subtitles, --list-subs only gives danmaku. Need SESSDATA for CC/AI subtitles; without cookie, directly use ASR.
  • 1080P+ high-bitrate requires membership cookie, but audio streams are unaffected — audio route needs no login.
  • Bilibili search API anonymous gets rate-limited: x/web-interface/wbi/search/type returns 412 / v_voucher. Use yt-dlp's built-in search (with wbi signing): yt-dlp --flat-playlist --print "%(id)s|%(url)s" "bilisearch5:keyword"; second consecutive call gets 412, add sleep seconds between calls, and use https://www.bilibili.com/video/av<id> to access retrieved IDs.
  • whisper tiny unusable for Chinese: It transcribes "成长股价值" as "成長武士戒". Always use large-v3-turbo for Chinese; if output is traditional/simplified incorrectly, use --initial-prompt "以下是普通话的句子,请输出简体中文." to enforce simplified Chinese.
  • Model 708M (not 1.6G, measured by du -sh), don't wait in foreground: Run as background task + notify; HF cache supports resuming, if killed by foreground timeout, rerun resumes (check du -sh ~/.cache/huggingface/hub/models--mlx-community--* to see progress).
  • mlx_whisper decoding depends on ffmpeg in PATH, otherwise it errors directly.
  • --cookies-from-browser chrome not tested: Cookie passing is only documented, needs verification first (on macOS, reading browser cookies may trigger TCC/keychain authorization).
  • ~/Documents, ~/Desktop, ~/Downloads enumeration hangs ≠ directory broken: Tested as macOS TCC permission (the executing process lacks "Documents" folder access); symptom is ls outputs nothing for seconds until timeout, while ~/Repositories etc. list normally. Grant "Full Disk Access" to the executing process to access vault.

Work Discipline (User Preferences)

  • Always present a complete plan for confirmation before executing; do not rush. However, exploratory testing (probing endpoints/testing pipelines) can be done directly, as it feeds conclusions.
  • Conclusions must be based on measured data (size/time/API response codes), not guesses.
  • Platform API details in references/bilibili-anonymous-access.md; output format examples (including investment signal field extraction) in references/example-output.md.

Individual skills in this repo

This repo contains 2 individual skills — each has its own dedicated page.

Related Skills