@open-take/compositor 0.4.2 → 0.4.4
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 +203 -132
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +611 -251
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/audit-cursor.ts +487 -0
- package/src/index.ts +15 -8
- package/src/render.ts +5 -1
- package/src/types.ts +7 -1
package/dist/index.js
CHANGED
|
@@ -8,233 +8,6 @@ import { dirname, join, resolve, sep } from "node:path";
|
|
|
8
8
|
import { fileURLToPath } from "node:url";
|
|
9
9
|
import { renderVideo } from "@open-take/revideo-renderer";
|
|
10
10
|
|
|
11
|
-
//#region src/types.ts
|
|
12
|
-
const DEFAULT_CAMERA = {
|
|
13
|
-
enabled: true,
|
|
14
|
-
fillFrac: .6,
|
|
15
|
-
maxScale: 2.4,
|
|
16
|
-
minHoldMs: 1200,
|
|
17
|
-
minZoomScale: 1.25,
|
|
18
|
-
coalesceWindowMs: 900,
|
|
19
|
-
travelThreshold: .18,
|
|
20
|
-
pullOutCoverage: .55
|
|
21
|
-
};
|
|
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). */
|
|
25
|
-
function motionBlurActive(mb) {
|
|
26
|
-
return !!mb && mb.samples > 1 && mb.shutter > 0;
|
|
27
|
-
}
|
|
28
|
-
const DEFAULT_FRAMING = {
|
|
29
|
-
insetFrac: .92,
|
|
30
|
-
cornerRadius: 28,
|
|
31
|
-
shadow: {
|
|
32
|
-
color: "rgba(0,0,0,0.55)",
|
|
33
|
-
blur: 60,
|
|
34
|
-
offset: {
|
|
35
|
-
x: 0,
|
|
36
|
-
y: 28
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
background: {
|
|
40
|
-
from: "#1e1b3a",
|
|
41
|
-
to: "#0a0e1c"
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
const DEFAULT_MOTION_BLUR = {
|
|
45
|
-
samples: 6,
|
|
46
|
-
shutter: .7
|
|
47
|
-
};
|
|
48
|
-
const DEFAULT_CURSOR = {
|
|
49
|
-
travelMs: 560,
|
|
50
|
-
travelWidthsPerSec: .35,
|
|
51
|
-
travelMinMs: 300,
|
|
52
|
-
travelMaxMs: 850,
|
|
53
|
-
scale: 2,
|
|
54
|
-
arcFrac: .05,
|
|
55
|
-
arcMax: 24,
|
|
56
|
-
rippleMs: 450,
|
|
57
|
-
holdMs: 1100,
|
|
58
|
-
zoomOutMs: 1340,
|
|
59
|
-
zoomInMs: 730,
|
|
60
|
-
zoomSettleFrac: .04,
|
|
61
|
-
pullOutDwellMs: 800,
|
|
62
|
-
dragLagMs: 190,
|
|
63
|
-
travelEase: [
|
|
64
|
-
.3,
|
|
65
|
-
0,
|
|
66
|
-
.2,
|
|
67
|
-
1
|
|
68
|
-
]
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
//#endregion
|
|
72
|
-
//#region src/presets.ts
|
|
73
|
-
const ZOOM_LEVELS = {
|
|
74
|
-
light: 1.25,
|
|
75
|
-
medium: 1.5,
|
|
76
|
-
tight: 1.8,
|
|
77
|
-
close: 2.2
|
|
78
|
-
};
|
|
79
|
-
/** Name a scale if it sits within tolerance of a preset; else null (custom). */
|
|
80
|
-
function zoomLevelName(scale, tol = .07) {
|
|
81
|
-
let best = null;
|
|
82
|
-
let bestD = tol;
|
|
83
|
-
for (const [name, v] of Object.entries(ZOOM_LEVELS)) {
|
|
84
|
-
const d = Math.abs(scale - v);
|
|
85
|
-
if (d <= bestD) {
|
|
86
|
-
best = name;
|
|
87
|
-
bestD = d;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return best;
|
|
91
|
-
}
|
|
92
|
-
const MOTION = {
|
|
93
|
-
calm: {
|
|
94
|
-
travelWidthsPerSec: .28,
|
|
95
|
-
travelMinMs: 375,
|
|
96
|
-
travelMaxMs: 1060,
|
|
97
|
-
holdMs: 1500,
|
|
98
|
-
zoomInMs: 900,
|
|
99
|
-
zoomOutMs: 1650,
|
|
100
|
-
pullOutDwellMs: 1e3,
|
|
101
|
-
zoomEase: void 0
|
|
102
|
-
},
|
|
103
|
-
natural: {
|
|
104
|
-
travelWidthsPerSec: .35,
|
|
105
|
-
travelMinMs: 300,
|
|
106
|
-
travelMaxMs: 850,
|
|
107
|
-
holdMs: 1100,
|
|
108
|
-
zoomInMs: 730,
|
|
109
|
-
zoomOutMs: 1340,
|
|
110
|
-
pullOutDwellMs: 800,
|
|
111
|
-
zoomEase: void 0
|
|
112
|
-
},
|
|
113
|
-
brisk: {
|
|
114
|
-
travelWidthsPerSec: .45,
|
|
115
|
-
travelMinMs: 235,
|
|
116
|
-
travelMaxMs: 660,
|
|
117
|
-
holdMs: 750,
|
|
118
|
-
zoomInMs: 550,
|
|
119
|
-
zoomOutMs: 1e3,
|
|
120
|
-
pullOutDwellMs: 600,
|
|
121
|
-
zoomEase: void 0
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
/** A clamp matches its preset — or the LEGACY value every composition carried
|
|
125
|
-
* before the clamps joined the presets. Without that second door, applying
|
|
126
|
-
* "brisk" to an old take and re-reading it would report "custom" purely
|
|
127
|
-
* because the take predates clamp-aware presets. Same escape hatch
|
|
128
|
-
* pullOutDwellMs already has. */
|
|
129
|
-
const CLAMP_TOL_MS = 20;
|
|
130
|
-
const clampMatches = (v, want, legacy) => v == null || Math.abs(v - want) < CLAMP_TOL_MS || Math.abs(v - legacy) < 1;
|
|
131
|
-
function motionName(cursor) {
|
|
132
|
-
for (const [name, m] of Object.entries(MOTION)) if (Math.abs(cursor.travelWidthsPerSec - m.travelWidthsPerSec) < .015 && Math.abs(cursor.holdMs - m.holdMs) < 60 && Math.abs(cursor.zoomInMs - m.zoomInMs) < 60 && Math.abs(cursor.zoomOutMs - m.zoomOutMs) < 60 && clampMatches(cursor.travelMinMs, m.travelMinMs, MOTION.natural.travelMinMs) && clampMatches(cursor.travelMaxMs, m.travelMaxMs, MOTION.natural.travelMaxMs) && (cursor.pullOutDwellMs == null || Math.abs(cursor.pullOutDwellMs - (m.pullOutDwellMs ?? 0)) < 60)) return name;
|
|
133
|
-
return null;
|
|
134
|
-
}
|
|
135
|
-
const DARK_SHADOW = {
|
|
136
|
-
color: "rgba(0,0,0,0.55)",
|
|
137
|
-
blur: 60,
|
|
138
|
-
offset: {
|
|
139
|
-
x: 0,
|
|
140
|
-
y: 28
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
const LOOKS = {
|
|
144
|
-
midnight: {
|
|
145
|
-
background: {
|
|
146
|
-
from: "#1e1b3a",
|
|
147
|
-
to: "#0a0e1c"
|
|
148
|
-
},
|
|
149
|
-
cornerRadius: 28,
|
|
150
|
-
shadow: DARK_SHADOW
|
|
151
|
-
},
|
|
152
|
-
ink: {
|
|
153
|
-
background: {
|
|
154
|
-
from: "#16181d",
|
|
155
|
-
to: "#07080a"
|
|
156
|
-
},
|
|
157
|
-
cornerRadius: 28,
|
|
158
|
-
shadow: DARK_SHADOW
|
|
159
|
-
},
|
|
160
|
-
slate: {
|
|
161
|
-
background: {
|
|
162
|
-
from: "#232733",
|
|
163
|
-
to: "#0e1116"
|
|
164
|
-
},
|
|
165
|
-
cornerRadius: 28,
|
|
166
|
-
shadow: DARK_SHADOW
|
|
167
|
-
},
|
|
168
|
-
ocean: {
|
|
169
|
-
background: {
|
|
170
|
-
from: "#0c2b36",
|
|
171
|
-
to: "#071019"
|
|
172
|
-
},
|
|
173
|
-
cornerRadius: 28,
|
|
174
|
-
shadow: DARK_SHADOW
|
|
175
|
-
},
|
|
176
|
-
plum: {
|
|
177
|
-
background: {
|
|
178
|
-
from: "#2a1e3a",
|
|
179
|
-
to: "#140a1c"
|
|
180
|
-
},
|
|
181
|
-
cornerRadius: 28,
|
|
182
|
-
shadow: DARK_SHADOW
|
|
183
|
-
},
|
|
184
|
-
ember: {
|
|
185
|
-
background: {
|
|
186
|
-
from: "#38231d",
|
|
187
|
-
to: "#1a0d09"
|
|
188
|
-
},
|
|
189
|
-
cornerRadius: 28,
|
|
190
|
-
shadow: DARK_SHADOW
|
|
191
|
-
},
|
|
192
|
-
paper: {
|
|
193
|
-
background: {
|
|
194
|
-
from: "#f6f4ef",
|
|
195
|
-
to: "#ddd8cd"
|
|
196
|
-
},
|
|
197
|
-
cornerRadius: 22,
|
|
198
|
-
shadow: {
|
|
199
|
-
color: "rgba(31,27,20,0.30)",
|
|
200
|
-
blur: 45,
|
|
201
|
-
offset: {
|
|
202
|
-
x: 0,
|
|
203
|
-
y: 20
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
},
|
|
207
|
-
plain: {
|
|
208
|
-
background: {
|
|
209
|
-
from: "#101014",
|
|
210
|
-
to: "#101014",
|
|
211
|
-
type: "solid"
|
|
212
|
-
},
|
|
213
|
-
cornerRadius: 28,
|
|
214
|
-
shadow: DARK_SHADOW
|
|
215
|
-
}
|
|
216
|
-
};
|
|
217
|
-
function lookName(framing) {
|
|
218
|
-
const bg = framing.background;
|
|
219
|
-
for (const [name, l] of Object.entries(LOOKS)) if (l.background.from.toLowerCase() === bg.from.toLowerCase() && l.background.to.toLowerCase() === bg.to.toLowerCase() && (l.background.type ?? "gradient") === (bg.type ?? "gradient")) return name;
|
|
220
|
-
return null;
|
|
221
|
-
}
|
|
222
|
-
const FINISH = {
|
|
223
|
-
smooth: DEFAULT_MOTION_BLUR,
|
|
224
|
-
crisp: void 0,
|
|
225
|
-
heavy: {
|
|
226
|
-
samples: 8,
|
|
227
|
-
shutter: .85
|
|
228
|
-
}
|
|
229
|
-
};
|
|
230
|
-
function finishName(mb) {
|
|
231
|
-
const active = !!mb && mb.samples > 1 && mb.shutter > 0;
|
|
232
|
-
if (!active) return "crisp";
|
|
233
|
-
for (const [name, f] of Object.entries(FINISH)) if (f && mb && f.samples === mb.samples && Math.abs(f.shutter - mb.shutter) < .03) return name;
|
|
234
|
-
return null;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
//#endregion
|
|
238
11
|
//#region src/ffmpeg.ts
|
|
239
12
|
let cachedFfmpeg;
|
|
240
13
|
let cachedFfprobe;
|
|
@@ -973,30 +746,389 @@ function ghostCardLines(files) {
|
|
|
973
746
|
}
|
|
974
747
|
|
|
975
748
|
//#endregion
|
|
976
|
-
//#region src/
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
const
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
749
|
+
//#region src/audit-cursor.ts
|
|
750
|
+
/** The pointer polygon, tip at (0,0), stage units. Copied from
|
|
751
|
+
* src/scene/scene.tsx (CURSOR) — the scene is compiled by revideo's vite and
|
|
752
|
+
* exports nothing, so the vertex list is duplicated here ON PURPOSE: any
|
|
753
|
+
* drift between the drawn cursor and the audited one shows up in review. */
|
|
754
|
+
const CURSOR_POLYGON = [
|
|
755
|
+
[0, 0],
|
|
756
|
+
[0, 17],
|
|
757
|
+
[4.5, 13],
|
|
758
|
+
[7.5, 19.5],
|
|
759
|
+
[10, 18.3],
|
|
760
|
+
[7, 11.7],
|
|
761
|
+
[12, 11.7]
|
|
762
|
+
];
|
|
763
|
+
/** supersample factor for the template rasteriser */
|
|
764
|
+
const SS = 4;
|
|
765
|
+
/** template pixels below this mask weight do not score */
|
|
766
|
+
const MASK_MIN = .15;
|
|
767
|
+
/** search radius around the expected tip, output px */
|
|
768
|
+
const SEARCH_WIN_PX = 45;
|
|
769
|
+
/** Below this the template never locked onto a cursor at all — a different
|
|
770
|
+
* failure from "matched but offset". Measured with the Python prototype's
|
|
771
|
+
* LANCZOS template: ncc 0.825 on a clean take, 0.611 at 8% skew, 0.421 at
|
|
772
|
+
* 13% (the shipped-to-a-PR failure). Re-measured with THIS module's box
|
|
773
|
+
* downsample on a real 10-beat draft render: all 9 pointer beats found at
|
|
774
|
+
* 0.00px error, ncc 0.626–0.944 — the 0.5 floor holds for this template. */
|
|
775
|
+
const NCC_MATCH_MIN = .5;
|
|
776
|
+
/** the scene's cursor body fill, rgb(20,20,24) ≈ 20/255 gray */
|
|
777
|
+
const BODY_GRAY = 20 / 255;
|
|
778
|
+
const DEFAULT_SAMPLE_AFTER_MS = 500;
|
|
779
|
+
const DEFAULT_TOL_PX = 6;
|
|
780
|
+
/** Rasterise the cursor sprite at its on-screen scale (cursor.scale × camera
|
|
781
|
+
* scale): supersampled scanline polygon fill + a distance-field outline
|
|
782
|
+
* stroke, box-downsampled — matching how the scene draws it (dark body,
|
|
783
|
+
* 2 stage-px white stroke) closely enough for NCC to lock on. */
|
|
784
|
+
function makeCursorTemplate(scale) {
|
|
785
|
+
const pad = 3;
|
|
786
|
+
const width = Math.ceil(12 * scale) + 6 + pad;
|
|
787
|
+
const height = Math.ceil(19.5 * scale) + 6 + pad;
|
|
788
|
+
const sW = width * SS;
|
|
789
|
+
const sH = height * SS;
|
|
790
|
+
const pts = CURSOR_POLYGON.map(([x, y]) => [(x * scale + pad / 2) * SS, (y * scale + pad / 2) * SS]);
|
|
791
|
+
const fill = new Float32Array(sW * sH);
|
|
792
|
+
for (let y = 0; y < sH; y++) {
|
|
793
|
+
const yc = y + .5;
|
|
794
|
+
const xs = [];
|
|
795
|
+
for (let i = 0; i < pts.length; i++) {
|
|
796
|
+
const [x1, y1] = pts[i];
|
|
797
|
+
const [x2, y2] = pts[(i + 1) % pts.length];
|
|
798
|
+
if (y1 <= yc !== y2 <= yc) xs.push(x1 + (yc - y1) * (x2 - x1) / (y2 - y1));
|
|
799
|
+
}
|
|
800
|
+
xs.sort((a, b) => a - b);
|
|
801
|
+
for (let k = 0; k + 1 < xs.length; k += 2) {
|
|
802
|
+
const x0 = Math.max(0, Math.ceil(xs[k] - .5));
|
|
803
|
+
const x1 = Math.min(sW - 1, Math.floor(xs[k + 1] - .5));
|
|
804
|
+
for (let x = x0; x <= x1; x++) fill[y * sW + x] = 1;
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
const half = Math.max(2, Math.round(scale * SS)) / 2;
|
|
808
|
+
const strk = new Float32Array(sW * sH);
|
|
809
|
+
for (let i = 0; i < pts.length; i++) {
|
|
810
|
+
const [ax, ay] = pts[i];
|
|
811
|
+
const [bx, by] = pts[(i + 1) % pts.length];
|
|
812
|
+
const dx = bx - ax;
|
|
813
|
+
const dy = by - ay;
|
|
814
|
+
const len2 = dx * dx + dy * dy || 1;
|
|
815
|
+
const x0 = Math.max(0, Math.floor(Math.min(ax, bx) - half - 1));
|
|
816
|
+
const x1 = Math.min(sW - 1, Math.ceil(Math.max(ax, bx) + half + 1));
|
|
817
|
+
const y0 = Math.max(0, Math.floor(Math.min(ay, by) - half - 1));
|
|
818
|
+
const y1 = Math.min(sH - 1, Math.ceil(Math.max(ay, by) + half + 1));
|
|
819
|
+
for (let y = y0; y <= y1; y++) for (let x = x0; x <= x1; x++) {
|
|
820
|
+
const px = x + .5 - ax;
|
|
821
|
+
const py = y + .5 - ay;
|
|
822
|
+
const u = Math.max(0, Math.min(1, (px * dx + py * dy) / len2));
|
|
823
|
+
const ex = px - u * dx;
|
|
824
|
+
const ey = py - u * dy;
|
|
825
|
+
if (ex * ex + ey * ey <= half * half) strk[y * sW + x] = 1;
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
const down = (src) => {
|
|
829
|
+
const out = new Float32Array(width * height);
|
|
830
|
+
for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
|
|
831
|
+
let s$1 = 0;
|
|
832
|
+
for (let sy = 0; sy < SS; sy++) for (let sx = 0; sx < SS; sx++) s$1 += src[(y * SS + sy) * sW + x * SS + sx];
|
|
833
|
+
out[y * width + x] = s$1 / (SS * SS);
|
|
834
|
+
}
|
|
835
|
+
return out;
|
|
990
836
|
};
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
const
|
|
994
|
-
const
|
|
837
|
+
const f = down(fill);
|
|
838
|
+
const s = down(strk);
|
|
839
|
+
const pixels = new Float32Array(width * height);
|
|
840
|
+
const mask = new Float32Array(width * height);
|
|
841
|
+
for (let i = 0; i < pixels.length; i++) {
|
|
842
|
+
const interior = Math.min(1, Math.max(0, f[i] - s[i]));
|
|
843
|
+
pixels[i] = interior * BODY_GRAY + s[i];
|
|
844
|
+
mask[i] = Math.min(1, interior + s[i]);
|
|
845
|
+
}
|
|
995
846
|
return {
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
847
|
+
width,
|
|
848
|
+
height,
|
|
849
|
+
pixels,
|
|
850
|
+
mask,
|
|
851
|
+
tip: {
|
|
852
|
+
x: pad / 2,
|
|
853
|
+
y: pad / 2
|
|
854
|
+
}
|
|
855
|
+
};
|
|
856
|
+
}
|
|
857
|
+
/** Masked-NCC search over a ±win px window around the expected tip. Returns
|
|
858
|
+
* the best score and the tip position it was found at; `found` is absent
|
|
859
|
+
* only when no template placement fits inside the frame at all. */
|
|
860
|
+
function findCursor(frame, expect, scale, win = SEARCH_WIN_PX) {
|
|
861
|
+
const tpl = makeCursorTemplate(scale);
|
|
862
|
+
const { width: fw, height: fh, data } = frame;
|
|
863
|
+
const offs = [];
|
|
864
|
+
const b = [];
|
|
865
|
+
for (let ty = 0; ty < tpl.height; ty++) for (let tx = 0; tx < tpl.width; tx++) {
|
|
866
|
+
const j = ty * tpl.width + tx;
|
|
867
|
+
if (tpl.mask[j] > MASK_MIN) {
|
|
868
|
+
offs.push(ty * fw + tx);
|
|
869
|
+
b.push(tpl.pixels[j]);
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
const n = offs.length;
|
|
873
|
+
if (n < 12) return { ncc: -1 };
|
|
874
|
+
let bMean = 0;
|
|
875
|
+
for (const v of b) bMean += v;
|
|
876
|
+
bMean /= n;
|
|
877
|
+
let db2 = 0;
|
|
878
|
+
for (let j = 0; j < n; j++) {
|
|
879
|
+
b[j] = b[j] - bMean;
|
|
880
|
+
db2 += b[j] * b[j];
|
|
881
|
+
}
|
|
882
|
+
const db = Math.sqrt(db2);
|
|
883
|
+
if (db < 1e-6) return { ncc: -1 };
|
|
884
|
+
let best = -2;
|
|
885
|
+
let found;
|
|
886
|
+
for (let dy = -win; dy <= win; dy++) for (let dx = -win; dx <= win; dx++) {
|
|
887
|
+
const x0 = Math.round(expect.x + dx - tpl.tip.x);
|
|
888
|
+
const y0 = Math.round(expect.y + dy - tpl.tip.y);
|
|
889
|
+
if (x0 < 0 || y0 < 0 || x0 + tpl.width > fw || y0 + tpl.height > fh) continue;
|
|
890
|
+
const base = y0 * fw + x0;
|
|
891
|
+
let sa = 0;
|
|
892
|
+
let saa = 0;
|
|
893
|
+
let sab = 0;
|
|
894
|
+
for (let j = 0; j < n; j++) {
|
|
895
|
+
const a = data[base + offs[j]];
|
|
896
|
+
sa += a;
|
|
897
|
+
saa += a * a;
|
|
898
|
+
sab += a * b[j];
|
|
899
|
+
}
|
|
900
|
+
const da = Math.sqrt(Math.max(0, saa - sa * sa / n));
|
|
901
|
+
const score = da < 1e-6 ? -1 : sab / (da * db);
|
|
902
|
+
if (score > best) {
|
|
903
|
+
best = score;
|
|
904
|
+
found = {
|
|
905
|
+
x: expect.x + dx,
|
|
906
|
+
y: expect.y + dy
|
|
907
|
+
};
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
return {
|
|
911
|
+
ncc: best,
|
|
912
|
+
found
|
|
913
|
+
};
|
|
914
|
+
}
|
|
915
|
+
/** Where the compositor MEANT to draw the pointer tip, per pointer-landing
|
|
916
|
+
* beat, in finished-frame px — via the engine's own public math, so there is
|
|
917
|
+
* no second geometry to drift. */
|
|
918
|
+
function predictCursorTips(comp, sampleAfterMs = DEFAULT_SAMPLE_AFTER_MS) {
|
|
919
|
+
const legs = buildLegs(comp);
|
|
920
|
+
const cam = stageCamera(comp);
|
|
921
|
+
const { width: oW, height: oH, fps } = comp.output;
|
|
922
|
+
const startMs = comp.startMs ?? 0;
|
|
923
|
+
const frameMs = 1e3 / fps;
|
|
924
|
+
const out = [];
|
|
925
|
+
for (const [beat, e] of comp.events.entries()) {
|
|
926
|
+
if (!e.point) continue;
|
|
927
|
+
if (e.kind === "press" && !e.bbox) continue;
|
|
928
|
+
let sampleMs = e.tMs + sampleAfterMs;
|
|
929
|
+
for (const l of legs) {
|
|
930
|
+
const departMs = l.t0 * 1e3;
|
|
931
|
+
if (departMs > e.tMs) {
|
|
932
|
+
sampleMs = Math.min(sampleMs, departMs - frameMs);
|
|
933
|
+
break;
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
sampleMs = Math.max(Math.min(sampleMs, comp.durationMs - frameMs), e.tMs);
|
|
937
|
+
const tS = sampleMs / 1e3;
|
|
938
|
+
const c = cursorPos(tS, legs, comp);
|
|
939
|
+
const k = cam.at(tS);
|
|
940
|
+
const expect = {
|
|
941
|
+
x: (c.x - k.center.x) * k.scale + oW / 2,
|
|
942
|
+
y: (c.y - k.center.y) * k.scale + oH / 2
|
|
943
|
+
};
|
|
944
|
+
const tSec = (sampleMs - startMs) / 1e3;
|
|
945
|
+
const offscreen = tSec < 0 || expect.x < 0 || expect.x >= oW || expect.y < 0 || expect.y >= oH;
|
|
946
|
+
out.push({
|
|
947
|
+
beat,
|
|
948
|
+
sampleMs,
|
|
949
|
+
tSec,
|
|
950
|
+
expect,
|
|
951
|
+
camScale: k.scale,
|
|
952
|
+
offscreen
|
|
953
|
+
});
|
|
954
|
+
}
|
|
955
|
+
return out;
|
|
956
|
+
}
|
|
957
|
+
const median = (xs) => {
|
|
958
|
+
const s = xs.slice().sort((a, b) => a - b);
|
|
959
|
+
const m = s.length >> 1;
|
|
960
|
+
return s.length % 2 ? s[m] : (s[m - 1] + s[m]) / 2;
|
|
961
|
+
};
|
|
962
|
+
const signed = (v) => `${v >= 0 ? "+" : ""}${v.toFixed(1)}`;
|
|
963
|
+
/** Turn measured rows into issues (pure — unit-testable without a video). */
|
|
964
|
+
function auditIssues(rows, tolPx = DEFAULT_TOL_PX) {
|
|
965
|
+
const issues = [];
|
|
966
|
+
const offscreen = rows.filter((r) => r.offscreen);
|
|
967
|
+
if (offscreen.length) {
|
|
968
|
+
const names = offscreen.map((r) => `events[${r.beat}] (tip at ${r.expect.x.toFixed(0)},${r.expect.y.toFixed(0)})`).join(", ");
|
|
969
|
+
issues.push({
|
|
970
|
+
severity: "warn",
|
|
971
|
+
path: "events",
|
|
972
|
+
message: `${offscreen.length} beat${offscreen.length === 1 ? "" : "s"} cannot be audited — the zoom pushed the expected cursor tip out of the output frame: ${names}`,
|
|
973
|
+
fix: "check those beats by eye; to make them auditable, pull zoom.center toward the pointer or lower zoom.scale so the pointer stays in frame"
|
|
974
|
+
});
|
|
975
|
+
}
|
|
976
|
+
const checked = rows.filter((r) => !r.offscreen && r.ncc != null && r.found);
|
|
977
|
+
const unmatched = checked.filter((r) => (r.ncc ?? -1) < NCC_MATCH_MIN);
|
|
978
|
+
const offsetFails = checked.filter((r) => (r.ncc ?? -1) >= NCC_MATCH_MIN && (r.errViewportPx ?? 0) > tolPx);
|
|
979
|
+
if (!unmatched.length && !offsetFails.length) return issues;
|
|
980
|
+
const parts = [...offsetFails.map((r) => `events[${r.beat}] drawn ${r.errViewportPx.toFixed(1)}px off (ncc ${r.ncc.toFixed(2)} — the cursor matched, at the wrong place)`), ...unmatched.map((r) => `events[${r.beat}] never matched (best ncc ${r.ncc.toFixed(2)} < ${NCC_MATCH_MIN} — no cursor found near the expected tip, so its offset means nothing)`)];
|
|
981
|
+
let fix = "re-render and re-audit; a repeat means the renderer disagrees with math.cursorPos/stageCamera — the fix is in the renderer, no composition edit moves the drawn cursor";
|
|
982
|
+
if (offsetFails.length >= 2) {
|
|
983
|
+
const vecs = offsetFails.map((r) => {
|
|
984
|
+
const dx = r.found.x - r.expect.x;
|
|
985
|
+
const dy = r.found.y - r.expect.y;
|
|
986
|
+
const errOut = Math.hypot(dx, dy);
|
|
987
|
+
const k = errOut > 0 ? (r.errViewportPx ?? 0) / errOut : 0;
|
|
988
|
+
return {
|
|
989
|
+
x: dx * k,
|
|
990
|
+
y: dy * k
|
|
991
|
+
};
|
|
992
|
+
});
|
|
993
|
+
const mx = median(vecs.map((v) => v.x));
|
|
994
|
+
const my = median(vecs.map((v) => v.y));
|
|
995
|
+
const spread = Math.max(...vecs.map((v) => Math.hypot(v.x - mx, v.y - my)));
|
|
996
|
+
if (spread <= 2) fix = `every failing beat shares one offset ≈ (${signed(mx)}, ${signed(my)}) viewport px — a systematic renderer↔math skew; fix the cursor transform in the renderer and re-render (no composition edit moves the drawn cursor)`;
|
|
997
|
+
}
|
|
998
|
+
issues.push({
|
|
999
|
+
severity: "error",
|
|
1000
|
+
path: "events",
|
|
1001
|
+
message: `the drawn cursor misses the composition's own intent on ${offsetFails.length + unmatched.length} of ${checked.length} verifiable beats (tolerance ${tolPx}px): ${parts.join("; ")}`,
|
|
1002
|
+
fix
|
|
1003
|
+
});
|
|
1004
|
+
return issues;
|
|
1005
|
+
}
|
|
1006
|
+
/** Decode ONE frame of the delivered mp4 at tSec to raw grayscale pixels,
|
|
1007
|
+
* piped straight from ffmpeg — no image-decoding dependency. */
|
|
1008
|
+
function extractGrayFrame(ffmpeg, mp4Path, tSec, width, height) {
|
|
1009
|
+
return new Promise((res, rej) => {
|
|
1010
|
+
const child = spawn(ffmpeg, [
|
|
1011
|
+
"-hide_banner",
|
|
1012
|
+
"-v",
|
|
1013
|
+
"error",
|
|
1014
|
+
"-ss",
|
|
1015
|
+
tSec.toFixed(4),
|
|
1016
|
+
"-i",
|
|
1017
|
+
mp4Path,
|
|
1018
|
+
"-frames:v",
|
|
1019
|
+
"1",
|
|
1020
|
+
"-f",
|
|
1021
|
+
"rawvideo",
|
|
1022
|
+
"-pix_fmt",
|
|
1023
|
+
"gray",
|
|
1024
|
+
"pipe:1"
|
|
1025
|
+
], { stdio: [
|
|
1026
|
+
"ignore",
|
|
1027
|
+
"pipe",
|
|
1028
|
+
"pipe"
|
|
1029
|
+
] });
|
|
1030
|
+
const chunks = [];
|
|
1031
|
+
let errText = "";
|
|
1032
|
+
child.stdout.on("data", (d) => chunks.push(d));
|
|
1033
|
+
child.stderr.on("data", (d) => {
|
|
1034
|
+
errText += d;
|
|
1035
|
+
});
|
|
1036
|
+
child.on("error", rej);
|
|
1037
|
+
child.on("close", (code) => {
|
|
1038
|
+
const bytes = Buffer.concat(chunks);
|
|
1039
|
+
const need = width * height;
|
|
1040
|
+
if (code !== 0) return rej(new Error(`ffmpeg exited ${code} extracting the ${tSec.toFixed(2)}s frame from ${mp4Path}${errText.trim() ? `: ${errText.trim()}` : ""}`));
|
|
1041
|
+
if (bytes.length !== need) return rej(new Error(`ffmpeg returned ${bytes.length} bytes for the ${tSec.toFixed(2)}s frame — expected one ${width}x${height} gray frame (${need} bytes); is ${mp4Path} the delivered render of this composition?`));
|
|
1042
|
+
const data = new Float32Array(need);
|
|
1043
|
+
for (let i = 0; i < need; i++) data[i] = bytes[i] / 255;
|
|
1044
|
+
res({
|
|
1045
|
+
data,
|
|
1046
|
+
width,
|
|
1047
|
+
height
|
|
1048
|
+
});
|
|
1049
|
+
});
|
|
1050
|
+
});
|
|
1051
|
+
}
|
|
1052
|
+
/** Audit the drawn cursor of a delivered mp4 against the composition that
|
|
1053
|
+
* rendered it. One row per pointer-landing beat; issues in the
|
|
1054
|
+
* validateComposition shape ("error" = the render is wrong, "warn" = a beat
|
|
1055
|
+
* the audit cannot see). */
|
|
1056
|
+
async function auditCursor(comp, mp4Path, opts = {}) {
|
|
1057
|
+
const tolPx = opts.tolPx ?? DEFAULT_TOL_PX;
|
|
1058
|
+
const preds = predictCursorTips(comp, opts.sampleAfterMs ?? DEFAULT_SAMPLE_AFTER_MS);
|
|
1059
|
+
if (!preds.length) return {
|
|
1060
|
+
rows: [],
|
|
1061
|
+
issues: [{
|
|
1062
|
+
severity: "warn",
|
|
1063
|
+
path: "events",
|
|
1064
|
+
message: "no pointer-landing beats to audit — the drawn cursor was never verified on this take"
|
|
1065
|
+
}]
|
|
1066
|
+
};
|
|
1067
|
+
const ffmpeg = await resolveFfmpeg();
|
|
1068
|
+
const { width: oW, height: oH } = comp.output;
|
|
1069
|
+
const rows = [];
|
|
1070
|
+
for (const p of preds) {
|
|
1071
|
+
if (p.offscreen) {
|
|
1072
|
+
rows.push({
|
|
1073
|
+
beat: p.beat,
|
|
1074
|
+
tSec: p.tSec,
|
|
1075
|
+
expect: p.expect,
|
|
1076
|
+
offscreen: true
|
|
1077
|
+
});
|
|
1078
|
+
continue;
|
|
1079
|
+
}
|
|
1080
|
+
const frame = await extractGrayFrame(ffmpeg, mp4Path, p.tSec, oW, oH);
|
|
1081
|
+
const { ncc, found } = findCursor(frame, p.expect, comp.cursor.scale * p.camScale);
|
|
1082
|
+
if (!found) {
|
|
1083
|
+
rows.push({
|
|
1084
|
+
beat: p.beat,
|
|
1085
|
+
tSec: p.tSec,
|
|
1086
|
+
expect: p.expect,
|
|
1087
|
+
offscreen: true
|
|
1088
|
+
});
|
|
1089
|
+
continue;
|
|
1090
|
+
}
|
|
1091
|
+
const errOutPx = Math.hypot(found.x - p.expect.x, found.y - p.expect.y);
|
|
1092
|
+
rows.push({
|
|
1093
|
+
beat: p.beat,
|
|
1094
|
+
tSec: p.tSec,
|
|
1095
|
+
expect: p.expect,
|
|
1096
|
+
found,
|
|
1097
|
+
errViewportPx: errOutPx / p.camScale,
|
|
1098
|
+
ncc
|
|
1099
|
+
});
|
|
1100
|
+
}
|
|
1101
|
+
return {
|
|
1102
|
+
rows,
|
|
1103
|
+
issues: auditIssues(rows, tolPx)
|
|
1104
|
+
};
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
//#endregion
|
|
1108
|
+
//#region src/camera.ts
|
|
1109
|
+
const centerOf = (b) => ({
|
|
1110
|
+
x: b.x + b.w / 2,
|
|
1111
|
+
y: b.y + b.h / 2
|
|
1112
|
+
});
|
|
1113
|
+
const dist = (a, b) => Math.hypot(a.x - b.x, a.y - b.y);
|
|
1114
|
+
const union = (a, b) => {
|
|
1115
|
+
const x = Math.min(a.x, b.x);
|
|
1116
|
+
const y = Math.min(a.y, b.y);
|
|
1117
|
+
return {
|
|
1118
|
+
x,
|
|
1119
|
+
y,
|
|
1120
|
+
w: Math.max(a.x + a.w, b.x + b.w) - x,
|
|
1121
|
+
h: Math.max(a.y + a.h, b.y + b.h) - y
|
|
1122
|
+
};
|
|
1123
|
+
};
|
|
1124
|
+
function growDown(box, video) {
|
|
1125
|
+
const grownH = Math.max(box.h, Math.min(video.h * .42, box.w * .55));
|
|
1126
|
+
const h = Math.min(grownH, video.h - box.y);
|
|
1127
|
+
return {
|
|
1128
|
+
x: box.x,
|
|
1129
|
+
y: box.y,
|
|
1130
|
+
w: box.w,
|
|
1131
|
+
h
|
|
1000
1132
|
};
|
|
1001
1133
|
}
|
|
1002
1134
|
/** The region a beat is "about" — what the camera should frame. A type is
|
|
@@ -1188,6 +1320,67 @@ function directCamera(beats, video, out, cam, rest, endMs) {
|
|
|
1188
1320
|
return framings;
|
|
1189
1321
|
}
|
|
1190
1322
|
|
|
1323
|
+
//#endregion
|
|
1324
|
+
//#region src/types.ts
|
|
1325
|
+
const DEFAULT_CAMERA = {
|
|
1326
|
+
enabled: true,
|
|
1327
|
+
fillFrac: .6,
|
|
1328
|
+
maxScale: 2.4,
|
|
1329
|
+
minHoldMs: 1200,
|
|
1330
|
+
minZoomScale: 1.25,
|
|
1331
|
+
coalesceWindowMs: 900,
|
|
1332
|
+
travelThreshold: .18,
|
|
1333
|
+
pullOutCoverage: .55
|
|
1334
|
+
};
|
|
1335
|
+
/** True when motion blur is configured to actually do something — whether the
|
|
1336
|
+
* delivery encode folds in the tmix shutter average (render.ts deliverMp4;
|
|
1337
|
+
* OFF skips tmix but still runs the same single delivery encode). */
|
|
1338
|
+
function motionBlurActive(mb) {
|
|
1339
|
+
return !!mb && mb.samples > 1 && mb.shutter > 0;
|
|
1340
|
+
}
|
|
1341
|
+
const DEFAULT_FRAMING = {
|
|
1342
|
+
insetFrac: .92,
|
|
1343
|
+
cornerRadius: 28,
|
|
1344
|
+
shadow: {
|
|
1345
|
+
color: "rgba(0,0,0,0.55)",
|
|
1346
|
+
blur: 60,
|
|
1347
|
+
offset: {
|
|
1348
|
+
x: 0,
|
|
1349
|
+
y: 28
|
|
1350
|
+
}
|
|
1351
|
+
},
|
|
1352
|
+
background: {
|
|
1353
|
+
from: "#1e1b3a",
|
|
1354
|
+
to: "#0a0e1c"
|
|
1355
|
+
}
|
|
1356
|
+
};
|
|
1357
|
+
const DEFAULT_MOTION_BLUR = {
|
|
1358
|
+
samples: 6,
|
|
1359
|
+
shutter: .7
|
|
1360
|
+
};
|
|
1361
|
+
const DEFAULT_CURSOR = {
|
|
1362
|
+
travelMs: 560,
|
|
1363
|
+
travelWidthsPerSec: .35,
|
|
1364
|
+
travelMinMs: 300,
|
|
1365
|
+
travelMaxMs: 850,
|
|
1366
|
+
scale: 2,
|
|
1367
|
+
arcFrac: .05,
|
|
1368
|
+
arcMax: 24,
|
|
1369
|
+
rippleMs: 450,
|
|
1370
|
+
holdMs: 1100,
|
|
1371
|
+
zoomOutMs: 1340,
|
|
1372
|
+
zoomInMs: 730,
|
|
1373
|
+
zoomSettleFrac: .04,
|
|
1374
|
+
pullOutDwellMs: 800,
|
|
1375
|
+
dragLagMs: 190,
|
|
1376
|
+
travelEase: [
|
|
1377
|
+
.3,
|
|
1378
|
+
0,
|
|
1379
|
+
.2,
|
|
1380
|
+
1
|
|
1381
|
+
]
|
|
1382
|
+
};
|
|
1383
|
+
|
|
1191
1384
|
//#endregion
|
|
1192
1385
|
//#region src/plan.ts
|
|
1193
1386
|
function planComposition(log, opts = {}) {
|
|
@@ -1364,6 +1557,172 @@ function manualFraming(b, rest) {
|
|
|
1364
1557
|
};
|
|
1365
1558
|
}
|
|
1366
1559
|
|
|
1560
|
+
//#endregion
|
|
1561
|
+
//#region src/presets.ts
|
|
1562
|
+
const ZOOM_LEVELS = {
|
|
1563
|
+
light: 1.25,
|
|
1564
|
+
medium: 1.5,
|
|
1565
|
+
tight: 1.8,
|
|
1566
|
+
close: 2.2
|
|
1567
|
+
};
|
|
1568
|
+
/** Name a scale if it sits within tolerance of a preset; else null (custom). */
|
|
1569
|
+
function zoomLevelName(scale, tol = .07) {
|
|
1570
|
+
let best = null;
|
|
1571
|
+
let bestD = tol;
|
|
1572
|
+
for (const [name, v] of Object.entries(ZOOM_LEVELS)) {
|
|
1573
|
+
const d = Math.abs(scale - v);
|
|
1574
|
+
if (d <= bestD) {
|
|
1575
|
+
best = name;
|
|
1576
|
+
bestD = d;
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
return best;
|
|
1580
|
+
}
|
|
1581
|
+
const MOTION = {
|
|
1582
|
+
calm: {
|
|
1583
|
+
travelWidthsPerSec: .28,
|
|
1584
|
+
travelMinMs: 375,
|
|
1585
|
+
travelMaxMs: 1060,
|
|
1586
|
+
holdMs: 1500,
|
|
1587
|
+
zoomInMs: 900,
|
|
1588
|
+
zoomOutMs: 1650,
|
|
1589
|
+
pullOutDwellMs: 1e3,
|
|
1590
|
+
zoomEase: void 0
|
|
1591
|
+
},
|
|
1592
|
+
natural: {
|
|
1593
|
+
travelWidthsPerSec: .35,
|
|
1594
|
+
travelMinMs: 300,
|
|
1595
|
+
travelMaxMs: 850,
|
|
1596
|
+
holdMs: 1100,
|
|
1597
|
+
zoomInMs: 730,
|
|
1598
|
+
zoomOutMs: 1340,
|
|
1599
|
+
pullOutDwellMs: 800,
|
|
1600
|
+
zoomEase: void 0
|
|
1601
|
+
},
|
|
1602
|
+
brisk: {
|
|
1603
|
+
travelWidthsPerSec: .45,
|
|
1604
|
+
travelMinMs: 235,
|
|
1605
|
+
travelMaxMs: 660,
|
|
1606
|
+
holdMs: 750,
|
|
1607
|
+
zoomInMs: 550,
|
|
1608
|
+
zoomOutMs: 1e3,
|
|
1609
|
+
pullOutDwellMs: 600,
|
|
1610
|
+
zoomEase: void 0
|
|
1611
|
+
}
|
|
1612
|
+
};
|
|
1613
|
+
/** A clamp matches its preset — or the LEGACY value every composition carried
|
|
1614
|
+
* before the clamps joined the presets. Without that second door, applying
|
|
1615
|
+
* "brisk" to an old take and re-reading it would report "custom" purely
|
|
1616
|
+
* because the take predates clamp-aware presets. Same escape hatch
|
|
1617
|
+
* pullOutDwellMs already has. */
|
|
1618
|
+
const CLAMP_TOL_MS = 20;
|
|
1619
|
+
const clampMatches = (v, want, legacy) => v == null || Math.abs(v - want) < CLAMP_TOL_MS || Math.abs(v - legacy) < 1;
|
|
1620
|
+
function motionName(cursor) {
|
|
1621
|
+
for (const [name, m] of Object.entries(MOTION)) if (Math.abs(cursor.travelWidthsPerSec - m.travelWidthsPerSec) < .015 && Math.abs(cursor.holdMs - m.holdMs) < 60 && Math.abs(cursor.zoomInMs - m.zoomInMs) < 60 && Math.abs(cursor.zoomOutMs - m.zoomOutMs) < 60 && clampMatches(cursor.travelMinMs, m.travelMinMs, MOTION.natural.travelMinMs) && clampMatches(cursor.travelMaxMs, m.travelMaxMs, MOTION.natural.travelMaxMs) && (cursor.pullOutDwellMs == null || Math.abs(cursor.pullOutDwellMs - (m.pullOutDwellMs ?? 0)) < 60)) return name;
|
|
1622
|
+
return null;
|
|
1623
|
+
}
|
|
1624
|
+
const DARK_SHADOW = {
|
|
1625
|
+
color: "rgba(0,0,0,0.55)",
|
|
1626
|
+
blur: 60,
|
|
1627
|
+
offset: {
|
|
1628
|
+
x: 0,
|
|
1629
|
+
y: 28
|
|
1630
|
+
}
|
|
1631
|
+
};
|
|
1632
|
+
const LOOKS = {
|
|
1633
|
+
midnight: {
|
|
1634
|
+
background: {
|
|
1635
|
+
from: "#1e1b3a",
|
|
1636
|
+
to: "#0a0e1c"
|
|
1637
|
+
},
|
|
1638
|
+
cornerRadius: 28,
|
|
1639
|
+
shadow: DARK_SHADOW
|
|
1640
|
+
},
|
|
1641
|
+
ink: {
|
|
1642
|
+
background: {
|
|
1643
|
+
from: "#16181d",
|
|
1644
|
+
to: "#07080a"
|
|
1645
|
+
},
|
|
1646
|
+
cornerRadius: 28,
|
|
1647
|
+
shadow: DARK_SHADOW
|
|
1648
|
+
},
|
|
1649
|
+
slate: {
|
|
1650
|
+
background: {
|
|
1651
|
+
from: "#232733",
|
|
1652
|
+
to: "#0e1116"
|
|
1653
|
+
},
|
|
1654
|
+
cornerRadius: 28,
|
|
1655
|
+
shadow: DARK_SHADOW
|
|
1656
|
+
},
|
|
1657
|
+
ocean: {
|
|
1658
|
+
background: {
|
|
1659
|
+
from: "#0c2b36",
|
|
1660
|
+
to: "#071019"
|
|
1661
|
+
},
|
|
1662
|
+
cornerRadius: 28,
|
|
1663
|
+
shadow: DARK_SHADOW
|
|
1664
|
+
},
|
|
1665
|
+
plum: {
|
|
1666
|
+
background: {
|
|
1667
|
+
from: "#2a1e3a",
|
|
1668
|
+
to: "#140a1c"
|
|
1669
|
+
},
|
|
1670
|
+
cornerRadius: 28,
|
|
1671
|
+
shadow: DARK_SHADOW
|
|
1672
|
+
},
|
|
1673
|
+
ember: {
|
|
1674
|
+
background: {
|
|
1675
|
+
from: "#38231d",
|
|
1676
|
+
to: "#1a0d09"
|
|
1677
|
+
},
|
|
1678
|
+
cornerRadius: 28,
|
|
1679
|
+
shadow: DARK_SHADOW
|
|
1680
|
+
},
|
|
1681
|
+
paper: {
|
|
1682
|
+
background: {
|
|
1683
|
+
from: "#f6f4ef",
|
|
1684
|
+
to: "#ddd8cd"
|
|
1685
|
+
},
|
|
1686
|
+
cornerRadius: 22,
|
|
1687
|
+
shadow: {
|
|
1688
|
+
color: "rgba(31,27,20,0.30)",
|
|
1689
|
+
blur: 45,
|
|
1690
|
+
offset: {
|
|
1691
|
+
x: 0,
|
|
1692
|
+
y: 20
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
},
|
|
1696
|
+
plain: {
|
|
1697
|
+
background: {
|
|
1698
|
+
from: "#101014",
|
|
1699
|
+
to: "#101014",
|
|
1700
|
+
type: "solid"
|
|
1701
|
+
},
|
|
1702
|
+
cornerRadius: 28,
|
|
1703
|
+
shadow: DARK_SHADOW
|
|
1704
|
+
}
|
|
1705
|
+
};
|
|
1706
|
+
function lookName(framing) {
|
|
1707
|
+
const bg = framing.background;
|
|
1708
|
+
for (const [name, l] of Object.entries(LOOKS)) if (l.background.from.toLowerCase() === bg.from.toLowerCase() && l.background.to.toLowerCase() === bg.to.toLowerCase() && (l.background.type ?? "gradient") === (bg.type ?? "gradient")) return name;
|
|
1709
|
+
return null;
|
|
1710
|
+
}
|
|
1711
|
+
const FINISH = {
|
|
1712
|
+
smooth: DEFAULT_MOTION_BLUR,
|
|
1713
|
+
crisp: void 0,
|
|
1714
|
+
heavy: {
|
|
1715
|
+
samples: 8,
|
|
1716
|
+
shutter: .85
|
|
1717
|
+
}
|
|
1718
|
+
};
|
|
1719
|
+
function finishName(mb) {
|
|
1720
|
+
const active = !!mb && mb.samples > 1 && mb.shutter > 0;
|
|
1721
|
+
if (!active) return "crisp";
|
|
1722
|
+
for (const [name, f] of Object.entries(FINISH)) if (f && mb && f.samples === mb.samples && Math.abs(f.shutter - mb.shutter) < .03) return name;
|
|
1723
|
+
return null;
|
|
1724
|
+
}
|
|
1725
|
+
|
|
1367
1726
|
//#endregion
|
|
1368
1727
|
//#region src/decode-guard.ts
|
|
1369
1728
|
const CAPTURE_UNDECODABLE_MARK = "capture video is not decodable in the render browser";
|
|
@@ -1880,7 +2239,8 @@ async function renderTakeExclusive(opts) {
|
|
|
1880
2239
|
return {
|
|
1881
2240
|
mp4Path: resolve(opts.outPath),
|
|
1882
2241
|
compositionPath,
|
|
1883
|
-
warnings
|
|
2242
|
+
warnings,
|
|
2243
|
+
composition
|
|
1884
2244
|
};
|
|
1885
2245
|
} finally {
|
|
1886
2246
|
await cleanupScratch(scratch);
|
|
@@ -1888,5 +2248,5 @@ async function renderTakeExclusive(opts) {
|
|
|
1888
2248
|
}
|
|
1889
2249
|
|
|
1890
2250
|
//#endregion
|
|
1891
|
-
export { CLAMP_TOL_MS, DEFAULT_CAMERA, DEFAULT_CURSOR, DEFAULT_FRAMING, DEFAULT_MOTION_BLUR, FINISH, LOOKS, MOTION, ZOOM_LEVELS, directCamera, finishName, formatIssues, lookName, math_exports as math, motionBlurActive, motionName, planComposition, renderTake, resolveFfmpeg, resolveFfprobe, validateComposition, zoomLevelName };
|
|
2251
|
+
export { CLAMP_TOL_MS, DEFAULT_CAMERA, DEFAULT_CURSOR, DEFAULT_FRAMING, DEFAULT_MOTION_BLUR, FINISH, LOOKS, MOTION, ZOOM_LEVELS, auditCursor, auditIssues, directCamera, finishName, formatIssues, lookName, math_exports as math, motionBlurActive, motionName, planComposition, predictCursorTips, renderTake, resolveFfmpeg, resolveFfprobe, validateComposition, zoomLevelName };
|
|
1892
2252
|
//# sourceMappingURL=index.js.map
|