youtube-chapter-clipper
Original:🇺🇸 English
Translated
1 scripts
Generate chapter clips from YouTube videos with yt-dlp and ffmpeg. Use when asked to download YouTube videos/subtitles, generate fine-grained chapters, cut precise clips, or generate per-chapter English SRTs.
1installs
Sourceseefreed/skills
Added on
NPX Install
npx skill4agent add seefreed/skills youtube-chapter-clipperTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →YouTube Chapter Clipper
Overview
Generate chapter clips from a YouTube video by downloading MP4 + English subtitles, segmenting content, cutting clips, and producing per-chapter English SRTs. Chapter length is user-selectable (1-2, 2-3, or 3-4 minutes).
Workflow
1) Use the automation script to reduce tokens
- Prefer for end-to-end runs (download, chaptering, clip cut, subtitle slicing).
scripts/smart_edit.py - The script uses heuristic chaptering to avoid AI token usage.
- Create and use a local venv (no external packages required):
python3 -m venv .venvsource .venv/bin/activatepython scripts/smart_edit.py --help- Speed-focused default: (approximate cuts, faster encode, optional downscale).
--mode fast - Use when you need precise boundaries.
--mode accurate
2) Confirm inputs and environment
- Ask for the YouTube URL and whether English subtitles are available (manual preferred; auto as fallback).
- Check tools: and
yt-dlp. If missing, install before proceeding.ffmpeg - Use command templates in .
references/commands.md
3) Download source video and subtitles
- Check current directory for existing source files before downloading:
- If and
<id>.mp4already exist, skip yt-dlp download.<id>.en.vtt
- If
- Download highest 1080p MP4 and English VTT. Save in current directory with ID-based names:
<id>.mp4- (or
<id>.en.vttif manual subs absent)<id>.en.auto.vtt
- Also capture video metadata (id, title, duration, uploader) for reporting.
- The script handles this when is provided.
--url
- The script handles this when
4) Prepare output directory
- Create output directory using the original video title:
- Replace spaces with underscores.
- Remove/replace filesystem-unsafe characters.
- Place all chapter clips and subtitle files into this directory.
5) Generate fine-grained chapters (user-selected length)
- Ask the user to choose a chapter length preset: 1-2, 2-3, or 3-4 minutes.
- Perform AI analysis (critical step):
- Read the full subtitle content.
- Understand the semantic flow and topic transitions.
- Identify natural topic switch points.
- Draft chapter boundaries based on semantic topic changes and sentence boundaries.
- Target the selected range; avoid cutting mid-sentence.
- Prefer semantic breaks (new concept, example, recap) over strict timing.
- Produce a chapter list with:
- ,
title,start,endreason - The script uses (or
--chapter-presetfor custom).--min-seconds/--target-seconds/--max-seconds
6) Cut precise clips (speed vs accuracy)
- Use ffmpeg with accurate trimming and stable outputs. Always re-encode:
- Place after
-ssfor accurate seeking.-i - Use +
libx264,aac, and-movflags +faststartto maximize player compatibility.-pix_fmt yuv420p - Use a fast preset (e.g., ) to avoid long encodes and timeouts.
-preset veryfast
- Place
- Run clips serially and avoid external timeouts that kill ffmpeg mid-write.
- After each clip, validate with ; retry once if validation fails.
ffprobe - If speed is the priority (listening practice), prefer approximate cuts:
- Put before
-ssto avoid decoding from the start every time.-i - Use and a higher CRF (e.g., 28).
-preset ultrafast - Optionally downscale (e.g., width 1280) to reduce encode time.
- Put
- Name each clip with an ordered prefix: using safe filenames:
<nn>_<chapter_title>.mp4- Use a 2-digit index starting at 01.
- Replace spaces with underscores.
- Remove filesystem-unsafe characters.
7) Extract and convert subtitles per chapter
- Extract VTT segment for each chapter by time range.
- Convert each segment to SRT:
<nn>_<chapter_title>.en.srt- The script deletes per-chapter VTT unless is set.
--keep-vtt
8) Report outputs
- Print output directory path, chapter list, and generated files.
Output Rules
- Source files stay in current directory (,
<id>.mp4).<id>.en.vtt - All chapter clips and subtitle files are placed in the per-video directory named after the sanitized title.
- Use consistent time formats ().
HH:MM:SS.mmm
References
- Command templates and copy/paste examples:
references/commands.md - Automation:
scripts/smart_edit.py