Media & Image v1.0.0

youtube-chapter-generator

Auto-generate YouTube video chapters from subtitles. Parses VTT/SRT files, identifies topic transitions, and produces...

dzxiatian 更新于 2026-04-09 1 浏览
下载 SKILL

技能说明

Auto-generate YouTube video chapters from subtitles. Parses VTT/SRT files, identifies topic transitions, and produces timestamped chapter markers. Triggers: "youtube chapters", "视频章节", "youtube分段".

使用场景

Auto-generate YouTube video chapters from subtitles. Parses VTT/SRT files, identifies topic transitions, and produces timestamped chapter markers.

查看英文原始说明

Auto-generate YouTube video chapters from subtitles. Parses VTT/SRT files, identifies topic transitions, and produces timestamped chapter markers. Triggers: "youtube chapters", "视频章节", "youtube分段".

直接复制以下提示词,发送给你的 AI 助手即可完成安装。

帮我下载并安装这个SKILL:https://skillhub.cstcloud.cn/download/youtube-chapter-generator
  1. 点击上方「下载 SKILL」按钮,获取技能压缩包。
  2. 将压缩包解压到你的 Agent 技能目录。
  3. 重启客户端后即可在技能列表中选择该技能。

技能文件内容

4 个文件 · 16 kB
SKILL.md text/markdown
---
name: youtube-chapter-generator
description: >
  Auto-generate YouTube video chapters from subtitles. Parses VTT/SRT files,
  identifies topic transitions, and produces timestamped chapter markers.
  Triggers: "youtube chapters", "视频章节", "youtube分段".
version: 1.0.0
tags:
  - latest
  - youtube
  - video
  - automation
---

# YouTube Chapter Generator

Auto-generate YouTube video chapters from subtitles. Parses VTT/SRT files, identifies topic transitions, and produces timestamped chapter markers.

## Usage

```bash
# Download subtitles first
yt-dlp --write-sub --write-auto-sub \
  --sub-lang "zh-Hans,zh,en" \
  --convert-subs vtt \
  --skip-download \
  -o "/tmp/%(id)s" \
  "https://www.youtube.com/watch?v=VIDEO_ID"

# Generate chapters from subtitle file
python3 generate_chapters.py "/tmp/VIDEO_ID.zh-Hans.vtt"
```

## Chapter Generation Logic

```python
import re

def parse_vtt_timestamps(vtt_content):
    """Extract timestamps and text from VTT file"""
    timestamps = []
    for match in re.finditer(r'(\d{2}:\d{2}:\d{2})\.\d{3}\s*-->\s*\d{2}:\d{2}:\d{2}\.\d{3}', vtt_content):
        timestamps.append(match.group(1))
    return timestamps

def generate_chapters(vtt_file, min_gap_seconds=30):
    """Generate chapters from VTT subtitle file"""
    with open(vtt_file) as f:
        content = f.read()
    
    timestamps = parse_vtt_timestamps(content)
    if len(timestamps) < 2:
        return []
    
    # Find natural breaks (gaps > min_gap_seconds)
    chapters = []
    last_ts = timestamps[0]
    
    for ts in timestamps[1:]:
        gap = parse_ts(ts) - parse_ts(last_ts)
        if gap >= min_gap_seconds:
            chapters.append(last_ts)
            last_ts = ts
    
    chapters.append(timestamps[-1])
    return chapters

def parse_ts(ts_str):
    """Parse HH:MM:SS to seconds"""
    parts = ts_str.split(":")
    return int(parts[0])*3600 + int(parts[1])*60 + int(parts[2])

# Output format: "00:00 Introduction\n00:45 Main Topic\n..."
```

## YouTube Chapter Requirements

- Minimum 3 chapters for YouTube to auto-display
- First chapter must start at 0:00
- Chapters must be at least 10 seconds apart
- Maximum 12 chapters recommended

## Tags

`youtube` `chapters` `video` `timestamps` `subtitles` `automation`

文件内容直接读取自技能仓库,仅供安装前审阅;以实际下载的压缩包为准。