Skip to content

rereel cut-retakes

Analyzes a raw narration recording (audio or video) and returns a list of kept segments with source offsets and new timeline positions. The source file is never modified or re-encoded, and playback speed is never changed (tempoRatio is always 1.0). Paste the segments into mix_plan.json narration[] to apply the cut.

Terminal window
rereel cut-retakes --input <audio_or_video> [--asr-json <path>] [--script <path>] [--out <json>]
[--silence-db -40] [--min-silence-sec 0.45] [--keep-gap-sec 0.14]
[--pad-edge-sec 0.05] [--fade-sec 0.015] [--target-sec <sec>]

The input may also be given as the first positional argument (rereel cut-retakes raw.wav).

  1. Fails with exit 2 if the input does not exist or ffprobe cannot determine a positive duration.
  2. Picks a detection mode:

Mode A: ASR-based (--asr-json given and the file exists)

Section titled “Mode A: ASR-based (--asr-json given and the file exists)”
  1. Builds utterances from the Whisper-style JSON. Words come from segments[].words[]. A segment without words contributes its whole text as one word. A new utterance starts when the gap between a word’s start and the current utterance’s end is >= --min-silence-sec, or when the current text ends with 。!?!?.. Word strings are concatenated as-is.
  2. Filler removal: an utterance whose normalized text (NFKC, lower-cased, punctuation and whitespace stripped) is empty or one of あー えー えーと えっと あのー うーん まあ そのー um uh er erm ah like is dropped with reason filler.
  3. Retake removal, in one of two ways:
    • Script-guided (--script given and the file exists): the script is cleaned (front matter, # headings, and HTML comments removed) and split into sentences after 。!?!?. or a newline. Sentences with fewer than 2 normalized characters are ignored. Each utterance is matched to the sentence with the highest score, where the score is the larger of the Dice bigram similarity and 0.75 when the utterance has ≥ 3 characters and the sentence starts with its first (up to 8) characters. A score >= 0.35 counts as a match. When several utterances map to the same sentence, only the last one is kept, and earlier ones are dropped with reason retake. Unmatched utterances are kept.
    • Transcript-free: an utterance is dropped as retake when the next utterance starts with the same first min(len, nextLen, 6) characters (≥ 3) and is at least as long, or when the Dice similarity to the next utterance is >= 0.65.

--silence-db is not used in this mode.

Mode B: waveform silence (no usable --asr-json)

Section titled “Mode B: waveform silence (no usable --asr-json)”

Runs ffmpeg -af silencedetect=noise=<silence-db>dB:d=<min-silence-sec>. Each detected silence is dropped with reason silence, and the audio between silences is kept if it is longer than 0.05 s.

  1. Each kept range is widened by --pad-edge-sec on both sides (clamped to the source duration). Ranges shorter than 0.04 s are discarded.
  2. Gap: segments are laid out back-to-back on a new timeline separated by --keep-gap-sec. With --target-sec and more than one segment, the gap becomes (target − totalSpeech) / (n − 1), clamped to [0.05, keepGap + sourceDuration × 0.15 / (n − 1)]. Speech is never stretched, so the target is approximate.
  3. Each segment gets fadeInSec = fadeOutSec = min(--fade-sec, duration / 4).
  4. All times are rounded to 4 decimals. With --out, the result is also written as pretty-printed JSON.
Flag Type Default Description
--input (or 1st positional) path — (required) Source audio/video.
--asr-json path — Whisper JSON with word timestamps. Silently ignored if the file does not exist.
--script path — Target script (Markdown or plain text) for script-guided retake removal. Used only together with --asr-json. Ignored if missing.
--out path — Also write the result JSON to this file. Parent directories are created.
--silence-db number (dB) -40 silencedetect noise threshold (Mode B).
--min-silence-sec number 0.45 Minimum silence to cut (Mode B) / utterance split gap (Mode A).
--keep-gap-sec number 0.14 Pause inserted between kept segments.
--pad-edge-sec number 0.05 Padding added before/after each kept range.
--fade-sec number 0.015 Micro-fade at segment boundaries (capped at a quarter of the segment).
--target-sec number — Approximate target duration; only the gaps are adjusted. 0 is treated as unset.

The programmatic API additionally accepts maxStretchRatio (default 0.15). See cutRetakesAndSilence.

{
"language": "en",
"segments": [
{
"start": 0.0, "end": 2.1, "text": " Today we will…",
"words": [
{ "word": " Today", "start": 0.0, "end": 0.32, "probability": 0.98 },
{ "word": " we", "start": 0.34, "end": 0.45 }
]
}
]
}

Shape: CutRetakesResult.

{
"sourcePath": "./raw/narration_take1.wav",
"sourceDurationSec": 61.237,
"keptDurationSec": 44.982,
"removedSec": 16.255,
"tempoRatio": 1,
"segments": [
{
"id": "seg_001",
"srcStartSec": 0.41,
"srcEndSec": 3.92,
"durationSec": 3.51,
"timelineStartSec": 0,
"timelineEndSec": 3.51,
"fadeInSec": 0.015,
"fadeOutSec": 0.015,
"text": " Today we will look at rereel."
}
],
"dropped": [
{ "srcStartSec": 4.1, "srcEndSec": 5.0, "reason": "retake", "text": " Today we wi" },
{ "srcStartSec": 5.2, "srcEndSec": 5.6, "reason": "filler", "text": " um" }
],
"speechIntervals": [[0, 3.51]]
}
CutSegment narration[] field
id id
timelineStartSec start_sec
srcStartSec src_start_sec
durationSec duration_sec
fadeInSec / fadeOutSec fade_in_sec / fade_out_sec
text text

speechIntervals can be copied to mix_plan.json speech to drive BGM ducking.

Code When
0 Success.
2 No input, input not found, duration undetectable, non-numeric option, or invalid ASR JSON.
3 ffmpeg/ffprobe not found.
4 ffmpeg/ffprobe exited non-zero.

Script-guided retake removal fitted to roughly 45 s:

Terminal window
rereel cut-retakes \
--input ./raw/narration_take1.wav \
--asr-json ./raw/asr.json \
--script ./script.md \
--target-sec 45 \
--out ./reels/ep01/cuts.json

Pure silence trimming with a stricter threshold:

Terminal window
rereel cut-retakes --input ./raw/vo.wav --silence-db -35 --min-silence-sec 0.6