@open-take/compositor 0.1.0 → 0.1.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 +3 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +148 -48
- package/dist/index.js.map +1 -1
- package/package.json +11 -9
- package/src/ffmpeg.ts +27 -0
- package/src/index.ts +1 -1
- package/src/math.ts +2 -2
- package/src/render.ts +214 -80
- package/src/scene/scene.tsx +2 -1
- package/src/scene/tsconfig.json +14 -0
package/dist/index.d.ts
CHANGED
|
@@ -363,10 +363,9 @@ type RenderTakeOpts = {
|
|
|
363
363
|
planOpts?: PlanOpts;
|
|
364
364
|
logProgress?: boolean;
|
|
365
365
|
/** Chrome binary for the headless render. Pass the same Chrome-for-Testing
|
|
366
|
-
* the capture path uses so a single browser serves both stages
|
|
367
|
-
*
|
|
368
|
-
|
|
369
|
-
chromePath?: string;
|
|
366
|
+
* the capture path uses so a single browser serves both stages. The
|
|
367
|
+
* higher-level runtime resolves and supplies this to puppeteer-core. */
|
|
368
|
+
chromePath: string;
|
|
370
369
|
/** the capture log, for cross-checking that an edited composition didn't
|
|
371
370
|
* drift an action's capture-locked tMs (see validateComposition). Optional —
|
|
372
371
|
* the structural checks run regardless. */
|
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/render.ts","../src/validate.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;;AAOW;KAZP,gBAAA;EAgBA;;;EAIA;QAfJ;;EAyBI,GAAA,EAAA,MAAA;;;EAiBA,IAAA,CAAA,EAAA,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A,GCjE8C;EAAY;EAA3C,OAAA,EAAA,OAAA;EAKf;EAEI,KAAA,EAAA,MAAU;EAAA;EAAA,MAAS,EDgEzB,EChEyB;EAAY;EAAa,MAAA,EAAA,MAAA;EAiBhD;;;;AAAiB;AAM7B;EAyCC,KAAA,CAAA,EDSS,ECTT;EAAA;EAzC4C,MAAzB,EAAA,MAAA;AAAM,CAAA;AA0Cd,KDaA,SAAA,GCbQ;EAEJ,IAAA,EAAA,OAAQ,GAAA,MAAU,GAAA,MAAA,GAAA,QAAa,GAAA,OAAA,GAAA,OAAA;EAclC,GAAA,EAAA,MAIZ;EAAA;;EAJyE,KAArD,EDEZ,ECFY;EAAM;EAKf,IAAA,CAAA,EDDH,ICCG;EAEI,KAAA,CAAA,EAAA,MAAU;EAAA,IAAA,EDDlB,YCCkB;EAAA;;EAA8C,UAAA,CAAA,EAAA,MAAA;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/presets.ts","../src/ffmpeg.ts","../src/plan.ts","../src/render.ts","../src/validate.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;;AAOW;KAZP,gBAAA;EAgBA;;;EAIA;QAfJ;;EAyBI,GAAA,EAAA,MAAA;;;EAiBA,IAAA,CAAA,EAAA,MAAA;;SAnCH;AA6CT,CAAA;;KAzCY,YAAA,GAAe;;AAkD3B,CAAA;AAQA;;AACI,KAvDQ,WAAA,GAAc,gBAuDtB,GAAA;EAAY,IACZ,EAAA,MAAA;EAAW;EACA,IACX,EAAA,MAAA;EAAa;EACD,UACZ,EAAA,MAAA;AAAY,CAAA;AAEhB;AAWA;AAAwB,KA/DZ,WAAA,GAAc,gBA+DF,GAAA;EAAA,IAMd,EAAA,MAAA;EAAE;EASA,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AAA,CAAA,EAAA,MAAA;;iBM6H1B,cAAA;AN5GhB;;;AAUA;;;;AASA;AAQA;;AACI,iBMoGY,WAAA,CNpGZ,MAAA,EMqGM,ENrGN,EAAA,KAAA,EAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,IAAA,EAAA,MAAA,EAAA,IAAA,EAAA,MAAA,CAAA,EM2GD,EN3GC;AACA,KMsHQ,cAAA,GNtHR;EAAW,CAAA,EMuHV,ENtHD,CAAA,MAAA,CAAA,EAAA;EAAW,CAAA,EMuHV,ENtHD,CMsHI,ENtHJ,CAAA,EAAA;EAAa,CAAA,EACb,MAAA;CAAY;AACA,iBMwHA,mBAAA,CNxHA,IAAA,EMwH0B,eNxH1B,CAAA,EMwH4C,cNxH5C;AAEhB,KM2PK,GAAA,GN3PO;EAWA,EAAA,EAAA,MAAA;EAAY,EAAA,EAAA,MAAA;EAAA,CAAA,EMmPnB,EN7OK;EAAE,CAAA,EM8OP,ENrOK;EAAE,IAAA,CAAA,EAAA,OAAA;EAKA,IAAA,CAAA,EMkOH,ENlOG,EAAA;EAAS,IAAA,CAAA,EAAA,QAAA,GAAA,QAAA;CAAA;AAOZ,iBM+NO,SAAA,CN/NP,IAAA,EM+NuB,eN/NvB,CAAA,EM+NyC,GN/NzC,EAAA;AAED,iBMiSQ,SAAA,CNjSR,CAAA,EAAA,MAAA,EAAA,IAAA,EMiSmC,GNjSnC,EAAA,EAAA,IAAA,EMiSgD,eNjShD,CAAA,EMiSkE,ENjSlE;;AAWC,iBMmTO,UAAA,CNnTP,CAAA,EAAA,MAAA,EAAA,IAAA,EMmTmC,GNnTnC,EAAA,CAAA,EAAA,OAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { __export } from "./chunk-Cl8Af3a2.js";
|
|
2
2
|
import { spawn, spawnSync } from "node:child_process";
|
|
3
|
-
import { copyFile, mkdir, writeFile } from "node:fs/promises";
|
|
4
|
-
import {
|
|
3
|
+
import { chmod, copyFile, mkdir, mkdtemp, readFile, readdir, rm, stat, symlink, unlink, writeFile } from "node:fs/promises";
|
|
4
|
+
import { existsSync, realpathSync } from "node:fs";
|
|
5
|
+
import { createRequire } from "node:module";
|
|
6
|
+
import { tmpdir } from "node:os";
|
|
7
|
+
import { dirname, join, resolve, sep } from "node:path";
|
|
5
8
|
import { fileURLToPath } from "node:url";
|
|
6
|
-
import { renderVideo } from "@revideo
|
|
9
|
+
import { renderVideo } from "@open-take/revideo-renderer";
|
|
7
10
|
|
|
8
11
|
//#region src/types.ts
|
|
9
12
|
/** True when motion blur is configured to actually do something (so the OFF
|
|
@@ -224,6 +227,23 @@ async function installerPath(pkg) {
|
|
|
224
227
|
return null;
|
|
225
228
|
}
|
|
226
229
|
}
|
|
230
|
+
/** Some pnpm installs leave the platform packages' media binaries without an
|
|
231
|
+
* executable bit. Repair the resolved target at the point of use as well as
|
|
232
|
+
* in the repo postinstall: published consumers do not run this monorepo's
|
|
233
|
+
* root lifecycle script. Windows does not use POSIX execute bits. */
|
|
234
|
+
async function ensureExecutable(path) {
|
|
235
|
+
if (!path || process.platform === "win32") return;
|
|
236
|
+
try {
|
|
237
|
+
const info = await stat(path);
|
|
238
|
+
if ((info.mode & 73) === 0) await chmod(path, info.mode | 73);
|
|
239
|
+
} catch {}
|
|
240
|
+
}
|
|
241
|
+
/** Revideo resolves its own bundled ffprobe rather than calling
|
|
242
|
+
* resolveFfprobe(), so repair both installer targets before invoking it. */
|
|
243
|
+
async function repairBundledMediaPermissions() {
|
|
244
|
+
const paths = await Promise.all([installerPath("@ffmpeg-installer/ffmpeg"), installerPath("@ffprobe-installer/ffprobe")]);
|
|
245
|
+
await Promise.all(paths.map(ensureExecutable));
|
|
246
|
+
}
|
|
227
247
|
async function resolveFfmpeg() {
|
|
228
248
|
if (cachedFfmpeg) return cachedFfmpeg;
|
|
229
249
|
if (runsOk("ffmpeg")) {
|
|
@@ -231,6 +251,7 @@ async function resolveFfmpeg() {
|
|
|
231
251
|
return cachedFfmpeg;
|
|
232
252
|
}
|
|
233
253
|
const p = await installerPath("@ffmpeg-installer/ffmpeg");
|
|
254
|
+
await ensureExecutable(p);
|
|
234
255
|
if (p && runsOk(p)) {
|
|
235
256
|
cachedFfmpeg = p;
|
|
236
257
|
return p;
|
|
@@ -244,6 +265,7 @@ async function resolveFfprobe() {
|
|
|
244
265
|
return cachedFfprobe;
|
|
245
266
|
}
|
|
246
267
|
const p = await installerPath("@ffprobe-installer/ffprobe");
|
|
268
|
+
await ensureExecutable(p);
|
|
247
269
|
if (p && runsOk(p)) {
|
|
248
270
|
cachedFfprobe = p;
|
|
249
271
|
return p;
|
|
@@ -272,8 +294,8 @@ __export(math_exports, {
|
|
|
272
294
|
stageEasing: () => stageEasing
|
|
273
295
|
});
|
|
274
296
|
function smoother(t) {
|
|
275
|
-
|
|
276
|
-
return
|
|
297
|
+
const clamped = Math.max(0, Math.min(1, t));
|
|
298
|
+
return clamped * clamped * clamped * (clamped * (clamped * 6 - 15) + 10);
|
|
277
299
|
}
|
|
278
300
|
function cubicBezier(x1, y1, x2, y2) {
|
|
279
301
|
const bx = (s) => {
|
|
@@ -843,8 +865,6 @@ function formatIssues(issues) {
|
|
|
843
865
|
//#endregion
|
|
844
866
|
//#region src/render.ts
|
|
845
867
|
const PKG_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
846
|
-
const PUBLIC_MP4 = resolve(PKG_ROOT, "public/capture.mp4");
|
|
847
|
-
const COMP_JSON = resolve(PKG_ROOT, "src/scene/.composition.json");
|
|
848
868
|
const RENDER_OUT = "out-render";
|
|
849
869
|
function run(cmd, args) {
|
|
850
870
|
return new Promise((res, rej) => {
|
|
@@ -854,7 +874,9 @@ function run(cmd, args) {
|
|
|
854
874
|
"pipe"
|
|
855
875
|
] });
|
|
856
876
|
let err = "";
|
|
857
|
-
c.stderr.on("data", (d) =>
|
|
877
|
+
c.stderr.on("data", (d) => {
|
|
878
|
+
err += d;
|
|
879
|
+
});
|
|
858
880
|
c.on("error", rej);
|
|
859
881
|
c.on("close", (code) => code === 0 ? res() : rej(new Error(`${cmd} exited ${code}: ${err}`)));
|
|
860
882
|
});
|
|
@@ -911,7 +933,80 @@ async function motionBlurMp4(inMp4, outMp4, baseFps, samples, shutter) {
|
|
|
911
933
|
outMp4
|
|
912
934
|
]);
|
|
913
935
|
}
|
|
936
|
+
/** The nearest node_modules above the installed package. Symlinked into the
|
|
937
|
+
* scratch dir so the copied scene can still resolve `@revideo/*` — pnpm keeps
|
|
938
|
+
* a node_modules beside the package, npm/yarn hoist it to the project root, so
|
|
939
|
+
* walk up rather than assume either. */
|
|
940
|
+
function hostNodeModules() {
|
|
941
|
+
let dir = PKG_ROOT;
|
|
942
|
+
for (;;) {
|
|
943
|
+
const candidate = join(dir, "node_modules");
|
|
944
|
+
if (existsSync(candidate)) return candidate;
|
|
945
|
+
const up = dirname(dir);
|
|
946
|
+
if (up === dir) return null;
|
|
947
|
+
dir = up;
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
/** The whole dependency tree in one directory, for vite's fs.allow. Vite serves
|
|
951
|
+
* realpaths, and pnpm's are under `<root>/node_modules/.pnpm/…`, so the first
|
|
952
|
+
* `node_modules` segment of a resolved dependency covers every layout. */
|
|
953
|
+
function depsRoot() {
|
|
954
|
+
try {
|
|
955
|
+
const real = realpathSync(createRequire(import.meta.url).resolve("@revideo/core"));
|
|
956
|
+
const parts = real.split(sep);
|
|
957
|
+
const i = parts.indexOf("node_modules");
|
|
958
|
+
return i === -1 ? null : parts.slice(0, i + 1).join(sep);
|
|
959
|
+
} catch {
|
|
960
|
+
return null;
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
/** Copy a tree WITHOUT inheriting its permission bits. `fs.cp` preserves mode,
|
|
964
|
+
* so copying out of a read-only install yields a read-only copy we then can't
|
|
965
|
+
* write the composition into. Re-creating each file gives us the umask
|
|
966
|
+
* default instead. The scene tree is a handful of small source files. */
|
|
967
|
+
async function copyWritable(from, to) {
|
|
968
|
+
await mkdir(to, { recursive: true });
|
|
969
|
+
for (const e of await readdir(from, { withFileTypes: true })) {
|
|
970
|
+
const src = join(from, e.name);
|
|
971
|
+
const dst = join(to, e.name);
|
|
972
|
+
if (e.isDirectory()) await copyWritable(src, dst);
|
|
973
|
+
else if (e.isFile()) await writeFile(dst, await readFile(src));
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
async function cleanupScratch(dir) {
|
|
977
|
+
await unlink(join(dir, "node_modules")).catch(() => {});
|
|
978
|
+
if (!process.env.OPEN_TAKE_KEEP_SCRATCH) await rm(dir, {
|
|
979
|
+
recursive: true,
|
|
980
|
+
force: true
|
|
981
|
+
});
|
|
982
|
+
else process.stderr.write(`render scratch kept: ${dir}\n`);
|
|
983
|
+
}
|
|
984
|
+
/** Build the throwaway directory this render runs in: the package's `src/`
|
|
985
|
+
* (the scene and everything it imports), this render's composition, the
|
|
986
|
+
* normalised capture as vite's public asset, and a node_modules link. */
|
|
987
|
+
async function prepareScratch(composition, videoPath) {
|
|
988
|
+
const dir = await mkdtemp(join(tmpdir(), "open-take-render-"));
|
|
989
|
+
try {
|
|
990
|
+
await copyWritable(join(PKG_ROOT, "src"), join(dir, "src"));
|
|
991
|
+
await writeFile(join(dir, "src", "scene", ".composition.json"), JSON.stringify(composition, null, 2));
|
|
992
|
+
const nm = hostNodeModules();
|
|
993
|
+
if (!nm) throw new Error("render: could not locate node_modules for the scene's imports");
|
|
994
|
+
await symlink(nm, join(dir, "node_modules"), "junction");
|
|
995
|
+
await toMp4(videoPath, join(dir, "public", "capture.mp4"), composition.output.fps);
|
|
996
|
+
return dir;
|
|
997
|
+
} catch (error) {
|
|
998
|
+
await cleanupScratch(dir);
|
|
999
|
+
throw error;
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
let renderQueue = Promise.resolve();
|
|
914
1003
|
async function renderTake(opts) {
|
|
1004
|
+
const run$1 = renderQueue.then(() => renderTakeExclusive(opts), () => renderTakeExclusive(opts));
|
|
1005
|
+
renderQueue = run$1.catch(() => {});
|
|
1006
|
+
return run$1;
|
|
1007
|
+
}
|
|
1008
|
+
async function renderTakeExclusive(opts) {
|
|
1009
|
+
if (!opts.chromePath) throw new Error("renderTake: `chromePath` is required; use @open-take/runtime to resolve managed Chrome automatically");
|
|
915
1010
|
const composition = opts.composition ?? planComposition(opts.log ?? (() => {
|
|
916
1011
|
throw new Error("renderTake: provide `log` or `composition`");
|
|
917
1012
|
})(), opts.planOpts);
|
|
@@ -922,50 +1017,55 @@ async function renderTake(opts) {
|
|
|
922
1017
|
if (opts.logProgress && warns.length) process.stderr.write(`composition warnings:\n${formatIssues(warns)}\n`);
|
|
923
1018
|
if (errors.length) throw new Error(`composition has ${errors.length} error(s) — refusing to render:\n${formatIssues(errors)}`);
|
|
924
1019
|
}
|
|
925
|
-
await
|
|
926
|
-
await
|
|
927
|
-
|
|
928
|
-
if (process.env.DISABLE_TELEMETRY === void 0) process.env.DISABLE_TELEMETRY = "true";
|
|
929
|
-
const prevCwd = process.cwd();
|
|
930
|
-
process.chdir(PKG_ROOT);
|
|
931
|
-
let produced;
|
|
1020
|
+
await repairBundledMediaPermissions();
|
|
1021
|
+
const scratch = await prepareScratch(composition, opts.videoPath);
|
|
1022
|
+
const deps = depsRoot();
|
|
932
1023
|
try {
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
1024
|
+
if (process.env.DISABLE_TELEMETRY === void 0) process.env.DISABLE_TELEMETRY = "true";
|
|
1025
|
+
const prevCwd = process.cwd();
|
|
1026
|
+
process.chdir(scratch);
|
|
1027
|
+
let produced;
|
|
1028
|
+
try {
|
|
1029
|
+
produced = await renderVideo({
|
|
1030
|
+
projectFile: "/src/scene/project.ts",
|
|
1031
|
+
settings: {
|
|
1032
|
+
outFile: "take.mp4",
|
|
1033
|
+
outDir: RENDER_OUT,
|
|
1034
|
+
workers: 1,
|
|
1035
|
+
...opts.rangeSec ? { projectSettings: { range: opts.rangeSec } } : {},
|
|
1036
|
+
logProgress: opts.logProgress ?? false,
|
|
1037
|
+
...opts.onProgress ? { progressCallback: (_worker, progress) => opts.onProgress(progress) } : {},
|
|
1038
|
+
viteConfig: { server: { fs: { allow: [scratch, ...deps ? [deps] : []] } } },
|
|
1039
|
+
puppeteer: {
|
|
1040
|
+
args: [
|
|
1041
|
+
"--no-sandbox",
|
|
1042
|
+
"--disable-setuid-sandbox",
|
|
1043
|
+
"--password-store=basic",
|
|
1044
|
+
"--use-mock-keychain"
|
|
1045
|
+
],
|
|
1046
|
+
executablePath: opts.chromePath
|
|
1047
|
+
}
|
|
950
1048
|
}
|
|
951
|
-
}
|
|
952
|
-
}
|
|
1049
|
+
});
|
|
1050
|
+
} finally {
|
|
1051
|
+
process.chdir(prevCwd);
|
|
1052
|
+
}
|
|
1053
|
+
await mkdir(dirname(resolve(opts.outPath)), { recursive: true });
|
|
1054
|
+
const producedAbs = resolve(scratch, produced);
|
|
1055
|
+
if (motionBlurActive(composition.motionBlur)) await motionBlurMp4(producedAbs, resolve(opts.outPath), composition.output.fps, composition.motionBlur.samples, composition.motionBlur.shutter);
|
|
1056
|
+
else await copyFile(producedAbs, resolve(opts.outPath));
|
|
1057
|
+
const compositionPath = resolve(opts.outPath).replace(/\.mp4$/i, "") + ".composition.json";
|
|
1058
|
+
if (opts.writeCompositionSibling !== false) {
|
|
1059
|
+
const { review: _review,...persisted } = composition;
|
|
1060
|
+
await writeFile(compositionPath, JSON.stringify(persisted, null, 2));
|
|
1061
|
+
}
|
|
1062
|
+
return {
|
|
1063
|
+
mp4Path: resolve(opts.outPath),
|
|
1064
|
+
compositionPath
|
|
1065
|
+
};
|
|
953
1066
|
} finally {
|
|
954
|
-
|
|
1067
|
+
await cleanupScratch(scratch);
|
|
955
1068
|
}
|
|
956
|
-
await mkdir(dirname(resolve(opts.outPath)), { recursive: true });
|
|
957
|
-
const producedAbs = resolve(PKG_ROOT, produced);
|
|
958
|
-
if (motionBlurActive(composition.motionBlur)) await motionBlurMp4(producedAbs, resolve(opts.outPath), composition.output.fps, composition.motionBlur.samples, composition.motionBlur.shutter);
|
|
959
|
-
else await copyFile(producedAbs, resolve(opts.outPath));
|
|
960
|
-
const compositionPath = resolve(opts.outPath).replace(/\.mp4$/i, "") + ".composition.json";
|
|
961
|
-
if (opts.writeCompositionSibling !== false) {
|
|
962
|
-
const { review: _review,...persisted } = composition;
|
|
963
|
-
await writeFile(compositionPath, JSON.stringify(persisted, null, 2));
|
|
964
|
-
}
|
|
965
|
-
return {
|
|
966
|
-
mp4Path: resolve(opts.outPath),
|
|
967
|
-
compositionPath
|
|
968
|
-
};
|
|
969
1069
|
}
|
|
970
1070
|
|
|
971
1071
|
//#endregion
|