@open-take/compositor 0.2.0 → 0.2.2
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 +56 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +210 -30
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/camera.ts +49 -9
- package/src/math.ts +186 -25
- package/src/plan.ts +12 -3
- package/src/presets.ts +36 -8
- package/src/render.ts +12 -1
- package/src/types.ts +47 -0
- package/src/validate.ts +72 -4
package/src/validate.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
// action needs a re-capture, not a JSON edit. Pass the capture log to enforce
|
|
17
17
|
// this; without it the check is skipped (we can't know the ground truth).
|
|
18
18
|
|
|
19
|
-
import { restStageScale } from "./math";
|
|
19
|
+
import { buildStageKeyframes, restStageScale } from "./math";
|
|
20
20
|
import type { CaptureLog, TakeComposition } from "./types";
|
|
21
21
|
|
|
22
22
|
export type CompositionIssue = {
|
|
@@ -154,11 +154,13 @@ export function validateComposition(
|
|
|
154
154
|
`scale ${z.scale.toFixed(3)} is below rest ${rest.toFixed(3)} — that zooms OUT past the frame (dead space)`,
|
|
155
155
|
`raise to ≥ ${rest.toFixed(2)}, or set zoom.enabled=false for a full-view beat`,
|
|
156
156
|
);
|
|
157
|
-
else if (z.scale
|
|
157
|
+
else if (z.scale < rest * 1.2)
|
|
158
|
+
// the whole dead band, not just ≈rest exactly: a 1.03× "zoom" renders
|
|
159
|
+
// an enabled move the eye can't see (issue #1 — it shipped silently).
|
|
158
160
|
warn(
|
|
159
161
|
`${p}.zoom.scale`,
|
|
160
|
-
`scale ${z.scale.toFixed(3)}
|
|
161
|
-
"raise scale to actually zoom, or set enabled=false",
|
|
162
|
+
`scale ${z.scale.toFixed(3)} is within 20% of rest ${rest.toFixed(3)} — an imperceptible zoom (enabled but invisible)`,
|
|
163
|
+
"raise scale to ≥ ~1.25 to actually zoom, or set enabled=false",
|
|
162
164
|
);
|
|
163
165
|
if (z.scale > maxScale)
|
|
164
166
|
warn(
|
|
@@ -205,6 +207,30 @@ export function validateComposition(
|
|
|
205
207
|
);
|
|
206
208
|
}
|
|
207
209
|
|
|
210
|
+
// asymptotic settle: the residual left to creep out after the action instant.
|
|
211
|
+
// Beyond ~0.15 the camera visibly hasn't arrived when the action fires.
|
|
212
|
+
const settleFrac = comp.cursor.zoomSettleFrac;
|
|
213
|
+
if (settleFrac != null && !(settleFrac >= 0 && settleFrac <= 0.15))
|
|
214
|
+
err(
|
|
215
|
+
"cursor.zoomSettleFrac",
|
|
216
|
+
`zoomSettleFrac ${settleFrac} outside [0, 0.15]`,
|
|
217
|
+
"~0.04 = the reference-measured tail; 0 = legacy cut spring",
|
|
218
|
+
);
|
|
219
|
+
else if (settleFrac != null && settleFrac > 0 && (comp.cursor.zoomEase || spring != null))
|
|
220
|
+
warn(
|
|
221
|
+
"cursor.zoomSettleFrac",
|
|
222
|
+
`zoomSettleFrac is IGNORED while cursor.${comp.cursor.zoomEase ? "zoomEase" : "zoomSpring"} is set — the render is byte-identical to not setting it`,
|
|
223
|
+
"delete cursor.zoomEase / cursor.zoomSpring (a pace preset clears zoomEase) to activate the settle tail",
|
|
224
|
+
);
|
|
225
|
+
|
|
226
|
+
const dwell = comp.cursor.pullOutDwellMs;
|
|
227
|
+
if (dwell != null && !(dwell >= 0 && dwell <= 5000))
|
|
228
|
+
err(
|
|
229
|
+
"cursor.pullOutDwellMs",
|
|
230
|
+
`pullOutDwellMs ${dwell} outside [0, 5000]`,
|
|
231
|
+
"600-1000 reads as a natural beat; 0 = legacy (depart as soon as the action ends)",
|
|
232
|
+
);
|
|
233
|
+
|
|
208
234
|
// tail: the composition must outlast the last action (+ a little settle)
|
|
209
235
|
if (comp.durationMs < lastEnd)
|
|
210
236
|
err(
|
|
@@ -219,6 +245,48 @@ export function validateComposition(
|
|
|
219
245
|
`allow ≥ ${comp.cursor.zoomOutMs}ms (cursor.zoomOutMs) of tail`,
|
|
220
246
|
);
|
|
221
247
|
|
|
248
|
+
// A dwell-delayed final pull-out can land LATER than the legacy tail math
|
|
249
|
+
// above assumes — check the actual schedule, not the formula. (Guarded: the
|
|
250
|
+
// schedule needs a structurally sound composition; earlier errors mean this
|
|
251
|
+
// check would throw, and its absence is already explained by them.)
|
|
252
|
+
if ((comp.cursor.pullOutDwellMs ?? 0) > 0 && issues.every((i) => i.severity !== "error")) {
|
|
253
|
+
try {
|
|
254
|
+
const kfs = buildStageKeyframes(comp).r;
|
|
255
|
+
let motionEndS = 0;
|
|
256
|
+
for (let i = 0; i < kfs.length - 1; i++) {
|
|
257
|
+
const [, a] = kfs[i]!;
|
|
258
|
+
const [t1, b] = kfs[i + 1]!;
|
|
259
|
+
if (a.cx !== b.cx || a.cy !== b.cy || a.w !== b.w) motionEndS = t1;
|
|
260
|
+
}
|
|
261
|
+
if (motionEndS * 1000 > comp.durationMs + 1)
|
|
262
|
+
warn(
|
|
263
|
+
"durationMs",
|
|
264
|
+
`the camera is still mid-motion at durationMs (dwell-delayed landing ends ~${Math.round(motionEndS * 1000)}ms)`,
|
|
265
|
+
`raise durationMs to ≥ ${Math.round(motionEndS * 1000)}`,
|
|
266
|
+
);
|
|
267
|
+
} catch {
|
|
268
|
+
/* never let a diagnostics pass throw */
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// head trim: cut dead pre-paint frames, never a beat. The trim only moves
|
|
273
|
+
// the delivered head — tMs values stay on the capture timeline.
|
|
274
|
+
const startMs = comp.startMs;
|
|
275
|
+
if (startMs != null) {
|
|
276
|
+
if (!(startMs >= 0) || startMs >= comp.durationMs)
|
|
277
|
+
err(
|
|
278
|
+
"startMs",
|
|
279
|
+
`startMs ${startMs} outside [0, durationMs ${comp.durationMs})`,
|
|
280
|
+
"the head trim must leave a video",
|
|
281
|
+
);
|
|
282
|
+
else if (comp.events[0] && startMs > comp.events[0].zoom.inAtMs)
|
|
283
|
+
warn(
|
|
284
|
+
"startMs",
|
|
285
|
+
`startMs ${startMs} cuts into the first beat (camera/cursor already moving at ${comp.events[0].zoom.inAtMs}ms)`,
|
|
286
|
+
`keep the trim ≤ ${comp.events[0].zoom.inAtMs} so the delivered video opens at rest`,
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
|
|
222
290
|
// --- CAPTURE-LOCKED: action tMs must match the recording ---
|
|
223
291
|
// The video is temporal: a beat's tMs is WHEN it is visible in the capture.
|
|
224
292
|
// A render-only edit cannot move that, so a drifted tMs would fire the
|