Video Transcribe
Extract text from video links (Douyin, Bilibili, YouTube, Kuaishou, etc.) with timestamps.
Dependencies
pip install yt-dlp openai-whisper
winget install ffmpeg # Windows
# brew install ffmpeg # macOS
# sudo apt install ffmpeg # Linux
First-time Setup
Model cache directory (recommended: non-system drive)
Whisper large-v3 model is ~2.9GB. Set cache to a non-system drive:
# Windows PowerShell (permanent, User-level):
[Environment]::SetEnvironmentVariable("WHISPER_DOWNLOAD_ROOT", "X:\whisper_cache", "User")
# macOS/Linux (~/.zshrc or ~/.bashrc):
export WHISPER_DOWNLOAD_ROOT="~/whisper_cache"
Video download directory (optional)
# Windows PowerShell:
[Environment]::SetEnvironmentVariable("VIDEO_DOWNLOAD_DIR", "X:\video_downloads", "User")
# macOS/Linux:
export VIDEO_DOWNLOAD_DIR="~/video_downloads"
yt-dlp global config (optional)
# Windows: Create %APPDATA%\yt-dlp\config (one line):
-o X:\video_downloads\%(title)s.%(ext)s
# macOS/Linux: Create ~/.config/yt-dlp/config (one line):
-o ~/video_downloads/%(title)s.%(ext)s
Usage
Agent call
python transcribe.py "<video_url>" [model] [prompt]
model:large-v3(default, best quality) orturbo(faster)prompt: optional context hint for better recognition
Manual use
python transcribe.py "<video_url>"
Output
- Segmented text: with timestamps for editing
[0.0s-8.0s] Text here... [8.0s-20.0s] More text... - Full text: plain text for copying
- Video file: saved to download directory
Supported Platforms
yt-dlp supports 1000+ sites: Douyin, TikTok, Bilibili, YouTube, Kuaishou, Weibo, Xiaohongshu, Xigua Video, etc.
Notes
- CPU-only, no GPU required
- large-v3: ~77s per minute of video on CPU
- Chinese text optimized with punctuation
- Models stored in
WHISPER_DOWNLOAD_ROOTdirectory - If env vars not set, defaults to script directory
