@open-take/compositor 0.3.1 → 0.4.1
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 +64 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +211 -49
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/camera.ts +11 -1
- package/src/decode-guard.ts +35 -0
- package/src/ffmpeg.ts +41 -1
- package/src/math.ts +11 -8
- package/src/plan.ts +24 -0
- package/src/render.ts +193 -78
- package/src/scene/scene.tsx +170 -4
- package/src/types.ts +53 -4
- package/src/validate.ts +65 -1
package/dist/index.d.ts
CHANGED
|
@@ -26,6 +26,11 @@ type CaptureEventBase = {
|
|
|
26
26
|
/** selector / note, kept for editability */
|
|
27
27
|
sel?: string;
|
|
28
28
|
note?: string;
|
|
29
|
+
/** One-line viewer-facing caption from the plan step ("Applying the
|
|
30
|
+
* filter re-prices every row"). planComposition turns these into `captions`
|
|
31
|
+
* windows — the beat explains itself to a viewer who has never seen the
|
|
32
|
+
* app, which footage alone cannot do. */
|
|
33
|
+
caption?: string;
|
|
29
34
|
/** selective-zoom intent from the plan. Absent/"auto" ⇒ the camera director
|
|
30
35
|
* decides from the ground-truth log; "always"/"never" hard-override it (and
|
|
31
36
|
* cut the beat out of any cluster — an override is a segment boundary). */
|
|
@@ -94,6 +99,18 @@ type CaptureHover = CaptureEventBase & {
|
|
|
94
99
|
/** ms the dwell occupies on screen (ground-truth wall time) */
|
|
95
100
|
durationMs: number;
|
|
96
101
|
};
|
|
102
|
+
/** A look: a CAMERA-only beat. Nothing is done to the page and the cursor
|
|
103
|
+
* does not move — the camera frames the target element and holds for
|
|
104
|
+
* `durationMs`. This is the honest spelling of "show the viewer this
|
|
105
|
+
* region": before it existed, the only way to aim the camera was to hover
|
|
106
|
+
* a control you never meant to activate, which reads on screen as a
|
|
107
|
+
* promise ("about to click") the video then breaks. `x,y` is the target's
|
|
108
|
+
* center (zoom anchor); the cursor rests at its previous anchor. */
|
|
109
|
+
type CaptureLook = CaptureEventBase & {
|
|
110
|
+
kind: "look";
|
|
111
|
+
/** ms the framed hold occupies on screen */
|
|
112
|
+
durationMs: number;
|
|
113
|
+
};
|
|
97
114
|
/** A key press / shortcut: keyboard-driven, so the cursor holds (no travel).
|
|
98
115
|
* Holds for `durationMs` while the effect plays out; if a reveal element was
|
|
99
116
|
* located, `box` carries its bbox so the zoom can frame it. */
|
|
@@ -131,7 +148,7 @@ type CaptureDropFiles = CaptureEventBase & {
|
|
|
131
148
|
size?: number;
|
|
132
149
|
}[];
|
|
133
150
|
};
|
|
134
|
-
type CaptureEvent = CaptureClick | CaptureType | CaptureDrag | CaptureScroll | CaptureHover | CapturePress | CaptureDropFiles;
|
|
151
|
+
type CaptureEvent = CaptureClick | CaptureType | CaptureDrag | CaptureScroll | CaptureHover | CaptureLook | CapturePress | CaptureDropFiles;
|
|
135
152
|
type CaptureLog = {
|
|
136
153
|
video: {
|
|
137
154
|
width: number;
|
|
@@ -216,7 +233,7 @@ type GhostCardConfig = {
|
|
|
216
233
|
releaseMs?: number;
|
|
217
234
|
};
|
|
218
235
|
type CompEvent = {
|
|
219
|
-
kind: "click" | "type" | "drag" | "scroll" | "hover" | "press" | "dropFiles";
|
|
236
|
+
kind: "click" | "type" | "drag" | "scroll" | "hover" | "look" | "press" | "dropFiles";
|
|
220
237
|
tMs: number;
|
|
221
238
|
/** anchor point (click / focus / drag start / hover) in video-px. For a
|
|
222
239
|
* scroll/press the cursor does not move; this is its resting point. */
|
|
@@ -387,6 +404,29 @@ type ReviewBadge = {
|
|
|
387
404
|
toMs: number;
|
|
388
405
|
text: string;
|
|
389
406
|
};
|
|
407
|
+
/** One viewer-facing caption window on the DELIVERED video: `text` shows
|
|
408
|
+
* bottom-center from `fromMs` (inclusive) to `toMs` (exclusive) on the
|
|
409
|
+
* composition timeline. Unlike ReviewBadge this is a first-class, persisted
|
|
410
|
+
* composition field rendered on masters — footage alone shows WHAT happened;
|
|
411
|
+
* the caption says what it MEANS, which is the difference between a demo a
|
|
412
|
+
* stranger can follow and "the screen moves around". Absent ⇒ rendered
|
|
413
|
+
* output is byte-identical to a caption-less composition. */
|
|
414
|
+
type Caption = {
|
|
415
|
+
fromMs: number;
|
|
416
|
+
toMs: number;
|
|
417
|
+
text: string;
|
|
418
|
+
};
|
|
419
|
+
/** An opening title card: `title` (the app / the thesis) over a full-frame
|
|
420
|
+
* scrim on top of the establishing hold, gone by `untilMs` (300ms fade).
|
|
421
|
+
* Typographic and deterministic — rendered by the scene in the composition's
|
|
422
|
+
* own look, in whatever language the author wrote, deletable like any field
|
|
423
|
+
* — never generated imagery. The single cheapest "produced, not captured"
|
|
424
|
+
* signal a demo can send. */
|
|
425
|
+
type TitleCard = {
|
|
426
|
+
title: string;
|
|
427
|
+
subtitle?: string;
|
|
428
|
+
untilMs?: number;
|
|
429
|
+
};
|
|
390
430
|
/** Render-time decoration for review copies and A/B variant reels: burned-in
|
|
391
431
|
* beat badges, a REVIEW watermark, and a per-variant corner label. Drawn by the
|
|
392
432
|
* scene in SCREEN space (fixed, outside the composition camera) so the text is
|
|
@@ -471,11 +511,24 @@ type TakeComposition = {
|
|
|
471
511
|
* capture is the ground truth); only the delivered head moves. 0/absent =
|
|
472
512
|
* no trim. */
|
|
473
513
|
startMs?: number;
|
|
474
|
-
/**
|
|
514
|
+
/** Viewer-facing captions, drawn bottom-center in SCREEN space (outside the
|
|
515
|
+
* camera — legible at any zoom) on EVERY render including the master.
|
|
516
|
+
* Persisted and hand-editable like any composition field; times are on the
|
|
517
|
+
* untrimmed composition timeline (same convention as zoom.inAtMs — a
|
|
518
|
+
* caption entirely inside the startMs head trim is never seen, and the
|
|
519
|
+
* validator says so). Seeded from the plan steps' `caption` fields by
|
|
520
|
+
* planComposition. */
|
|
521
|
+
captions?: Caption[];
|
|
522
|
+
/** optional opening title card over the establishing hold (see TitleCard) */
|
|
523
|
+
titleCard?: TitleCard;
|
|
524
|
+
/** render-time review decoration (badges/watermark/label); never persisted
|
|
525
|
+
* (render strips exactly this field — `captions` above deliberately IS
|
|
526
|
+
* persisted; it is content, not review scaffolding) */
|
|
475
527
|
review?: ReviewDecor;
|
|
476
528
|
};
|
|
477
|
-
/** True when motion blur is configured to actually do something
|
|
478
|
-
*
|
|
529
|
+
/** True when motion blur is configured to actually do something — whether the
|
|
530
|
+
* delivery encode folds in the tmix shutter average (render.ts deliverMp4;
|
|
531
|
+
* OFF skips tmix but still runs the same single delivery encode). */
|
|
479
532
|
declare function motionBlurActive(mb: MotionBlurConfig | undefined): mb is MotionBlurConfig;
|
|
480
533
|
declare const DEFAULT_FRAMING: FramingConfig;
|
|
481
534
|
declare const DEFAULT_MOTION_BLUR: MotionBlurConfig;
|
|
@@ -516,6 +569,10 @@ declare function finishName(mb: MotionBlurConfig | undefined): FinishName | null
|
|
|
516
569
|
//#region src/ffmpeg.d.ts
|
|
517
570
|
//# sourceMappingURL=presets.d.ts.map
|
|
518
571
|
declare function resolveFfmpeg(): Promise<string>;
|
|
572
|
+
/** True when an `ffmpeg -encoders` table has a video-encoder ROW named
|
|
573
|
+
* `encoder` (" V....D libx264 ..."), not merely the name as a substring
|
|
574
|
+
* somewhere — descriptions repeat encoder names constantly. */
|
|
575
|
+
|
|
519
576
|
declare function resolveFfprobe(): Promise<string>;
|
|
520
577
|
|
|
521
578
|
//#endregion
|
|
@@ -542,7 +599,7 @@ declare function planComposition(log: CaptureLog, opts?: PlanOpts): TakeComposit
|
|
|
542
599
|
//# sourceMappingURL=plan.d.ts.map
|
|
543
600
|
/** One action, already mapped into video-px, handed to the director. */
|
|
544
601
|
type Beat = {
|
|
545
|
-
kind: "click" | "type" | "drag" | "scroll" | "hover" | "press" | "dropFiles";
|
|
602
|
+
kind: "click" | "type" | "drag" | "scroll" | "hover" | "look" | "press" | "dropFiles";
|
|
546
603
|
tMs: number;
|
|
547
604
|
durationMs: number;
|
|
548
605
|
/** element bbox (for a drag: the path's bbox), video-px — or undefined for a
|
|
@@ -794,5 +851,5 @@ declare function ghostCardLines(files: {
|
|
|
794
851
|
};
|
|
795
852
|
|
|
796
853
|
//#endregion
|
|
797
|
-
export { BBox, Beat, CLAMP_TOL_MS, CameraConfig, CaptureClick, CaptureDrag, CaptureDropFiles, CaptureEvent, CaptureEventBase, CaptureHover, CaptureLog, CapturePress, CaptureScroll, CaptureType, CompEvent, CompositionIssue, CursorConfig, DEFAULT_CAMERA, DEFAULT_CURSOR, DEFAULT_FRAMING, DEFAULT_MOTION_BLUR, FINISH, FinishName, Framing, FramingConfig, GhostCardConfig, LOOKS, LookName, LookPreset, MOTION, MotionBlurConfig, MotionName, MotionPreset, PlanOpts, Pt, RenderTakeOpts, RenderTakeResult, ReviewBadge, ReviewDecor, TakeComposition, ValidateOpts, ZOOM_LEVELS, ZoomDecision, ZoomIntent, ZoomLevelName, directCamera, finishName, formatIssues, lookName, math_d_exports as math, motionBlurActive, motionName, planComposition, renderTake, resolveFfmpeg, resolveFfprobe, validateComposition, zoomLevelName };
|
|
854
|
+
export { BBox, Beat, CLAMP_TOL_MS, CameraConfig, Caption, CaptureClick, CaptureDrag, CaptureDropFiles, CaptureEvent, CaptureEventBase, CaptureHover, CaptureLog, CaptureLook, CapturePress, CaptureScroll, CaptureType, CompEvent, CompositionIssue, CursorConfig, DEFAULT_CAMERA, DEFAULT_CURSOR, DEFAULT_FRAMING, DEFAULT_MOTION_BLUR, FINISH, FinishName, Framing, FramingConfig, GhostCardConfig, LOOKS, LookName, LookPreset, MOTION, MotionBlurConfig, MotionName, MotionPreset, PlanOpts, Pt, RenderTakeOpts, RenderTakeResult, ReviewBadge, ReviewDecor, TakeComposition, TitleCard, ValidateOpts, ZOOM_LEVELS, ZoomDecision, ZoomIntent, ZoomLevelName, directCamera, finishName, formatIssues, lookName, math_d_exports as math, motionBlurActive, motionName, planComposition, renderTake, resolveFfmpeg, resolveFfprobe, validateComposition, zoomLevelName };
|
|
798
855
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/presets.ts","../src/ffmpeg.ts","../src/plan.ts","../src/camera.ts","../src/validate.ts","../src/render.ts","../src/math.ts"],"sourcesContent":null,"mappings":";;;KAMY,EAAA;;;AAAZ,CAAA;AACY,KAAA,IAAA,GAAI;;EAKJ,CAAA,EAAA,MAAA;;;AAIZ,CAAA;;AAKQ,KATI,UAAA,GASJ,MAAA,GAAA,OAAA,GAAA,QAAA;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/presets.ts","../src/ffmpeg.ts","../src/plan.ts","../src/camera.ts","../src/validate.ts","../src/render.ts","../src/math.ts"],"sourcesContent":null,"mappings":";;;KAMY,EAAA;;;AAAZ,CAAA;AACY,KAAA,IAAA,GAAI;;EAKJ,CAAA,EAAA,MAAA;;;AAIZ,CAAA;;AAKQ,KATI,UAAA,GASJ,MAAA,GAAA,OAAA,GAAA,QAAA;;;AAoBU,KAzBN,gBAAA,GAyBM;;EAUN,CAAA,EAAA,MAAA;;;EAIA,GAAA,CAAA,EAlCJ,IAkCI;;;EAUA;;;EAiBA;;;AAUZ;;;;;SAzDS;;;AAsET;;;cAhEc;EAyEF;;;;;;AAaZ,CAAA;AAcA;AAAwB,KA1FZ,YAAA,GAAe,gBA0FH,GAAA;EAAA,IACpB,CAAA,EAAA,OAAA;CAAY;;;AAIZ,KA3FQ,WAAA,GAAc,gBA2FtB,GAAA;EAAY,IACZ,EAAA,MAAA;EAAW;EACC,IACZ,EAAA,MAAA;EAAgB;EAER,UAAA,EAAA,MAAU;AA0CtB,CAAA;;;AAeU,KA/IE,WAAA,GAAc,gBA+IhB,GAAA;EAAE,IAAA,EAAA,MAAA;;;IAOA,CAAA,EAAA,MAAA;IAQA,CAAA,EAAA,MAAS;EAAA,CAAA;EAAA;EAKV,IAEF,CAAA,EAAA;IAED,CAAA,EAAA,MAAA;IASD,CAA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AAE,MASF,EAAA,MAAA;EAAE,OAAA,EAAA,OAAA;;iBOyOI,mBAAA,OAA0B,kBAAkB;APlO5D;AAQA;AAAqB,iBO4UL,WAAA,CP5UK,IAAA,EO4Ua,eP5Ub,CAAA,EAAA;EAAA,CAAA,EAKZ,MAAA;EAAE,IAEF,EAAA,MAAA;EAAI,SAEL,EAAA,MAAA;EAAY,EAAA,EASb,CAAA,CAAA,EAAA,MAAA,EAAA,GAAA;IAEE,KAAA,EAAA,MAAA;IAOK,MAAA,EOqTgC,EPrThC;EAAe,CAAA;AAG7B,CAAA;AAWA,KOwUK,GAAA,GPxUO;;;KO2UP;KACA;;SAEI;;EPlOG;;;AAUZ;;;;;;;;EASY,KAAA,CAAA,EAAA,MAAO;;iBOoRH,SAAA,OAAgB,kBAAkB;iBAoIlC,SAAA,kBAA2B,aAAa,kBAAkB;;iBAiC1D,UAAA,kBAA4B;;APjb5C;;;iBO2bgB,WAAA;;;SAER;;EPpbI,EAAA,EAAA,MAAA;;;iBO4bI,QAAA;;;;AP7ahB;AA8Ba,iBOyZG,cAAA,CPzZa,KAS5B,EAAA;EAEW,IAAA,EAAA,MAAA;EAAe,IAAA,CAAA,EAAA,MAAA;CAAA,EAAA,CAAA,EAAA;EAYH,KACd,EAAA,MAAA;EAAY,IAEP,EAAA,MAAA;CAAgB"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __export } from "./chunk-Cl8Af3a2.js";
|
|
2
2
|
import { spawn, spawnSync } from "node:child_process";
|
|
3
|
-
import { chmod,
|
|
3
|
+
import { chmod, mkdir, mkdtemp, readFile, readdir, rm, stat, symlink, unlink, writeFile } from "node:fs/promises";
|
|
4
4
|
import { existsSync, realpathSync } from "node:fs";
|
|
5
5
|
import { createRequire } from "node:module";
|
|
6
6
|
import { tmpdir } from "node:os";
|
|
@@ -19,8 +19,9 @@ const DEFAULT_CAMERA = {
|
|
|
19
19
|
travelThreshold: .18,
|
|
20
20
|
pullOutCoverage: .55
|
|
21
21
|
};
|
|
22
|
-
/** True when motion blur is configured to actually do something
|
|
23
|
-
*
|
|
22
|
+
/** True when motion blur is configured to actually do something — whether the
|
|
23
|
+
* delivery encode folds in the tmix shutter average (render.ts deliverMp4;
|
|
24
|
+
* OFF skips tmix but still runs the same single delivery encode). */
|
|
24
25
|
function motionBlurActive(mb) {
|
|
25
26
|
return !!mb && mb.samples > 1 && mb.shutter > 0;
|
|
26
27
|
}
|
|
@@ -283,6 +284,42 @@ async function resolveFfmpeg() {
|
|
|
283
284
|
}
|
|
284
285
|
throw new Error("ffmpeg not found — install it (e.g. `brew install ffmpeg`) or `npm install` so the bundled @ffmpeg-installer binary resolves for this platform");
|
|
285
286
|
}
|
|
287
|
+
/** True when an `ffmpeg -encoders` table has a video-encoder ROW named
|
|
288
|
+
* `encoder` (" V....D libx264 ..."), not merely the name as a substring
|
|
289
|
+
* somewhere — descriptions repeat encoder names constantly. */
|
|
290
|
+
function parseEncoders(encodersText, encoder) {
|
|
291
|
+
const escaped = encoder.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
292
|
+
return new RegExp(`^\\s*V\\S{5}\\s+${escaped}(?:\\s|$)`, "m").test(encodersText);
|
|
293
|
+
}
|
|
294
|
+
const encoderCache = new Map();
|
|
295
|
+
/** True when the RESOLVED ffmpeg (resolveFfmpeg — which may be a system
|
|
296
|
+
* binary lacking libvpx-vp9) offers the named video encoder. Cached per
|
|
297
|
+
* name; any failure is false, never a throw. */
|
|
298
|
+
function ffmpegHasEncoder(name) {
|
|
299
|
+
let cached = encoderCache.get(name);
|
|
300
|
+
if (!cached) {
|
|
301
|
+
cached = hasEncoderOnce(name).catch(() => false);
|
|
302
|
+
encoderCache.set(name, cached);
|
|
303
|
+
}
|
|
304
|
+
return cached;
|
|
305
|
+
}
|
|
306
|
+
async function hasEncoderOnce(name) {
|
|
307
|
+
const ffmpeg = await resolveFfmpeg();
|
|
308
|
+
const text = await new Promise((res, rej) => {
|
|
309
|
+
const child = spawn(ffmpeg, ["-hide_banner", "-encoders"], { stdio: [
|
|
310
|
+
"ignore",
|
|
311
|
+
"pipe",
|
|
312
|
+
"ignore"
|
|
313
|
+
] });
|
|
314
|
+
let out = "";
|
|
315
|
+
child.stdout.on("data", (d) => {
|
|
316
|
+
out += d;
|
|
317
|
+
});
|
|
318
|
+
child.on("error", rej);
|
|
319
|
+
child.on("close", (code) => code === 0 ? res(out) : rej(new Error(`ffmpeg -encoders exited ${code}`)));
|
|
320
|
+
});
|
|
321
|
+
return parseEncoders(text, name);
|
|
322
|
+
}
|
|
286
323
|
async function resolveFfprobe() {
|
|
287
324
|
if (cachedFfprobe) return cachedFfprobe;
|
|
288
325
|
if (runsOk("ffprobe")) {
|
|
@@ -813,7 +850,7 @@ function buildLegs(comp) {
|
|
|
813
850
|
return { sec: ms / 1e3 };
|
|
814
851
|
};
|
|
815
852
|
for (const [evIdx, e] of comp.events.entries()) {
|
|
816
|
-
if (e.kind === "scroll" || e.kind === "press") {
|
|
853
|
+
if (e.kind === "scroll" || e.kind === "press" || e.kind === "look") {
|
|
817
854
|
freeAt = Math.max(freeAt, (e.tMs + (e.durationMs ?? 0)) / 1e3);
|
|
818
855
|
continue;
|
|
819
856
|
}
|
|
@@ -967,6 +1004,7 @@ function growDown(box, video) {
|
|
|
967
1004
|
* kind trusts the captured effect region, else shapes one from the bbox. */
|
|
968
1005
|
function roiForBeat(b, video) {
|
|
969
1006
|
if (b.kind === "press" && b.intent === "always" && b.box) return b.box;
|
|
1007
|
+
if (b.kind === "look" && b.box) return b.box;
|
|
970
1008
|
if (b.kind === "type" && b.box) {
|
|
971
1009
|
const capH = growDown(b.box, video).h;
|
|
972
1010
|
if (b.effectBox) {
|
|
@@ -1114,6 +1152,7 @@ function directCamera(beats, video, out, cam, rest, endMs) {
|
|
|
1114
1152
|
}
|
|
1115
1153
|
segs.forEach((s, si) => {
|
|
1116
1154
|
if (s.kind !== "punch") return;
|
|
1155
|
+
if (s.idx.some((i) => beats[i].kind === "look")) return;
|
|
1117
1156
|
const firstT = beats[s.idx[0]].tMs;
|
|
1118
1157
|
const next = segs[si + 1];
|
|
1119
1158
|
const heldUntil = next ? beats[next.idx[0]].tMs : endMs;
|
|
@@ -1271,6 +1310,21 @@ function planComposition(log, opts = {}) {
|
|
|
1271
1310
|
y: vH * .9
|
|
1272
1311
|
};
|
|
1273
1312
|
const durationMs = Math.max(log.tEndMs ?? 0, lastEnd + cursor.holdMs + cursor.zoomOutMs + 400);
|
|
1313
|
+
const captions = [];
|
|
1314
|
+
log.events.forEach((c, i) => {
|
|
1315
|
+
const text = c.caption?.trim();
|
|
1316
|
+
if (!text) return;
|
|
1317
|
+
const e = events[i];
|
|
1318
|
+
const prevEnd = captions.length ? captions[captions.length - 1].toMs : 0;
|
|
1319
|
+
const fromMs = Math.max(e.tMs, prevEnd);
|
|
1320
|
+
const next = events[i + 1];
|
|
1321
|
+
const toMs = Math.max(fromMs + 300, next ? next.tMs : durationMs);
|
|
1322
|
+
captions.push({
|
|
1323
|
+
fromMs,
|
|
1324
|
+
toMs,
|
|
1325
|
+
text
|
|
1326
|
+
});
|
|
1327
|
+
});
|
|
1274
1328
|
return {
|
|
1275
1329
|
output: {
|
|
1276
1330
|
width: oW,
|
|
@@ -1288,7 +1342,8 @@ function planComposition(log, opts = {}) {
|
|
|
1288
1342
|
motionBlur: DEFAULT_MOTION_BLUR,
|
|
1289
1343
|
start,
|
|
1290
1344
|
events,
|
|
1291
|
-
durationMs
|
|
1345
|
+
durationMs,
|
|
1346
|
+
...captions.length ? { captions } : {}
|
|
1292
1347
|
};
|
|
1293
1348
|
}
|
|
1294
1349
|
function manualFraming(b, rest) {
|
|
@@ -1309,6 +1364,17 @@ function manualFraming(b, rest) {
|
|
|
1309
1364
|
};
|
|
1310
1365
|
}
|
|
1311
1366
|
|
|
1367
|
+
//#endregion
|
|
1368
|
+
//#region src/decode-guard.ts
|
|
1369
|
+
const CAPTURE_UNDECODABLE_MARK = "capture video is not decodable in the render browser";
|
|
1370
|
+
/** Did this render rejection come from the scene's decode guard? Substring
|
|
1371
|
+
* match on the message — the Error identity does not survive the
|
|
1372
|
+
* browser→Node crossing. */
|
|
1373
|
+
function isCaptureUndecodable(err) {
|
|
1374
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
1375
|
+
return message.includes(CAPTURE_UNDECODABLE_MARK);
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1312
1378
|
//#endregion
|
|
1313
1379
|
//#region src/validate.ts
|
|
1314
1380
|
/** Tail past the last beat's settle that still reads as "the shot breathing".
|
|
@@ -1340,7 +1406,8 @@ const reqField = {
|
|
|
1340
1406
|
type: "text",
|
|
1341
1407
|
press: "keys",
|
|
1342
1408
|
drag: "to",
|
|
1343
|
-
dropFiles: "to"
|
|
1409
|
+
dropFiles: "to",
|
|
1410
|
+
look: "durationMs"
|
|
1344
1411
|
};
|
|
1345
1412
|
function validateComposition(comp, opts = {}) {
|
|
1346
1413
|
const issues = [];
|
|
@@ -1470,7 +1537,7 @@ function validateComposition(comp, opts = {}) {
|
|
|
1470
1537
|
const nominal = r.pullOut ? comp.cursor.zoomOutMs : comp.cursor.zoomInMs;
|
|
1471
1538
|
const handSet = Math.abs(e.zoom.inAtMs - Math.max(0, e.tMs - comp.cursor.zoomInMs)) >= 1;
|
|
1472
1539
|
if (handSet && nominal > 0 && rampMs > nominal * RAMP_SLACK) warn(`events[${i}].zoom.inAtMs`, `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`, `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`);
|
|
1473
|
-
if (e.kind === "press") continue;
|
|
1540
|
+
if (e.kind === "press" || e.kind === "look") continue;
|
|
1474
1541
|
const lateMs = Math.round(r.landMs - e.tMs);
|
|
1475
1542
|
if (lateMs <= MOVING_AT_ACTION_MS) continue;
|
|
1476
1543
|
if (!(rampMs > 0) || lateMs / rampMs <= MOVING_AT_ACTION_FRAC) continue;
|
|
@@ -1491,11 +1558,29 @@ function validateComposition(comp, opts = {}) {
|
|
|
1491
1558
|
}
|
|
1492
1559
|
if (motionEndS * 1e3 > comp.durationMs + 1) warn("durationMs", `the camera is still mid-motion at durationMs (dwell-delayed landing ends ~${Math.round(motionEndS * 1e3)}ms)`, `raise durationMs to ≥ ${Math.round(motionEndS * 1e3)}`);
|
|
1493
1560
|
} catch {}
|
|
1561
|
+
if (comp.events.length) {
|
|
1562
|
+
const firstVisible = comp.events[0].zoom.inAtMs;
|
|
1563
|
+
const deadHeadMs = firstVisible - (comp.startMs ?? 0);
|
|
1564
|
+
if (deadHeadMs > DEAD_TAIL_MS) warn("startMs", `${(deadHeadMs / 1e3).toFixed(1)}s of dead opening before the first beat's camera moves — the delivered video starts on a frozen screen`, `set startMs ≈ ${Math.max(0, firstVisible - 1200)} (leave ~1.2s of establishing hold, trim the rest of the load wait)`);
|
|
1565
|
+
}
|
|
1494
1566
|
const startMs = comp.startMs;
|
|
1495
1567
|
if (startMs != null) {
|
|
1496
1568
|
if (!(startMs >= 0) || startMs >= comp.durationMs) err("startMs", `startMs ${startMs} outside [0, durationMs ${comp.durationMs})`, "the head trim must leave a video");
|
|
1497
1569
|
else if (comp.events[0] && startMs > comp.events[0].zoom.inAtMs) warn("startMs", `startMs ${startMs} cuts into the first beat (camera/cursor already moving at ${comp.events[0].zoom.inAtMs}ms)`, `keep the trim ≤ ${comp.events[0].zoom.inAtMs} so the delivered video opens at rest`);
|
|
1498
1570
|
}
|
|
1571
|
+
for (const [i, cap] of (comp.captions ?? []).entries()) {
|
|
1572
|
+
if (!cap.text?.trim()) {
|
|
1573
|
+
err(`captions[${i}].text`, "empty caption text", "give the caption a line, or delete it");
|
|
1574
|
+
continue;
|
|
1575
|
+
}
|
|
1576
|
+
if (!(cap.toMs > cap.fromMs)) err(`captions[${i}].toMs`, `toMs ${cap.toMs} is not after fromMs ${cap.fromMs} — an inverted/empty window shows nothing`, "set toMs > fromMs (a readable line needs ~1500ms on screen)");
|
|
1577
|
+
if (!(cap.fromMs >= 0) || cap.fromMs >= comp.durationMs) err(`captions[${i}].fromMs`, `fromMs ${cap.fromMs} outside [0, durationMs ${comp.durationMs})`, "captions live on the composition timeline");
|
|
1578
|
+
const prev = comp.captions?.[i - 1];
|
|
1579
|
+
if (prev && cap.fromMs < prev.toMs) warn(`captions[${i}].fromMs`, `window [${cap.fromMs}, ${cap.toMs}) overlaps captions[${i - 1}] [${prev.fromMs}, ${prev.toMs}) — two pills stack in the same slot`, `start this caption at ${prev.toMs}, or end the previous one at ${cap.fromMs}`);
|
|
1580
|
+
if (comp.startMs != null && cap.toMs <= comp.startMs) warn(`captions[${i}]`, `window [${cap.fromMs}, ${cap.toMs}) sits entirely inside the startMs head trim (${comp.startMs}) — it is never seen`, "move the window past the trim, or delete the caption");
|
|
1581
|
+
if (cap.text.trim().length > 120) warn(`captions[${i}].text`, `${cap.text.trim().length} chars — a caption is one explanatory sentence, not a paragraph`, "cut to one sentence (~15-30 CJK chars / 8-14 words); move detail into the beat itself");
|
|
1582
|
+
}
|
|
1583
|
+
if (comp.titleCard && !comp.titleCard.title?.trim()) err("titleCard.title", "empty title on a title card", "give it the app/thesis line, or delete titleCard");
|
|
1499
1584
|
if (opts.captureLog) {
|
|
1500
1585
|
const log = opts.captureLog;
|
|
1501
1586
|
if (log.events.length !== events.length) warn("events", `composition has ${events.length} beats but the capture log has ${log.events.length} — added/removed actions need a re-capture`, "re-capture to change the choreography; edit only renders the existing recording");
|
|
@@ -1536,50 +1621,90 @@ function run(cmd, args) {
|
|
|
1536
1621
|
}
|
|
1537
1622
|
/** Normalise the capture to a constant-fps mp4 the web decoder can read.
|
|
1538
1623
|
* fps follows the composition so a hi-fps capture can render at 60 (the
|
|
1539
|
-
* render grid must match — a 30-grid would throw away the extra frames).
|
|
1540
|
-
|
|
1624
|
+
* render grid must match — a 30-grid would throw away the extra frames).
|
|
1625
|
+
*
|
|
1626
|
+
* `codec` is normally h264; "vp9" is the retry arm for render browsers
|
|
1627
|
+
* WITHOUT H.264 decoding (Playwright-style Chromium builds ship no
|
|
1628
|
+
* proprietary codecs). The scene's decode guard rejects in seconds when the
|
|
1629
|
+
* capture can't decode there (see src/decode-guard.ts); renderTakeExclusive
|
|
1630
|
+
* catches that rejection and re-encodes the scratch capture with this arm
|
|
1631
|
+
* before one retry. The VP9 fallback must keep the .mp4 container AND the
|
|
1632
|
+
* capture.mp4 name: revideo routes video decoding by file extension, so a
|
|
1633
|
+
* .webm would take a different (and broken) decode path — VP9-in-MP4 (vp09
|
|
1634
|
+
* track) is the shape that works. */
|
|
1635
|
+
async function toMp4(videoPath, outMp4, fps, codec) {
|
|
1541
1636
|
await mkdir(dirname(outMp4), { recursive: true });
|
|
1637
|
+
const codecArgs = codec === "vp9" ? [
|
|
1638
|
+
"-c:v",
|
|
1639
|
+
"libvpx-vp9",
|
|
1640
|
+
"-b:v",
|
|
1641
|
+
"0",
|
|
1642
|
+
"-crf",
|
|
1643
|
+
"24",
|
|
1644
|
+
"-row-mt",
|
|
1645
|
+
"1",
|
|
1646
|
+
"-cpu-used",
|
|
1647
|
+
"4"
|
|
1648
|
+
] : [
|
|
1649
|
+
"-c:v",
|
|
1650
|
+
"libx264",
|
|
1651
|
+
"-crf",
|
|
1652
|
+
"18"
|
|
1653
|
+
];
|
|
1542
1654
|
await run(await resolveFfmpeg(), [
|
|
1543
1655
|
"-y",
|
|
1544
1656
|
"-loglevel",
|
|
1545
1657
|
"error",
|
|
1546
1658
|
"-i",
|
|
1547
1659
|
resolve(videoPath),
|
|
1548
|
-
|
|
1549
|
-
"libx264",
|
|
1660
|
+
...codecArgs,
|
|
1550
1661
|
"-pix_fmt",
|
|
1551
1662
|
"yuv420p",
|
|
1552
|
-
"-crf",
|
|
1553
|
-
"18",
|
|
1554
1663
|
"-r",
|
|
1555
1664
|
String(fps),
|
|
1556
1665
|
"-an",
|
|
1557
1666
|
outMp4
|
|
1558
1667
|
]);
|
|
1559
1668
|
}
|
|
1560
|
-
/**
|
|
1561
|
-
*
|
|
1562
|
-
*
|
|
1563
|
-
*
|
|
1564
|
-
*
|
|
1565
|
-
*
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1669
|
+
/** Delivery encode: the visually-lossless ProRes intermediate -> the postable
|
|
1670
|
+
* H.264. The ONLY lossy generation in the pipeline, so its CRF is the
|
|
1671
|
+
* master's quality — overlay text (captions/title card) used to look soft
|
|
1672
|
+
* because it took TWO generations before this fix: revideo's default wasm
|
|
1673
|
+
* exporter (WebCodecs H.264 at the browser's default bitrate, no knob, at
|
|
1674
|
+
* fps·samples) and then this re-encode on top.
|
|
1675
|
+
*
|
|
1676
|
+
* Motion blur folds in here (temporal supersampling: the scene was rendered
|
|
1677
|
+
* at fps·samples, project.ts): `tmix=frames=M` averages M consecutive
|
|
1678
|
+
* sub-frames; `fps=baseFps` then decimates ≈every `samples`-th, so each
|
|
1679
|
+
* output frame = the mean of the last M sub-frames of its interval (a
|
|
1680
|
+
* trailing shutter).
|
|
1681
|
+
*
|
|
1682
|
+
* The scale step is a REAL conversion, not a re-tag: the ProRes encode
|
|
1683
|
+
* converts the scene's RGB frames with swscale's default bt601 matrix, so
|
|
1684
|
+
* the intermediate is 601-coded. Convert to bt709 and tag it — verified by
|
|
1685
|
+
* round-tripping primaries (601-coded red merely tagged 709 decodes to
|
|
1686
|
+
* rgb(255,24,0); converted it decodes to rgb(252,0,0)). */
|
|
1687
|
+
async function deliverMp4(inMov, outMp4, baseFps, blur) {
|
|
1688
|
+
const vf = [];
|
|
1689
|
+
if (blur) {
|
|
1690
|
+
const M = Math.max(1, Math.min(blur.samples, Math.round(blur.shutter * blur.samples)));
|
|
1691
|
+
vf.push(`tmix=frames=${M}`, `fps=${baseFps}`);
|
|
1692
|
+
}
|
|
1693
|
+
vf.push("scale=in_color_matrix=bt601:out_color_matrix=bt709", "format=yuv420p", "setparams=range=tv:colorspace=bt709:color_primaries=bt709:color_trc=bt709");
|
|
1569
1694
|
await run(await resolveFfmpeg(), [
|
|
1570
1695
|
"-y",
|
|
1571
1696
|
"-loglevel",
|
|
1572
1697
|
"error",
|
|
1573
1698
|
"-i",
|
|
1574
|
-
resolve(
|
|
1699
|
+
resolve(inMov),
|
|
1575
1700
|
"-vf",
|
|
1576
|
-
vf,
|
|
1701
|
+
vf.join(","),
|
|
1577
1702
|
"-c:v",
|
|
1578
1703
|
"libx264",
|
|
1579
|
-
"-pix_fmt",
|
|
1580
|
-
"yuv420p",
|
|
1581
1704
|
"-crf",
|
|
1582
1705
|
"18",
|
|
1706
|
+
"-movflags",
|
|
1707
|
+
"+faststart",
|
|
1583
1708
|
"-r",
|
|
1584
1709
|
String(baseFps),
|
|
1585
1710
|
"-an",
|
|
@@ -1645,7 +1770,7 @@ async function prepareScratch(composition, videoPath) {
|
|
|
1645
1770
|
const nm = hostNodeModules();
|
|
1646
1771
|
if (!nm) throw new Error("render: could not locate node_modules for the scene's imports");
|
|
1647
1772
|
await symlink(nm, join(dir, "node_modules"), "junction");
|
|
1648
|
-
await toMp4(videoPath, join(dir, "public", "capture.mp4"), composition.output.fps);
|
|
1773
|
+
await toMp4(videoPath, join(dir, "public", "capture.mp4"), composition.output.fps, "h264");
|
|
1649
1774
|
return dir;
|
|
1650
1775
|
} catch (error) {
|
|
1651
1776
|
await cleanupScratch(dir);
|
|
@@ -1675,40 +1800,77 @@ async function renderTakeExclusive(opts) {
|
|
|
1675
1800
|
await repairBundledMediaPermissions();
|
|
1676
1801
|
const scratch = await prepareScratch(composition, opts.videoPath);
|
|
1677
1802
|
const deps = depsRoot();
|
|
1803
|
+
const videoAbs = resolve(opts.videoPath);
|
|
1678
1804
|
try {
|
|
1679
1805
|
if (process.env.DISABLE_TELEMETRY === void 0) process.env.DISABLE_TELEMETRY = "true";
|
|
1806
|
+
const renderOnce = async () => {
|
|
1807
|
+
let noProgressTimer = setTimeout(() => {
|
|
1808
|
+
process.stderr.write("open-take: no render progress after 3 minutes — if this never advances, the render browser may be stuck decoding the capture (see OPEN_TAKE_CHROME)\n");
|
|
1809
|
+
}, 18e4);
|
|
1810
|
+
try {
|
|
1811
|
+
return await renderVideo({
|
|
1812
|
+
projectFile: "/src/scene/project.ts",
|
|
1813
|
+
settings: {
|
|
1814
|
+
outFile: "take.mov",
|
|
1815
|
+
outDir: RENDER_OUT,
|
|
1816
|
+
workers: 1,
|
|
1817
|
+
projectSettings: {
|
|
1818
|
+
exporter: {
|
|
1819
|
+
name: "@revideo/core/ffmpeg",
|
|
1820
|
+
options: { format: "proRes" }
|
|
1821
|
+
},
|
|
1822
|
+
...rangeSec ? { range: rangeSec } : {}
|
|
1823
|
+
},
|
|
1824
|
+
logProgress: opts.logProgress ?? false,
|
|
1825
|
+
progressCallback: (_worker, progress) => {
|
|
1826
|
+
if (noProgressTimer !== void 0) {
|
|
1827
|
+
clearTimeout(noProgressTimer);
|
|
1828
|
+
noProgressTimer = void 0;
|
|
1829
|
+
}
|
|
1830
|
+
opts.onProgress?.(progress);
|
|
1831
|
+
},
|
|
1832
|
+
viteConfig: { server: { fs: { allow: [scratch, ...deps ? [deps] : []] } } },
|
|
1833
|
+
puppeteer: {
|
|
1834
|
+
args: [
|
|
1835
|
+
"--no-sandbox",
|
|
1836
|
+
"--disable-setuid-sandbox",
|
|
1837
|
+
"--password-store=basic",
|
|
1838
|
+
"--use-mock-keychain"
|
|
1839
|
+
],
|
|
1840
|
+
executablePath: opts.chromePath
|
|
1841
|
+
}
|
|
1842
|
+
}
|
|
1843
|
+
});
|
|
1844
|
+
} finally {
|
|
1845
|
+
if (noProgressTimer !== void 0) clearTimeout(noProgressTimer);
|
|
1846
|
+
}
|
|
1847
|
+
};
|
|
1680
1848
|
const prevCwd = process.cwd();
|
|
1681
1849
|
process.chdir(scratch);
|
|
1682
1850
|
let produced;
|
|
1683
1851
|
try {
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
"--password-store=basic",
|
|
1699
|
-
"--use-mock-keychain"
|
|
1700
|
-
],
|
|
1701
|
-
executablePath: opts.chromePath
|
|
1702
|
-
}
|
|
1852
|
+
try {
|
|
1853
|
+
produced = await renderOnce();
|
|
1854
|
+
} catch (error) {
|
|
1855
|
+
if (!isCaptureUndecodable(error)) throw error;
|
|
1856
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
1857
|
+
if (!await ffmpegHasEncoder("libvpx-vp9")) throw new Error(`render: the browser at ${opts.chromePath} cannot decode the capture (${detail}) — point OPEN_TAKE_CHROME at a full Chrome/Chrome-for-Testing build, or install an ffmpeg with libvpx-vp9 to enable the VP9 fallback`, { cause: error });
|
|
1858
|
+
process.stderr.write("open-take: the render browser cannot decode the H.264 capture — retrying with a VP9 intermediate (output unchanged)\n");
|
|
1859
|
+
await toMp4(videoAbs, join(scratch, "public", "capture.mp4"), composition.output.fps, "vp9");
|
|
1860
|
+
try {
|
|
1861
|
+
produced = await renderOnce();
|
|
1862
|
+
} catch (retryError) {
|
|
1863
|
+
if (!isCaptureUndecodable(retryError)) throw retryError;
|
|
1864
|
+
const retryDetail = retryError instanceof Error ? retryError.message : String(retryError);
|
|
1865
|
+
throw new Error(`render: the browser at ${opts.chromePath} cannot decode the capture even as VP9 (${retryDetail}) — point OPEN_TAKE_CHROME at a full Chrome/Chrome-for-Testing build`, { cause: retryError });
|
|
1703
1866
|
}
|
|
1704
|
-
}
|
|
1867
|
+
}
|
|
1705
1868
|
} finally {
|
|
1706
1869
|
process.chdir(prevCwd);
|
|
1707
1870
|
}
|
|
1708
1871
|
await mkdir(dirname(resolve(opts.outPath)), { recursive: true });
|
|
1709
1872
|
const producedAbs = resolve(scratch, produced);
|
|
1710
|
-
|
|
1711
|
-
else await copyFile(producedAbs, resolve(opts.outPath));
|
|
1873
|
+
await deliverMp4(producedAbs, resolve(opts.outPath), composition.output.fps, motionBlurActive(composition.motionBlur) ? composition.motionBlur : null);
|
|
1712
1874
|
const compositionPath = opts.compositionPath ? resolve(opts.compositionPath) : `${resolve(opts.outPath).replace(/\.mp4$/i, "")}.composition.json`;
|
|
1713
1875
|
if (opts.writeCompositionSibling !== false) {
|
|
1714
1876
|
const { review: _review,...persisted } = composition;
|