rereel build
Builds an MP4 from a bundle. Video is rendered by Remotion in fixed-size frame chunks. A chunk is re-rendered only when its slice hash changes (see Incremental rendering). In mix_plan audio mode, chunks are rendered muted and the soundtrack is compiled separately (see Audio compilation).
Synopsis
Section titled “Synopsis”rereel build <reel_dir> [--out <mp4>] [--template-dir <dir>] [--offline] [--storage-config <path>]What it does (remotion_single / remotion_chapter)
Section titled “What it does (remotion_single / remotion_chapter)”-
Reads the bundle. Loads
rereel.json, the lockfile (missing = empty), andprops.json(required). -
Determines the duration, using the first match:
duration_sec > 0intiming.json(timingFile, defaulttiming.json)props.duration_secprops.durationSecprops.durationInFrames / props.fpsprops.clip.end_sec - props.clip.start_secprops.outline.duration_sec
If none matches, the build fails with exit
2. ThentotalFrames = max(1, round(duration × fps)), withfps = video.fps || 30. -
Stages the template into
<reel_dir>/build/template/:- Source directory:
--template-dirif given, otherwise resolved fromrereel.jsontemplate(details). - Files are copied, skipping top-level
node_modules,.remotion,out, andprops. - If
build/template/node_modulesdoes not exist yet, it is cloned from the source template’snode_modules. If the source has none, it comes from~/.cache/rereel/node_modules/<template.name>-<sha256(package-lock.json)[0:16] | nolock>/, which is populated on first use by runningnpm ci(with a lockfile) ornpm installwith--no-audit --no-fund. <reel_dir>/media/is copied intobuild/template/public/media/.
- Source directory:
-
Hydrates media (same as
hydratewith the source template dir and--offline), then re-stages so freshly hydrated media lands inpublic/media/. -
Computes the template hash over
package.json,remotion.config.*, and every file undersrc/of the staged template. -
Detects the entry:
template.entry(must exist, else exit2), otherwise the first existing ofsrc/index.ts,src/index.tsx,src/index.js,src/Root.tsx. -
Renders chunks. For
start = 0, chunkFrames, 2·chunkFrames, …, the chunk covers frames[start, min(totalFrames, start+chunkFrames) − 1]and is written tobuild/chunks/<SSSSS>-<EEEEE>.mp4(zero-padded, inclusive end). A chunk is reused when its manifest entry key equals the new slice hash, the file exists, andffprobecounts the expected number of frames. Otherwise it runs:remotion render <entry> <composition> <chunk.mp4> --props <reel_dir>/props.json--frames <start>-<end> --concurrency=<video.concurrency|2> --image-format=<video.imageFormat|jpeg>--log=error [--muted] [--jpeg-quality=<video.jpegQuality|80>] [...video.remotionArgs]--mutedis added unlessaudioModeisremotion.--jpeg-qualityis added only for JPEG. The command runs inbuild/template/with a 15-minute timeout. After rendering, the frame count must match exactly (else exit1), andbuild/chunks/manifest.jsonis updated after every chunk. -
Concatenates chunks with the FFmpeg concat demuxer and
-c copyintobuild/video.muted.mp4(-anunlessaudioModeisremotion). -
Audio:
audioMode: "mix_plan": usesmix_plan.json, or, if absent, a plan derived from props (seederiveMixPlanFromProps). If neither yields anything, the muted video is copied. A missingduration_secin the plan is filled with the build duration. The plan is compiled with scopechapterforremotion_chapter(no loudness normalization; stems for a later merge) andfinalotherwise (2-passloudnorm). The result is muxed with-c:v copy -c:a aac -b:a 192k.remotion/none: the concatenated video is copied to the output.
Template resolution
Section titled “Template resolution”template.source |
Resolution |
|---|---|
local |
template.path resolved relative to <reel_dir>. Must contain package.json (exit 2). Missing path → exit 2. |
builtin |
<root>/<template.name>/package.json for root in $REREEL_TEMPLATES_DIR, then ~/.samurai/templates/remotion. Not found → exit 3. |
storage |
template.uri is fetched through template.provider (or default) and extracted into the template cache. The archive can contain package.json at its root or under remotion/ (Kogatana). The root takes precedence when both are present. An already extracted template is reused. Missing uri or package.json → exit 2. |
What it does (composite_merge)
Section titled “What it does (composite_merge)”- Hydrates the composite bundle itself (no template dir).
- For each entry in
parts(in order):kind: "chapter": recursively runsbuildon<reel_dir>/<part.reelDir>with the same--template-dirand--offline, and uses the child’s default output (<child>/build/output.mp4). Chunk counters are summed.kind: "media": uses<reel_dir>/<part.mediaPath>. It must exist, else exit1.
- Probes the video streams before concatenating them into
build/final.video.mp4. Compatible streams at the configured dimensions and frame rate are copied. Otherwise, each video is scaled and padded to the configured dimensions, resampled to the target frame rate, and encoded as H.264 before concatenation. Each segment’s video frame count sets its placement, independent of its audio duration. - If
audioModeismix_planandmix_plan.jsonexists, compiles it with scopefinal(a missingduration_secis taken from the probed video duration) and muxes. Otherwise the muted video is copied as-is. Typically the compositemix_plan.jsonuseschapters[]to merge each chapter’s stems. totalFramesis counted from the output file withffprobe.
Options
Section titled “Options”| Flag | Type | Default | Description |
|---|---|---|---|
<reel_dir> |
path (positional) | — (required) | Bundle directory. |
--out |
path | <reel_dir>/build/output.mp4 (composite: <reel_dir>/build/final.mp4) |
Output MP4 path. |
--template-dir |
path | from rereel.json template |
Use this template directory instead of resolving template. Also passed to chapter builds. |
--offline |
flag | off | Hydrate without network; fail on any missing or mismatched asset. |
--storage-config |
path | lookup rules | Storage configuration file. |
Build directory layout
Section titled “Build directory layout”<reel_dir>/build/├── template/ # staged Remotion workspace (+ public/media/)├── chunks/│ ├── manifest.json # { "chunks": { "<name>.mp4": { key, frames, sha256, renderedAt } } }│ ├── concat.txt│ └── 00000-00299.mp4 …├── video.muted.mp4├── stems/ # narration.wav bgm.wav sfx.wav brand.wav premix.wav filter_complex.txt mix.json├── mix.wav└── output.mp4 # default --outOutput
Section titled “Output”{ "status": "built", "reelDir": "/abs/path/reels/ep01", "outPath": "/abs/path/reels/ep01/build/output.mp4", "sha256": "c0ffee…", "totalFrames": 1800, "fps": 30, "chunksTotal": 6, "chunksRendered": 1, "chunksReused": 5}| Key | Description |
|---|---|
outPath |
Absolute output path. |
sha256 |
SHA-256 of the output MP4. |
totalFrames |
Computed frame count (composite: counted from the output). |
fps |
video.fps. |
chunksTotal / chunksRendered / chunksReused |
Chunk counters (composite: summed over chapter parts). |
Exit codes
Section titled “Exit codes”| Code | When |
|---|---|
0 |
Built. |
1 |
Chunk frame-count mismatch, composite media part missing, audio asset in mix_plan.json not found, or any hydrate failure. |
2 |
Missing <reel_dir>, rereel.json, or props.json; duration cannot be determined; no template and no --template-dir; entry not found; invalid local/storage template ref; composite without parts; mix plan without positive duration. |
3 |
Builtin template not found, or ffmpeg, ffprobe, Remotion, npm, cp, or tar cannot be spawned. |
4 |
Remotion render, FFmpeg, npm, or tar exited non-zero, or loudnorm measurements could not be parsed. |
Examples
Section titled “Examples”rereel build ./reels/ep01 --out ./reels/ep01/build/final.mp4Use a local checkout of the template and stay offline:
rereel build ./reels/ep01 --template-dir ./remotion-template --offline