Ripple shift, trim and swap
rereel patch <reel_dir> <op> makes deterministic edits that would be error-prone by hand. Every op prints one JSON line and only rewrites JSON and SRT files.
ripple-shift
Section titled “ripple-shift”Insert or remove time at a point, and move everything after it.
# Remove 0.5 s at 12.0 s (e.g. after deleting a pause)npx @mathrunet/rereel patch reels/ep01 ripple-shift --at-sec 12.0 --delta-sec -0.5
# Insert 1.2 s at 30 snpx @mathrunet/rereel patch reels/ep01 ripple-shift --at-sec 30 --delta-sec 1.2{"status":"patched","atSec":12,"deltaSec":-0.5,"filesUpdated":["props.json","mix_plan.json","timing.json","captions.srt"]}filesUpdated lists the files that existed and were rewritten. The same rules apply to all four files.
What moves
Section titled “What moves”The patcher walks every object recursively and applies these rules (with a 1 µs tolerance):
| Field | Shifted when |
|---|---|
start_sec, at_sec |
value ≥ at-sec |
end_sec |
value > at-sec |
fromFrame, atFrame, startFrame |
value ≥ round(at-sec × fps) |
endFrame |
value > round(at-sec × fps) |
top-level duration_sec (props, mix_plan, timing) |
always |
top-level durationInFrames (props) |
always, minimum 1 |
mix_plan.speech[[a, b]] |
a ≥ at-sec / b > at-sec |
captions.srt cue start / end |
same as start_sec / end_sec |
Seconds are rounded to 0.1 ms and clamped at 0. Frame deltas use round(delta-sec × fps) with fps from rereel.json.
An item that spans the shift point keeps its start, and its end moves, so it grows or shrinks. Objects under keys named anchor or end_anchor are not traversed.
What does not move
Section titled “What does not move”src_start_sec,duration_secanddurationInFrameson individual items (source offsets and per-item lengths are not timeline positions)startSec/endSec(camelCase) fields- any field not listed above
trim-segment
Section titled “trim-segment”Adjust one narration segment in mix_plan.json by id:
npx @mathrunet/rereel patch reels/ep01 trim-segment --id seg_004 \ --src-start-sec 12.38 --duration-sec 2.10 --start-sec 9.6 --gain-db -1.5{"status":"patched","segmentId":"seg_004"}| Flag | Field set | Notes |
|---|---|---|
--src-start-sec |
src_start_sec |
offset in the source file |
--duration-sec |
duration_sec |
minimum 0.01 |
--start-sec |
start_sec |
timeline position |
--gain-db |
gain_db |
added after loudness normalization |
Only the flags you pass are changed. An unknown --id exits with code 2. trim-segment does not ripple: if the segment gets longer or shorter, follow up with ripple-shift at its end.
swap-asset
Section titled “swap-asset”Replace every string in props.json and mix_plan.json that exactly equals --old with --new:
npx @mathrunet/rereel patch reels/ep01 swap-asset \ --old media/bgm_lofi_0d4e1f20.mp3 --new incoming/bgm_upbeat.mp3{"status":"patched","replacements":2}Pass an existing lock key to reuse it, or a local file path to hash and store it automatically:
rereel patch reels/ep01 swap-asset --old media/bg_1a2b3c4d.png --new ./work/bg_v2.pngThe command updates the lockfile for fresh media and keeps the original entry available for undo. See the command reference.
Recommended sequence
Section titled “Recommended sequence”rereel inspect reels/ep01 # find the IDs and timesrereel patch reels/ep01 ripple-shift ... # or trim-segment / swap-assetrereel validate reels/ep01 # must be "valid": truerereel build reels/ep01 # check chunksRenderedgit diff reels/ep01 # review the JSON diffSee the patch reference for all flags.