Skip to content

Lockfile and hydration

freeze: from a working directory to a lockfile

Section titled “freeze: from a working directory to a lockfile”

rereel freeze <reel_dir> --props <props.json> [--mix-plan <mix_plan.json>] ... walks props.json and mix_plan.json recursively. A string value is treated as a media reference when:

  • it ends in a media extension: png jpg jpeg webp gif avif mp4 webm mov m4v mkv wav mp3 m4a aac ogg opus flac ttf otf woff woff2 svg
  • it is not an http(s):// or data: URL
  • its key is not output, layoutReport or log

The reference is resolved against these search bases, in order: the reel directory, the directory of --props, the directory of --mix-plan, <template-dir>/public, and <template-dir>. Absolute paths are used as-is. A reference that cannot be resolved is left untouched, unless an entry with that exact key is already in the lockfile, in which case the entry is kept.

For each resolved file, freeze:

  1. computes its SHA-256 and size
  2. if the lockfile already has an entry with the same hash and a storage URI, reuses that entry and its path, without uploading again
  3. otherwise calls store() on the selected provider (--provider, or defaultProvider) and gets back a URI
  4. probes images, video and audio with ffprobe to record durationSec, width, height, fps, and vfr: true when the real and average frame rates differ by more than 0.25
  5. writes the entry under the key media/<stem>_<sha8><ext> and copies the file there (skip the copy with --no-keep-media)
  6. rewrites the string in the JSON to that key
rereel.lock.json
{
"schemaVersion": 1,
"items": {
"media/bg_s001_3fa9c2d1.png": {
"source": "storage",
"provider": "r2",
"uri": "s3://my-video-assets/rereel/3f/3fa9c2d1....png",
"sha256": "3fa9c2d1...",
"bytes": 482113,
"kind": "image",
"width": 1920,
"height": 1080
},
"fonts/NotoSansJP-Bold.ttf": {
"source": "template",
"templateRel": "public/fonts/NotoSansJP-Bold.ttf",
"sha256": "9b0e...",
"bytes": 5730032,
"kind": "font"
}
}
}

The lockfile is rebuilt from the references found on each freeze, so entries that are no longer referenced are dropped. Items are sorted by key.

Files that resolve inside <template-dir>/public/fonts/, public/sfx/ or public/sample/ are not uploaded. They are locked with source: "template" and a templateRel path, and the JSON reference becomes the path relative to public/ (e.g. fonts/NotoSansJP-Bold.ttf). These assets ship with the template. Other files under public/ are stored like any other media.

The Remotion template itself is referenced from rereel.json template:

template.source Resolved from
local template.path, resolved relative to the reel directory; must contain package.json
builtin $REREEL_TEMPLATES_DIR/<name>/ or ~/.samurai/templates/remotion/<name>/
storage template.uri fetched through template.provider as a .tar.gz, extracted once into ~/.cache/rereel/templates/<name>-<hash>/

build --template-dir <dir> overrides all three.

freeze reads an existing rereel.json and uses its values as defaults for any flag you omit, so you can re-run it after adding media. Re-freezing a reel in place (--props <reel_dir>/props.json) works: the existing media/... references resolve inside the reel directory, match by hash, and are kept without re-uploading.

The default local-cache provider is a content-addressed store (CAS) at ~/.cache/rereel/cas/. Objects live at <cacheDir>/<sha[0:2]>/<sha><ext>, and the URI is cas://<sha><ext>. The S3-compatible provider uses the same layout under its prefix: s3://<bucket>/<prefix>/<sha[0:2]>/<sha><ext>. Identical bytes are stored once, however many reels use them.

rereel hydrate <reel_dir> (also run automatically at the start of build) iterates over the lockfile:

  • source: "template": if --template-dir is given and the destination is missing, the file is copied from <template-dir>/<templateRel>. These entries are counted as templateStatic.
  • source: "storage":
    • if <reel_dir>/<key> exists and its SHA-256 matches, it counts as cached
    • with --offline, any missing or mismatched file is an error (exit 1)
    • otherwise the provider named in the entry’s provider field resolves the URI to the destination, and the file is hashed again. A mismatch fails with expected and actual in the error JSON.
{"status":"hydrated","reelDir":"/.../reels/ep01","total":7,"fetched":6,"cached":0,"templateStatic":1}

validate works on the JSON alone, so CI needs no media and no credentials. It reports errors and warnings with stable codes, including UNLOCKED_ASSET (a reference that is neither in the lockfile nor on disk), ABSOLUTE_PATH, MISSING_URI and VFR_MEDIA. With --check-media, it also hashes hydrated files (MEDIA_NOT_HYDRATED, MEDIA_SHA_MISMATCH). See CI validation and validate.