Skip to content

Claude Code skill that makes launch videos, ads and music videos from one line: idea, script, visuals, voice, music, edit and review, then a review room where your notes make the next take

Picture audit and a broken-value check

Tal Siachb81bdafa4ed2
diff --git a/README.md b/README.md
index fd7ff71..41f129a 100644
--- a/README.md
+++ b/README.md
@@ -131,7 +131,7 @@ It is slow, and it is strongest for product and brand films.
## Inside the repo
-`SKILL.md` is the entry point. `references/` holds the craft (timing, words, sound, brand, the checks before the first cut, the reviewer's brief, the illustrated looks). `scripts/` holds the tools (machine check, frames, export, quality gate, text audit, sound check, review room).
+`SKILL.md` is the entry point. `references/` holds the craft (timing, words, sound, brand, the checks before the first cut, the reviewer's brief, the illustrated looks). `scripts/` holds the tools (machine check, frames, export, quality gate, text audit, picture audit, sound check, review room).
## Credits
diff --git a/SKILL.md b/SKILL.md
index 40f7fd8..d27973c 100644
--- a/SKILL.md
+++ b/SKILL.md
@@ -190,7 +190,7 @@ Set up a project folder from the style's engine (the style file says how; a bran
- For films over about a minute or with many chapters, and for shorter ones when the person chose the split at the pitch, split into chapter files and brief parallel subagents with a shared guide (the P(doom) video did this: one guide, one storyboard, one chapter per agent, shared files read-only).
- For epic pieces (music videos, 1-3 min films) where the user can let it run for hours with tools and a budget, use the overnight-run method in `references/overnight-run.md`: a rich voice-style brief, a proven base repo, an image model for designs, a video model for reference motion that gets redrawn in code (rotoscoping), sound design, and explicit self-review loops. Agree the budget first.
- Timing rules, all styles, from `references/timing.md`. Read it before building. The short version: list the reads per shot, one read at a time, fast actions but held meanings, lead the eye, let the reads set the length, hold the final payoff long enough to land. All motion runs on springs (`springs.js`, presets in timing.md); linear motion never. Moves that read as designed (log-space zooms, beat punches, shared elements across handoffs, flood circles): `references/motion-kit.md`.
-- **Stills gate before the first full export. This is the storyboard drawn.** Render one frame per storyboard beat (`node frames.mjs 0 <beat times>`), read every one at full size and on the 360 px sheet, and fix what's wrong in the stills. Composition, type size, contrast and on-brand colour are all visible in a still, and a still costs seconds where an export costs minutes. No full export until every beat's still is right. Run `node <skill>/scripts/text-audit.mjs` from the film folder (it measures every word the film draws: too small for a phone, up too briefly to read, parked in a corner, held too long, printed over another text) and fix every FAIL. Then walk `references/before-the-first-cut.md` on those stills (phone width, the first second, people on screen, states that agree, payoffs that hold, nothing on what matters): it is the list of things fresh reviewers kept finding after the export.
+- **Stills gate before the first full export. This is the storyboard drawn.** Render one frame per storyboard beat (`node frames.mjs 0 <beat times>`), read every one at full size and on the 360 px sheet, and fix what's wrong in the stills. Composition, type size, contrast and on-brand colour are all visible in a still, and a still costs seconds where an export costs minutes. No full export until every beat's still is right. Run `node <skill>/scripts/text-audit.mjs` from the film folder (it measures every word the film draws: too small for a phone, up too briefly to read, parked in a corner, held too long, printed over another text, a value that failed to compute such as "NaN") and fix every FAIL. On a film with photos or footage, also run `node <skill>/scripts/plate-audit.mjs` (a picture drawn bigger than its own pixels, slow motion made by mixing frames: both soften faces) and fix every FAIL. Then walk `references/before-the-first-cut.md` on those stills (phone width, the first second, people on screen, states that agree, payoffs that hold, nothing on what matters): it is the list of things fresh reviewers kept finding after the export.
### 5. Review: your own pass, then fresh eyes
The review is of an exported file with its sound, so render and mix first (step 6), then come back here. For a real brand or product, run the brand pass first (`references/brand-pass.md`): their typeface, colors, logo SVGs, headline and CTA pulled from the live site. Render contact sheets and full frames and actually look at them (`scripts/frames.mjs`, see `references/pipeline.md`). Then walk `references/quality-checklist.md`. If the film has a main character, run the face audit (`scripts/audit-faces.mjs`) in every aspect ratio and fix every overlap before anyone sees it. Then score the critique rubric in `references/quality-checklist.md`: hook in the first 2 s, readability at 360 px, motion quality, variety (something new every 2-4 s), composition, data accuracy and sound sync, each 1-10; name the 3 worst problems with timestamps, fix them, and loop until every axis is 8+. Read a 12-frame strip around each fast move (whips, handoffs, floods): that is where text blurs and floods read as flashes. Then the bar check: put your frames next to the reference's, score it 1-10, and close the three biggest gaps (or price them for the user). Fix and re-render until it passes; re-render only the shots you changed (`references/pipeline.md`). The first render is never the one to show.
@@ -225,7 +225,8 @@ Put the MP4 somewhere obvious (Desktop or Downloads), named plainly (`<name>.mp4
- `references/quality-checklist.md` : the bar before showing anything
- `references/before-the-first-cut.md` : the checks to walk on the stills, before any export
- `references/page-or-picture.md` : the storyboard check that catches a slideshow before it is built
-- `scripts/text-audit.mjs` : measures the words a film draws (size at phone width, time on screen, corners, edges, faces, text printed over text)
+- `scripts/text-audit.mjs` : measures the words a film draws (size at phone width, time on screen, corners, edges, faces, text printed over text, broken values like NaN)
+- `scripts/plate-audit.mjs` : measures the big pictures a film draws (enlarged past their own pixels, frames of one clip mixed into slow motion)
- `scripts/edge-audit.mjs` : finds pictures, cards and labels cut by an edge, the frame's, a window's inside it, or a big picture's own (warnings only)
- `references/video-models.md` : read a video model's limits live; dated notes on the models we have used
- `references/pipeline.md` : render tools, flags, gotchas
diff --git a/references/pipeline.md b/references/pipeline.md
index a5ba7a6..631eecd 100644
--- a/references/pipeline.md
+++ b/references/pipeline.md
@@ -60,10 +60,23 @@ Run it at the stills gate and again before the reviewer. It draws the film frame
- **FLASH**: a caption or card that is not up long enough to read (0.4 s plus 0.2 s a word). A line typed letter by letter in one place (a prompt) counts as one piece from its first letter. A fast roll (a count whose name changes every beat, read at one fixed spot) flags on every name: it is not a caption, so pass the names to `--ignore` and tell the reviewer it is a roll. When the film replays itself inside a small player (a rewind, a film in the film), set `window.TEXT_AUDIT_SKIP = true` while that inner picture is drawn and back to `false` after: its words are picture, not captions.
- **EDGE**, **PINNED**, **LONG**: text partly out of the frame, small text parked in a corner for six seconds in all, one big line held past six seconds.
- **FACE**: text on a face, when the film defines `window.FACES = (t) => [[x, y, w, h], ...]` in canvas pixels.
+- **BROKEN**: a value that failed to compute, on screen for any length of time: `NaN`, `undefined`, `Infinity` or `[object Object]` as a word (FAIL; a lone `null` is a WARN). A counter whose start value a timing script had moved to -1.1 showed "NaN" across a whole beat, and nobody saw it until the owner did.
- **OVERLAP**: two different texts printed on top of each other and sitting still for 0.3 s or more (FAIL): a label over a label, a caption over a number. One moving across the other, or a huge word across small text, is a WARN to look at. The same text drawn twice (an outline, a glow, a counter changing its value) and single letters (a rolling digit) are left alone. It does not know about masks, so text hidden under a clip can still be reported; skip it with `--ignore`.
A FAIL is fixed. A WARN is a lead: look, then fix it or say why it stays. On one product ad the first cut had 15 fails, all things a fresh reviewer later named (status chips, tags, a note that flashed for 0.4 s); the delivered cut had 4. It sees only text the page draws itself, not words inside pictures, and it reads size, not contrast, so the 360 px sheet still gets read by eye.
+## Plate audit (soft pictures: enlarged or mixed frames)
+
+```bash
+node <skill>/scripts/plate-audit.mjs # film.html in this folder
+node <skill>/scripts/plate-audit.mjs cut.html --step 0.05 --min-area 0.15 --json plates.json
+```
+Run it next to the text audit, before the reviewer, on any film with photos or footage. It records every `drawImage` the page makes while it draws each sampled frame, keeps the big ones (a picture covering a fifth of the frame or more), and reports:
+- **UPSCALE**: a picture drawn bigger than its own pixels: WARN above 1.12x for half a second or more, FAIL at 1.2x or more. A 1080p clip pushed to 1.3x for a "closer shot" was the shot the owner called blurry; the fix was a new clip at its own size, not a sharpening pass.
+- **BLEND**: two different frames of one clip laid over each other in the same place, one see-through, for 0.25 s or more: slow motion made by mixing frames, which ghosts faces (WARN). Play the clip at its own speed, end the shot earlier, or hold clean frames.
+
+Frames from one folder (`assets/seq/<clip>/f012.jpg`) or one video file count as one clip. SVG pictures and small pictures (tiles, icons, logos) are left out. A picture drawn onto an off-screen canvas at least half the frame's width is measured against that canvas. It cannot see sharpness inside the source itself (a soft clip at 1.0x passes), so still look at faces at full size next to the raw clip. Set `window.PLATE_AUDIT_SKIP = true` while drawing something that is enlarged on purpose (a deliberately soft background).
+
## Edge audit (pictures and shapes cut by an edge)
```bash
@@ -148,6 +161,7 @@ START=26.5 END=32.5 node export.mjs 24 fix-b.mp4 # renders frames round(STA
```
Splice by frame index into the previous master (`trim=start_frame=..:end_frame=..` for the untouched parts, `concat` in order), one re-encode at CRF 14. Make each range cover the whole changed shot plus a few frames either side; frames are deterministic, so the overlap is identical. Then verify alignment: the PSNR of the untouched regions against the old master should be above 40 dB (one app-builder film: 44-57 dB). A one-frame slip drops it far lower.
- To add a held ending, raise `FILM_DURATION` and render only the new tail, then concat.
+- **A script that moves part of the film later moves times, never values.** Adding one bar to every `from` and `to` after a point also moved a counter's start and end values (1 became -1.1), and its climb printed "NaN" for a whole beat. Shift only the keys that are times, list every value the script touched, and run the text audit after (its BROKEN rule catches a failed value on screen).
- **Joining without a re-encode (`-c copy`): cut only at a keyframe, and count packets, not seconds.** `-t 17.46 -c copy` on a 60 fps part gave the right NUMBER of frames (1050) and the wrong frames: 0 to 1048 and 1050, with 1049 missing, because the P frame comes before the B frame it is shown after. The joined film then showed one frame of the next shot a frame early. Do this instead: list the kept part's keyframes (`ffprobe -select_streams v:0 -skip_frame nokey -show_entries frame=pts_time`), take the last one at or before the change (frame K), copy exactly K packets (`ffmpeg -i part.mp4 -frames:v K -c copy head.mp4`: everything before a keyframe in file order is frames 0 to K-1), and render from K/fps on. Then prove it: the sorted packet times of `head.mp4` must be 0 to K-1 with none missing, and the joined file must have the full frame count.
- To keep editing while a long render runs, render from a frozen copy: copy the scripts folder and point a copy of film.html at it. The page loads its scripts once, but a copy removes any doubt.
diff --git a/references/real-shots.md b/references/real-shots.md
index 6a27d4e..927f6cb 100644
--- a/references/real-shots.md
+++ b/references/real-shots.md
@@ -55,7 +55,8 @@ Movement comes last: after the cut works with pictures and the person has seen i
**What goes wrong.**
- Two different pictures as first and last frame do not give a camera move between them; they dissolve. For a story in several moments, make one picture per moment, animate each alone and cut.
- Fast hands, tiny lettering, liquids, crowds and mirrors are weak points. Check lettering while the clip plays, not only on its first frame.
-- Zooming into a clip by more than about 1.5 turns it to mush. A close-up is its own picture and its own clip.
+- **Keep footage at its own size.** A 1080p clip is soft long before mush: past about 1.1x a face starts to lose detail, and at 1.25 to 1.3x the owner called it blurry on first watch, next to sharp type that then looked pasted on. A push-in that ends near 1.1x is fine; a "closer shot" made by zooming the same clip is not. A close-up is its own picture and its own clip. `scripts/plate-audit.mjs` measures every big picture the film draws and fails one drawn at 1.2x or more (see `pipeline.md`).
+- **Slow motion made by mixing two frames ghosts faces.** Stretching a clip to fit a slot by laying the next frame over the current one, partly see-through, gave a doubled outline round a face and smeared eyes for a third of a second, and softened every shot it touched. Play the clip at its own speed and pick the stretch that fits, end the shot earlier, or hold clean frames (a slight stutter is less visible than a ghost). The plate audit lists every BLEND.
- An upscaler is a rescue, not a plan. It sharpened soft clips, but the owner still saw the opening as lower quality than the rest; rendering again at native 1080p fixed it. At twice the size an upscaled clip paints skin.
- A person on a screen inside the picture (a video call, a TV) copies the gestures of the person in the room unless told otherwise. Say who moves and who only listens.
- When several shots form a set (four colours, three reasons), treat them alike: if three get a wide shot and then a different close-up, the fourth does too. The odd one out is what the viewer notices.
diff --git a/scripts/plate-audit.mjs b/scripts/plate-audit.mjs
new file mode 100644
index 0000000..d3cf791
--- /dev/null
+++ b/scripts/plate-audit.mjs
@@ -0,0 +1,139 @@
+#!/usr/bin/env node
+// scripts/plate-audit.mjs : measure how every big picture in a canvas film is drawn, so a soft shot is found before a person sees it.
+//
+// node <skill>/scripts/plate-audit.mjs [film.html] [--step 0.1] [--min-area 0.2] [--json out.json]
+//
+// Run it from the film's folder before the reviewer, next to text-audit.mjs. It loads the film in headless Chrome, records every
+// drawImage the page makes while it draws each sampled frame, and keeps the big ones (a picture covering a fifth of the frame or
+// more: a photo, a video frame, a plate). Then it checks the two things that quietly soften footage:
+//
+// UPSCALE a picture drawn bigger than its own pixels. A 1080p clip pushed to 1.3x shows 1478 of its pixels across 1920: faces
+// go soft and text drawn on top looks pasted. WARN above 1.12x held 0.5 s or more, FAIL at 1.2x or more.
+// A gentle push-in to about 1.1x passes; one that ends at 1.15x is a WARN to look at; a "closer shot" made by
+// zooming the same clip is usually a FAIL.
+// BLEND two different frames of the same clip laid over each other at the same place, one of them see-through: slow motion
+// made by mixing frames. Faces get a ghost outline and smear. WARN when it lasts 0.25 s or more. Play the clip at 1x,
+// hold clean frames instead of mixing them, or end the shot earlier.
+//
+// What counts as the same clip: frames from one folder (assets/seq/<clip>/f012.jpg) or one video file. SVG pictures are left out
+// (they stay sharp at any size), and so are small pictures (icons, tiles in a wall, logos).
+// Pictures drawn onto an off-screen canvas that is at least half the frame are measured against that canvas, on the
+// assumption that the layer is later drawn about 1:1. Exit 1 when there is a FAIL; WARN lines are leads to look at.
+import fs from 'node:fs';
+import http from 'node:http';
+import path from 'node:path';
+import { createRequire } from 'node:module';
+import { fileURLToPath } from 'node:url';
+
+const args = process.argv.slice(2);
+const opt = (name, def) => { const i = args.indexOf('--' + name); if (i < 0) return def; const v = args[i + 1]; args.splice(i, 2); return v; };
+const STEP = Number(opt('step', 0.1)), MIN_AREA = Number(opt('min-area', 0.2)), JSON_OUT = opt('json', null);
+const film = path.resolve(args[0] || 'film.html');
+if (!fs.existsSync(film)) { console.error(`plate-audit: no film at ${film}\nusage: node plate-audit.mjs [film.html] [--step 0.1] [--min-area 0.2] [--json out.json]`); process.exit(2); }
+const SELF = fileURLToPath(import.meta.url);
+const loadChromium = () => {
+ for (const r of [process.env.PLAYWRIGHT_NODE_MODULES, path.join(path.dirname(film), 'node_modules'), path.join(process.cwd(), 'node_modules'), path.join(path.dirname(SELF), 'node_modules')].filter(Boolean)) {
+ try { return createRequire(path.join(r, 'x.cjs'))('playwright-core').chromium; } catch { /* next */ } }
+ try { return createRequire(SELF)('playwright-core').chromium; } catch { /* fall through */ }
+ console.error('plate-audit: playwright-core not found. Run it from the film project folder (new-canvas-project.sh installs it there), or set PLAYWRIGHT_NODE_MODULES.'); process.exit(2);
+};
+const TYPES = { '.html': 'text/html; charset=utf-8', '.js': 'text/javascript', '.mjs': 'text/javascript', '.json': 'application/json', '.css': 'text/css', '.svg': 'image/svg+xml', '.png': 'image/png', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg', '.webp': 'image/webp', '.woff2': 'font/woff2', '.woff': 'font/woff', '.ttf': 'font/ttf', '.otf': 'font/otf', '.mp4': 'video/mp4', '.wav': 'audio/wav', '.mp3': 'audio/mpeg' };
+const serve = (root) => new Promise((res) => { const srv = http.createServer((req, rs) => {
+ // only files inside the film folder (symlinked asset folders inside it are followed)
+ let p = ''; try { p = path.join(root, decodeURIComponent(new URL(req.url, 'http://x').pathname)); } catch {}
+ if ((p !== root && !p.startsWith(root + path.sep)) || !fs.existsSync(p) || fs.statSync(p).isDirectory()) { rs.writeHead(404); return rs.end(); }
+ rs.writeHead(200, { 'content-type': TYPES[path.extname(p).toLowerCase()] || 'application/octet-stream' }); fs.createReadStream(p).pipe(rs); });
+ srv.listen(0, '127.0.0.1', () => res({ srv, url: `http://127.0.0.1:${srv.address().port}` })); });
+
+const { srv, url } = await serve(path.dirname(film));
+const browser = await loadChromium().launch({ channel: 'chrome', headless: true });
+const page = await browser.newPage({ viewport: { width: 1920, height: 1080 } });
+// record every big raster draw: which picture, its own pixel size, how big it lands, where, how opaque
+await page.addInitScript((MIN_AREA) => {
+ window.__IMG = [];
+ const orig = CanvasRenderingContext2D.prototype.drawImage;
+ const srcOf = (im) => {
+ if (typeof HTMLImageElement !== 'undefined' && im instanceof HTMLImageElement) { const s = im.currentSrc || im.src || ''; return { id: s, w: im.naturalWidth, h: im.naturalHeight, svg: /\.svg(\?|#|$)|^data:image\/svg/i.test(s) }; }
+ if (typeof HTMLVideoElement !== 'undefined' && im instanceof HTMLVideoElement) return { id: im.currentSrc || im.src || 'video', w: im.videoWidth, h: im.videoHeight, video: true };
+ if (typeof ImageBitmap !== 'undefined' && im instanceof ImageBitmap) { if (!im.__pid) im.__pid = 'bitmap#' + Math.random().toString(36).slice(2, 8); return { id: im.__pid, w: im.width, h: im.height }; }
+ return null; // canvases are layers the film drew itself: measured where their own content was drawn
+ };
+ CanvasRenderingContext2D.prototype.drawImage = function (im, ...a) {
+ try {
+ if (window.__IMG_ON && !window.PLATE_AUDIT_SKIP) {
+ const s = srcOf(im);
+ if (s && !s.svg && s.w > 0) {
+ let sx = 0, sy = 0, sw = s.w, sh = s.h, dx, dy, dw, dh;
+ if (a.length === 2) { [dx, dy] = a; dw = s.w; dh = s.h; } else if (a.length === 4) { [dx, dy, dw, dh] = a; } else if (a.length === 8) { [sx, sy, sw, sh, dx, dy, dw, dh] = a; }
+ const tr = this.getTransform(), kx = Math.hypot(tr.a, tr.b), ky = Math.hypot(tr.c, tr.d);
+ const cw = this.canvas.width, ch = this.canvas.height, main = window.__MAIN_W || cw;
+ const layer = cw >= 0.5 * main; // the frame itself or a big off-screen layer
+ const ow = Math.abs(dw) * kx, oh = Math.abs(dh) * ky, area = (ow * oh) / (cw * ch);
+ if (layer && area >= MIN_AREA && Math.abs(sw) > 0) {
+ const x0 = tr.a * dx + tr.c * dy + tr.e, y0 = tr.b * dx + tr.d * dy + tr.f;
+ window.__IMG.push({ id: s.id, up: Math.max(ow / Math.abs(sw), oh / Math.abs(sh)), a: this.globalAlpha, area, x0, y0, x1: x0 + ow, y1: y0 + oh, onMain: cw === main });
+ }
+ }
+ }
+ } catch { /* never break the film's own drawing */ }
+ return orig.call(this, im, ...a);
+ };
+}, MIN_AREA);
+const errs = []; page.on('pageerror', (e) => errs.push(e.message));
+await page.goto(url + '/' + path.basename(film));
+await page.waitForFunction(() => typeof window.renderFrame === 'function' && window.READY === true, null, { timeout: 120000 });
+const info = await page.evaluate(() => { const c = [...document.querySelectorAll('canvas')].sort((a, b) => b.width * b.height - a.width * a.height)[0]; window.__MAIN_W = c.width; return { W: c.width, H: c.height, D: window.FILM_DURATION }; });
+const { W, H, D } = info, n = Math.floor(D / STEP);
+const samples = await page.evaluate(async ({ n, STEP }) => { const out = [];
+ for (let i = 0; i <= n; i++) { const t = Math.min(i * STEP, window.FILM_DURATION - 1e-3); window.__IMG = []; window.__IMG_ON = true; await window.renderFrame(t); window.__IMG_ON = false; out.push({ t, img: window.__IMG }); }
+ return out; }, { n, STEP });
+await browser.close(); srv.close();
+
+// a clip is a folder of frames or one file: assets/seq/walk/f012.jpg and f013.jpg are the same clip
+const clipOf = (id) => { let p = id; try { p = decodeURIComponent(new URL(id, 'http://x').pathname); } catch {} return /\/f?\d{2,}\.(jpe?g|png|webp)$/i.test(p) ? p.replace(/[^/]+$/, '') : p; };
+const nameOf = (c) => c.replace(/\/$/, '').split('/').slice(-2).join('/');
+const f = (t) => t.toFixed(1), finds = [];
+// UPSCALE: per clip, the stretches where it is drawn bigger than its pixels (largest draw of that clip in each sample)
+const up = new Map(), upDone = [];
+for (const smp of samples) {
+ const best = new Map();
+ for (const d of smp.img) { const c = clipOf(d.id); if (d.a < 0.5) continue; const b = best.get(c); if (!b || d.up > b.up) best.set(c, d); }
+ for (const [c, d] of best) {
+ let r = up.get(c);
+ if (r && smp.t - r.t1 > STEP * 2.5) { upDone.push(r); r = null; }
+ if (d.up <= 1.12) continue;
+ if (!r) { r = { clip: c, t0: smp.t, t1: smp.t, max: d.up, fail: 0 }; up.set(c, r); }
+ r.t1 = smp.t; r.max = Math.max(r.max, d.up); if (d.up >= 1.2) r.fail += STEP;
+ }
+}
+upDone.push(...up.values());
+for (const r of upDone) { const held = r.t1 - r.t0 + STEP; if (held < 0.5) continue;
+ finds.push({ sev: r.fail >= 0.5 ? 'FAIL' : 'WARN', rule: 'UPSCALE', t0: r.t0, t1: r.t1, clip: nameOf(r.clip), why: `drawn up to ${r.max.toFixed(2)}x its own pixels${r.fail >= 0.5 ? ` (1.2x or more for ${f(r.fail)} s): soft` : ''}` }); }
+// BLEND: two different frames of one clip at the same place in the same sample, the upper one see-through
+const bl = new Map(), blDone = [];
+for (const smp of samples) {
+ const byClip = new Map(); for (const d of smp.img) { const c = clipOf(d.id); if (!byClip.has(c)) byClip.set(c, []); byClip.get(c).push(d); }
+ const hit = new Set();
+ for (const [c, ds] of byClip) for (let i = 0; i < ds.length; i++) for (let j = i + 1; j < ds.length; j++) {
+ const u = ds[i], v = ds[j]; if (u.id === v.id) continue;
+ const ix = Math.max(0, Math.min(u.x1, v.x1) - Math.max(u.x0, v.x0)), iy = Math.max(0, Math.min(u.y1, v.y1) - Math.max(u.y0, v.y0));
+ const inter = ix * iy, uni = (u.x1 - u.x0) * (u.y1 - u.y0) + (v.x1 - v.x0) * (v.y1 - v.y0) - inter;
+ if (uni > 0 && inter / uni > 0.8 && ((v.a > 0.05 && v.a < 0.95) || (u.a > 0.05 && u.a < 0.95))) hit.add(c);
+ }
+ for (const c of new Set([...bl.keys(), ...hit])) { let r = bl.get(c);
+ if (r && smp.t - r.t1 > STEP * 2.5) { blDone.push(r); bl.delete(c); r = null; }
+ if (!hit.has(c)) continue;
+ if (!r) { r = { clip: c, t0: smp.t, t1: smp.t }; bl.set(c, r); } r.t1 = smp.t; }
+}
+blDone.push(...bl.values());
+for (const r of blDone) { const held = r.t1 - r.t0 + STEP; if (held >= 0.25) finds.push({ sev: 'WARN', rule: 'BLEND', t0: r.t0, t1: r.t1, clip: nameOf(r.clip), why: `two frames of one clip mixed for ${f(held)} s: slow motion by blending ghosts faces` }); }
+finds.sort((a, b) => (a.sev === b.sev ? a.t0 - b.t0 : a.sev === 'FAIL' ? -1 : 1));
+const fails = finds.filter((x) => x.sev === 'FAIL').length, warns = finds.length - fails;
+const clips = new Set(samples.flatMap((s) => s.img.map((d) => clipOf(d.id))));
+console.log(`PLATE AUDIT ${path.basename(film)} ${W}x${H}, ${f(D)} s, a sample every ${STEP} s, ${clips.size} big pictures or clips`);
+if (errs.length) console.log(' page errors while drawing: ' + errs.slice(0, 3).join(' | '));
+if (!clips.size) console.log(' no picture covering a fifth of the frame was drawn: nothing to measure (a code-only film?)');
+for (const x of finds) console.log(` ${x.sev} ${x.rule.padEnd(7)} ${(f(x.t0) + '-' + f(x.t1) + ' s').padEnd(15)} ${x.clip.padEnd(34)} ${x.why}`);
+console.log(fails ? `PLATE AUDIT: FAIL ${fails} to fix, ${warns} to look at` : warns ? `PLATE AUDIT: PASS with ${warns} to look at` : 'PLATE AUDIT: PASS');
+if (JSON_OUT) fs.writeFileSync(JSON_OUT, JSON.stringify({ film: path.basename(film), W, H, D, step: STEP, finds }, null, 1));
+process.exit(fails ? 1 : 0);
diff --git a/scripts/text-audit.mjs b/scripts/text-audit.mjs
index fded8d0..306b314 100644
--- a/scripts/text-audit.mjs
+++ b/scripts/text-audit.mjs
@@ -20,6 +20,9 @@
// PINNED small text parked in a corner zone for 6 s or more in total: a label, a counter, a name. A film is not a page.
// LONG one big line (5 % of the height or more) held more than 6 s: the frame may have become a slide.
// FACE text over a face, when the film exposes window.FACES = (t) => [[x, y, w, h], ...] in canvas pixels.
+// BROKEN a value that failed to compute, printed on screen for any length of time: NaN, undefined, Infinity or
+// [object Object] as a word (a counter whose start was shifted to -1.1 showed "NaN" for a whole beat). FAIL.
+// A lone "null" as a word is a WARN.
// OVERLAP two different texts printed on top of each other for 0.3 s or more (a label over a label, a caption over a
// number). It counts when the overlap covers a fifth of the smaller text's width and a quarter of its height, so
// a descender touching the next line or two words crossing in a transition pass. The same text drawn twice (an
@@ -129,6 +132,8 @@ for (const r of done) { const held = r.t1 - r.t0 + STEP, w = words(r.s); if (!w)
const need = 0.4 + 0.2 * w; if (held < need && !nearEnd && r.minPx / H >= 0.035) add(held < need * 0.6 ? 'FAIL' : 'WARN', 'FLASH', r, `${w} word${w > 1 ? 's' : ''} up for ${f(held)} s, needs about ${f(need)} s`);
if (r.edge >= 0.8 && r.maxPx / H < 0.2) add('WARN', 'EDGE', r, `partly out of the frame for ${f(r.edge)} s`);
if (r.faceHit) add('FAIL', 'FACE', r, 'sits on a face');
+ if (/(^|[^\p{L}])(NaN|undefined|Infinity)([^\p{L}]|$)|\[object [A-Za-z]+\]/u.test(r.s)) add('FAIL', 'BROKEN', r, 'a value that failed to compute is on screen');
+ else if (/(^|[^\p{L}])null([^\p{L}]|$)/u.test(r.s)) add('WARN', 'BROKEN', r, '"null" on screen: a missing value?');
if (r.maxPx / H < 0.05 && r.corner > 0) pinned.set(r.s, (pinned.get(r.s) || 0) + r.corner);
if (held > 6 && w >= 2 && r.minPx / H >= 0.05) add('WARN', 'LONG', r, `held ${f(held)} s: the same frame for too long?`);
}