@anime-studio/cli 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -34,7 +34,26 @@ layer) the picture is transparent.
34
34
 
35
35
  ## 2. MP4 without a browser
36
36
 
37
- The repo's own promo videos are rendered this way (`examples/promo/render.ts`). Steps:
37
+ **Use `toon video` (0.3+).** It takes a scene or a sequence, renders frames in parallel worker
38
+ threads with resvg, streams them in order into ffmpeg and mixes the audio with the engine's own
39
+ levels (fades, loops, `duck` under speech):
40
+
41
+ ```bash
42
+ toon video my.scene.json -o out/my.mp4 # H.264 + AAC
43
+ toon video my.sequence.json -o out/ep.mp4 --width 1920 # resized (one side keeps the aspect)
44
+ toon video my.scene.json -o out/quick.mp4 --to 2 --fps 12 # a quick check: 2 s at 12 fps
45
+ toon video my.scene.json -o out/clip.webm --transparent # VP9 with alpha (also .mov ProRes 4444)
46
+ toon video my.scene.json -o out/loop.gif --width 480 # no audio in a GIF
47
+ toon video my.scene.json -o out/frames # PNG frames 00000.png… + audio.wav
48
+ toon render my.scene.json --time 2.6 -o f.png # one still, rasterised the same way
49
+ ```
50
+
51
+ From code: `renderVideo(path, { out, from?, to?, fps?, width?, workers?, transparent?, mute? })`
52
+ from `@anime-studio/cli`. It needs `ffmpeg` on the PATH (not for PNG frames without audio).
53
+ Text uses the fonts the frame names, found with fontconfig; pass `--fonts <dir>` for fonts that
54
+ are not installed.
55
+
56
+ **By hand** (what `toon video` does, if you need your own pipeline):
38
57
 
39
58
  1. Load the scene and its assets, `validateScene(doc, assets)`, `prepareScene(doc, assets)`.
40
59
  2. Frame count: `frameCount(scene)` (= ⌈duration × fps⌉ without float noise); time of frame i:
@@ -43,9 +62,11 @@ The repo's own promo videos are rendered this way (`examples/promo/render.ts`).
43
62
  `rsvg-convert -w W -h H -o 00042.png 00042.svg`. Run ~8 conversions at once (a small async
44
63
  pool over `execFile`); frames are independent, so order does not matter.
45
64
  4. Encode: `ffmpeg -framerate FPS -i %05d.png -c:v libx264 -preset slow -crf 14 -pix_fmt yuv420p`.
46
- 5. Audio: `scene.audio` lists `{ src, start, volume }` events (`say` with `audio`, `sound`). Mix
47
- them with one input each, `adelay=<ms>:all=1`, `volume=`, `amix=…:normalize=0`, `apad`, `atrim`
48
- to the video length, then mux with `-c:a aac`. Resolve `src` against the scene file's folder.
65
+ 5. Audio: `scene.audio` lists events (`say` with `audio`, `sound`) with `src`, `start`, `volume`
66
+ and the mix fields (`trimStart`, `loop`, `maxDuration`, `fadeIn`, `fadeOut`, `duck`, `kind`, `length`).
67
+ `mixAudio(events, duration)` from `@anime-studio/cli` mixes them with `audioGain` (core) and
68
+ `writeWav` saves the result; mux it with `-c:a aac`. Resolve `src` against the scene file's
69
+ folder.
49
70
 
50
71
  [`../examples/render-video.ts`](../examples/render-video.ts) does all of it for a scene or a
51
72
  sequence:
@@ -65,7 +65,7 @@ Every action has `at` (seconds); actor actions have `actor`. Valid `action` valu
65
65
  | Camera | `camera` `x`/`y`/`zoom`/`duration`, or `follow`, `frame: [ids]`, `punch`, `path`… |
66
66
  | Cartoon effect | `fx` `type` (`surprise`, `question`, `sweat`, `sparkle`, `dust`, `hearts`, `impact`…) |
67
67
  | Impact | `shake` `amount`, `duration` |
68
- | Sound / light | `sound` `audio`; `light` `channel`, `value`, `duration` |
68
+ | Sound / light | `sound` `audio` (+ `volume`, `from`, `duration`, `loop`, `fadeIn`, `fadeOut`, `duck`); `light` `channel`, `value`, `duration` |
69
69
  | In-scene transition | `transition` `type` (`fade`, `iris`, `wipe`, `flash`), `mode`, `duration` |
70
70
 
71
71
  Clip layers mix in order: the `layer: -1` base loops underneath, gestures on layer 0 override it
@@ -34,21 +34,20 @@ error listing all issues. `validateScene` **without assets checks only the schem
34
34
  | `script[13].action: Invalid discriminator value. Expected 'play' \| 'set' \| …` | Not an action; use one of the listed ones (a gesture is `play` + `clip`) |
35
35
  | `script[11].type: Invalid option: expected one of "surprise"\|"exclaim"\|…` | fx type not in the list |
