Explainer videos and product demos made by your AI agent. Free and open source: a local voice (Kokoro), word timing (Whisper) and a canvas renderer turn a script into a narrated MP4.
JavaScript ai-agentsanimationcanvasclaude-codecodexexplainer-videoffmpegjavascriptkokoroproduct-demotext-to-speechvideo-generationwhisper
Render one project in several sizes (#15)
Vincent Schmalbach797624440d3b
diff --git a/AGENTS.md b/AGENTS.mdindex 5b973f7..3f11220 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -599,6 +599,41 @@ elements draw themselves in, frame one is empty. Give the title`enter: 'none'` so it is there from the first frame, or pick another coverframe in the app.+## One project, several sizes++Use `--size <size>` on `preview`, `still`, `sheet`, `check` and `render`+to use another size for one run. It leaves `video.json` alone. The narration+and word times are shared between sizes. Captions set to `"auto"` follow+the size you choose.++Place things from `s.safe`, `s.cx`, `s.cy`, `s.row`, `s.col` and `s.grid`+instead of fixed pixel positions. Use `s.portrait` to stack things in tall+frames. Keep text sizes relative to the frame, for example `s.W * 0.05`.+`examples/merge-vs-rebase` works in `9:16` and in `youtube`; its scenes.js+shows one way to do it.++```js+intro(s) {+ const cells = s.grid(s.portrait ? 1 : 2, s.portrait ? 2 : 1);+ ['Question', 'Answer'].forEach((label, i) => {+ const { x, y, w, h } = cells[i];+ s.box(label, { x, y, w: w * 0.8, h: h * 0.6,+ size: s.W * 0.05, at: i ? '#answer' : 0 });+ });+}+```++For every size, run `check --size <size>` and look at+`sheet --size <size>`. Fix cut-off text and overlaps. Then run+`render --size <size>` for each size.++`render --size tiktok` writes `out/video-tiktok.mp4` and matching subtitle,+cover and chapter files. With `--draft`, it writes `draft-tiktok.mp4`.+Stills go in `out/stills-tiktok/`. A sheet is `out/sheet-tiktok.jpg`, or+`out/sheet-intro-tiktok.jpg` with `--scene intro`. Ratios use a hyphen in+file names, for example `video-9-16.mp4`. Without `--size`, names stay the+same. `render --out` still sets the file name you choose.+## Pace`pace` makes the whole video quicker or slower. At 1.3 the voice speaks 30%@@ -720,11 +755,11 @@ when `ink` or `muted` has too little contrast against `bg`.|---|---|| `init <dir>` | creates a project (`--theme`, `--size`, `--pace`, `--language`, `--voice`, `--title`) || `voice [project]` | makes the narration and the word times, saved per scene so only changed scenes are made again |-| `preview [project]` | a live preview in the browser that reloads when you save |-| `still [project] [times]` | PNG pictures at `12.5`, `scene`, `[email protected]` or `scene@end` (`--transparent` keeps alpha) |-| `sheet [project]` | one image with many frames of the video or of one scene (`--scene`, `--every`) |-| `check [project]` | finds layout, timing and pronunciation problems |-| `render [project]` | the video plus subtitle files, chapters and a cover (`--format mp4`, `gif`, `webm` or `mov`, `--transparent`, `--draft`, `--from`, `--to`, `--workers`, `--out`) |+| `preview [project]` | a live preview in the browser that reloads when you save (`--size`) |+| `still [project] [times]` | PNG pictures at `12.5`, `scene`, `[email protected]` or `scene@end` (`--size`, `--transparent` keeps alpha) |+| `sheet [project]` | one image with many frames of the video or of one scene (`--scene`, `--every`, `--size`) |+| `check [project]` | finds layout, timing and pronunciation problems (`--size`) |+| `render [project]` | the video plus subtitle files, chapters and a cover (`--format mp4`, `gif`, `webm` or `mov`, `--transparent`, `--size`, `--draft`, `--from`, `--to`, `--workers`, `--out`) || `verify [project]` | checks the finished MP4, WebM or MOV: loudness, black frames, silence, clear voice (`--file` picks another file) || `capture [project] <url>` | saves screenshots, wording, colors, fonts and logos from a live site (`--mobile`, `--json`) || `image [project] <name> "<prompt>"` | makes an illustration with OpenRouter |@@ -813,6 +848,7 @@ there for your own math.| Member | Meaning ||---|---|| `s.W`, `s.H`, `s.cx`, `s.cy` | canvas size and its center (on Shorts, TikTok and Reels the center of `s.safe`) |+| `s.portrait` | true when the frame is taller than wide || `s.safe` | `{ x, y, w, h, left, top, right, bottom }`: the area for content (a 7% margin, or the part a platform leaves free) || `s.row(n, { width, x })` | n x positions spread over a width || `s.col(n, { height, y })` | n y positions spread over a height, centered in `s.safe` |diff --git a/engine/stage.js b/engine/stage.jsindex f421cd9..b59b45f 100644--- a/engine/stage.js+++ b/engine/stage.js@@ -25,6 +25,7 @@ export class Stage {this.pen = engine.pen;this.W = engine.W;this.H = engine.H;+ this.portrait = this.H > this.W;// Platform formats (tiktok, reels, shorts...) keep content inside the part// of the frame the app leaves free, so the center moves with it.this.safe = engine.safeArea;diff --git a/examples/merge-vs-rebase/scenes.js b/examples/merge-vs-rebase/scenes.jsindex 167e217..4487d1f 100644--- a/examples/merge-vs-rebase/scenes.js+++ b/examples/merge-vs-rebase/scenes.js@@ -1,91 +1,129 @@-// git merge vs rebase, as a vertical short. Time flows down the screen: main-// is the left column, your branch the right one. Captions fill the lower part-// of the frame, so the graph stays above y = 1300.+// Time flows down in portrait and across in wide frames.+function layout(s) {+ const { safe } = s;+ const scale = s.portrait ? Math.min(safe.w / 928, safe.h / 1221) : Math.min(s.W / 1920, s.H / 1080);+ const x = (v) => safe.left + (v - 76) * safe.w / 928;+ const y = (v) => safe.top + (v - 76) * safe.h / 1221;+ const r = (s.portrait ? 58 : 96) * scale;+ const count = s.id === 'hook' ? 5 : s.id === 'merge' ? 6 : 7;+ const xs = s.row(count, { width: safe.w - r * 2 });+ const midY = safe.top + safe.h / 2;+ const point = (i, feature = false) => s.portrait+ ? [x(feature ? 760 : 300), y(400 + i * 142)]+ : [xs[i], midY + safe.h * (feature ? 0.2 : -0.2)];+ return { x, y, point, scale, r, titleY: s.portrait ? y(190) : safe.top + safe.h * 0.1 };+}-const MAIN_X = 300;-const FEAT_X = 760;-const Y = (i) => 400 + i * 142;-const R = 58;+function link(s, a, b, r, o) {+ const dx = b[0] - a[0];+ const dy = b[1] - a[1];+ const d = Math.hypot(dx, dy);+ s.line([[a[0] + dx * r / d, a[1] + dy * r / d], [b[0] - dx * r / d, b[1] - dy * r / d]], o);+}// Draws main (A to E) and the feature branch (F1, F2 off B).-function history(s, { at = -1, main = true, feature = true, featureOut, ghost = false } = {}) {+function history(s, l, { at = -1, main = true, feature = true, featureOut, ghost = false } = {}) {+ const { point, scale, r } = l;const t0 = s.time(at);const when = (d) => (t0 < 0 ? t0 : t0 + d);if (main) {['A', 'B', 'C', 'D', 'E'].forEach((c, i) => {- s.circle({ id: c, x: MAIN_X, y: Y(i), r: R, label: c, size: 52, color: 'blue', at: when(i * 0.15) });- if (i) s.line([[MAIN_X, Y(i - 1) + R], [MAIN_X, Y(i) - R]], { color: 'blue', at: when(i * 0.15 - 0.05), sfx: false });+ const [x, y] = point(i);+ s.circle({ id: c, x, y, r, label: c, size: (s.portrait ? 52 : 64) * scale, color: 'blue', at: when(i * 0.15) });+ if (i) link(s, point(i - 1), point(i), r, { color: 'blue', at: when(i * 0.15 - 0.05), sfx: false });});- s.note('main', { x: MAIN_X, y: Y(0) - 105, size: 44, color: 'blue', at: t0 });+ const [x, y] = point(0);+ s.note('main', { x, y: y - (s.portrait ? 105 : 150) * scale, size: Math.max(32, (s.portrait ? 44 : 56) * scale), color: 'blue', at: t0 });}if (!feature) return;const f = { at: when(0.8), out: featureOut, dashed: ghost, opacity: ghost ? 0.45 : 1 };- s.line([[MAIN_X + R * 0.7, Y(1) + R * 0.7], [FEAT_X - R * 0.7, Y(2) - R * 0.7]], { color: 'green', ...f, sfx: false });- s.circle({ id: 'F1', x: FEAT_X, y: Y(2), r: R, label: 'F1', size: 46, color: 'green', ...f });- s.line([[FEAT_X, Y(2) + R], [FEAT_X, Y(3) - R]], { color: 'green', ...f, sfx: false });- s.circle({ id: 'F2', x: FEAT_X, y: Y(3), r: R, label: 'F2', size: 46, color: 'green', ...f, at: f.at + 0.15 });- s.note('your branch', { x: FEAT_X, y: Y(2) - 105, size: 44, color: 'green', ...f });+ link(s, point(1), point(2, true), r, { color: 'green', ...f, sfx: false });+ const [x1, y1] = point(2, true);+ const [x2, y2] = point(3, true);+ s.circle({ id: 'F1', x: x1, y: y1, r, label: 'F1', size: Math.max(32, (s.portrait ? 46 : 56) * scale), color: 'green', ...f });+ link(s, point(2, true), point(3, true), r, { color: 'green', ...f, sfx: false });+ s.circle({ id: 'F2', x: x2, y: y2, r, label: 'F2', size: Math.max(32, (s.portrait ? 46 : 56) * scale), color: 'green', ...f, at: f.at + 0.15 });+ s.note('your branch', { x: s.portrait ? x1 : (x1 + x2) / 2, y: y1 + (s.portrait ? -105 : 150) * scale, size: Math.max(32, (s.portrait ? 44 : 56) * scale), color: 'green', ...f });}export default {hook(s) {- s.title('merge or *rebase*?', { y: 190, size: 88, at: 0 });- history(s, { at: 'branch' });- s.icon('git-merge', { x: 300, y: 1150, size: 120, color: 'purple', at: '#two', label: 'merge', labelSize: 48 });- s.icon('git-commit-vertical', { x: 780, y: 1150, size: 120, color: 'accent', at: '#or', label: 'rebase', labelSize: 48 });+ const l = layout(s);+ s.title('merge or *rebase*?', { y: l.titleY, size: Math.max(64, 88 * l.scale), at: 0, enter: 'none' });+ history(s, l, { at: 'branch' });+ const xs = s.portrait ? [l.x(300), l.x(780)] : s.row(2, { width: s.safe.w * 0.18, x: s.safe.left + s.safe.w * 0.18 });+ const y = s.portrait ? l.y(1150) : l.point(2, true)[1];+ s.icon('git-merge', { x: xs[0], y, size: (s.portrait ? 120 : 160) * l.scale, color: 'purple', at: '#two', label: 'merge', labelSize: Math.max(32, (s.portrait ? 48 : 56) * l.scale) });+ s.icon('git-commit-vertical', { x: xs[1], y, size: (s.portrait ? 120 : 160) * l.scale, color: 'accent', at: '#or', label: 'rebase', labelSize: Math.max(32, (s.portrait ? 48 : 56) * l.scale) });},merge(s) {- s.title('merge', { y: 190, size: 88, at: -1 });- history(s);- const my = Y(5);- s.circle({ id: 'M', x: MAIN_X, y: my, r: R + 6, label: 'M', size: 52, color: 'purple', at: '#knot', enter: 'pop' });- s.line([[MAIN_X, Y(4) + R], [MAIN_X, my - R - 6]], { color: 'purple', at: s.mark('knot') - 0.2 });- s.line([[FEAT_X, Y(3) + R], [MAIN_X + R, my - R * 0.5]], { color: 'purple', at: s.mark('knot') - 0.2 });- s.note('merge commit', { x: 420, y: my, size: 48, color: 'purple', align: 'left', at: s.mark('knot') + 0.4 });+ const l = layout(s);+ s.title('merge', { y: l.titleY, size: Math.max(64, 88 * l.scale), at: -1 });+ history(s, l);+ const [x, y] = l.point(5);+ s.circle({ id: 'M', x, y, r: l.r + 6 * l.scale, label: 'M', size: (s.portrait ? 52 : 64) * l.scale, color: 'purple', at: '#knot', enter: 'pop' });+ link(s, l.point(4), l.point(5), l.r + 6 * l.scale, { color: 'purple', at: s.mark('knot') - 0.2 });+ link(s, l.point(3, true), l.point(5), l.r, { color: 'purple', at: s.mark('knot') - 0.2 });+ s.note('merge commit', { x: s.portrait ? l.x(420) : s.safe.right - 200 * l.scale, y: s.portrait ? y : y - 150 * l.scale, size: Math.max(32, (s.portrait ? 48 : 56) * l.scale), color: 'purple', align: s.portrait ? 'left' : 'center', at: s.mark('knot') + 0.4 });},rebase(s) {- s.title('rebase', { y: 190, size: 88, at: -1 });- history(s, { featureOut: 'takes', ghost: false });- history(s, { main: false, ghost: true, at: s.cueEnd('off') - 0.8 });- const y1 = Y(5);- const y2 = Y(6);- s.line([[MAIN_X, Y(4) + R], [MAIN_X, y1 - R]], { color: 'accent', at: s.mark('replay') + 0.1 });- s.circle({ id: 'F1b', x: MAIN_X, y: y1, r: R, label: "F1'", size: 46, color: 'accent', at: s.mark('replay') + 0.3, enter: 'drop' });- s.line([[MAIN_X, y1 + R], [MAIN_X, y2 - R]], { color: 'accent', at: s.mark('replay') + 0.8 });- s.circle({ id: 'F2b', x: MAIN_X, y: y2, r: R, label: "F2'", size: 46, color: 'accent', at: s.mark('replay') + 1.0, enter: 'drop' });- s.arrow([FEAT_X - 20, Y(2) + 70], [MAIN_X + 90, y1 - 10], { bend: -0.3, dashed: true, color: 'muted', at: s.mark('replay') + 0.1, width: 3 });- s.note('a straight line', { x: 420, y: y2, size: 48, color: 'accent', align: 'left', at: '#line' });+ const l = layout(s);+ s.title('rebase', { y: l.titleY, size: Math.max(64, 88 * l.scale), at: -1 });+ history(s, l, { featureOut: 'takes' });+ history(s, l, { main: false, ghost: true, at: s.cueEnd('off') - 0.8 });+ const [x1, y1] = l.point(5);+ const [x2, y2] = l.point(6);+ link(s, l.point(4), l.point(5), l.r, { color: 'accent', at: s.mark('replay') + 0.1 });+ s.circle({ id: 'F1b', x: x1, y: y1, r: l.r, label: "F1'", size: Math.max(32, (s.portrait ? 46 : 56) * l.scale), color: 'accent', at: s.mark('replay') + 0.3, enter: 'drop' });+ link(s, l.point(5), l.point(6), l.r, { color: 'accent', at: s.mark('replay') + 0.8 });+ s.circle({ id: 'F2b', x: x2, y: y2, r: l.r, label: "F2'", size: Math.max(32, (s.portrait ? 46 : 56) * l.scale), color: 'accent', at: s.mark('replay') + 1.0, enter: 'drop' });+ const [fx, fy] = l.point(2, true);+ const from = s.portrait ? [fx - 20 * l.scale, fy + 70 * l.scale] : [l.point(3, true)[0] + l.r + 20 * l.scale, fy];+ s.arrow(from, [x1 + (s.portrait ? 90 : 0) * l.scale, y1 + (s.portrait ? -10 : 120) * l.scale], { bend: -0.3, dashed: true, color: 'muted', at: s.mark('replay') + 0.1, width: 3 });+ s.note('a straight line', { x: s.portrait ? l.x(420) : (x1 + x2) / 2, y: s.portrait ? y2 : y2 + 180 * l.scale, size: Math.max(32, (s.portrait ? 48 : 56) * l.scale), color: 'accent', align: s.portrait ? 'left' : 'center', at: '#line' });},hashes(s) {- s.title('new hashes', { y: 190, size: 88, at: 0 });+ const l = layout(s);+ s.title('new hashes', { y: l.titleY, size: Math.max(64, 88 * l.scale), at: 0 });+ const cells = s.grid(s.portrait ? 1 : 2, s.portrait ? 2 : 1, { y: s.safe.top + s.safe.h * (s.portrait ? 0.48 : 0.5), h: s.safe.h * 0.56, gap: s.portrait ? 80 : 120 });const rows = [['F1', 'a3f9c21', "F1'", 'e1d7b09'],['F2', '7be04d8', "F2'", '4c2a8f3'],];rows.forEach(([o, oh, n, nh], i) => {- const y = 480 + i * 340;- s.circle({ id: `o${i}`, x: 230, y, r: R, label: o, size: 46, color: 'green', at: -1, opacity: 0.55, dashed: true });- s.text(oh, { id: `oh${i}`, font: 'mono', x: 340, y, size: 60, align: 'left', color: 'muted', at: -1 });+ const x = s.portrait ? l.x(230) : cells[i].x - 180 * l.scale;+ const tx = s.portrait ? l.x(340) : x + 160 * l.scale;+ const y = s.portrait ? l.y(480 + i * 340) : cells[i].y - 160 * l.scale;+ const nextY = s.portrait ? l.y(630 + i * 340) : y + 320 * l.scale;+ s.circle({ id: `o${i}`, x, y, r: l.r, label: o, size: Math.max(32, (s.portrait ? 46 : 56) * l.scale), color: 'green', at: -1, opacity: 0.55, dashed: true });+ s.text(oh, { id: `oh${i}`, font: 'mono', x: tx, y, size: (s.portrait ? 60 : 72) * l.scale, align: 'left', color: 'muted', at: -1 });s.annotate(`oh${i}`, { type: 'strike', color: 'red', at: s.mark('new') + i * 0.3 });- s.circle({ id: `n${i}`, x: 230, y: y + 150, r: R, label: n, size: 46, color: 'accent', at: s.cue('new') + i * 0.25 });- s.text(nh, { font: 'mono', x: 340, y: y + 150, size: 60, align: 'left', color: 'accent', at: s.mark('new') + 0.2 + i * 0.3, enter: 'type', dur: 0.5 });+ s.circle({ id: `n${i}`, x, y: nextY, r: l.r, label: n, size: Math.max(32, (s.portrait ? 46 : 56) * l.scale), color: 'accent', at: s.cue('new') + i * 0.25 });+ s.text(nh, { font: 'mono', x: tx, y: nextY, size: (s.portrait ? 60 : 72) * l.scale, align: 'left', color: 'accent', at: s.mark('new') + 0.2 + i * 0.3, enter: 'type', dur: 0.5 });});- s.note('same changes, new commits', { y: 1230, size: 48, at: s.cue('commits') });+ s.note('same changes, new commits', { y: s.portrait ? l.y(1230) : s.safe.bottom - 100 * l.scale, size: Math.max(32, (s.portrait ? 48 : 56) * l.scale), at: s.cue('commits') });},rule(s) {- s.icon('triangle-alert', { y: 470, size: 210, color: 'yellow', at: 0.2, bg: 'circle', bgScale: 1.5 });- s.text("Don't rebase\n*shared* branches", { font: 'display', size: 84, y: 850, at: '#shared', lineHeight: 1.15, mark: 'yellow' });- s.icon('users', { y: 1150, size: 120, color: 'muted', at: 'people' });+ const l = layout(s);+ s.icon('triangle-alert', { x: s.portrait ? s.cx : s.safe.left + s.safe.w * 0.22, y: s.portrait ? l.y(470) : s.cy, size: 210 * l.scale, color: 'yellow', at: 0.2, bg: 'circle', bgScale: 1.5 });+ const x = s.portrait ? s.cx : s.safe.left + s.safe.w * 0.65;+ s.text("Don't rebase\n*shared* branches", { x, font: 'display', size: 84 * l.scale, y: s.portrait ? l.y(850) : s.cy - 60 * l.scale, at: '#shared', lineHeight: 1.15, mark: 'yellow' });+ s.icon('users', { x, y: s.portrait ? l.y(1150) : s.cy + 190 * l.scale, size: 120 * l.scale, color: 'muted', at: 'people' });},outro(s) {- s.box('merge', { x: 540, y: 520, w: 760, h: 250, icon: 'git-merge', color: 'purple', size: 56, at: 'merge' });- s.note('history as it happened', { y: 710, size: 48, at: 'happened' });- s.box('rebase', { x: 540, y: 960, w: 760, h: 250, icon: 'git-commit-vertical', color: 'accent', size: 56, at: '#clean' });- s.note('a straight line, easier to read', { y: 1150, size: 48, at: 'easier' });+ const l = layout(s);+ const xs = s.portrait ? [s.cx, s.cx] : s.row(2, { width: s.safe.w * 0.53 });+ const midY = s.safe.top + s.safe.h / 2;+ const ys = s.portrait ? [l.y(520), l.y(960)] : [midY, midY];+ const w = s.portrait ? l.x(920) - l.x(160) : s.safe.w * 0.46;+ s.box('merge', { x: xs[0], y: ys[0], w, h: (s.portrait ? 250 : 460) * l.scale, icon: 'git-merge', iconSize: s.portrait ? undefined : 200 * l.scale, color: 'purple', size: (s.portrait ? 56 : 80) * l.scale, at: 'merge' });+ s.note('history as it happened', { x: xs[0], y: s.portrait ? l.y(710) : ys[0] + 320 * l.scale, size: Math.max(32, (s.portrait ? 48 : 56) * l.scale), at: 'happened' });+ s.box('rebase', { x: xs[1], y: ys[1], w, h: (s.portrait ? 250 : 460) * l.scale, icon: 'git-commit-vertical', iconSize: s.portrait ? undefined : 200 * l.scale, color: 'accent', size: (s.portrait ? 56 : 80) * l.scale, at: '#clean' });+ s.note('a straight line, easier to read', { x: xs[1], y: s.portrait ? l.y(1150) : ys[1] + 320 * l.scale, size: Math.max(32, (s.portrait ? 48 : 56) * l.scale), at: 'easier' });},};diff --git a/src/cli.js b/src/cli.jsindex e25721d..23996f9 100644--- a/src/cli.js+++ b/src/cli.js@@ -26,12 +26,12 @@ Usage: explainroo <command> [project] [options]Make a videoinit <dir> create a project (--theme, --size, --pace, --language es, --voice, --title)voice [project] make the narration (Kokoro, ElevenLabs or a recording) and word timings- preview [project] live preview in your browser, reloads on save (--port)- still [project] [t…] PNG stills: "12.5", "scene", "[email protected]" (--transparent, default: end of every scene)- sheet [project] contact sheet of the whole video (--scene id, --every s)- check [project] find layout, timing and pronunciation problems (--view-width pixels)+ preview [project] live preview in your browser, reloads on save (--port, --size)+ still [project] [t…] PNG stills: "12.5", "scene", "[email protected]" (default: end of every scene; --size, --transparent)+ sheet [project] contact sheet of the whole video (--scene id, --every s, --size)+ check [project] find layout, timing and pronunciation problems (--view-width pixels, --size)render [project] write the video with subtitles, chapters and a cover (--format mp4|gif|webm|mov,- --transparent, --draft, --from s, --to s, --workers n, --out file)+ --transparent, --size, --draft, --from s, --to s, --workers n, --out file)verify [project] check the video: loudness, black frames, narration (--file)Product demos@@ -50,7 +50,9 @@ Referenceicons <word…> search the 1,800+ built-in iconsdoctor check ffmpeg, Chrome, espeak-ng and models (--fetch downloads English models)-Options: --json for machine-readable output. The project defaults to the current folder.+Options: --size <size> overrides video.json for preview, still, sheet, check and render.+ Size outputs get a suffix, like video-tiktok.mp4. --out still wins.+ --json for machine-readable output. The project defaults to the current folder.Docs: AGENTS.md (for coding agents) and https://www.explainroo.com/docs/`;function parseArgs(argv) {@@ -130,19 +132,19 @@ export async function main(argv) {case 'preview': return await preview(pos[0], flags, log);case 'still': {const isProject = pos[0] && fs.existsSync(path.join(pos[0], 'video.json'));- const project = loadProject(isProject ? pos.shift() : undefined);+ const project = loadProject(isProject ? pos.shift() : undefined, { size: textFlag(flags, 'size') });const list = await stills(project, pos, { log, scale: num(flags.scale, 'scale') ?? 1, transparent: !!flags.transparent });print(list.map((s) => `${s.label.padEnd(24)} ${s.file}`).join('\n'), { stills: list });return 0;}case 'sheet': {- const project = loadProject(pos[0]);+ const project = loadProject(pos[0], { size: textFlag(flags, 'size') });const r = await sheet(project, { scene: flags.scene, every: num(flags.every, 'every'), cols: num(flags.cols, 'cols'), log });print(`${r.file} (${r.frames} frames)`, r);return 0;}case 'check': {- const project = loadProject(pos[0]);+ const project = loadProject(pos[0], { size: textFlag(flags, 'size') });const r = await check(project, { log, step: num(flags.step, 'step') ?? 0.25, viewWidth: num(flags['view-width'], 'view-width') ?? null });const errors = r.issues.filter((i) => i.level === 'error').length;const human = r.issues.length@@ -152,7 +154,7 @@ export async function main(argv) {return errors ? 1 : 0;}case 'render': {- const project = loadProject(pos[0]);+ const project = loadProject(pos[0], { size: textFlag(flags, 'size') });const r = await render(project, { log, draft: !!flags.draft, transparent: !!flags.transparent, from: num(flags.from, 'from'), to: num(flags.to, 'to'), workers: num(flags.workers, 'workers'), scale: num(flags.scale, 'scale'), out: textFlag(flags, 'out'), format: textFlag(flags, 'format') });print([r.out, r.subtitles?.srt, r.subtitles?.vtt, r.chapters, r.cover].filter(Boolean).map((f) => path.relative(process.cwd(), f) || f).join('\n'), r);return 0;@@ -224,7 +226,7 @@ export async function main(argv) {return { name, width: f.size[0], height: f.size[1], use: f.use, captions: cfg.captions, content: { x: safe.x, y: safe.y, w: safe.w, h: safe.h } };});const rows = info.map((r) => `${r.name.padEnd(10)} ${`${r.width}x${r.height}`.padEnd(10)} ${r.use}\n${''.padEnd(22)}content area ${r.content.w}x${r.content.h} at ${r.content.x},${r.content.y}${r.captions ? ', captions below it' : ''}`);- print(rows.join('\n') + '\n\nAlso: 16:9, 9:16, 1:1, 4:5 or WIDTHxHEIGHT. Set it with "size" in video.json or init --size.', { formats: info });+ print(rows.join('\n') + '\n\nAlso: 16:9, 9:16, 1:1, 4:5 or WIDTHxHEIGHT. Set it with "size" in video.json or --size on init, preview, still, sheet, check or render.', { formats: info });return 0;}case 'icons': return icons(pos, print);@@ -283,7 +285,8 @@ function init(dir, flags, print) {}async function preview(dir, flags, log) {- let project = loadProject(dir);+ const size = textFlag(flags, 'size');+ let project = loadProject(dir, { size });let { timeline } = await prepare(project, { log });let state = makeState(project, timeline);let lastError = null;@@ -309,7 +312,7 @@ async function preview(dir, flags, log) {if (now !== last) {last = now;log('script, settings or look changed, updating project');- project = loadProject(project.dir);+ project = loadProject(project.dir, { size });({ timeline } = await prepare(project, { log }));lastError = null;}diff --git a/src/pipeline.js b/src/pipeline.jsindex 97583c4..5eb869b 100644--- a/src/pipeline.js+++ b/src/pipeline.js@@ -57,5 +57,5 @@ export async function withEngine(project, timeline, { scale = 1, pages = 1, tran}export function reloadProject(project) {- return loadProject(project.dir);+ return loadProject(project.dir, { size: project.sizeOverride });}diff --git a/src/project.js b/src/project.jsindex 61c5342..6bd74f8 100644--- a/src/project.js+++ b/src/project.js@@ -283,7 +283,7 @@ export function findProjectDir(arg) {fail('no video.json here. Run the command in a video folder or pass the project folder, for example "explainroo <command> videos/my-video".');}-export function loadProject(arg) {+export function loadProject(arg, { size } = {}) {const dir = findProjectDir(arg);let raw;try {@@ -291,7 +291,7 @@ export function loadProject(arg) {} catch (e) {fail(`video.json is not valid JSON: ${e.message}`);}- const config = normalizeConfig(raw, dir);+ const config = normalizeConfig(size === undefined ? raw : { ...raw, size }, dir);for (const f of [...config.fonts.map((x) => x.src), ...(config.brand?.logo ? [config.brand.logo] : [])]) {if (!fs.existsSync(path.join(dir, f))) fail(`${f} is listed in video.json but the file is missing`);}@@ -303,7 +303,12 @@ export function loadProject(arg) {if (!fs.existsSync(scenesPath)) fail(`${scenesPath} is missing`);const build = path.join(dir, 'build');const out = path.join(dir, 'out');- return { dir, config, script, paths: { build, out, voice: path.join(build, 'voice'), scenes: scenesPath, script: scriptPath, look: config.look ? path.resolve(dir, config.theme) : null } };+ return { dir, config, script, sizeOverride: size, paths: { build, out, voice: path.join(build, 'voice'), scenes: scenesPath, script: scriptPath, look: config.look ? path.resolve(dir, config.theme) : null } };+}++export function outputPath(project, name, ext = '', out = null) {+ const suffix = project.sizeOverride === undefined ? '' : `-${project.sizeOverride.replace(':', '-')}`;+ return path.resolve(out || path.join(project.paths.out, `${name}${suffix}${ext}`));}export function listAssets(dir) {diff --git a/src/qa.js b/src/qa.jsindex f4f28a6..b847008 100644--- a/src/qa.js+++ b/src/qa.js@@ -8,6 +8,7 @@ import { transcribeWords } from './models.js';import { readWav } from './wav.js';import { alignWords } from './align.js';import { buildChapters, chapterHints } from './chapters.js';+import { outputPath } from './project.js';export async function check(project, { log = () => {}, step = 0.25, viewWidth = null } = {}) {if (viewWidth !== null && (!Number.isFinite(viewWidth) || viewWidth <= 0)) throw new Error("--view-width must be a positive number");@@ -53,7 +54,8 @@ export function resolveTimes(timeline, specs) {export async function stills(project, specs, { log = () => {}, scale = 1, transparent = false } = {}) {const { timeline } = await prepare(project, { log });- const list = resolveTimes(timeline, specs).map((x) => ({ ...x, path: `out/stills/${x.label.replace(/[^\[email protected]]/g, '_')}.png` }));+ const dir = path.relative(project.dir, outputPath(project, 'stills')).split(path.sep).join('/');+ const list = resolveTimes(timeline, specs).map((x) => ({ ...x, path: `${dir}/${x.label.replace(/[^\[email protected]]/g, '_')}.png` }));await withEngine(project, timeline, { scale, transparent, log }, (page) => page.evaluate((l) => window.explainroo.stills(l), list));return list.map((x) => ({ time: Math.round(x.T * 100) / 100, label: x.label, file: path.join(project.dir, x.path) }));}@@ -62,7 +64,7 @@ export async function sheet(project, { scene = null, every = null, cols = null,const { timeline } = await prepare(project, { log });let times = [];let labels = [];- let file = 'out/sheet.jpg';+ const file = path.relative(project.dir, outputPath(project, scene ? `sheet-${scene}` : 'sheet', '.jpg')).split(path.sep).join('/');if (scene) {const sc = timeline.scenes.find((s) => s.id === scene);if (!sc) throw new Error(`no scene "${scene}". Scenes: ${timeline.scenes.map((s) => s.id).join(', ')}`);@@ -73,7 +75,6 @@ export async function sheet(project, { scene = null, every = null, cols = null,}times.push(sc.start + sc.dur - 0.05);labels.push(`${sc.id} end`);- file = `out/sheet-${scene}.jpg`;} else {const step = every ?? Math.max(0.5, Math.min(3, timeline.duration / 30));for (let T = 0; T < timeline.duration; T += step) {diff --git a/src/render.js b/src/render.jsindex 51c039e..0a529c1 100644--- a/src/render.js+++ b/src/render.js@@ -7,6 +7,7 @@ import { frameEncoder, ffmpeg, normalizeLoudness } from './ffmpeg.js';import { subtitleCues, toSrt, toVtt } from './subtitles.js';import { buildChapters, toChaptersText, toChapterMetadata } from './chapters.js';import { resolveTimes } from './qa.js';+import { outputPath } from './project.js';export function renderFormat({ format = 'mp4', out, transparent = false } = {}) {if (!['mp4', 'gif', 'webm', 'mov'].includes(format)) throw new Error('--format must be mp4, gif, webm or mov');@@ -15,9 +16,9 @@ export function renderFormat({ format = 'mp4', out, transparent = false } = {})return format;}-export function renderOutput(outDir, opts = {}) {+export function renderOutput(project, opts = {}) {const format = renderFormat(opts);- return path.resolve(opts.out || path.join(outDir, `${opts.draft ? 'draft' : 'video'}.${format}`));+ return outputPath(project, opts.draft ? 'draft' : 'video', `.${format}`, opts.out);}export async function render(project, opts = {}) {@@ -35,7 +36,7 @@ export async function render(project, opts = {}) {const to = Math.min(total, opts.to !== undefined ? Math.ceil(opts.to * fps) : total);if (to <= from) throw new Error('nothing to render: --from must be before --to');const partial = from > 0 || to < total;- const out = renderOutput(project.paths.out, opts);+ const out = renderOutput(project, opts);const base = out.slice(0, -path.extname(out).length);const cues = subtitleCues(timeline, { from: from / fps, to: to / fps });const chapters = partial ? [] : buildChapters(timeline, project.script.title || project.config.title);diff --git a/test/cli.test.js b/test/cli.test.jsindex a2809f1..4732349 100644--- a/test/cli.test.js+++ b/test/cli.test.js@@ -93,3 +93,24 @@ test('render rejects bad formats, mismatched extensions and missing text flags b}} finally { fs.rmSync(dir, { recursive: true, force: true }); }});++test('size overrides reject missing values and invalid sizes before building for all five commands', async () => {+ const dir = tempDir();+ try {+ fs.writeFileSync(path.join(dir, 'video.json'), '{}');+ fs.writeFileSync(path.join(dir, 'script.md'), '## intro\n');+ fs.writeFileSync(path.join(dir, 'scenes.js'), 'export default { intro(s) {} };');+ for (const command of ['render', 'still', 'sheet', 'check', 'preview']) {+ for (const [flags, message] of [+ [['--size'], /--size needs a value/],+ [['--size', 'bad'], /size must be/],+ [['--size', '1081x1350'], /even numbers/],+ ]) {+ const r = await run([command, dir, ...flags]);+ assert.equal(r.code, 1, command);+ assert.match(r.err, message);+ assert.equal(fs.existsSync(path.join(dir, 'build')), false);+ }+ }+ } finally { fs.rmSync(dir, { recursive: true, force: true }); }+});diff --git a/test/multi-size-browser.test.js b/test/multi-size-browser.test.jsnew file mode 100644index 0000000..635b888--- /dev/null+++ b/test/multi-size-browser.test.js@@ -0,0 +1,133 @@+import test from 'node:test';+import assert from 'node:assert/strict';+import fs from 'node:fs';+import os from 'node:os';+import path from 'node:path';+import { spawn, spawnSync } from 'node:child_process';+import { once } from 'node:events';+import { setTimeout } from 'node:timers/promises';+import { fileURLToPath } from 'node:url';+import { findChrome } from '../src/browser.js';+import { loadProject } from '../src/project.js';+import { speechChunks } from '../src/script.js';+import { sceneHash, voicePaths } from '../src/voice.js';+import { writeWav } from '../src/wav.js';+import { probe } from '../src/ffmpeg.js';++const bin = fileURLToPath(new URL('../bin/explainroo.js', import.meta.url));+let chrome;+try { chrome = findChrome(); } catch {}++function fixture(t) {+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'explainroo-sizes-browser-'));+ t.after(() => fs.rmSync(dir, { recursive: true, force: true }));+ fs.writeFileSync(path.join(dir, 'video.json'), JSON.stringify({ size: '320x180', theme: 'clean', fps: 24, music: false, sfx: false, end: 0, lead: 0, hold: 0 }));+ fs.writeFileSync(path.join(dir, 'script.md'), '# Sizes\n\n## intro {min=0.5 chapter="Intro"}\nHello.');+ fs.writeFileSync(path.join(dir, 'scenes.js'), `export default { intro(s) {+ s.text(s.portrait ? 'Tall' : 'Wide', { x: s.cx, y: s.safe.y + s.safe.h / 2, size: s.W * 0.05, at: 0 });+ } };`);+ // A short cached tone avoids loading speech models for output tests.+ const project = loadProject(dir);+ const scene = project.script.scenes[0];+ const chunks = speechChunks(scene.units, project.config);+ fs.mkdirSync(project.paths.voice, { recursive: true });+ const files = voicePaths(project, scene.id);+ writeWav(files.wav, Float32Array.from({ length: 6000 }, (_, i) => 0.1 * Math.sin(i * Math.PI / 24)), 24000);+ fs.writeFileSync(files.json, JSON.stringify({ hash: sceneHash(scene, chunks, project.config), id: scene.id,+ duration: 0.25, words: [{ text: 'Hello.', spoken: 'Hello.', start: 0, end: 0.25, matched: true }],+ marks: {}, chunks: [{ start: 0, end: 0.25, text: 'Hello.' }], transcript: 'Hello.', matchRate: 1, unmatched: [] }));+ return dir;+}++function run(command, dir, flags = []) {+ const r = spawnSync(process.execPath, [bin, command, dir, ...flags, '--json'], { encoding: 'utf8', timeout: 30000 });+ assert.equal(r.status, 0, `${command}: ${r.stderr}\n${r.stdout}`);+ return JSON.parse(r.stdout);+}++test('CLI renders use size names for every extra file and --out wins with and without --draft', { skip: !chrome, timeout: 120000 }, async t => {+ const dir = fixture(t);+ const voiceFile = voicePaths(loadProject(dir), 'intro').json;+ const mtime = fs.statSync(voiceFile).mtimeMs;+ const cases = [+ [[], 'video'],+ [['--draft'], 'draft'],+ [['--out', path.join(dir, 'plain.mp4')], '../plain'],+ [['--draft', '--out', path.join(dir, 'plain-draft.mp4')], '../plain-draft'],+ [['--size', 'tiktok'], 'video-tiktok'],+ [['--size', 'tiktok', '--draft'], 'draft-tiktok'],+ [['--size', 'youtube', '--out', path.join(dir, 'custom.mp4')], '../custom'],+ [['--size', 'youtube', '--draft', '--out', path.join(dir, 'custom-draft.mp4')], '../custom-draft'],+ ];+ for (const [flags, name] of cases) {+ const result = run('render', dir, [...flags, '--scale', '0.1', '--workers', '1']);+ const base = path.resolve(dir, 'out', name);+ assert.equal(result.out, `${base}.mp4`);+ assert.deepEqual(result.subtitles, { srt: `${base}.srt`, vtt: `${base}.vtt` });+ assert.equal(result.cover, `${base}.cover.jpg`);+ assert.equal(result.chapters, `${base}.chapters.txt`);+ for (const ext of ['mp4', 'srt', 'vtt', 'cover.jpg', 'chapters.txt']) assert.ok(fs.statSync(`${base}.${ext}`).size > 0);+ const info = await probe(result.out);+ const video = info.streams.find(s => s.codec_type === 'video');+ assert.equal(video.width, result.width);+ assert.equal(video.height, result.height);+ }+ assert.equal(fs.statSync(voiceFile).mtimeMs, mtime);+ assert.ok(fs.existsSync(path.join(dir, 'out/video.mp4')));+ assert.ok(fs.existsSync(path.join(dir, 'out/video-tiktok.mp4')));+});++test('CLI still, sheet and check use the override, while existing names stay unchanged', { skip: !chrome, timeout: 60000 }, t => {+ const dir = fixture(t);+ for (const [flags, suffix] of [[[], ''], [['--size', 'tiktok'], '-tiktok']]) {+ const still = run('still', dir, [...flags, '--scale', '0.1']).stills[0];+ assert.equal(still.file, path.join(dir, `out/stills${suffix}/[email protected]`));+ assert.ok(fs.statSync(still.file).size > 0);+ for (const scene of [null, 'intro']) {+ const result = run('sheet', dir, [...flags, ...(scene ? ['--scene', scene] : [])]);+ assert.equal(result.file, path.join(dir, `out/sheet${scene ? '-intro' : ''}${suffix}.jpg`));+ assert.ok(fs.statSync(result.file).size > 0);+ }+ const result = run('check', dir, flags);+ assert.deepEqual(result.issues.filter(i => i.level !== 'hint'), []);+ const timeline = JSON.parse(fs.readFileSync(path.join(dir, 'build/timeline.json'), 'utf8'));+ assert.equal(timeline.width, suffix ? 1080 : 320);+ assert.equal(timeline.height, suffix ? 1920 : 180);+ }+});++test('preview keeps the size override after settings change', { timeout: 15000 }, async t => {+ const dir = fixture(t);+ const child = spawn(process.execPath, [bin, 'preview', dir, '--size', 'tiktok', '--port', '0'], { stdio: ['ignore', 'ignore', 'pipe'] });+ const exited = once(child, 'exit');+ let logs = '';+ child.stderr.on('data', chunk => { logs += chunk; });+ const until = async fn => {+ for (let i = 0; i < 80; i++) {+ const value = await fn();+ if (value) return value;+ await setTimeout(100);+ }+ assert.fail(`preview did not update: ${logs}`);+ };+ try {+ const url = await until(() => /preview: (http:\/\/127\.0\.0\.1:\d+)/.exec(logs)?.[1]);+ const state = async () => (await fetch(url + '/__state.json')).json();+ const first = await state();+ assert.equal(first.config.size, 'tiktok');+ assert.equal(first.config.captions, true);+ assert.equal(first.timeline.height, 1920);+ const settings = path.join(dir, 'video.json');+ fs.writeFileSync(settings, JSON.stringify({ ...JSON.parse(fs.readFileSync(settings, 'utf8')), size: 'square', title: 'Changed' }));+ const changed = await until(async () => { const s = await state(); return s.title === 'Changed' && s; });+ assert.equal(changed.config.size, 'tiktok');+ assert.equal(changed.config.captions, true);+ assert.deepEqual(changed.config.safe, first.config.safe);+ assert.equal(changed.timeline.width, 1080);+ assert.equal(changed.timeline.height, 1920);+ assert.notEqual(changed.version, first.version);+ } finally {+ child.kill('SIGTERM');+ await exited;+ }+});diff --git a/test/multi-size.test.js b/test/multi-size.test.jsnew file mode 100644index 0000000..e138e15--- /dev/null+++ b/test/multi-size.test.js@@ -0,0 +1,116 @@+import test from 'node:test';+import assert from 'node:assert/strict';+import fs from 'node:fs';+import os from 'node:os';+import path from 'node:path';+import { loadProject, normalizeConfig, outputPath, FORMATS } from '../src/project.js';+import { prepare, reloadProject } from '../src/pipeline.js';+import { sceneHash, voicePaths } from '../src/voice.js';+import { speechChunks } from '../src/script.js';+import { Stage } from '../engine/stage.js';+import { getTheme } from '../engine/themes.js';+import { layoutAreas } from '../engine/layout.js';++function fixture(t, raw = {}) {+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'explainroo-multi-size-'));+ t.after(() => fs.rmSync(dir, { recursive: true, force: true }));+ fs.writeFileSync(path.join(dir, 'video.json'), JSON.stringify({ size: 'youtube', ...raw }));+ fs.writeFileSync(path.join(dir, 'script.md'), '## intro {min=1}\n');+ fs.writeFileSync(path.join(dir, 'scenes.js'), 'export default { intro(s) {} };');+ return dir;+}++test('size overrides normalize captions, dimensions and safe areas without changing the project file', t => {+ const dir = fixture(t);+ const before = fs.readFileSync(path.join(dir, 'video.json'), 'utf8');+ for (const size of [...Object.keys(FORMATS), '16:9', '9:16', '1:1', '4:5', '1080x1350']) {+ const project = loadProject(dir, { size });+ const expected = normalizeConfig({ size });+ for (const key of ['size', 'format', 'width', 'height', 'captions', 'safe']) assert.deepEqual(project.config[key], expected[key], `${size}: ${key}`);+ assert.deepEqual(layoutAreas(project.config, project.config.width, project.config.height), layoutAreas(expected, expected.width, expected.height));+ assert.equal(project.config.captions, expected.height >= expected.width);+ assert.equal(project.sizeOverride, size);+ assert.equal(reloadProject(project).config.size, size);+ }+ assert.equal(fs.readFileSync(path.join(dir, 'video.json'), 'utf8'), before);+ assert.equal(loadProject(dir).config.size, 'youtube');+ assert.equal(loadProject(dir).sizeOverride, undefined);+ assert.throws(() => loadProject(dir, { size: 'bad' }), /size must be/);+ assert.throws(() => loadProject(dir, { size: '1081x1350' }), /even numbers/);+});++test('overriding a platform size clears its safe area and recalculates auto captions', t => {+ const dir = fixture(t, { size: 'tiktok' });+ const cfg = loadProject(dir, { size: 'youtube' }).config;+ assert.equal(cfg.captions, false);+ assert.equal(cfg.safe, null);+ const areas = layoutAreas(cfg, cfg.width, cfg.height);+ assert.equal(areas.app, null);+ assert.equal(areas.band, null);+ const platform = loadProject(dir).config;+ const tall = layoutAreas(platform, platform.width, platform.height);+ assert.ok(tall.app);+ assert.ok(tall.safe.top > tall.app.top);+ assert.ok(tall.safe.bottom < tall.band.top);+});++test('explicit captions settings survive a size override', t => {+ for (const captions of [true, false]) {+ const dir = fixture(t, { captions });+ for (const size of ['youtube', 'tiktok', 'square']) assert.equal(loadProject(dir, { size }).config.captions, captions);+ }+});++test('output paths keep existing names or add the explicit size to every output type', () => {+ const project = { paths: { out: '/tmp/video/out' } };+ const names = [+ ['video', '.mp4'], ['draft', '.mp4'], ['video', '.gif'], ['draft', '.gif'],+ ['video', '.srt'], ['video', '.vtt'], ['video', '.cover.jpg'], ['video', '.chapters.txt'],+ ['draft', '.srt'], ['draft', '.vtt'], ['draft', '.cover.jpg'], ['draft', '.chapters.txt'],+ ['stills', ''], ['sheet', '.jpg'], ['sheet-intro', '.jpg'],+ ];+ for (const [name, ext] of names) {+ assert.equal(outputPath(project, name, ext), `/tmp/video/out/${name}${ext}`);+ for (const size of ['tiktok', 'youtube', '9:16', '1:1', '1080x1350']) {+ assert.equal(outputPath({ ...project, sizeOverride: size }, name, ext), `/tmp/video/out/${name}-${size.replace(':', '-')}${ext}`);+ }+ }+ for (const sizeOverride of [undefined, 'tiktok']) {+ for (const name of ['video', 'draft']) {+ assert.equal(outputPath({ ...project, sizeOverride }, name, '.mp4', 'chosen.mp4'), path.resolve('chosen.mp4'));+ assert.equal(outputPath({ ...project, sizeOverride }, name, '.gif', '/tmp/chosen.gif'), '/tmp/chosen.gif');+ }+ }+});++test('portrait is true only when the frame is taller than wide', () => {+ for (const size of ['youtube', 'vertical', 'linkedin', 'square', '400x400', '800x600']) {+ const config = normalizeConfig({ size });+ const { width: W, height: H } = config;+ const engine = { config, W, H, theme: getTheme('paper'), safeArea: layoutAreas(config, W, H).safe,+ timeline: { duration: 1, frames: 30, fps: 30, width: W, height: H, scenes: [{}] } };+ const scene = { id: 'intro', index: 0, start: 0, dur: 1, words: [], marks: {} };+ assert.equal(new Stage(engine, null, scene, 0).portrait, H > W, size);+ }+});++test('sizes share voice hashes and caches, while prepare rebuilds the timeline for the current frame', async t => {+ const dir = fixture(t);+ const wide = loadProject(dir);+ const tall = loadProject(dir, { size: 'vertical' });+ const { timeline: first } = await prepare(wide);+ const voiceFile = voicePaths(wide, 'intro').json;+ const mtime = fs.statSync(voiceFile).mtimeMs;+ const { timeline: second } = await prepare(tall);+ assert.equal(voicePaths(tall, 'intro').json, voiceFile);+ assert.equal(fs.statSync(voiceFile).mtimeMs, mtime);+ assert.deepEqual(first.scenes, second.scenes);+ assert.equal(first.duration, second.duration);+ assert.equal(first.width, 1920);+ assert.equal(second.width, 1080);+ assert.equal(second.height, 1920);+ assert.deepEqual(JSON.parse(fs.readFileSync(path.join(dir, 'build/timeline.json'), 'utf8')), second);+ const scene = { ...wide.script.scenes[0], units: [{ type: 'word', display: 'Hello', spoken: 'Hello' }] };+ const chunks = speechChunks(scene.units);+ assert.equal(sceneHash(scene, chunks, wide.config), sceneHash(scene, chunks, tall.config));+});diff --git a/test/render-options.test.js b/test/render-options.test.jsindex b4a5044..7df16e6 100644--- a/test/render-options.test.js+++ b/test/render-options.test.js@@ -29,11 +29,11 @@ test('transparent export needs an alpha format', () => {test('render output names follow format, draft and --out', () => {for (const format of ['mp4', 'gif', 'webm', 'mov']) {- assert.equal(renderOutput('/tmp/out', { format }), path.resolve(`/tmp/out/video.${format}`));- assert.equal(renderOutput('/tmp/out', { format, draft: true }), path.resolve(`/tmp/out/draft.${format}`));- assert.equal(renderOutput('/tmp/out', { format, draft: true, out: `/tmp/custom.${format}` }), path.resolve(`/tmp/custom.${format}`));+ assert.equal(renderOutput({ paths: { out: '/tmp/out' } }, { format }), path.resolve(`/tmp/out/video.${format}`));+ assert.equal(renderOutput({ paths: { out: '/tmp/out' } }, { format, draft: true }), path.resolve(`/tmp/out/draft.${format}`));+ assert.equal(renderOutput({ paths: { out: '/tmp/out' } }, { format, draft: true, out: `/tmp/custom.${format}` }), path.resolve(`/tmp/custom.${format}`));}- assert.equal(renderOutput('/tmp/out'), path.resolve('/tmp/out/video.mp4'));+ assert.equal(renderOutput({ paths: { out: '/tmp/out' } }), path.resolve('/tmp/out/video.mp4'));});test('cover validates its type and syntax while allowing still specs', () => {