# Delivery

The deliverable Laminolith writes itself is an EXR image sequence. Video is made by ffmpeg encoding the frames that `lamino` streams.

## EXR image sequences

```sh
lamino render shots/010/010.comp.ts --frames 1001-1120 \
  --out '$OUT/SHOW_010_v001/SHOW_010.####.exr' --json
```

It evaluates at full resolution, crops to the display window and writes. No display transform is applied; the scene-linear values are written as they are. The node's colour state is recorded in `lamino:colorspace` in the EXR header. Frames are given in the forms `1001-1120`, `1,3,5-9` and `1-9x2`.

| Option | Meaning |
| --- | --- |
| `--half` | Write half float instead of 32-bit float |
| `--exr-compression <...>` | Compression. `none`, `rle`, `zips`, `zip`, `piz`, `pxr24`, `b44`, `b44a`, `dwaa`, `dwab` |
| `--keep-overscan` | Keep the data window (the pixels outside the frame) |
| `--node <NODE>` | Write the given node instead of the comp output |
| `--stop-on-error` | Stop at the first frame that fails to evaluate. By default it carries on to the end and lists the failed frames in `failed` |

## Version folder rules

Output can go only inside a version folder of the form `$OUT/<name>_vNNN/`. Frames inside it are never overwritten.

- Before writing, it checks the headers (`lamino:nodeKey` and `lamino:outputOptions`) of every frame already in the version folder.
- If they all match the current graph and output settings, it skips the existing frames and writes only the missing ones (resuming an interrupted render).
- If even one differs, it writes nothing and returns `E_PATH_VERSION_EXISTS`. After changing the comp, bump the version (`_v002`).
- A version that another render is still writing gives `E_OUTPUT_LOCKED`.

These rules mean old and new frames never mix in one version folder.

## Video

Video is made with the bundled script `lamino_movie.py`. It lives in `contrib/` next to `lamino`, and `lamino --version` shows where. It needs `ffmpeg` and Python 3.8 or later.

| What to make | Command |
| --- | --- |
| Video for delivery | `python <contrib>/lamino_movie.py shots/010/010.comp.ts --frames 1001-1120 --out '$OUT/SHOW_010_v001/SHOW_010.mov' --preset prores` |
| Small video for review | Add `--preview --out shots/010/.lamino/preview/010_review.mp4`. The picture is the same as `lamino preview` |
| Video that joins an OTIO edit | `--timeline edit/SHOW.otio --out edit/.lamino/preview/SHOW.mp4` |
| Video with alpha | `--alpha --preset prores4444`. The alpha is straight |

The presets are `h264`, `hevc`, `prores`, `prores4444`, `dnxhr_hq` and `dnxhr_hqx`. `-- <ffmpeg options>` changes the encoding settings. The script attaches the correct colour labels (BT.709, limited range) and puts the file in a location under the same rules as `lamino` itself. If it fails partway, no video is left behind. Asking `lamino` to write video directly, as in `render --out x.mov`, gives `E_INVALID_ARGUMENT`.

In video with alpha, colour is divided by alpha, so light added with alpha 0 (such as a glow that has no alpha) does not appear.

## Frame streams

For encodings the script does not cover, use the stream directly. `render --pipe` streams full-resolution frames (or `--proxy` frames), and `preview --pipe` streams the same picture as the preview, both with the display transform applied, to stdout.

| Format | Content | Notes |
| --- | --- | --- |
| `y4m` | YUV4MPEG2, BT.709 limited range, 4:4:4, 16 bit. Size and frame rate are in the stream | Only for an sRGB or Rec.709 display. Label it on the ffmpeg side, for example `-vf setparams=colorspace=bt709:color_primaries=bt709:color_trc=bt709:range=tv`. For the Rec.2020 family, `--matrix bt2020nc` |
| `ppm` | Concatenated R'G'B' 16-bit PPMs. Works with any display | No frame rate in it. Conversion to Y'CbCr happens on the ffmpeg side |
| `pam` | R'G'B'A 16-bit PAM. Straight alpha. `render --pipe` only | For video with alpha |

Only frames go to stdout; the JSON result comes out as the last line of stderr. The stream ends at a failed frame, so throw away what ffmpeg wrote. Windows PowerShell 5 pipes corrupt binary data, so run it from Git Bash or cmd.

## Edits (OTIO)

A sequence of several shots is described as OpenTimelineIO JSON (`edit/<name>.otio`). A clip refers to a comp, an image sequence or a video. The agent writes the `.otio`; `lamino` only reads it.

- `lamino timeline edit/SHOW.otio --handles 8` checks which comp each clip maps to, whether the footage is all there and whether the handles are long enough.
- If a comp does not have the frames a cut uses, you get `E_OTIO_COVERAGE`. Fix it by extending the comp's `frames`, not by trimming the cut in the edit.
- Frame rates are limited to those in the table (24, 25, 30, 48, 50, 60 and the 1001 family). Each comp's fps must match the track, and all comps must have the same resolution.
- Transitions are treated as cuts. Constant speed changes and freeze frames are read. Build speed curves inside the comp with `retime`.

## Reproducible renders

`lamino render --job job.json` renders exactly as the job definition says (repository, commit, comp, frames, destination, lock hash). It refuses to render if the working tree's `HEAD` differs from the job's commit, if the source has uncommitted changes, or if the footage differs from the lock. It is the entry point for managed render environments and is rarely used by hand.
