Most YouTube transcript tools either require paid APIs, use suspicious proxies, or just dump raw text without structure. This skill extracts transcripts locally using yt-dlp, preserves timestamps for navigation, detects chapters automatically, and exports to any format you need.
When to Use
User shares a YouTube link and wants to read instead of watch. User asks what someone says about a topic at a specific moment. User needs to extract quotes with timestamps for research or content creation. User wants to summarize a video or search within its content.
How It Works
CODEBLOCK0
The Extraction Process
1. 📋 Get Metadata First
Always fetch video info before extracting subtitles:
CODEBLOCK1
This gives you title, duration, official chapters, and available languages. Use it to confirm the right video and check what subtitles exist.
2. 📝 Prefer Manual Subtitles
Manual (uploaded) subtitles are higher quality than auto-generated:
CODEBLOCK2
Auto-generated transcripts often have errors, missing punctuation, and wrong word boundaries. Manual subtitles are human-verified.
3. 🕐 Preserve Timestamps Always
Every segment must include timestamps. Format: [HH:MM:SS] or [MM:SS] for videos under 1 hour.
Why this matters: Users need to jump to specific moments. "Take me to where they discuss pricing" requires knowing the timestamp.
Output format:
CODEBLOCK3
Chapter Detection
From Video Markers
Many videos have chapter markers embedded. Extract from metadata:
CODEBLOCK4
Smart Detection (No Markers)
When video lacks chapters, detect natural breaks from transcript:
- - Topic changes (semantic shift in content)
- Speaker changes (different voice patterns)
- Explicit transitions ("Now let's talk about...", "Moving on...")
- Long pauses between segments
Search Within Transcripts
When user asks "where do they talk about X":
- 1. Search transcript for keywords and semantic matches
- Return segments with timestamps
- Include surrounding context (10-15 seconds before/after)
Response format:
CODEBLOCK5
Generate clickable links: INLINECODE2
Architecture
Memory lives in ~/youtube-video-transcript/. See memory-template.md for structure.
CODEBLOCK6
Quick Reference
| Topic | File |
|---|
| Setup process | INLINECODE5 |
| Memory template |
memory-template.md |
| Advanced patterns |
patterns.md |
Core Rules
1. Metadata Before Extraction
Always run yt-dlp -j URL first. This confirms the video, shows available languages, and reveals official chapters. Never extract blind.
2. Manual Over Auto
| Subtitle Type | Quality | When to Use |
|---|
| Manual | High | Always try first |
| Auto-generated |
Medium | Fallback only |
Check with yt-dlp --list-subs URL for unfamiliar channels.
3. Timestamps Are Sacred
Never strip timestamps during any operation. They enable navigation, citation, and deep linking into the video.
4. Cache With Consent
| User Response | Action |
|---|
| "Yes, save it" | Cache to ~/youtube-video-transcript/videos/ |
| "No thanks" |
Don't cache, show once |
| Not asked yet | Ask after first extraction |
Always tell user where files are saved and offer to show or delete them.
5. Handle Multiple Languages
If user doesn't specify:
- 1. Check available languages
- Prefer manual over auto
- Default to English
- Report which language was used
CODEBLOCK7
6. Quote Extraction Includes Context
When extracting quotes for research:
- - 10-15 seconds before/after for context
- Exact timestamp for the quote start
- Speaker identification if multiple speakers
7. Transparency on Quality
| Subtitle Type | Tell User |
|---|
| Manual | "Using official subtitles" |
| Auto-generated |
"Using auto-generated (may have errors)" |
| None available | "No subtitles found for this video" |
Export Formats
| Format | Use Case | Command |
|---|
| Markdown | Reading, notes | Default |
| SRT |
Video editors |
--sub-format srt |
| Plain text | Search, grep | Strip timestamps |
| JSON | Programmatic |
--write-info-json |
Common Traps
| Trap | Consequence | Prevention |
|---|
| Not checking subtitles first | Wasted time on unavailable video | Always --list-subs first |
| Ignoring auto-generated quality |
Garbage text with errors | Prefer manual, warn about auto |
| Losing timestamps | Can't navigate video | Never strip in any operation |
| Extracting without metadata | Missing title, chapters | Always fetch
-j first |
| Caching without consent | Privacy violation | Ask before saving |
Quick Commands
| User Says | Action |
|---|
| "Transcribe this video" | Extract + display |
| "What do they say about X?" |
Search + timestamps |
| "Save this transcript" | Cache with confirmation |
| "Export as SRT" | Convert format |
| "Show saved videos" | List ~/youtube-video-transcript/videos/ |
| "Delete video X" | Remove from cache |
Security & Privacy
Data that stays local (with your consent):
- - Transcripts cached in ~/youtube-video-transcript/ (only if you agree)
- Preferences stored locally (only after confirmation)
- No external API calls beyond YouTube's public subtitle endpoints
Transparency guarantees:
- - Always asks before saving transcripts locally
- Tells you where files are saved
- Offers to show or delete saved data anytime
This skill does NOT:
- - Use proxy services or third-party APIs
- Send your queries to external services
- Store credentials or authentication
- Save anything without your explicit consent
Related Skills
Install with
clawhub install <slug> if user confirms:
- -
summarizer — create summaries from any content - INLINECODE16 — generate and edit video subtitles
- INLINECODE17 — advanced video and audio processing
Feedback
- - If useful: INLINECODE18
- Stay updated: INLINECODE19
技能名称: YouTube视频转录
详细描述:
大多数YouTube转录工具要么需要付费API,要么使用可疑的代理,要么直接输出毫无结构的原始文本。本技能使用yt-dlp在本地提取转录,保留时间戳以便导航,自动检测章节,并可导出为你需要的任何格式。
使用场景
用户分享一个YouTube链接,并希望阅读而非观看。用户询问某人在特定时刻对某个话题说了什么。用户需要提取带有时间戳的引文用于研究或内容创作。用户想要总结视频或在视频内容中进行搜索。
工作原理
┌──────────────────────────────────────────────┐
│ YOUTUBE 转录流程 │
└──────────────────────────────────────────────┘
│
┌────────────────────┼────────────────────┐
▼ ▼ ▼
┌─────────┐ ┌──────────┐ ┌─────────┐
│ 视频 │ │ 元数据 │ │ 字幕 │
│ URL │ │ 获取 │ │ 检查 │
└────┬────┘ └────┬─────┘ └────┬────┘
│ │ │
│ youtube.com/ │ 标题、时长、 │ 优先手动,
│ watch?v=... │ 章节、语言 │ 自动作为备选
│ │ │
└───────────────────┴────────────────────┘
│
▼
┌─────────────────┐
│ 提取 + 清理 │
│ VTT → Markdown │
│ 带时间戳 │
└────────┬────────┘
│
┌───────────────┼───────────────┐
▼ ▼ ▼
┌──────────┐ ┌───────────┐ ┌──────────┐
│ 章节 │ │ 搜索 │ │ 导出 │
│ 检测 │ │ 按主题 │ │ MD/SRT/ │
│ 或智能 │ │ 时间戳 │ │ TXT/JSON │
└──────────┘ └───────────┘ └──────────┘
提取过程
1. 📋 首先获取元数据
在提取字幕之前,始终先获取视频信息:
bash
yt-dlp -j VIDEO_URL
这将为你提供标题、时长、官方章节和可用语言。用于确认正确的视频并检查存在哪些字幕。
2. 📝 优先使用手动字幕
手动(上传的)字幕质量高于自动生成的字幕:
bash
优先尝试手动字幕
yt-dlp --write-sub --sub-lang en --skip-download VIDEO_URL
如果手动字幕不可用,则回退到自动生成的字幕
yt-dlp --write-auto-sub --sub-lang en --skip-download VIDEO_URL
自动生成的转录通常包含错误、缺少标点符号以及错误的单词边界。手动字幕是经过人工验证的。
3. 🕐 始终保留时间戳
每个片段都必须包含时间戳。格式:[HH:MM:SS] 或对于时长小于1小时的视频使用 [MM:SS]。
为什么这很重要: 用户需要跳转到特定时刻。带我去他们讨论定价的地方需要知道时间戳。
输出格式:
markdown
[00:00] 欢迎观看这个关于机器学习的视频
[00:15] 今天我们将涵盖三个主要主题
[00:30] 首先,让我们谈谈神经网络
章节检测
来自视频标记
许多视频嵌入了章节标记。从元数据中提取:
bash
yt-dlp -j VIDEO_URL | jq .chapters
智能检测(无标记)
当视频缺少章节时,从转录中检测自然断点:
- - 主题变化(内容的语义转变)
- 说话者变化(不同的声音模式)
- 明确的过渡(现在让我们谈谈..., 接下来...)
- 片段之间的长时间停顿
在转录中搜索
当用户询问他们在哪里谈论X时:
- 1. 在转录中搜索关键词和语义匹配
- 返回带有时间戳的片段
- 包含上下文(前后10-15秒)
响应格式:
找到3处提及机器学习:
[05:23] ...这正是机器学习大放异彩的地方...
上下文:讨论数据处理方法
[12:45] ...传统方法与机器学习...
上下文:比较部分
生成可点击链接:https://youtube.com/watch?v=VIDEO_ID&t=323
架构
记忆存储在 ~/youtube-video-transcript/ 中。结构见 memory-template.md。
~/youtube-video-transcript/
├── memory.md # 偏好设置 + 最近视频
├── videos/ # 缓存的转录(需经同意)
│ └── {video_id}.md # 单个视频数据
└── exports/ # 导出的文件
快速参考
memory-template.md |
| 高级模式 | patterns.md |
核心规则
1. 先获取元数据再提取
始终先运行 yt-dlp -j URL。这可以确认视频、显示可用语言并揭示官方章节。切勿盲目提取。
2. 手动字幕优先于自动字幕
中等 | 仅作为备选 |
对于不熟悉的频道,使用 yt-dlp --list-subs URL 进行检查。
3. 时间戳是神圣的
在任何操作中切勿剥离时间戳。它们支持导航、引用和视频深度链接。
4. 经同意后缓存
| 用户响应 | 操作 |
|---|
| 是的,保存它 | 缓存到 ~/youtube-video-transcript/videos/ |
| 不用了,谢谢 |
不缓存,仅显示一次 |
| 尚未询问 | 首次提取后询问 |
始终告知用户文件保存的位置,并提供显示或删除的选项。
5. 处理多语言
如果用户未指定:
- 1. 检查可用语言
- 优先选择手动字幕而非自动字幕
- 默认使用英语
- 报告使用了哪种语言
bash
yt-dlp --list-subs VIDEO_URL
6. 引文提取包含上下文
为研究提取引文时:
- - 包含前后10-15秒作为上下文
- 提供引文开始的确切时间戳
- 如果有多位说话者,进行说话者识别
7. 质量透明度
使用自动生成的字幕(可能包含错误) |
| 无可用字幕 | 未找到此视频的字幕 |
导出格式
视频编辑器 | --sub-format srt |
| 纯文本 | 搜索、grep | 剥离时间戳 |
| JSON | 编程使用 | --write-info-json |
常见陷阱
| 陷阱 | 后果 | 预防措施 |
|---|
| 未先检查字幕 | 在不可用的视频上浪费时间 | 始终先执行 --list-subs |
| 忽视自动生成的质量 |
包含错误的垃圾文本 | 优先手动字幕,对自动字幕发出警告 |
| 丢失时间戳 | 无法导航视频 | 在任何操作中切勿剥离 |
| 未获取元数据就提取 | 缺少标题、章节 | 始终先获取 -j |
| 未经同意缓存 | 隐私侵犯 | 保存前询问 |
快速命令
| 用户说 | 操作 |
|---|
| 转录这个视频 | 提取 + 显示 |
| 他们关于X说了什么? |
搜索 + 时间戳 |
| 保存这个转录 | 经确认后缓存 |
| 导出为SRT格式 | 转换格式 |
| 显示已保存的视频 | 列出 ~/youtube-video-transcript/videos/ |
| 删除视频X | 从缓存中移除 |
安全与隐私
本地保存的数据(需经你同意):
- - 转录缓存于 ~/youtube-video-transcript/(仅在你同意的情况下)
- 偏好设置本地存储(仅在确认后)
- 除YouTube的公共字幕端点外,无外部