基于字幕语义自动识别章节边界,精准切割视频为独立片段的 Claude Code Skill。
$ npx -y skills add qiyongchuan/video-chapter-splitter --agent claude-code
基于字幕语义自动识别章节边界,精准切割视频为独立片段的 Claude Code Skill。
English | 中文
视频文件 (1.5GB)
↓ FFmpeg 提取音频 (~3秒)
16kHz mono WAV (~180MB)
↓ Whisper 本地转录 (~5分钟, CPU small模型)
字幕文本(带精确时间戳)
↓ Claude 语义分析 (~72K token)
章节边界 JSON
↓ FFmpeg 精准切割 (~10分钟)
独立视频片段
以 1.5GB / 1小时38分钟直播课为例:
| 环节 | Token | 时间 | 费用 |
|---|---|---|---|
| FFmpeg 提取音频 | 0 | 3秒 | 免费 |
| Whisper 转录 (small/CPU) | 0 | ~5分钟 | 免费 |
| Claude 语义分析 | ~72K | ~3分钟 | ~$1.2 |
| FFmpeg 切割 | 0 | ~10分钟 | 免费 |
每小时视频约 67K token,约 $0.74(¥5)
# Python 3.8+
pip install openai-whisper
# FFmpeg(系统安装)
# Windows: winget install Gyan.FFmpeg
# Mac: brew install ffmpeg
# Linux: apt install ffmpeg
# 第一步:提取字幕(自动先分离音频再转录)
python video_chapter_splitter.py "视频.mp4" --extract-only
# 第二步:查看生成的 xxx_subtitles.md,创建 xxx_chapters.json
# 或让 Claude 分析字幕自动生成章节 JSON
# 第三步:按章节切割
python video_chapter_splitter.py "视频.mp4" --split-only
| 参数 | 默认值 | 说明 |
|---|---|---|
--model | small | Whisper 模型 (CPU 推荐 small, GPU 推荐 medium) |
--extract-only | - | 只提取字幕 |
--split-only | - | 只按 chapters.json 切割 |
--keep-audio | false | 保留中间音频文件 |
--output-dir | 视频名_chapters | 自定义输出目录 |
{
"chapters": [
{
"title": "01_开篇介绍",
"start_time": "00:00:00",
"end_time": "00:05:10",
"summary": "介绍系统架构",
"type": "knowledge"
},
{
"title": "02_问答环节",
"start_time": "00:05:10",
"end_time": "00:12:00",
"summary": "学员提问与解答",
"type": "qa"
}
]
}
音频预提取优化
Whisper 只处理音频,但直接传视频时内部解码效率极低。预先用 FFmpeg 提取 16kHz mono WAV:
FFmpeg 切割精度
使用 output seeking 模式(-ss 在 -i 后),实现帧级精度:
# 不推荐:快但不准,可能漂移 5-10 秒
ffmpeg -ss 00:01:00 -i input.mp4 ...
# 推荐:稍慢但精准到帧
ffmpeg -i input.mp4 -ss 00:01:00 ...
Video (1.5GB)
↓ FFmpeg extract audio (~3s)
16kHz mono WAV (~180MB)
↓ Whisper transcribe (~5min, CPU small)
Timestamped subtitles
↓ Claude semantic analysis (~72K tokens)
Chapter boundaries JSON
↓ FFmpeg precise cut (~10min)
Individual video clips
For a 1.5GB / 1h38m live stream:
| Step | Tokens | Time | Cost |
|---|---|---|---|
| FFmpeg extract audio | 0 | 3s | Free |
| Whisper transcribe (small/CPU) | 0 | ~5min | Free |
| Claude semantic analysis | ~72K | ~3min | ~$1.2 |
| FFmpeg split | 0 | ~10min | Free |
~67K tokens per hour of video, ~$0.74 per hour
pip install openai-whisper
# Install FFmpeg system-wide
# Step 1: Extract subtitles (auto extracts audio first)
python video_chapter_splitter.py "video.mp4" --extract-only
# Step 2: Review xxx_subtitles.md, create xxx_chapters.json
# Step 3: Split by chapters
python video_chapter_splitter.py "video.mp4" --split-only
Created with Claude Code. v1.0 in 5 minutes, v2.0 optimized through real-world usage.
MIT License
video-chapter-splitter is a Claude Code plugin with 1 hand-picked skill, indexed on Flowy in the Video & Audio category. Install it with the command on its page. It includes video-chapter-splitter. Its skills do not fire on their own yet. Request auto-invocation to have Flowy route them as you prompt. Free and open source.
Is this plugin yours?
Claim it with GitHubSubmit a pluginPromote it