36
36
  | `characters.kai: cannot load "…": ENOENT` | Path is relative to the scene file; the file must exist |
37
- | `walkTo needs a "walk" clip on "…"` | The rig has no such locomotion clip; pass `clip` or use a kit character |
37
+ | `walkTo needs a "walk" clip on "…". Known clips: …` | The rig has no such locomotion clip; pass `clip` or use a kit character |
38
+ | `script[4] (pose): "glad" is not a pose of the "emotion" control of "…". Valid: neutral, sleep, happy, …` | Use a listed value (`toon describe`); every key of a `{ name: weight }` blend too |
39
+ | `script[2] (pose): "~half" is not a pose of the "view" control of "…". Valid: … use "half" and turn the actor round with its "flip"` | Body views are not mirrored by name: `flip` / `face` the actor (`~` angles exist for the kit's `head` control only) |
40
+ | warn `script[7] (walkTo): walkTo of "maya" (2–3.5 s) overlaps script[5] (1–3 s): …` | Two walks of one actor at once: the later takes over mid-walk. Start it when the first ends |
38
41
  | `unknown bone "x". Known bones: …` | (characters) use a listed bone id |
39
42
  | `parent "x" is not declared before this bone` | (characters) parents first in `skeleton` |
40
43
 
41
- The compiler stops at the first script error: fix it and validate again until ✓.
44
+ Every bad script action is reported (one error each, at its own `script[i]` path), so fix them all
45
+ before validating again. (`compileScene` itself throws one `SceneError` listing them all.)
42
46
 
43
47
  ## What validation does NOT catch
44
48
 
45
49
  These pass `toon validate` and `toon debug` silently; check them yourself:
46
50
 
47
- - **Unknown pose values.** `{ "action": "pose", "control": "emotion", "value": "glad" }` is
48
- accepted and does nothing. Only use values `toon describe` lists (kit emotions: `neutral`,
49
- `sleep`, `happy`, `joy`, `surprised`, `sad`, `smug`, `scared`, `angry`, `dead`, `determined`,
50
- `calm`, `excited`, `annoyed`, `gape`).
51
- - **Overlapping `walkTo`** for one actor: the second takes over from where the actor is.
52
51
  - **Staging mistakes**: actors facing away from whom they talk to, a character walking off the
53
52
  set, a gesture that ends before the line it accompanies, a camera that frames nobody. Only
54
53
  looking at frames catches these (the director's `check` catches many for staged episodes).
@@ -155,8 +155,9 @@ Nobody walks while seated: `getUp` first (the director does it for you). See
155
155
  Stagger them 0.1–0.3 s; one clear action at a time.
156
156
  - **Front-view arm swings**: from the front a clip's arm swing reads as flapping; prefer hand
157
157
  positions (the director's front gestures are IK reaches to the face).
158
- - **Unlisted names**: an unknown `view` value is accepted and silently falls back to the default
159
- view. Use only the names listed above (or from `toon describe`).
158
+ - **Unlisted names**: an unknown `view` value (or a mirrored one, `"~half"`: flip the actor
159
+ instead) is a validation error listing the valid views. Use only the names listed above (or
160
+ from `toon describe`).
160
161
  - **Not looking.** A script that validates can still have floating feet or a hand off the prop.
161
162
 
162
163
  ## Examples (run from the repo root; output in `examples/out/`)
@@ -32,9 +32,9 @@ Every action has `at` (seconds from the scene's start, ≥ 0) and `action`. Acto
32
32
  | `camera` | `x?`, `y?`, `zoom?`, `rotation?`, `duration?` (1; **0 = a cut**), `ease?` | Moves and cuts |
33
33
  | `camera` (rigs) | `follow` (id/`null`), `offset`, `lag`, `axes` (`x` \| `xy`), `deadZone`, `lookAhead`, `blend`; `frame` (ids/`null`), `padding`, `on` (`body` \| `face`), `minZoom`, `maxZoom`, `band`; `path` (`[[x,y]…]`); `punch`; `handheld`; `dolly`; `focus`, `blur`, `focusRange`; `motionBlur` | Tracking, two-shots that keep everyone in frame, curved moves, punch-ins, handheld drift, depth of field |
34
34
  | `transition` | `type` (`fade` \| `iris` \| `wipe` \| `flash`), `duration?`, `mode?` (`outIn` default, `out`, `in`), `color?`, `direction?` (wipe), `target?` (iris centre: id or `[x, y]`) | Inside a scene: an iris out on the last beat, a wipe in at the start |
35
- | `fx` | `type`, `actor?`, `anchor?` (`head` default, `origin` = feet), `offset?`, `prop?`, `x?`, `y?`, `duration?`, `scale?`, `color?`, `fill?`, `text?` + `style?` (captions), `angle?` (speedLines) | Cartoon accents (list below) |
35
+ | `fx` | `type`, `actor?`, `anchor?` (`head` default — `body` (chest) for `burst`, `origin` for `aura`; `origin` = feet), `offset?`, `prop?`, `x?`, `y?`, `duration?`, `scale?`, `color?`, `fill?`, `text?` + `style?` (captions), `angle?` (speedLines), `layer?` (speedLines/focusLines: `behind` default, `replace`, `over`) | Cartoon accents (list below) |
36
36
  | `shake` | `duration?` (0.5), `amount?` (10 px), `frequency?` (12 Hz) | Impacts |
37
- | `sound` | `audio` (id in the scene's `audio`), `volume?` | Sound effects |
37
+ | `sound` | `audio` (id in the scene's `audio`), `volume?`, `from?` (seconds into the file), `duration?`, `loop?`, `fadeIn?`, `fadeOut?`, `duck?` | Sound effects, ambiences and music beds: `{ "at": 0, "action": "sound", "audio": "music", "loop": true, "fadeIn": 1, "fadeOut": 2, "duck": 0.3 }` plays music under the whole scene, dipping to 30 % under every line |
38
38
  | `light` | `channel` (lighting channel), `value`, `duration?`, `ease?` | Lamps on, sunrise (`lights.<id>.intensity`, `lighting.ambient.opacity`) |
39
39
  | `impulse` | `prop`, `vector` (`[vx, vy]` px/s) | Kicking a physics prop |
40
40
  | `put` | `prop`, `on` (prop id or `null`) | A prop resting on another (a cup on a tray) |
@@ -18,7 +18,7 @@ These are the **only** valid `type` values.
18
18
  |---|---|
19
19
  | `type` | One of the 22 below |
20
20
  | `actor` | Attach to an actor: follows, flips and scales with it |
21
- | `anchor` | Actor anchor (default `head` if the rig has it); `"origin"` = between the feet |
21
+ | `anchor` | Actor anchor (default `head` if the rig has it; `body` for `burst`, `origin` for `aura`); `"origin"` = between the feet, `"body"` = the chest |
22
22
  | `offset` | `[x, y]` from the anchor, character setup space |
23
23
  | `prop` | At a prop, following it (unknown id = error) |
24
24
  | `x`, `y` | Scene point when not attached (screen point for screen-space fx) |
@@ -28,6 +28,7 @@ These are the **only** valid `type` values.
28
28
  | `fill` | Secondary colour (drops, hearts, sparkles, flames, speed lines) |
29
29
  | `text`, `style` | `caption` only: `style` is `title` \| `impact` \| `ko` \| `place` |
30
30
  | `angle` | `speedLines` only: direction of travel, degrees (0 = right) |
31
+ | `layer` | `speedLines` / `focusLines` only: `behind` (default: over the set, under the actors), `replace` (a plain backdrop instead of the set — `color` for speedLines, `fill` for focusLines — the actors on top), `over` (on top of everything). With `actor`: behind that actor only |
31
32
 
32
33
  Start a reaction fx ~0.05 s before the reaction; time physics fx (`dust`, `impact`) from a rendered
33
34
  still of the moment the body lands.
@@ -59,12 +60,12 @@ but stay readable.
59
60
 
60
61
  | `type` | Space | Look | Use | Default s |
61
62
  |---|---|---|---|---|
62
- | `focusLines` | screen | Wedges converging on the centre, new pattern every 2 frames (`color`) | Shock, reveal, shout | 1.2 |
63
- | `speedLines` | screen | Streaks across the frame (`angle`, `fill`) | A dash | 0.8 |
63
+ | `focusLines` | screen, behind the actors (`layer`) | Wedges converging on the centre, new pattern every 2 frames (`color`) | Shock, reveal, shout | 1.2 |
64
+ | `speedLines` | screen, behind the actors (`layer`) | Streaks across the frame (`angle`, `fill`) | A dash | 0.8 |
64
65
  | `impactFrame` | screen | Whole frame white then black (`fill`, `color`) | The instant a hit lands | 0.14 |
65
66
  | `caption` | screen | `text` in a `style`: `title` (big yellow), `impact` (red, shaking), `ko` (huge), `place` (italic name sliding in bottom left) | Title cards, place names | 2 |
66
- | `burst` | scene | Jagged yellow star, red heart, white core | A punch landing | 0.35 |
67
- | `aura` | behind actor | Three layers of flickering flames (`fill`; `anchor: "origin"`) | Powering up | 3 |
67
+ | `burst` | scene | Jagged yellow star, red heart, white core, about a head across; default anchor `body` (chest) | A punch landing: on the hitter's `fist` or the target's chest, never the face | 0.35 |
68
+ | `aura` | behind actor | Animated tongues of flame from the feet (default anchor `origin`), smooth flicker, soft glow (`fill`) | Powering up | 3 |
68
69
  | `ghost` | scene | Little ghost floating up (`anchor: "origin"`) | Comic K.O. | 4 |
69
70
 
70
71
  A `place` caption is the cheapest way to name a location when a set first appears.