Skip to content

rereel patch

patch applies small, deterministic edits to a bundle’s JSON files so that an agent never has to hand-edit timestamps in several files at once. The JSON files are rewritten pretty-printed with 2-space indentation.

Terminal window
rereel patch <reel_dir> ripple-shift --at-sec <sec> --delta-sec <sec>
rereel patch <reel_dir> trim-segment --id <seg_id> [--src-start-sec <sec>] [--duration-sec <sec>]
[--start-sec <sec>] [--gain-db <db>]
rereel patch <reel_dir> swap-asset --old <ref> --new <ref>

All operations read <reel_dir>/rereel.json first (exit 2 if missing) to find the file names (propsFile, mixPlanFile, timingFile, captionsFile, lockFile) and video.fps (default 30).


Shifts every timestamp at or after --at-sec by --delta-sec across all timeline files. Use a negative delta after removing a pause or cut, and a positive delta to insert time.

The following files are processed if they exist: props.json, mix_plan.json, timing.json, captions.srt. JSON files are walked recursively (objects and arrays), and in every object:

Key Shifted when Rule
start_sec >= at + delta, clamped at 0, rounded to 4 decimals
end_sec > at same
at_sec >= at same
fromFrame, atFrame, startFrame >= round(at × fps) + round(delta × fps), clamped at 0
endFrame > round(at × fps) same

Additional per-file rules:

  • props.json: top-level duration_sec += delta. Top-level durationInFrames += round(delta × fps) (minimum 1).
  • mix_plan.json: top-level duration_sec += delta. Each speech pair [a, b] is shifted with the same >=/> rules.
  • timing.json: top-level duration_sec += delta.
  • captions.srt: cue start (>= at) and end (> at) are shifted, and cues are renumbered from 1.

Objects under keys named anchor or end_anchor are not descended into. src_start_sec and nested duration_sec values are never changed, so items that straddle at are stretched or shrunk through their end_sec.

Flag Type Default Description
--at-sec number — (required) Pivot time in seconds.
--delta-sec number — (required) Seconds to add (negative to pull earlier).
{
"status": "patched",
"atSec": 12,
"deltaSec": -0.5,
"filesUpdated": ["props.json", "mix_plan.json", "timing.json", "captions.srt"]
}

filesUpdated lists only the files that existed and were rewritten.

Terminal window
# A 0.5 s pause at 12.0 s was removed from the narration
rereel patch ./reels/ep01 ripple-shift --at-sec 12.0 --delta-sec -0.5

Updates one mix_plan.json narration[] entry, found by its id.

  1. Reads mix_plan.json (exit 2 if missing).
  2. Finds the first narration segment with id === --id. Segments without an id cannot be targeted. If none matches, the command fails with exit 2 (Narration segment not found: <id>).
  3. Applies only the flags that were passed:
    • --src-start-sec → src_start_sec (clamped ≥ 0, 4 decimals)
    • --duration-sec → duration_sec (minimum 0.01)
    • --start-sec → start_sec (clamped ≥ 0, 4 decimals)
    • --gain-db → gain_db (as-is)
  4. Writes mix_plan.json. No other file is touched, so follow with ripple-shift if the segment length change should move later content.
Flag Type Default Description
--id string — (required) Narration segment id.
--src-start-sec number unchanged New source offset.
--duration-sec number unchanged New duration.
--start-sec number unchanged New timeline start.
--gain-db number unchanged New gain in dB.
{ "status": "patched", "segmentId": "seg_004" }
Terminal window
rereel patch ./reels/ep01 trim-segment --id seg_004 --src-start-sec 18.42 --duration-sec 3.1

Replaces every string exactly equal to --old with --new in props.json and mix_plan.json (when present). Replacement happens anywhere in the tree, including non-media fields and keys such as output.

Flag Type Default Description
--old string — (required) Exact reference to replace (e.g. media/bg_1a2b3c4d.png).
--new string — (required) Replacement reference.
{ "status": "patched", "replacements": 3 }

replacements is the total number of replaced strings across both files. 0 is not an error.

Terminal window
rereel patch ./reels/ep01 swap-asset --old media/bg_1a2b3c4d.png --new media/bg_v2_77ef0011.png

Code When
0 Patched.
2 Missing <reel_dir> or operation (patch requires <reel_dir> <op>); unknown operation (Unknown patch op: <op>); missing required flags; non-numeric values; missing rereel.json (or mix_plan.json for trim-segment); segment not found; invalid JSON.