Skip to content

Incremental rendering

build converts the duration to frames and splits it into fixed windows of video.chunkFrames frames (default 300, i.e. 10 s at 30 fps):

totalFrames = round(durationSec × fps)
chunks: [0, 299] [300, 599] [600, 899] ... [n×chunkFrames, totalFrames−1]
files: build/chunks/00000-00299.mp4, 00300-00599.mp4, ...

The duration comes from the first match of: timing.json duration_sec, then props duration_sec, durationSec, durationInFrames / fps, clip.end_sec − clip.start_sec, and outline.duration_sec. If none is found, the build fails with exit 2.

Each chunk is rendered with:

Terminal window
remotion render <entry> <composition> build/chunks/<start>-<end>.mp4 \
--props <reel_dir>/props.json --frames <start>-<end> \
--concurrency=2 --image-format=jpeg --log=error --muted --jpeg-quality=80 [...remotionArgs]

--muted is added unless audioMode is remotion. --jpeg-quality is added only for imageFormat: "jpeg". The defaults come from video.concurrency, video.imageFormat, video.jpegQuality and video.remotionArgs in rereel.json. After rendering, ffprobe counts the chunk’s frames, and a count that differs from end − start + 1 fails the build.

A chunk is reused only if build/chunks/manifest.json stores the same slice key for it, the file exists, and its frame count is still correct. The key is a SHA-256 over canonical (sorted-key) JSON of:

Input Effect of a change
frames: [start, end] Changing chunkFrames renames and re-renders all chunks
composition, entry, fps, imageFormat, jpegQuality, extraArgs All chunks
templateSha256: hash of the template’s package.json, remotion.config.* and every file under src/ All chunks
propsSlice: see below Only chunks whose slice changed
mediaHashes: lockfile SHA-256 of each media path referenced inside the slice Only chunks that show that media

For each chunk, rereel copies props.json but filters the timed collections down to items whose frame window overlaps [start − 30, end + 30]. The 30-frame padding covers transitions that bleed across a boundary.

Props key Treatment
cuts, edit.cuts filtered
scenes (array) or scenes.scenes filtered
overlays (array) or overlays.overlays filtered
dialogue filtered
hook, cta (single objects) kept if overlapping, else null
images.shots, structure.sections filtered
audio ignored: audio is mixed outside the video chunks
anything else (theme, palette, duration_sec, captions, …) global: included in every chunk’s slice

An item’s window is read from the first field set it has:

Fields Window (frames)
fromFrame + durationInFrames [fromFrame, fromFrame + durationInFrames]
startFrame + endFrame / durationInFrames [startFrame, endFrame]
atFrame + durationInFrames / durationSec / duration_sec defaults to 4 s if no duration
start_sec + end_sec / duration_sec [floor(start×fps), ceil(end×fps)]
startSec + endSec / durationSec same
only duration_sec placed sequentially after the previous such item

Items with no recognizable timing are kept in every chunk. Missing durations default to 1 frame (frame fields) or 1 s (second fields).

rereel.json slicePreset is auto (default), kogatana, scenes, lyrics or custom. In the current implementation, every preset except custom uses the same slicing rules from the table above. auto detects a preset name from the props shape, but that does not change the rules.

custom uses customSlices instead:

rereel.json (excerpt)
{
"slicePreset": "custom",
"customSlices": [
{ "arrayPath": "timeline.clips", "startSecKey": "in", "endSecKey": "out", "padFrames": 15 }
]
}

Each extractor names a dot-path to an array and the keys to read: startSecKey + endSecKey/durationSecKey, or startFrameKey + durationFramesKey, plus optional padFrames (default 30). Top-level keys whose root is not an extractor’s root stay global.

Once every chunk is current, rereel writes build/chunks/concat.txt and joins the chunks with the concat demuxer, without re-encoding:

Terminal window
ffmpeg -f concat -safe 0 -i concat.txt -an -c copy -movflags +faststart build/video.muted.mp4

(-an is omitted when audioMode is remotion.) Because chunks come from one Remotion configuration, their stream parameters match, so a stream copy is safe and takes almost no time. The audio is then compiled and muxed onto this file. See Audio compilation. The result is build/output.mp4 unless you pass --out.

For kind: "composite_merge", build:

  1. hydrates the parent reel
  2. builds each parts[] entry with kind: "chapter" as a child reel (incrementally, with its own chunk cache)
  3. takes each kind: "media" part (e.g. an opening or end card) from the locked media
  4. concatenates all parts into build/final.video.mp4 with -c:v copy, falling back to a libx264 re-encode at video.fps if the stream copy fails
  5. compiles mix_plan.json at final scope, and muxes the result to build/final.mp4 (or --out)

The chunksTotal, chunksRendered and chunksReused counts in the output are summed across child reels.

Rendering happens in <reel_dir>/build/template/, a copy of the template with hydrated media/ copied into public/media/. Media paths in props such as media/bg_3fa9c2d1.png must therefore be loaded with Remotion’s staticFile().