koubo-autocut: From raw talking-head footage → clean cut with bilingual subtitles
S=<directory containing this SKILL.md>/scripts, invoke with uv run --script $S/<x>.py (dependencies in script header, auto-installed on first run).
Working directory W defaults to <raw footage directory>/_koubo; steps communicate only via files in W, each can be rerun independently.
Requires local ffmpeg (with libass) and uv.
Core idea: Make editing decisions on words, not on the timeline. You read the word list, decide which words to keep; cut points, subtitle timing, and voice are all derived from this list by the script, so they align naturally.
Step 0: Gather requirements — ask the user all at once before starting
Absolute path to the raw footage, where to put the final video (default next to the footage), whether to use their own BGM track or generate an original one. Note down proper nouns (names, schools, platforms) the user mentions — they'll be needed in subtitles. Don't ask for a target duration: the final length is determined by what's left after removing disfluencies.
Workflow
| Step | Command | Output (under W) |
|---|---|---|
| 1 Transcribe | transcribe.py <raw> | words.json, and prints a numbered word list |
| 2 Write edit list | You write it (see below) | edit.json |
| 3 Compute cuts | plan.py <raw> | plan.json voice.wav subs.ass |
| 3.5 Self-check | check.py --work W | Diff table on screen |
| 4 BGM (optional) | bgm.py --work W | bgm.wav |
| 5 Mix | mix.py --work W [--music track] [--gap 21] | mix.m4a |
| 6 Render | render.py --work W --out <final.mp4> | Final video |
| 7 Deliver | Spot-check, inform user | — |
Step 1: Transcribe
transcribe.py uses sherpa-onnx with Parakeet TDT (English), fully local. First run downloads ~480MB model to ~/.cache/koubo-autocut/; let the user know.
Each output line is a breath group: [start_sec +interval_to_prev] idx:word …. The model writes out uh / um / mm; large intervals mark pauses.
To view the word list again: transcribe.py <raw> --show.
Step 2: Write edit.json (your decision)
A list, each item is one subtitle line:
{"w": [[6,8],[11,13]], "en": "I'm excited to tell you that", "zh": "我很兴奋地告诉大家"}
w = kept word index intervals (inclusive), must be sequential and non-overlapping; words not listed are cut.
Cut: uh / um / mm; restarted fragments; immediately repeated words; the mistaken part in self-corrections. Keep: natural oral connectors like Okay, Yeah, So; sentences that are complete enough even if grammatically imperfect. The user wants "pauses removed", not a rewritten monologue.
- When something was said twice, keep the one that connects naturally to the following text (usually the second one) for natural intonation. Example:
start this … uh this this challenge or this channel→ keepstart+ the finalthis channel. - Each English line ≤ ~45 characters (max two lines). Split long sentences by sense group.
- Lines ending a sentence must end with
. ? !; other lines must NOT end with them. The script uses this to decide sentence breaks and zoom transitions. - Write English as spoken; only fix recognition errors and one‑ or two‑word grammar issues (experience → experiences). Do not rephrase.
- Chinese: translate by meaning, colloquial, not word‑for‑word. No period at line end.
- Proper nouns (names, schools, platforms) are often misrecognized. Write the most likely spelling, and list them at delivery for the user to confirm.
Step 3: Compute cuts, then self-check
uv run --script $S/plan.py <raw>
uv run --script $S/check.py --work W
check.py re‑transcribes the cut voice and compares it to your kept words. "Missing" → a word was clipped; double‑check that interval. "Extra … ← missed filler" → a filler word is stuck to an adjacent kept word; one or two instances are acceptable; more → widen the interval to include it. "Different" is usually just variation between runs; ignore. Edit edit.json and rerun both commands.
Only edit edit.json, never words.json. The word list is the raw recognition result; indices and timestamps are the ground truth. Inserting, deleting, or changing timestamps will break all downstream cut calculations.
When self‑check hears words not in the word list (unrecognized uh, repeated "to"), you can only: cut the surrounding words together, or accept them in the final video.
Self‑check at most 2–3 rounds; if 1–2 remain, stop and tell the user at delivery.
Common plan.py parameters: --max-pause 0.45 (shorter pauses kept as‑is; larger = more relaxed, smaller = tighter), --zoom 1.05 (1 = no zoom), --size 1080x1920, --en-size --zh-size, --margin-v (distance from bottom).
Default subtitle style is fixed: Source Han Sans Bold (font shipped with the skill), English white on top, Chinese warm yellow below, black outline, bottom‑centered. Don't change unless the user asks; for font changes see references/pitfalls.md.
Steps 4–5: BGM and mix
User provided track: mix.py --work W --music <track>. No track: first bgm.py --work W to generate an original pad, then mix.py --work W. Do not download music from unknown sources. If the user says music is too loud/soft, adjust --gap (dB lower than voice; higher = softer), rerun mix.py and render.py … --join-only (no need to re‑render video).
No music at all: mix.py --work W --no-music.
Step 6: Render
uv run --script $S/render.py --work W --out <final.mp4>
4K footage renders roughly real‑time. For time‑limited environments: --chunk-span 90 to split chunks; to run on another machine: --emit, which writes W/render.sh, then run bash render.sh 0, 1 …, bash render.sh join <final> on that machine (override source path with --src if changed).
If only subtitle text changes (e.g., corrected a name): edit edit.json → rerun plan.py → rerun render.py; mixing stays untouched.
Step 7: Pre‑delivery check
- Final duration should equal
plan.json'sout_seconds. ffmpeg -ss <sec> -i final -frames:v 1 x.jpg— grab 2–3 frames to check subtitles: placement, no triple lines, Chinese not rendered as boxes (only happens if font was changed; see pitfalls).- You can't hear audio: ask the user to check BGM quality/volume and any remaining uh.
Tell the user: final path, original → final duration, proper nouns needing confirmation, three adjustable settings (BGM volume / swap track, subtitle size/position, zoom toggle).
The W directory is intermediate files; can be deleted after confirming the final video.
More
Common pitfalls and rationale behind each parameter are in references/pitfalls.md; check it first if modifying the script or if results look wrong.