@open-take/compositor 0.3.0 → 0.4.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.
- package/dist/index.d.ts +60 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +83 -24
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
- package/src/camera.ts +11 -1
- package/src/math.ts +11 -8
- package/src/plan.ts +24 -0
- package/src/render.ts +66 -36
- package/src/scene/scene.tsx +130 -4
- package/src/types.ts +53 -4
- package/src/validate.ts +65 -1
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-take/compositor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Polish compositor (D3) — event log + captured frames -> polished mp4 + editable revideo composition.",
|
|
5
5
|
"license": "MIT",
|
|
6
|
+
"funding": "https://ko-fi.com/pascal18663",
|
|
6
7
|
"type": "module",
|
|
7
8
|
"main": "./dist/index.js",
|
|
8
9
|
"types": "./dist/index.d.ts",
|
|
@@ -22,7 +23,7 @@
|
|
|
22
23
|
"@revideo/core": "0.11.0",
|
|
23
24
|
"@revideo/ui": "0.11.0",
|
|
24
25
|
"@revideo/vite-plugin": "0.11.0",
|
|
25
|
-
"@open-take/revideo-renderer": "0.
|
|
26
|
+
"@open-take/revideo-renderer": "0.4.0"
|
|
26
27
|
},
|
|
27
28
|
"devDependencies": {
|
|
28
29
|
"@types/node": "^22.10.1",
|
package/src/camera.ts
CHANGED
|
@@ -28,7 +28,7 @@ import type { BBox, CameraConfig, Pt, ZoomIntent } from "./types";
|
|
|
28
28
|
|
|
29
29
|
/** One action, already mapped into video-px, handed to the director. */
|
|
30
30
|
export type Beat = {
|
|
31
|
-
kind: "click" | "type" | "drag" | "scroll" | "hover" | "press" | "dropFiles";
|
|
31
|
+
kind: "click" | "type" | "drag" | "scroll" | "hover" | "look" | "press" | "dropFiles";
|
|
32
32
|
tMs: number;
|
|
33
33
|
durationMs: number;
|
|
34
34
|
/** element bbox (for a drag: the path's bbox), video-px — or undefined for a
|
|
@@ -93,6 +93,11 @@ function roiForBeat(b: Beat, video: { w: number; h: number }): BBox | undefined
|
|
|
93
93
|
// there the payoff usually lands AWAY from the element, which is the whole
|
|
94
94
|
// point of the frame-diff seam.
|
|
95
95
|
if (b.kind === "press" && b.intent === "always" && b.box) return b.box;
|
|
96
|
+
// A look names exactly what to frame — that IS the beat. Nothing happened on
|
|
97
|
+
// the page, so any effectBox is neighbouring noise (an animation, a ticking
|
|
98
|
+
// number), and preferring it would aim the "show the viewer this" camera at
|
|
99
|
+
// something else entirely.
|
|
100
|
+
if (b.kind === "look" && b.box) return b.box;
|
|
96
101
|
if (b.kind === "type" && b.box) {
|
|
97
102
|
// Bound the frame to "field + top of results": keep the effectBox's real
|
|
98
103
|
// reveal WIDTH, but cap the HEIGHT to growDown's result-sized window so an
|
|
@@ -321,6 +326,11 @@ export function directCamera(
|
|
|
321
326
|
// merges across a break (order: hard break → coalesce → min-hold).
|
|
322
327
|
segs.forEach((s, si) => {
|
|
323
328
|
if (s.kind !== "punch") return;
|
|
329
|
+
// A look segment is exempt: its hold length is the AUTHOR'S statement
|
|
330
|
+
// ("show the viewer this for durationMs"), not a derived gap — demoting it
|
|
331
|
+
// to full view would delete the beat's entire content. A tight look reads
|
|
332
|
+
// brisk, not flinchy, because nothing else competes for the frame.
|
|
333
|
+
if (s.idx.some((i) => beats[i]!.kind === "look")) return;
|
|
324
334
|
const firstT = beats[s.idx[0]!]!.tMs;
|
|
325
335
|
const next = segs[si + 1];
|
|
326
336
|
const heldUntil = next ? beats[next.idx[0]!]!.tMs : endMs;
|
package/src/math.ts
CHANGED
|
@@ -712,15 +712,18 @@ export function buildLegs(comp: TakeComposition): Leg[] {
|
|
|
712
712
|
return { sec: ms / 1000 };
|
|
713
713
|
};
|
|
714
714
|
for (const [evIdx, e] of comp.events.entries()) {
|
|
715
|
-
// scroll/press are not pointer-driven — the cursor holds where it was
|
|
716
|
-
// (the content pans / the keyboard acts
|
|
717
|
-
// so the between-legs parking logic keeps
|
|
715
|
+
// scroll/press/look are not pointer-driven — the cursor holds where it was
|
|
716
|
+
// (the content pans / the keyboard acts / the CAMERA does the moving). No
|
|
717
|
+
// travel leg; `cur` is untouched, so the between-legs parking logic keeps
|
|
718
|
+
// the cursor at its last anchor. For a look this parking IS the feature:
|
|
719
|
+
// cursor movement promises an action, and a look makes none — the camera
|
|
720
|
+
// frames the target while the cursor honestly stays put.
|
|
718
721
|
// They still OCCUPY the frame for durationMs, though: a scroll's duration IS
|
|
719
|
-
// the pan,
|
|
720
|
-
//
|
|
721
|
-
// cursor crossing it — so they push
|
|
722
|
-
// even though they contribute no leg.
|
|
723
|
-
if (e.kind === "scroll" || e.kind === "press") {
|
|
722
|
+
// the pan, a press's is the reveal animating in, a look's is the framed
|
|
723
|
+
// hold. A travel that departs into any of them puts two motions on screen
|
|
724
|
+
// at once — content sliding under a cursor crossing it — so they push
|
|
725
|
+
// `freeAt` exactly like a pointer beat even though they contribute no leg.
|
|
726
|
+
if (e.kind === "scroll" || e.kind === "press" || e.kind === "look") {
|
|
724
727
|
freeAt = Math.max(freeAt, (e.tMs + (e.durationMs ?? 0)) / 1000);
|
|
725
728
|
continue;
|
|
726
729
|
}
|
package/src/plan.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { restStageScale } from "./math";
|
|
|
12
12
|
import {
|
|
13
13
|
type BBox,
|
|
14
14
|
type CameraConfig,
|
|
15
|
+
type Caption,
|
|
15
16
|
type CaptureLog,
|
|
16
17
|
type CompEvent,
|
|
17
18
|
type CursorConfig,
|
|
@@ -172,6 +173,28 @@ export function planComposition(log: CaptureLog, opts: PlanOpts = {}): TakeCompo
|
|
|
172
173
|
const start = log.start ? mapPt(log.start) : { x: vW * 0.25, y: vH * 0.9 };
|
|
173
174
|
const durationMs = Math.max(log.tEndMs ?? 0, lastEnd + cursor.holdMs + cursor.zoomOutMs + 400);
|
|
174
175
|
|
|
176
|
+
// --- captions: per-step caption strings → viewer-facing subtitle windows.
|
|
177
|
+
// Deterministic tiling ANCHORED AT ACTION INSTANTS: a caption lands exactly
|
|
178
|
+
// when its beat's action does — the camera has finished (or nearly finished)
|
|
179
|
+
// its move by then, so the swap happens over a settled frame. Anchoring at
|
|
180
|
+
// the zoom DEPARTURE (the first design) put every caption swap inside a
|
|
181
|
+
// camera ramp, and two simultaneous motions read as "the subtitle moves
|
|
182
|
+
// with the zoom" — the field complaint that moved the anchor here. A
|
|
183
|
+
// caption holds until the next beat's action (never narrating someone
|
|
184
|
+
// else's beat); the last one rides out to the end. All times
|
|
185
|
+
// untrimmed-timeline, editable afterwards like any composition field.
|
|
186
|
+
const captions: Caption[] = [];
|
|
187
|
+
log.events.forEach((c, i) => {
|
|
188
|
+
const text = c.caption?.trim();
|
|
189
|
+
if (!text) return;
|
|
190
|
+
const e = events[i]!;
|
|
191
|
+
const prevEnd = captions.length ? captions[captions.length - 1]!.toMs : 0;
|
|
192
|
+
const fromMs = Math.max(e.tMs, prevEnd);
|
|
193
|
+
const next = events[i + 1];
|
|
194
|
+
const toMs = Math.max(fromMs + 300, next ? next.tMs : durationMs);
|
|
195
|
+
captions.push({ fromMs, toMs, text });
|
|
196
|
+
});
|
|
197
|
+
|
|
175
198
|
return {
|
|
176
199
|
output: { width: oW, height: oH, fps },
|
|
177
200
|
source: { videoUrl: "/capture.mp4", videoWidth: vW, videoHeight: vH, viewport: log.viewport },
|
|
@@ -181,6 +204,7 @@ export function planComposition(log: CaptureLog, opts: PlanOpts = {}): TakeCompo
|
|
|
181
204
|
start,
|
|
182
205
|
events,
|
|
183
206
|
durationMs,
|
|
207
|
+
...(captions.length ? { captions } : {}),
|
|
184
208
|
};
|
|
185
209
|
}
|
|
186
210
|
|
package/src/render.ts
CHANGED
|
@@ -16,11 +16,10 @@
|
|
|
16
16
|
import { spawn } from "node:child_process";
|
|
17
17
|
import { existsSync, realpathSync } from "node:fs";
|
|
18
18
|
import {
|
|
19
|
-
copyFile,
|
|
20
19
|
mkdir,
|
|
21
20
|
mkdtemp,
|
|
22
|
-
readFile,
|
|
23
21
|
readdir,
|
|
22
|
+
readFile,
|
|
24
23
|
rm,
|
|
25
24
|
symlink,
|
|
26
25
|
unlink,
|
|
@@ -33,7 +32,12 @@ import { fileURLToPath } from "node:url";
|
|
|
33
32
|
import { renderVideo } from "@open-take/revideo-renderer";
|
|
34
33
|
import { repairBundledMediaPermissions, resolveFfmpeg } from "./ffmpeg";
|
|
35
34
|
import { type PlanOpts, planComposition } from "./plan";
|
|
36
|
-
import {
|
|
35
|
+
import {
|
|
36
|
+
type CaptureLog,
|
|
37
|
+
type MotionBlurConfig,
|
|
38
|
+
motionBlurActive,
|
|
39
|
+
type TakeComposition,
|
|
40
|
+
} from "./types";
|
|
37
41
|
import { type CompositionIssue, formatIssues, validateComposition } from "./validate";
|
|
38
42
|
|
|
39
43
|
// dist/index.js -> package root
|
|
@@ -128,37 +132,54 @@ async function toMp4(videoPath: string, outMp4: string, fps: number): Promise<vo
|
|
|
128
132
|
]);
|
|
129
133
|
}
|
|
130
134
|
|
|
131
|
-
/**
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
|
|
138
|
-
|
|
135
|
+
/** Delivery encode: the visually-lossless ProRes intermediate -> the postable
|
|
136
|
+
* H.264. The ONLY lossy generation in the pipeline, so its CRF is the
|
|
137
|
+
* master's quality — overlay text (captions/title card) used to look soft
|
|
138
|
+
* because it took TWO generations before this fix: revideo's default wasm
|
|
139
|
+
* exporter (WebCodecs H.264 at the browser's default bitrate, no knob, at
|
|
140
|
+
* fps·samples) and then this re-encode on top.
|
|
141
|
+
*
|
|
142
|
+
* Motion blur folds in here (temporal supersampling: the scene was rendered
|
|
143
|
+
* at fps·samples, project.ts): `tmix=frames=M` averages M consecutive
|
|
144
|
+
* sub-frames; `fps=baseFps` then decimates ≈every `samples`-th, so each
|
|
145
|
+
* output frame = the mean of the last M sub-frames of its interval (a
|
|
146
|
+
* trailing shutter).
|
|
147
|
+
*
|
|
148
|
+
* The scale step is a REAL conversion, not a re-tag: the ProRes encode
|
|
149
|
+
* converts the scene's RGB frames with swscale's default bt601 matrix, so
|
|
150
|
+
* the intermediate is 601-coded. Convert to bt709 and tag it — verified by
|
|
151
|
+
* round-tripping primaries (601-coded red merely tagged 709 decodes to
|
|
152
|
+
* rgb(255,24,0); converted it decodes to rgb(252,0,0)). */
|
|
153
|
+
async function deliverMp4(
|
|
154
|
+
inMov: string,
|
|
139
155
|
outMp4: string,
|
|
140
156
|
baseFps: number,
|
|
141
|
-
|
|
142
|
-
shutter: number,
|
|
157
|
+
blur: MotionBlurConfig | null,
|
|
143
158
|
): Promise<void> {
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
159
|
+
const vf: string[] = [];
|
|
160
|
+
if (blur) {
|
|
161
|
+
const M = Math.max(1, Math.min(blur.samples, Math.round(blur.shutter * blur.samples)));
|
|
162
|
+
vf.push(`tmix=frames=${M}`, `fps=${baseFps}`);
|
|
163
|
+
}
|
|
164
|
+
vf.push(
|
|
165
|
+
"scale=in_color_matrix=bt601:out_color_matrix=bt709",
|
|
166
|
+
"format=yuv420p",
|
|
167
|
+
"setparams=range=tv:colorspace=bt709:color_primaries=bt709:color_trc=bt709",
|
|
168
|
+
);
|
|
148
169
|
await run(await resolveFfmpeg(), [
|
|
149
170
|
"-y",
|
|
150
171
|
"-loglevel",
|
|
151
172
|
"error",
|
|
152
173
|
"-i",
|
|
153
|
-
resolve(
|
|
174
|
+
resolve(inMov),
|
|
154
175
|
"-vf",
|
|
155
|
-
vf,
|
|
176
|
+
vf.join(","),
|
|
156
177
|
"-c:v",
|
|
157
178
|
"libx264",
|
|
158
|
-
"-pix_fmt",
|
|
159
|
-
"yuv420p",
|
|
160
179
|
"-crf",
|
|
161
180
|
"18",
|
|
181
|
+
"-movflags",
|
|
182
|
+
"+faststart",
|
|
162
183
|
"-r",
|
|
163
184
|
String(baseFps),
|
|
164
185
|
"-an",
|
|
@@ -332,10 +353,23 @@ async function renderTakeExclusive(opts: RenderTakeOpts): Promise<RenderTakeResu
|
|
|
332
353
|
produced = await renderVideo({
|
|
333
354
|
projectFile: "/src/scene/project.ts",
|
|
334
355
|
settings: {
|
|
335
|
-
outFile: "take.
|
|
356
|
+
outFile: "take.mov",
|
|
336
357
|
outDir: RENDER_OUT,
|
|
337
358
|
workers: 1,
|
|
338
|
-
|
|
359
|
+
// ProRes 4444 intermediate, NOT revideo's default wasm exporter: the
|
|
360
|
+
// wasm path encodes H.264 in-browser via WebCodecs at the browser's
|
|
361
|
+
// default bitrate (mp4-wasm passes `bitrate: undefined`, and revideo
|
|
362
|
+
// 0.11 exposes no knob) — at fps·samples that visibly softens fine
|
|
363
|
+
// detail, screen-space caption/title text worst of all, before the
|
|
364
|
+
// delivery encode ever runs. The ffmpeg exporter is fed lossless PNG
|
|
365
|
+
// frames and prores_ks 4444 keeps them visually intact (4:4:4, no
|
|
366
|
+
// DCT mush), leaving deliverMp4's CRF 18 as the single lossy
|
|
367
|
+
// generation. Costs scratch disk (GBs at fps·samples for a long
|
|
368
|
+
// take) and slower frame handoff — accepted for the master's text.
|
|
369
|
+
projectSettings: {
|
|
370
|
+
exporter: { name: "@revideo/core/ffmpeg", options: { format: "proRes" } },
|
|
371
|
+
...(rangeSec ? { range: rangeSec } : {}),
|
|
372
|
+
},
|
|
339
373
|
logProgress: opts.logProgress ?? false,
|
|
340
374
|
...(opts.onProgress
|
|
341
375
|
? {
|
|
@@ -367,21 +401,17 @@ async function renderTakeExclusive(opts: RenderTakeOpts): Promise<RenderTakeResu
|
|
|
367
401
|
process.chdir(prevCwd);
|
|
368
402
|
}
|
|
369
403
|
|
|
370
|
-
// 3. deliver
|
|
371
|
-
//
|
|
404
|
+
// 3. deliver the postable mp4 from the ProRes intermediate + the editable
|
|
405
|
+
// composition. Motion blur (when configured) and the 601→709 colour
|
|
406
|
+
// conversion both happen inside this single encode — see deliverMp4.
|
|
372
407
|
await mkdir(dirname(resolve(opts.outPath)), { recursive: true });
|
|
373
408
|
const producedAbs = resolve(scratch, produced);
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
composition.motionBlur.shutter,
|
|
381
|
-
);
|
|
382
|
-
} else {
|
|
383
|
-
await copyFile(producedAbs, resolve(opts.outPath));
|
|
384
|
-
}
|
|
409
|
+
await deliverMp4(
|
|
410
|
+
producedAbs,
|
|
411
|
+
resolve(opts.outPath),
|
|
412
|
+
composition.output.fps,
|
|
413
|
+
motionBlurActive(composition.motionBlur) ? composition.motionBlur : null,
|
|
414
|
+
);
|
|
385
415
|
const compositionPath = opts.compositionPath
|
|
386
416
|
? resolve(opts.compositionPath)
|
|
387
417
|
: `${resolve(opts.outPath).replace(/\.mp4$/i, "")}.composition.json`;
|
package/src/scene/scene.tsx
CHANGED
|
@@ -114,11 +114,13 @@ export default makeScene2D("take", function* (view) {
|
|
|
114
114
|
</Rect>
|
|
115
115
|
|
|
116
116
|
{/* click ripples — pointer-landing beats only (scroll/press have no
|
|
117
|
-
spatial click point
|
|
118
|
-
|
|
119
|
-
|
|
117
|
+
spatial click point; a look touches nothing, and a ripple at a point
|
|
118
|
+
the cursor never visited would invent a click that did not happen).
|
|
119
|
+
A dropFiles ripples at its DROP point on RELEASE — not at the
|
|
120
|
+
off-content carry entry — and stays on even when the ghost card is
|
|
121
|
+
disabled (parity with the editor preview). */}
|
|
120
122
|
{comp.events
|
|
121
|
-
.filter((e) => e.kind !== "scroll" && e.kind !== "press")
|
|
123
|
+
.filter((e) => e.kind !== "scroll" && e.kind !== "press" && e.kind !== "look")
|
|
122
124
|
.map((e, index) => {
|
|
123
125
|
const ms = comp.cursor.rippleMs / 1000;
|
|
124
126
|
const at =
|
|
@@ -303,5 +305,129 @@ export default makeScene2D("take", function* (view) {
|
|
|
303
305
|
if (review.label) view.add(pill(review.label, 1, true));
|
|
304
306
|
}
|
|
305
307
|
|
|
308
|
+
// Viewer-facing captions — SCREEN space like the review decor, but a
|
|
309
|
+
// first-class composition field drawn on EVERY render including the master.
|
|
310
|
+
// Bottom-CENTER (the subtitle slot), so review badges (bottom-left) never
|
|
311
|
+
// collide with it. Footage shows what happened; the caption says what it
|
|
312
|
+
// means — the difference between a demo a stranger can follow and "the
|
|
313
|
+
// screen moves around". 160ms fades: soft under motion blur, never a pop.
|
|
314
|
+
//
|
|
315
|
+
// Anchored INSIDE the framed card (above the at-rest backdrop band), never
|
|
316
|
+
// on the frame's edge: a pill straddling the card/backdrop seam has the
|
|
317
|
+
// zooming card boundary sweep THROUGH it, which reads as the caption itself
|
|
318
|
+
// moving — the field complaint that motivated this anchor. Sized for the
|
|
319
|
+
// couch, not the badge rail: 34px @1080 with a 600 weight (CJK at 500 reads
|
|
320
|
+
// thin), a hairline border and a soft drop shadow so it sits ON the video
|
|
321
|
+
// as a produced element instead of a debug overlay.
|
|
322
|
+
// CINEMA-style, not boxed: film subtitles earn their look from big
|
|
323
|
+
// confident type sitting on a soft bottom scrim — the pill/box treatment
|
|
324
|
+
// (two attempts, both rejected in the field) reads as a debug overlay no
|
|
325
|
+
// matter how it is dressed. The scrim is constant while captions exist
|
|
326
|
+
// (a pulsing scrim is worse than none) and the type carries a TIGHT
|
|
327
|
+
// shadow: at 1080p the footage is 4K-downsampled (supersampled-sharp)
|
|
328
|
+
// while overlays render native, so overlays must lean on stroke weight
|
|
329
|
+
// and contrast — a wide blur reads as smear next to that footage.
|
|
330
|
+
const k = oH / 1080;
|
|
331
|
+
const FONT = "system-ui, -apple-system, 'Segoe UI', 'Noto Sans', sans-serif";
|
|
332
|
+
if (comp.captions?.length) {
|
|
333
|
+
const cardBottom = (oH / 2) * comp.framing.insetFrac;
|
|
334
|
+
const scrimH = 190 * k;
|
|
335
|
+
view.add(
|
|
336
|
+
<Rect
|
|
337
|
+
width={oW}
|
|
338
|
+
height={scrimH}
|
|
339
|
+
position={[0, oH / 2]}
|
|
340
|
+
offset={[0, 1]}
|
|
341
|
+
fill={
|
|
342
|
+
new Gradient({
|
|
343
|
+
type: "linear",
|
|
344
|
+
from: { x: 0, y: -scrimH / 2 },
|
|
345
|
+
to: { x: 0, y: scrimH / 2 },
|
|
346
|
+
stops: [
|
|
347
|
+
{ offset: 0, color: "rgba(0,0,0,0)" },
|
|
348
|
+
{ offset: 1, color: "rgba(0,0,0,0.55)" },
|
|
349
|
+
],
|
|
350
|
+
})
|
|
351
|
+
}
|
|
352
|
+
/>,
|
|
353
|
+
);
|
|
354
|
+
for (const c of comp.captions) {
|
|
355
|
+
const op = () => {
|
|
356
|
+
const ms = t() * 1000;
|
|
357
|
+
if (ms < c.fromMs || ms >= c.toMs) return 0;
|
|
358
|
+
const inF = Math.min(1, (ms - c.fromMs) / 160);
|
|
359
|
+
const outF = Math.min(1, (c.toMs - ms) / 160);
|
|
360
|
+
return Math.min(inF, outF);
|
|
361
|
+
};
|
|
362
|
+
view.add(
|
|
363
|
+
<Txt
|
|
364
|
+
text={c.text}
|
|
365
|
+
fontFamily={FONT}
|
|
366
|
+
fontSize={36 * k}
|
|
367
|
+
fontWeight={600}
|
|
368
|
+
letterSpacing={0.8 * k}
|
|
369
|
+
fill={"rgba(255,255,255,0.98)"}
|
|
370
|
+
shadowColor={"rgba(0,0,0,0.9)"}
|
|
371
|
+
shadowBlur={6 * k}
|
|
372
|
+
shadowOffset={[0, 2 * k]}
|
|
373
|
+
maxWidth={oW * 0.82}
|
|
374
|
+
textWrap={true}
|
|
375
|
+
textAlign={"center"}
|
|
376
|
+
position={[0, cardBottom - 26 * k]}
|
|
377
|
+
offset={[0, 1]}
|
|
378
|
+
opacity={op}
|
|
379
|
+
/>,
|
|
380
|
+
);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
// Opening title card — full-frame scrim + the app/thesis in big type over
|
|
385
|
+
// the establishing hold, gone by untilMs. The cheapest "produced, not
|
|
386
|
+
// captured" signal; typographic and deterministic by design (no generated
|
|
387
|
+
// imagery — brand-safe, language follows the author, deletable field).
|
|
388
|
+
if (comp.titleCard?.title) {
|
|
389
|
+
const tc = comp.titleCard;
|
|
390
|
+
const untilMs = tc.untilMs ?? (comp.startMs ?? 0) + 1800;
|
|
391
|
+
const tcOp = () => {
|
|
392
|
+
const ms = t() * 1000;
|
|
393
|
+
if (ms >= untilMs) return 0;
|
|
394
|
+
return Math.min(1, (untilMs - ms) / 300);
|
|
395
|
+
};
|
|
396
|
+
view.add(
|
|
397
|
+
<Rect width={oW} height={oH} position={[0, 0]} fill={"rgba(6,7,14,0.55)"} opacity={tcOp} />,
|
|
398
|
+
);
|
|
399
|
+
view.add(
|
|
400
|
+
<Txt
|
|
401
|
+
text={tc.title}
|
|
402
|
+
fontFamily={FONT}
|
|
403
|
+
fontSize={72 * k}
|
|
404
|
+
fontWeight={800}
|
|
405
|
+
letterSpacing={2 * k}
|
|
406
|
+
fill={"rgba(255,255,255,0.98)"}
|
|
407
|
+
shadowColor={"rgba(0,0,0,0.8)"}
|
|
408
|
+
shadowBlur={10 * k}
|
|
409
|
+
shadowOffset={[0, 3 * k]}
|
|
410
|
+
position={[0, tc.subtitle ? -26 * k : 0]}
|
|
411
|
+
opacity={tcOp}
|
|
412
|
+
/>,
|
|
413
|
+
);
|
|
414
|
+
if (tc.subtitle)
|
|
415
|
+
view.add(
|
|
416
|
+
<Txt
|
|
417
|
+
text={tc.subtitle}
|
|
418
|
+
fontFamily={FONT}
|
|
419
|
+
fontSize={30 * k}
|
|
420
|
+
fontWeight={500}
|
|
421
|
+
letterSpacing={1 * k}
|
|
422
|
+
fill={"rgba(255,255,255,0.78)"}
|
|
423
|
+
shadowColor={"rgba(0,0,0,0.8)"}
|
|
424
|
+
shadowBlur={8 * k}
|
|
425
|
+
shadowOffset={[0, 2 * k]}
|
|
426
|
+
position={[0, 40 * k]}
|
|
427
|
+
opacity={tcOp}
|
|
428
|
+
/>,
|
|
429
|
+
);
|
|
430
|
+
}
|
|
431
|
+
|
|
306
432
|
yield* tween(cam.T, (v) => t(v * cam.T), linear);
|
|
307
433
|
});
|
package/src/types.ts
CHANGED
|
@@ -25,6 +25,11 @@ export type CaptureEventBase = {
|
|
|
25
25
|
/** selector / note, kept for editability */
|
|
26
26
|
sel?: string;
|
|
27
27
|
note?: string;
|
|
28
|
+
/** One-line viewer-facing caption from the plan step ("Applying the
|
|
29
|
+
* filter re-prices every row"). planComposition turns these into `captions`
|
|
30
|
+
* windows — the beat explains itself to a viewer who has never seen the
|
|
31
|
+
* app, which footage alone cannot do. */
|
|
32
|
+
caption?: string;
|
|
28
33
|
/** selective-zoom intent from the plan. Absent/"auto" ⇒ the camera director
|
|
29
34
|
* decides from the ground-truth log; "always"/"never" hard-override it (and
|
|
30
35
|
* cut the beat out of any cluster — an override is a segment boundary). */
|
|
@@ -91,6 +96,19 @@ export type CaptureHover = CaptureEventBase & {
|
|
|
91
96
|
durationMs: number;
|
|
92
97
|
};
|
|
93
98
|
|
|
99
|
+
/** A look: a CAMERA-only beat. Nothing is done to the page and the cursor
|
|
100
|
+
* does not move — the camera frames the target element and holds for
|
|
101
|
+
* `durationMs`. This is the honest spelling of "show the viewer this
|
|
102
|
+
* region": before it existed, the only way to aim the camera was to hover
|
|
103
|
+
* a control you never meant to activate, which reads on screen as a
|
|
104
|
+
* promise ("about to click") the video then breaks. `x,y` is the target's
|
|
105
|
+
* center (zoom anchor); the cursor rests at its previous anchor. */
|
|
106
|
+
export type CaptureLook = CaptureEventBase & {
|
|
107
|
+
kind: "look";
|
|
108
|
+
/** ms the framed hold occupies on screen */
|
|
109
|
+
durationMs: number;
|
|
110
|
+
};
|
|
111
|
+
|
|
94
112
|
/** A key press / shortcut: keyboard-driven, so the cursor holds (no travel).
|
|
95
113
|
* Holds for `durationMs` while the effect plays out; if a reveal element was
|
|
96
114
|
* located, `box` carries its bbox so the zoom can frame it. */
|
|
@@ -127,6 +145,7 @@ export type CaptureEvent =
|
|
|
127
145
|
| CaptureDrag
|
|
128
146
|
| CaptureScroll
|
|
129
147
|
| CaptureHover
|
|
148
|
+
| CaptureLook
|
|
130
149
|
| CapturePress
|
|
131
150
|
| CaptureDropFiles;
|
|
132
151
|
|
|
@@ -203,7 +222,7 @@ export type GhostCardConfig = {
|
|
|
203
222
|
};
|
|
204
223
|
|
|
205
224
|
export type CompEvent = {
|
|
206
|
-
kind: "click" | "type" | "drag" | "scroll" | "hover" | "press" | "dropFiles";
|
|
225
|
+
kind: "click" | "type" | "drag" | "scroll" | "hover" | "look" | "press" | "dropFiles";
|
|
207
226
|
tMs: number;
|
|
208
227
|
/** anchor point (click / focus / drag start / hover) in video-px. For a
|
|
209
228
|
* scroll/press the cursor does not move; this is its resting point. */
|
|
@@ -363,6 +382,23 @@ export type MotionBlurConfig = {
|
|
|
363
382
|
* (inclusive) to `toMs` (exclusive) on the composition timeline. */
|
|
364
383
|
export type ReviewBadge = { fromMs: number; toMs: number; text: string };
|
|
365
384
|
|
|
385
|
+
/** One viewer-facing caption window on the DELIVERED video: `text` shows
|
|
386
|
+
* bottom-center from `fromMs` (inclusive) to `toMs` (exclusive) on the
|
|
387
|
+
* composition timeline. Unlike ReviewBadge this is a first-class, persisted
|
|
388
|
+
* composition field rendered on masters — footage alone shows WHAT happened;
|
|
389
|
+
* the caption says what it MEANS, which is the difference between a demo a
|
|
390
|
+
* stranger can follow and "the screen moves around". Absent ⇒ rendered
|
|
391
|
+
* output is byte-identical to a caption-less composition. */
|
|
392
|
+
export type Caption = { fromMs: number; toMs: number; text: string };
|
|
393
|
+
|
|
394
|
+
/** An opening title card: `title` (the app / the thesis) over a full-frame
|
|
395
|
+
* scrim on top of the establishing hold, gone by `untilMs` (300ms fade).
|
|
396
|
+
* Typographic and deterministic — rendered by the scene in the composition's
|
|
397
|
+
* own look, in whatever language the author wrote, deletable like any field
|
|
398
|
+
* — never generated imagery. The single cheapest "produced, not captured"
|
|
399
|
+
* signal a demo can send. */
|
|
400
|
+
export type TitleCard = { title: string; subtitle?: string; untilMs?: number };
|
|
401
|
+
|
|
366
402
|
/** Render-time decoration for review copies and A/B variant reels: burned-in
|
|
367
403
|
* beat badges, a REVIEW watermark, and a per-variant corner label. Drawn by the
|
|
368
404
|
* scene in SCREEN space (fixed, outside the composition camera) so the text is
|
|
@@ -454,12 +490,25 @@ export type TakeComposition = {
|
|
|
454
490
|
* capture is the ground truth); only the delivered head moves. 0/absent =
|
|
455
491
|
* no trim. */
|
|
456
492
|
startMs?: number;
|
|
457
|
-
/**
|
|
493
|
+
/** Viewer-facing captions, drawn bottom-center in SCREEN space (outside the
|
|
494
|
+
* camera — legible at any zoom) on EVERY render including the master.
|
|
495
|
+
* Persisted and hand-editable like any composition field; times are on the
|
|
496
|
+
* untrimmed composition timeline (same convention as zoom.inAtMs — a
|
|
497
|
+
* caption entirely inside the startMs head trim is never seen, and the
|
|
498
|
+
* validator says so). Seeded from the plan steps' `caption` fields by
|
|
499
|
+
* planComposition. */
|
|
500
|
+
captions?: Caption[];
|
|
501
|
+
/** optional opening title card over the establishing hold (see TitleCard) */
|
|
502
|
+
titleCard?: TitleCard;
|
|
503
|
+
/** render-time review decoration (badges/watermark/label); never persisted
|
|
504
|
+
* (render strips exactly this field — `captions` above deliberately IS
|
|
505
|
+
* persisted; it is content, not review scaffolding) */
|
|
458
506
|
review?: ReviewDecor;
|
|
459
507
|
};
|
|
460
508
|
|
|
461
|
-
/** True when motion blur is configured to actually do something
|
|
462
|
-
*
|
|
509
|
+
/** True when motion blur is configured to actually do something — whether the
|
|
510
|
+
* delivery encode folds in the tmix shutter average (render.ts deliverMp4;
|
|
511
|
+
* OFF skips tmix but still runs the same single delivery encode). */
|
|
463
512
|
export function motionBlurActive(mb: MotionBlurConfig | undefined): mb is MotionBlurConfig {
|
|
464
513
|
return !!mb && mb.samples > 1 && mb.shutter > 0;
|
|
465
514
|
}
|
package/src/validate.ts
CHANGED
|
@@ -70,6 +70,8 @@ const reqField: Record<string, string> = {
|
|
|
70
70
|
press: "keys",
|
|
71
71
|
drag: "to",
|
|
72
72
|
dropFiles: "to",
|
|
73
|
+
// a look IS its hold — without a duration there is no beat to render
|
|
74
|
+
look: "durationMs",
|
|
73
75
|
};
|
|
74
76
|
|
|
75
77
|
export function validateComposition(
|
|
@@ -487,7 +489,10 @@ export function validateComposition(
|
|
|
487
489
|
`this beat's camera window runs ${Math.round(rampMs)}ms — ${(rampMs / nominal).toFixed(1)}× cursor.${r.pullOut ? "zoomOutMs" : "zoomInMs"} (${nominal}ms) — so the camera departs at ${Math.round(r.startMs)}ms and creeps to the action instead of moving at the take's pace`,
|
|
488
490
|
`set inAtMs = ${Math.max(0, e.tMs - comp.cursor.zoomInMs)} (tMs − cursor.zoomInMs) and change cursor.${r.pullOut ? "zoomOutMs" : "zoomInMs"} if the RAMP itself should be slower`,
|
|
489
491
|
);
|
|
490
|
-
|
|
492
|
+
// press: reveal-timed by construction. look: nothing fires at tMs —
|
|
493
|
+
// the camera arriving early in the DWELL is the beat working as
|
|
494
|
+
// designed, so "the frame slides out from under it" cannot happen.
|
|
495
|
+
if (e.kind === "press" || e.kind === "look") continue;
|
|
491
496
|
const lateMs = Math.round(r.landMs - e.tMs);
|
|
492
497
|
if (lateMs <= MOVING_AT_ACTION_MS) continue;
|
|
493
498
|
if (!(rampMs > 0) || lateMs / rampMs <= MOVING_AT_ACTION_FRAC) continue;
|
|
@@ -538,6 +543,22 @@ export function validateComposition(
|
|
|
538
543
|
}
|
|
539
544
|
}
|
|
540
545
|
|
|
546
|
+
// Dead HEAD — the mirror of the dead-tail check. A capture that had to wait
|
|
547
|
+
// out a cold load (map tiles, data fetch) ships that whole wait unless
|
|
548
|
+
// startMs trims it, and "8 seconds of nothing, then the cursor moves" is
|
|
549
|
+
// the first thing every viewer sees. The wait was necessary to SHOOT;
|
|
550
|
+
// shipping it is a choice, and the default choice should be no.
|
|
551
|
+
if (comp.events.length) {
|
|
552
|
+
const firstVisible = comp.events[0]!.zoom.inAtMs;
|
|
553
|
+
const deadHeadMs = firstVisible - (comp.startMs ?? 0);
|
|
554
|
+
if (deadHeadMs > DEAD_TAIL_MS)
|
|
555
|
+
warn(
|
|
556
|
+
"startMs",
|
|
557
|
+
`${(deadHeadMs / 1000).toFixed(1)}s of dead opening before the first beat's camera moves — the delivered video starts on a frozen screen`,
|
|
558
|
+
`set startMs ≈ ${Math.max(0, firstVisible - 1200)} (leave ~1.2s of establishing hold, trim the rest of the load wait)`,
|
|
559
|
+
);
|
|
560
|
+
}
|
|
561
|
+
|
|
541
562
|
// head trim: cut dead pre-paint frames, never a beat. The trim only moves
|
|
542
563
|
// the delivered head — tMs values stay on the capture timeline.
|
|
543
564
|
const startMs = comp.startMs;
|
|
@@ -556,6 +577,49 @@ export function validateComposition(
|
|
|
556
577
|
);
|
|
557
578
|
}
|
|
558
579
|
|
|
580
|
+
// --- captions: viewer-facing timeline overlays on the DELIVERED video ---
|
|
581
|
+
// Times are on the untrimmed composition timeline, like zoom.inAtMs.
|
|
582
|
+
for (const [i, cap] of (comp.captions ?? []).entries()) {
|
|
583
|
+
if (!cap.text?.trim()) {
|
|
584
|
+
err(`captions[${i}].text`, "empty caption text", "give the caption a line, or delete it");
|
|
585
|
+
continue;
|
|
586
|
+
}
|
|
587
|
+
if (!(cap.toMs > cap.fromMs))
|
|
588
|
+
err(
|
|
589
|
+
`captions[${i}].toMs`,
|
|
590
|
+
`toMs ${cap.toMs} is not after fromMs ${cap.fromMs} — an inverted/empty window shows nothing`,
|
|
591
|
+
"set toMs > fromMs (a readable line needs ~1500ms on screen)",
|
|
592
|
+
);
|
|
593
|
+
if (!(cap.fromMs >= 0) || cap.fromMs >= comp.durationMs)
|
|
594
|
+
err(
|
|
595
|
+
`captions[${i}].fromMs`,
|
|
596
|
+
`fromMs ${cap.fromMs} outside [0, durationMs ${comp.durationMs})`,
|
|
597
|
+
"captions live on the composition timeline",
|
|
598
|
+
);
|
|
599
|
+
const prev = comp.captions?.[i - 1];
|
|
600
|
+
if (prev && cap.fromMs < prev.toMs)
|
|
601
|
+
warn(
|
|
602
|
+
`captions[${i}].fromMs`,
|
|
603
|
+
`window [${cap.fromMs}, ${cap.toMs}) overlaps captions[${i - 1}] [${prev.fromMs}, ${prev.toMs}) — two pills stack in the same slot`,
|
|
604
|
+
`start this caption at ${prev.toMs}, or end the previous one at ${cap.fromMs}`,
|
|
605
|
+
);
|
|
606
|
+
if (comp.startMs != null && cap.toMs <= comp.startMs)
|
|
607
|
+
warn(
|
|
608
|
+
`captions[${i}]`,
|
|
609
|
+
`window [${cap.fromMs}, ${cap.toMs}) sits entirely inside the startMs head trim (${comp.startMs}) — it is never seen`,
|
|
610
|
+
"move the window past the trim, or delete the caption",
|
|
611
|
+
);
|
|
612
|
+
if (cap.text.trim().length > 120)
|
|
613
|
+
warn(
|
|
614
|
+
`captions[${i}].text`,
|
|
615
|
+
`${cap.text.trim().length} chars — a caption is one explanatory sentence, not a paragraph`,
|
|
616
|
+
"cut to one sentence (~15-30 CJK chars / 8-14 words); move detail into the beat itself",
|
|
617
|
+
);
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
if (comp.titleCard && !comp.titleCard.title?.trim())
|
|
621
|
+
err("titleCard.title", "empty title on a title card", "give it the app/thesis line, or delete titleCard");
|
|
622
|
+
|
|
559
623
|
// --- CAPTURE-LOCKED: action tMs must match the recording ---
|
|
560
624
|
// The video is temporal: a beat's tMs is WHEN it is visible in the capture.
|
|
561
625
|
// A render-only edit cannot move that, so a drifted tMs would fire the
|