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
| Route | When to Use | Cost |
|---|---|---|
| A Subtitles | Platform has CC/AI subtitles and can provide login cookie | Seconds, cheapest |
| B Local ASR | Default fallback, zero login required | First 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
- Probe metadata + subtitle list:
yt-dlp --list-subs <URL>- If
Available subtitlestable (containingzh-CN/ai-zh) appears = Route A possible; onlydanmaku= no CC/AI subtitles obtainable anonymously.
- If
- 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).
- If login required, add
- Route B get audio (download only audio stream, very small):
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.yt-dlp -f "30232/bestaudio" --no-playlist -o audio.m4a <URL> # Bilibili 30232 ≈76k m4a; YouTube use -f bestaudio - 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-formatwithsrt(tested: 129s audio produces 16 subtitles with timestamps); pure text usetxt. - For long audio, split into segments (≈30 min each) then transcribe segment by segment, avoid a single long run.
- 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.
- 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/v2returns[]forsubtitles,--list-subsonly givesdanmaku. 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/typereturns 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 usehttps://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 (checkdu -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 chromenot tested: Cookie passing is only documented, needs verification first (on macOS, reading browser cookies may trigger TCC/keychain authorization).~/Documents,~/Desktop,~/Downloadsenumeration hangs ≠ directory broken: Tested as macOS TCC permission (the executing process lacks "Documents" folder access); symptom islsoutputs nothing for seconds until timeout, while~/Repositoriesetc. 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) inreferences/example-output.md.