← 返回
未分类

Youtube Chapter Generator

Auto-generate YouTube video chapters from subtitles. Parses VTT/SRT files, identifies topic transitions, and produces timestamped chapter markers. Triggers:...
自动从字幕生成YouTube视频章节。解析VTT/SRT文件,识别主题切换并生成带时间戳的章节标记。触发条件:...
dzxiatian-crypto dzxiatian-crypto 来源
未分类 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 371
下载
💾 0
安装
1
版本
#ai#automation#latest

概述

YouTube Chapter Generator

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

Usage

# 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

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

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-05-03 08:42 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

dev-programming

Mcporter

steipete
使用 mcporter CLI 直接列出、配置、认证及调用 MCP 服务器/工具(支持 HTTP 或 stdio),涵盖临时服务器、配置编辑及 CLI/类型生成功能。
★ 198 📥 68,268
dev-programming

YouTube

byungkyu
使用托管OAuth集成YouTube Data API,支持搜索视频、管理播放列表、获取频道数据及评论互动,适用于用户需要时使用此技能。
★ 142 📥 42,142
dev-programming

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 686 📥 331,309