# The CLI


`build/effects` is the renderer. Every command takes a project directory (or, for `beats`, an audio file), compiles the project into a shared library under `<project>/.effects/`, loads it and does one job.

```bash
effects render <project> [--out f.mp4] [--from s] [--to s] [--fps n] [--workers n] [--scale k]
                         [--crf n] [--preset p] [--tune t] [--encoder auto|x264|nvenc]
effects still  <project> <t>... [--out dir] [--scale k] [--release 1]
effects mix    <project> [--out f.wav] [--from s] [--to s]
effects bench  <project> [--frames n]
effects build  <project>
effects beats  <audio file> [--band bass|full|high] [--threshold x]
```

`odin` and `ffmpeg` must be on `PATH`: the first compiles the project, the second encodes and decodes. Progress and messages go to stderr; the path of what was written goes to stdout, so `out=$(effects render project)` works.

## render

Renders the video to an MP4, by default `<project>/.effects/<project>.mp4`.

```bash
$ effects render projects/spot
$ effects render projects/spot --from 3 --to 7 --scale 0.5   # a stretch, at half size
$ effects render projects/spot --crf 16 --tune grain         # dark, grainy films
```

| Option | Meaning | Default |
| --- | --- | --- |
| `--out f.mp4` | Where to write the film. | `.effects/<name>.mp4` |
| `--from s`, `--to s` | Render only this stretch, in seconds. | The whole video |
| `--fps n` | Frames per second. | The video's `fps` |
| `--scale k` | Output size as a multiple of the design size, rounded to even pixels. | 1 |
| `--workers n` | Render threads. | One per core, capped by available memory |
| `--encoder` | `x264`, `nvenc`, or `auto`: NVENC when a test encode succeeds. | `auto` |
| `--crf n` | Quality: x264's CRF, or NVENC's constant QP. Lower is better and larger. | 18 |
| `--preset p` | x264 preset (`medium`, `slow`, …). For NVENC, `p1` to `p7`; anything else means `p5`. | `medium` |
| `--tune t` | x264 `-tune`. `grain` keeps fine noise in dark gradients, at the price of larger files. | None |

How it works: the frames are split into one contiguous chunk per worker. Each worker draws its chunk on its own CPU raster surface and pipes raw BGRA into its own encoder. The segments are then concatenated without re-encoding and muxed with the mixed soundtrack (AAC, 256 kb/s). The output is H.264, 8-bit 4:2:0, tagged BT.709.

At the end `render` counts the video frames in the file and warns if the number differs from what it drew.

With NVENC at most 12 workers are used. If an NVENC session fails mid-render, the chunks it was encoding are drawn again and encoded with x264.

## still

Writes PNGs of single frames.

```bash
$ effects still projects/spot 0.3 1.5 4.2
/…/projects/spot/.effects/stills/0000.30.png
/…/projects/spot/.effects/stills/0001.50.png
/…/projects/spot/.effects/stills/0004.20.png
```

| Option | Meaning | Default |
| --- | --- | --- |
| `<t>...` | One or more times in seconds. | 0 |
| `--out dir` | Where the PNGs go. | `.effects/stills/` |
| `--scale k` | Size as a multiple of the design size. | 1 |
| `--release 1` | Draw from the optimized build: slower to compile, faster to draw. Worth it for shader-heavy frames. | Off |

Files are named after their time, zero-padded to two decimals. `still` uses the unoptimized build, so the wait is the 0.4 s compile plus the frames themselves.

## mix

Writes the video's sounds, mixed, as a 32-bit float stereo WAV at 48 kHz, and prints how long the mix took and its peak level in dB.

```bash
$ effects mix projects/spot
mixed 3 sounds, 0.00s–12.40s, in 0.31s (peak -1.0 dB)
```

`--from` and `--to` mix a stretch; `--out` names the file (default `.effects/<name>.wav`). Use it to listen to a score without rendering pictures. See [sound](/docs/sound/).

## bench

Draws frames spread evenly across the whole video on one thread, at full size, and prints the average and the worst frame time.

```bash
$ effects bench projects/spot
240 frames across 7.0s · 13.75 ms/frame average, 31.32 ms worst (one thread, 1920x1080)
```

`--frames n` sets how many (default 240). Multiply the average by the frame count and divide by your cores for a floor on the render time; encoding comes on top. See [what things cost](/docs/performance/).

## build

Compiles the project and stops. Use it to check that code compiles. On failure it prints the compiler's output and exits with status 1.

## beats

Analyses an audio file (anything ffmpeg decodes) and prints what it finds, to cut to.

```bash
$ effects beats assets/song.wav --band bass
```

It lists every hit with its time, strength and level, then the most common gap between neighbouring hits as a tempo guess, then the drops. `--band` chooses what counts as a hit: `bass` (kicks and 808s, the default), `high` (snares and hats) or `full`. `--threshold` is the smallest jump in log energy that counts: 0.35 by default, 1 for hard hits only. The same analysis is available to scenes as [`fx.onsets` and `fx.drops`](/docs/sound/).

## What a project directory gets

| Path | What |
| --- | --- |
| `.effects/video-dev.so`, `video-release.so` | The compiled project. |
| `.effects/<name>.mp4`, `<name>.wav` | Renders and mixes. |
| `.effects/stills/` | Stills. |
| `.effects/analysis/` | Cached audio analysis. |
| `timing.json` | Times moved in the editor. Not in `.effects/`: it is part of the project. |

`.effects/` is disposable and belongs in `.gitignore`.
