@hyperframes/producer 0.9.67 → 0.9.69
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/distributed.js +11 -13
- package/dist/hyperframe.manifest.json +1 -1
- package/dist/hyperframe.runtime.iife.js +67 -66
- package/dist/index.js +450 -390
- package/dist/public-server.js +314 -255
- package/dist/services/render/segmentManifest.d.ts +29 -6
- package/dist/services/render/segmentPlan.d.ts +2 -5
- package/dist/services/render/stages/captureSegmentedStage.d.ts +1 -2
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
mkdirSync as mkdirSync12,
|
|
14
14
|
readdirSync as readdirSync6,
|
|
15
15
|
rmSync as rmSync12,
|
|
16
|
-
statSync as
|
|
16
|
+
statSync as statSync10,
|
|
17
17
|
writeFileSync as writeFileSync7,
|
|
18
18
|
copyFileSync as copyFileSync5,
|
|
19
19
|
appendFileSync
|
|
@@ -360,7 +360,7 @@ import {
|
|
|
360
360
|
referenceBackgroundResult,
|
|
361
361
|
createReferenceBackgroundRecorder
|
|
362
362
|
} from "@hyperframes/engine";
|
|
363
|
-
import { join as
|
|
363
|
+
import { join as join34, dirname as dirname14, resolve as resolve9 } from "path";
|
|
364
364
|
import { totalmem as totalmem2 } from "node:os";
|
|
365
365
|
import { randomUUID } from "crypto";
|
|
366
366
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
@@ -2593,8 +2593,8 @@ function replanAfterFailure(plan2, failure) {
|
|
|
2593
2593
|
}
|
|
2594
2594
|
|
|
2595
2595
|
// src/services/render/stages/captureSegmentedStage.ts
|
|
2596
|
-
import { existsSync as
|
|
2597
|
-
import { join as
|
|
2596
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync4, rmSync as rmSync6, statSync as statSync4 } from "node:fs";
|
|
2597
|
+
import { join as join12 } from "node:path";
|
|
2598
2598
|
import {
|
|
2599
2599
|
captureFrameToBuffer as captureFrameToBuffer2,
|
|
2600
2600
|
closeCaptureSession as closeCaptureSession2,
|
|
@@ -4281,6 +4281,7 @@ function cleanupEndedHdrVideos(args) {
|
|
|
4281
4281
|
}
|
|
4282
4282
|
|
|
4283
4283
|
// src/services/render/segmentPlan.ts
|
|
4284
|
+
import { join as join9 } from "node:path";
|
|
4284
4285
|
var DEFAULT_SEGMENT_FRAMES = 3e3;
|
|
4285
4286
|
var MIN_SEGMENT_FRAMES = 30;
|
|
4286
4287
|
function assertPositiveInteger(name, value) {
|
|
@@ -4301,6 +4302,9 @@ function planSegments(totalFrames, segmentFrames) {
|
|
|
4301
4302
|
}
|
|
4302
4303
|
return slices;
|
|
4303
4304
|
}
|
|
4305
|
+
function segmentOutputPath(segmentDir, index) {
|
|
4306
|
+
return join9(segmentDir, `segment_${String(index).padStart(5, "0")}.mp4`);
|
|
4307
|
+
}
|
|
4304
4308
|
function resolveSegmentFrames(env) {
|
|
4305
4309
|
const raw = env.HF_SEGMENT_FRAMES;
|
|
4306
4310
|
if (raw === void 0 || raw.trim() === "") return DEFAULT_SEGMENT_FRAMES;
|
|
@@ -4318,6 +4322,144 @@ function createSegmentQueue(slices) {
|
|
|
4318
4322
|
};
|
|
4319
4323
|
}
|
|
4320
4324
|
|
|
4325
|
+
// src/services/render/segmentManifest.ts
|
|
4326
|
+
import { createHash as createHash2, createHmac, timingSafeEqual } from "node:crypto";
|
|
4327
|
+
import {
|
|
4328
|
+
createReadStream as createReadStream2,
|
|
4329
|
+
existsSync as existsSync7,
|
|
4330
|
+
lstatSync as lstatSync3,
|
|
4331
|
+
mkdirSync as mkdirSync3,
|
|
4332
|
+
readFileSync as readFileSync4,
|
|
4333
|
+
writeFileSync as writeFileSync3
|
|
4334
|
+
} from "node:fs";
|
|
4335
|
+
import { join as join10 } from "node:path";
|
|
4336
|
+
import { previewToken } from "@hyperframes/core/preview-proof";
|
|
4337
|
+
import { renameWithRetry as renameWithRetry2 } from "@hyperframes/engine";
|
|
4338
|
+
var MANIFEST_FILENAME = "segments.json";
|
|
4339
|
+
function computeSegmentPlanHash(input) {
|
|
4340
|
+
const ordered = [
|
|
4341
|
+
input.compositionHash,
|
|
4342
|
+
input.cliVersion,
|
|
4343
|
+
String(input.totalFrames),
|
|
4344
|
+
String(input.segmentFrames),
|
|
4345
|
+
`${input.fps.num}/${input.fps.den}`,
|
|
4346
|
+
`${input.width}x${input.height}`,
|
|
4347
|
+
input.codec,
|
|
4348
|
+
input.preset,
|
|
4349
|
+
input.quality === void 0 ? "" : String(input.quality),
|
|
4350
|
+
input.bitrate ?? "",
|
|
4351
|
+
input.pixelFormat ?? "",
|
|
4352
|
+
input.imageFormat,
|
|
4353
|
+
input.useGpu ? "gpu" : "cpu",
|
|
4354
|
+
`${input.outputWidth}x${input.outputHeight}`,
|
|
4355
|
+
input.motionBlur,
|
|
4356
|
+
input.pageMotionBlur ?? "",
|
|
4357
|
+
input.captureQuality === void 0 ? "" : String(input.captureQuality)
|
|
4358
|
+
];
|
|
4359
|
+
const delivery = [input.maxBitrate, input.bufferSize, input.gopSize].map((v) => v ?? "");
|
|
4360
|
+
if (delivery.some((v) => v !== "")) ordered.push(...delivery.map(String));
|
|
4361
|
+
return createHash2("sha256").update(ordered.join(" ")).digest("hex").slice(0, 16);
|
|
4362
|
+
}
|
|
4363
|
+
function segmentDirFor(projectRendersDir, planHash) {
|
|
4364
|
+
return join10(projectRendersDir, ".hf-segments", planHash);
|
|
4365
|
+
}
|
|
4366
|
+
function hasNumber(value, key) {
|
|
4367
|
+
return key in value && typeof Reflect.get(value, key) === "number";
|
|
4368
|
+
}
|
|
4369
|
+
function hasString(value, key) {
|
|
4370
|
+
return key in value && typeof Reflect.get(value, key) === "string";
|
|
4371
|
+
}
|
|
4372
|
+
function isEntry(value) {
|
|
4373
|
+
if (typeof value !== "object" || value === null) return false;
|
|
4374
|
+
return hasNumber(value, "index") && hasNumber(value, "startFrame") && hasNumber(value, "endFrame") && hasString(value, "path") && hasNumber(value, "bytes") && hasString(value, "sha256") && hasString(value, "completedAt");
|
|
4375
|
+
}
|
|
4376
|
+
function isManifest(value) {
|
|
4377
|
+
if (typeof value !== "object" || value === null) return false;
|
|
4378
|
+
const completed = Reflect.get(value, "completed");
|
|
4379
|
+
return Reflect.get(value, "version") === 1 && hasString(value, "planHash") && hasNumber(value, "totalFrames") && hasNumber(value, "segmentFrames") && Array.isArray(completed) && completed.every(isEntry);
|
|
4380
|
+
}
|
|
4381
|
+
function readSegmentManifest(segmentDir) {
|
|
4382
|
+
const path = join10(segmentDir, MANIFEST_FILENAME);
|
|
4383
|
+
if (!existsSync7(path)) return null;
|
|
4384
|
+
try {
|
|
4385
|
+
const parsed = JSON.parse(readFileSync4(path, "utf-8"));
|
|
4386
|
+
return isManifest(parsed) ? parsed : null;
|
|
4387
|
+
} catch {
|
|
4388
|
+
return null;
|
|
4389
|
+
}
|
|
4390
|
+
}
|
|
4391
|
+
function segmentManifestKey(token = previewToken()) {
|
|
4392
|
+
return token ? createHmac("sha256", token).update("segment-manifest").digest() : null;
|
|
4393
|
+
}
|
|
4394
|
+
function manifestMac(manifest, key) {
|
|
4395
|
+
const signed = [
|
|
4396
|
+
manifest.planHash,
|
|
4397
|
+
manifest.totalFrames,
|
|
4398
|
+
manifest.segmentFrames,
|
|
4399
|
+
manifest.completed.map((e) => [e.index, e.startFrame, e.endFrame, e.bytes, e.sha256])
|
|
4400
|
+
];
|
|
4401
|
+
return createHmac("sha256", key).update(JSON.stringify(signed)).digest("hex");
|
|
4402
|
+
}
|
|
4403
|
+
function signSegmentManifest(manifest, key) {
|
|
4404
|
+
const { version, planHash, totalFrames, segmentFrames, completed } = manifest;
|
|
4405
|
+
const unsigned = { version, planHash, totalFrames, segmentFrames, completed };
|
|
4406
|
+
return key ? { ...unsigned, mac: manifestMac(unsigned, key) } : unsigned;
|
|
4407
|
+
}
|
|
4408
|
+
function hasValidMac(manifest, key) {
|
|
4409
|
+
if (!key || typeof manifest.mac !== "string") return false;
|
|
4410
|
+
const expected = Buffer.from(manifestMac(manifest, key), "hex");
|
|
4411
|
+
const actual = Buffer.from(manifest.mac, "hex");
|
|
4412
|
+
return actual.length === expected.length && timingSafeEqual(actual, expected);
|
|
4413
|
+
}
|
|
4414
|
+
async function hashSegmentFile(path) {
|
|
4415
|
+
const hash = createHash2("sha256");
|
|
4416
|
+
for await (const chunk of createReadStream2(path)) hash.update(chunk);
|
|
4417
|
+
return hash.digest("hex");
|
|
4418
|
+
}
|
|
4419
|
+
function writeSegmentManifest(segmentDir, manifest, key) {
|
|
4420
|
+
mkdirSync3(segmentDir, { recursive: true });
|
|
4421
|
+
const tmp = join10(segmentDir, `${MANIFEST_FILENAME}.${process.pid}.tmp`);
|
|
4422
|
+
writeFileSync3(tmp, JSON.stringify(signSegmentManifest(manifest, key), null, 2), "utf-8");
|
|
4423
|
+
renameWithRetry2(tmp, join10(segmentDir, MANIFEST_FILENAME));
|
|
4424
|
+
}
|
|
4425
|
+
async function probeSegmentFrameCount(path, probe) {
|
|
4426
|
+
try {
|
|
4427
|
+
const meta = await probe(path);
|
|
4428
|
+
if (!Number.isFinite(meta.videoStreamDurationSeconds) || !Number.isFinite(meta.fps))
|
|
4429
|
+
return null;
|
|
4430
|
+
if (meta.fps <= 0) return null;
|
|
4431
|
+
return Math.round(meta.videoStreamDurationSeconds * meta.fps);
|
|
4432
|
+
} catch {
|
|
4433
|
+
return null;
|
|
4434
|
+
}
|
|
4435
|
+
}
|
|
4436
|
+
function plannedSlice(entry, plan2) {
|
|
4437
|
+
const slice = Number.isInteger(entry.index) ? plan2[entry.index] : void 0;
|
|
4438
|
+
if (!slice || slice.startFrame !== entry.startFrame || slice.endFrame !== entry.endFrame) {
|
|
4439
|
+
return void 0;
|
|
4440
|
+
}
|
|
4441
|
+
return slice;
|
|
4442
|
+
}
|
|
4443
|
+
function isPlainFileOfSize(path, bytes) {
|
|
4444
|
+
const stat = lstatSync3(path, { throwIfNoEntry: false });
|
|
4445
|
+
return stat !== void 0 && stat.isFile() && stat.size > 0 && stat.size === bytes;
|
|
4446
|
+
}
|
|
4447
|
+
async function validateCompletedSegments(manifest, check) {
|
|
4448
|
+
const ok = /* @__PURE__ */ new Set();
|
|
4449
|
+
if (manifest.planHash !== check.expectedHash || !hasValidMac(manifest, check.key)) return ok;
|
|
4450
|
+
for (const entry of manifest.completed) {
|
|
4451
|
+
const slice = plannedSlice(entry, check.plan);
|
|
4452
|
+
if (!slice) continue;
|
|
4453
|
+
const path = segmentOutputPath(check.segmentDir, slice.index);
|
|
4454
|
+
if (!isPlainFileOfSize(path, entry.bytes)) continue;
|
|
4455
|
+
if (await hashSegmentFile(path) !== entry.sha256) continue;
|
|
4456
|
+
const frames = await check.probeFrames(path);
|
|
4457
|
+
if (frames !== slice.endFrame - slice.startFrame) continue;
|
|
4458
|
+
ok.add(slice.index);
|
|
4459
|
+
}
|
|
4460
|
+
return ok;
|
|
4461
|
+
}
|
|
4462
|
+
|
|
4321
4463
|
// src/services/render/segmentRecycle.ts
|
|
4322
4464
|
var DEFAULT_SEGMENT_BROWSER_RECYCLE = 3;
|
|
4323
4465
|
function resolveSegmentBrowserRecycle(env) {
|
|
@@ -4335,7 +4477,7 @@ function isTargetLossError(error) {
|
|
|
4335
4477
|
// src/services/render/stages/captureStreamingStage.ts
|
|
4336
4478
|
import { mkdtemp, writeFile } from "node:fs/promises";
|
|
4337
4479
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
4338
|
-
import { join as
|
|
4480
|
+
import { join as join11 } from "node:path";
|
|
4339
4481
|
import {
|
|
4340
4482
|
DrawElementVerificationError,
|
|
4341
4483
|
captureFrameToBuffer,
|
|
@@ -4558,11 +4700,11 @@ async function verifyDrawElementSample(session, idx, buf, ctx) {
|
|
|
4558
4700
|
return;
|
|
4559
4701
|
}
|
|
4560
4702
|
if (db < verifyMinDb) {
|
|
4561
|
-
const dumpDir = await mkdtemp(
|
|
4703
|
+
const dumpDir = await mkdtemp(join11(tmpdir2(), "hf-de-verify-fail-")).catch(() => null);
|
|
4562
4704
|
if (dumpDir) {
|
|
4563
4705
|
await Promise.all([
|
|
4564
|
-
writeFile(
|
|
4565
|
-
writeFile(
|
|
4706
|
+
writeFile(join11(dumpDir, `frame-${idx}-de.jpg`), buf),
|
|
4707
|
+
writeFile(join11(dumpDir, `frame-${idx}-truth.jpg`), truth)
|
|
4566
4708
|
]).catch(() => {
|
|
4567
4709
|
});
|
|
4568
4710
|
}
|
|
@@ -5132,9 +5274,6 @@ async function runCaptureStreamingStage(input) {
|
|
|
5132
5274
|
}
|
|
5133
5275
|
|
|
5134
5276
|
// src/services/render/stages/captureSegmentedStage.ts
|
|
5135
|
-
function segmentOutputPath(segmentDir, index) {
|
|
5136
|
-
return join10(segmentDir, `segment_${String(index).padStart(5, "0")}.mp4`);
|
|
5137
|
-
}
|
|
5138
5277
|
function segmentEncoderOptions(base, segment) {
|
|
5139
5278
|
return {
|
|
5140
5279
|
...base,
|
|
@@ -5232,7 +5371,8 @@ async function captureSegmentToEncoder(ctx, segment) {
|
|
|
5232
5371
|
path: segmentPath,
|
|
5233
5372
|
// Recorded so resume can prove the file on disk is the one that
|
|
5234
5373
|
// finished; absent only in unit tests, whose fake encoder writes none.
|
|
5235
|
-
bytes:
|
|
5374
|
+
bytes: existsSync8(segmentPath) ? statSync4(segmentPath).size : 0,
|
|
5375
|
+
sha256: existsSync8(segmentPath) ? await hashSegmentFile(segmentPath) : ""
|
|
5236
5376
|
});
|
|
5237
5377
|
return encodeResult;
|
|
5238
5378
|
} finally {
|
|
@@ -5466,8 +5606,8 @@ async function runCaptureSegmentedStage(input) {
|
|
|
5466
5606
|
const { log, dedupPerfs, assertNotAborted } = input;
|
|
5467
5607
|
const deps = { ...DEFAULT_DEPS, ...input.deps };
|
|
5468
5608
|
const segments = planSegments(input.totalFrames, input.segmentFrames);
|
|
5469
|
-
const segmentDir = input.segmentDir ??
|
|
5470
|
-
|
|
5609
|
+
const segmentDir = input.segmentDir ?? join12(input.workDir, "segments");
|
|
5610
|
+
mkdirSync4(segmentDir, { recursive: true });
|
|
5471
5611
|
const skip = input.completedSegments ?? /* @__PURE__ */ new Set();
|
|
5472
5612
|
const pending = segments.filter((s) => !skip.has(s.index));
|
|
5473
5613
|
for (const index of skip) log.info("[Render] segment skipped (resume)", { index });
|
|
@@ -5622,7 +5762,7 @@ function startRenderEtaGuard(options) {
|
|
|
5622
5762
|
}
|
|
5623
5763
|
|
|
5624
5764
|
// src/services/render/captureCost.ts
|
|
5625
|
-
import { join as
|
|
5765
|
+
import { join as join13 } from "node:path";
|
|
5626
5766
|
import { fpsToNumber as fpsToNumber4 } from "@hyperframes/core";
|
|
5627
5767
|
import {
|
|
5628
5768
|
calculateOptimalWorkers,
|
|
@@ -5875,7 +6015,7 @@ async function runCaptureCalibration(input) {
|
|
|
5875
6015
|
});
|
|
5876
6016
|
let calibration;
|
|
5877
6017
|
try {
|
|
5878
|
-
calibration = await runOneCalibration(
|
|
6018
|
+
calibration = await runOneCalibration(join13(workDir, "capture-calibration"), calibrationCfg);
|
|
5879
6019
|
} catch (error) {
|
|
5880
6020
|
const shouldFallback = !forceScreenshot && shouldFallbackToScreenshotAfterCalibrationError(error);
|
|
5881
6021
|
if (!shouldFallback) {
|
|
@@ -5909,7 +6049,7 @@ async function runCaptureCalibration(input) {
|
|
|
5909
6049
|
const screenshotCfg = createCaptureCalibrationConfig({ ...cfg, forceScreenshot: true });
|
|
5910
6050
|
try {
|
|
5911
6051
|
calibration = await runOneCalibration(
|
|
5912
|
-
|
|
6052
|
+
join13(workDir, "capture-calibration-screenshot"),
|
|
5913
6053
|
screenshotCfg
|
|
5914
6054
|
);
|
|
5915
6055
|
} catch (fallbackError) {
|
|
@@ -5973,8 +6113,8 @@ function checkPageNeverReady(input) {
|
|
|
5973
6113
|
}
|
|
5974
6114
|
|
|
5975
6115
|
// src/services/render/deferredVideoFrames.ts
|
|
5976
|
-
import { mkdirSync as
|
|
5977
|
-
import { dirname as dirname5, join as
|
|
6116
|
+
import { mkdirSync as mkdirSync5, rmSync as rmSync7 } from "node:fs";
|
|
6117
|
+
import { dirname as dirname5, join as join14 } from "node:path";
|
|
5978
6118
|
import {
|
|
5979
6119
|
createFrameLookupTable,
|
|
5980
6120
|
extractVideoFramesRange,
|
|
@@ -6019,7 +6159,7 @@ async function extractDeferredFrames(input) {
|
|
|
6019
6159
|
const shown = shownDeferredFrameIndexes(input, input.frames, input.fps);
|
|
6020
6160
|
return Promise.all(
|
|
6021
6161
|
deferred.map(async (video) => {
|
|
6022
|
-
const outputDir =
|
|
6162
|
+
const outputDir = join14(input.outputRoot, mediaIdPathSegment2(video.videoId));
|
|
6023
6163
|
const indexes = [...shown.get(video.videoId) ?? []].sort((a, b) => a - b);
|
|
6024
6164
|
if (indexes.length === 0) {
|
|
6025
6165
|
return { ...video, outputDir, framePaths: /* @__PURE__ */ new Map(), ownedByLookup: false };
|
|
@@ -6075,7 +6215,7 @@ async function extractAllDeferredFrames(extracted, input) {
|
|
|
6075
6215
|
maxTransientRetries: input.maxTransientRetries,
|
|
6076
6216
|
onRetry: () => {
|
|
6077
6217
|
rmSync7(video.outputDir, { recursive: true, force: true });
|
|
6078
|
-
|
|
6218
|
+
mkdirSync5(video.outputDir, { recursive: true });
|
|
6079
6219
|
}
|
|
6080
6220
|
}
|
|
6081
6221
|
);
|
|
@@ -6166,14 +6306,14 @@ async function measureLocalShownBoxes(page, videos, fps, duration, log) {
|
|
|
6166
6306
|
}
|
|
6167
6307
|
|
|
6168
6308
|
// src/services/render/segmentVideoFrames.ts
|
|
6169
|
-
import { mkdirSync as
|
|
6170
|
-
import { join as
|
|
6309
|
+
import { mkdirSync as mkdirSync6, rmSync as rmSync8 } from "node:fs";
|
|
6310
|
+
import { join as join15 } from "node:path";
|
|
6171
6311
|
import {
|
|
6172
6312
|
createFrameLookupTable as createFrameLookupTable2,
|
|
6173
6313
|
createVideoFrameInjector
|
|
6174
6314
|
} from "@hyperframes/engine";
|
|
6175
6315
|
function segmentFramesDir(rootDir, index) {
|
|
6176
|
-
return
|
|
6316
|
+
return join15(rootDir, "segment-frames", `segment_${String(index).padStart(5, "0")}`);
|
|
6177
6317
|
}
|
|
6178
6318
|
function createSegmentVideoFrames(input) {
|
|
6179
6319
|
const extractFrames = input.extractFrames ?? extractDeferredFrames;
|
|
@@ -6204,7 +6344,7 @@ function createSegmentVideoFrames(input) {
|
|
|
6204
6344
|
let onDemandCalls = 0;
|
|
6205
6345
|
const onDemandHook = () => Object.assign(
|
|
6206
6346
|
async (page, time, heldVideoTime) => {
|
|
6207
|
-
const dir =
|
|
6347
|
+
const dir = join15(
|
|
6208
6348
|
input.rootDir,
|
|
6209
6349
|
"segment-frames",
|
|
6210
6350
|
`on-demand_${String(onDemandCalls++).padStart(5, "0")}`
|
|
@@ -6221,11 +6361,11 @@ function createSegmentVideoFrames(input) {
|
|
|
6221
6361
|
);
|
|
6222
6362
|
return {
|
|
6223
6363
|
async forFrames(frames, name) {
|
|
6224
|
-
const dir =
|
|
6364
|
+
const dir = join15(input.rootDir, "segment-frames", name);
|
|
6225
6365
|
const release = () => rmSync8(dir, { recursive: true, force: true });
|
|
6226
6366
|
try {
|
|
6227
6367
|
release();
|
|
6228
|
-
|
|
6368
|
+
mkdirSync6(dir, { recursive: true });
|
|
6229
6369
|
const table = await tableFor([...frames], dir);
|
|
6230
6370
|
return { injector: () => createVideoFrameInjector(table, input.injectorOptions), release };
|
|
6231
6371
|
} catch (error) {
|
|
@@ -6254,7 +6394,7 @@ function createSegmentVideoFrames(input) {
|
|
|
6254
6394
|
folder = dir;
|
|
6255
6395
|
try {
|
|
6256
6396
|
rmSync8(dir, { recursive: true, force: true });
|
|
6257
|
-
|
|
6397
|
+
mkdirSync6(dir, { recursive: true });
|
|
6258
6398
|
injector = await injectorFor(
|
|
6259
6399
|
Array.from(
|
|
6260
6400
|
{ length: segment.endFrame - segment.startFrame },
|
|
@@ -6274,7 +6414,7 @@ function createSegmentVideoFrames(input) {
|
|
|
6274
6414
|
|
|
6275
6415
|
// src/services/render/videoFrameWindow.ts
|
|
6276
6416
|
import { readdirSync as readdirSync3, statSync as statSync5 } from "node:fs";
|
|
6277
|
-
import { join as
|
|
6417
|
+
import { join as join16 } from "node:path";
|
|
6278
6418
|
function shouldWindowVideoFrames(args) {
|
|
6279
6419
|
return args.segmented && args.env.HF_VIDEO_FRAME_WINDOW?.trim().toLowerCase() === "true";
|
|
6280
6420
|
}
|
|
@@ -6287,7 +6427,7 @@ function directoryBytes(path) {
|
|
|
6287
6427
|
return 0;
|
|
6288
6428
|
}
|
|
6289
6429
|
for (const entry of entries) {
|
|
6290
|
-
const child3 =
|
|
6430
|
+
const child3 = join16(path, entry.name);
|
|
6291
6431
|
try {
|
|
6292
6432
|
bytes += entry.isDirectory() ? directoryBytes(child3) : statSync5(child3).size;
|
|
6293
6433
|
} catch {
|
|
@@ -6305,7 +6445,7 @@ function trackSegmentFramePeak(frames, rootDir, onPeak) {
|
|
|
6305
6445
|
...worker,
|
|
6306
6446
|
async prepare(segment) {
|
|
6307
6447
|
await worker.prepare(segment);
|
|
6308
|
-
const held = directoryBytes(
|
|
6448
|
+
const held = directoryBytes(join16(rootDir, "segment-frames"));
|
|
6309
6449
|
if (held > peak) {
|
|
6310
6450
|
peak = held;
|
|
6311
6451
|
onPeak(peak);
|
|
@@ -6316,95 +6456,6 @@ function trackSegmentFramePeak(frames, rootDir, onPeak) {
|
|
|
6316
6456
|
};
|
|
6317
6457
|
}
|
|
6318
6458
|
|
|
6319
|
-
// src/services/render/segmentManifest.ts
|
|
6320
|
-
import { createHash as createHash2 } from "node:crypto";
|
|
6321
|
-
import { existsSync as existsSync8, mkdirSync as mkdirSync6, readFileSync as readFileSync4, statSync as statSync6, writeFileSync as writeFileSync3 } from "node:fs";
|
|
6322
|
-
import { join as join15 } from "node:path";
|
|
6323
|
-
import { renameWithRetry as renameWithRetry2 } from "@hyperframes/engine";
|
|
6324
|
-
var MANIFEST_FILENAME = "segments.json";
|
|
6325
|
-
function computeSegmentPlanHash(input) {
|
|
6326
|
-
const ordered = [
|
|
6327
|
-
input.compositionHash,
|
|
6328
|
-
input.cliVersion,
|
|
6329
|
-
String(input.totalFrames),
|
|
6330
|
-
String(input.segmentFrames),
|
|
6331
|
-
`${input.fps.num}/${input.fps.den}`,
|
|
6332
|
-
`${input.width}x${input.height}`,
|
|
6333
|
-
input.codec,
|
|
6334
|
-
input.preset,
|
|
6335
|
-
input.quality === void 0 ? "" : String(input.quality),
|
|
6336
|
-
input.bitrate ?? "",
|
|
6337
|
-
input.pixelFormat ?? "",
|
|
6338
|
-
input.imageFormat,
|
|
6339
|
-
input.useGpu ? "gpu" : "cpu",
|
|
6340
|
-
`${input.outputWidth}x${input.outputHeight}`,
|
|
6341
|
-
input.motionBlur,
|
|
6342
|
-
input.pageMotionBlur ?? "",
|
|
6343
|
-
input.captureQuality === void 0 ? "" : String(input.captureQuality)
|
|
6344
|
-
];
|
|
6345
|
-
const delivery = [input.maxBitrate, input.bufferSize, input.gopSize].map((v) => v ?? "");
|
|
6346
|
-
if (delivery.some((v) => v !== "")) ordered.push(...delivery.map(String));
|
|
6347
|
-
return createHash2("sha256").update(ordered.join(" ")).digest("hex").slice(0, 16);
|
|
6348
|
-
}
|
|
6349
|
-
function segmentDirFor(projectRendersDir, planHash) {
|
|
6350
|
-
return join15(projectRendersDir, ".hf-segments", planHash);
|
|
6351
|
-
}
|
|
6352
|
-
function hasNumber(value, key) {
|
|
6353
|
-
return key in value && typeof Reflect.get(value, key) === "number";
|
|
6354
|
-
}
|
|
6355
|
-
function hasString(value, key) {
|
|
6356
|
-
return key in value && typeof Reflect.get(value, key) === "string";
|
|
6357
|
-
}
|
|
6358
|
-
function isEntry(value) {
|
|
6359
|
-
if (typeof value !== "object" || value === null) return false;
|
|
6360
|
-
return hasNumber(value, "index") && hasNumber(value, "startFrame") && hasNumber(value, "endFrame") && hasString(value, "path") && hasNumber(value, "bytes") && hasString(value, "completedAt");
|
|
6361
|
-
}
|
|
6362
|
-
function isManifest(value) {
|
|
6363
|
-
if (typeof value !== "object" || value === null) return false;
|
|
6364
|
-
const completed = Reflect.get(value, "completed");
|
|
6365
|
-
return Reflect.get(value, "version") === 1 && hasString(value, "planHash") && hasNumber(value, "totalFrames") && hasNumber(value, "segmentFrames") && Array.isArray(completed) && completed.every(isEntry);
|
|
6366
|
-
}
|
|
6367
|
-
function readSegmentManifest(segmentDir) {
|
|
6368
|
-
const path = join15(segmentDir, MANIFEST_FILENAME);
|
|
6369
|
-
if (!existsSync8(path)) return null;
|
|
6370
|
-
try {
|
|
6371
|
-
const parsed = JSON.parse(readFileSync4(path, "utf-8"));
|
|
6372
|
-
return isManifest(parsed) ? parsed : null;
|
|
6373
|
-
} catch {
|
|
6374
|
-
return null;
|
|
6375
|
-
}
|
|
6376
|
-
}
|
|
6377
|
-
function writeSegmentManifest(segmentDir, manifest) {
|
|
6378
|
-
mkdirSync6(segmentDir, { recursive: true });
|
|
6379
|
-
const tmp = join15(segmentDir, `${MANIFEST_FILENAME}.${process.pid}.tmp`);
|
|
6380
|
-
writeFileSync3(tmp, JSON.stringify(manifest, null, 2), "utf-8");
|
|
6381
|
-
renameWithRetry2(tmp, join15(segmentDir, MANIFEST_FILENAME));
|
|
6382
|
-
}
|
|
6383
|
-
async function probeSegmentFrameCount(path, probe) {
|
|
6384
|
-
try {
|
|
6385
|
-
const meta = await probe(path);
|
|
6386
|
-
if (!Number.isFinite(meta.videoStreamDurationSeconds) || !Number.isFinite(meta.fps))
|
|
6387
|
-
return null;
|
|
6388
|
-
if (meta.fps <= 0) return null;
|
|
6389
|
-
return Math.round(meta.videoStreamDurationSeconds * meta.fps);
|
|
6390
|
-
} catch {
|
|
6391
|
-
return null;
|
|
6392
|
-
}
|
|
6393
|
-
}
|
|
6394
|
-
async function validateCompletedSegments(manifest, expectedHash, probeFrames) {
|
|
6395
|
-
const ok = /* @__PURE__ */ new Set();
|
|
6396
|
-
if (manifest.planHash !== expectedHash) return ok;
|
|
6397
|
-
for (const entry of manifest.completed) {
|
|
6398
|
-
if (!existsSync8(entry.path)) continue;
|
|
6399
|
-
const size = statSync6(entry.path).size;
|
|
6400
|
-
if (size <= 0 || size !== entry.bytes) continue;
|
|
6401
|
-
const frames = await probeFrames(entry.path);
|
|
6402
|
-
if (frames !== entry.endFrame - entry.startFrame) continue;
|
|
6403
|
-
ok.add(entry.index);
|
|
6404
|
-
}
|
|
6405
|
-
return ok;
|
|
6406
|
-
}
|
|
6407
|
-
|
|
6408
6459
|
// src/services/render/hdrMode.ts
|
|
6409
6460
|
import {
|
|
6410
6461
|
analyzeCompositionHdr,
|
|
@@ -7001,14 +7052,14 @@ function requireOutputDimensions(expected, width, height) {
|
|
|
7001
7052
|
|
|
7002
7053
|
// src/services/render/stages/compileStage.ts
|
|
7003
7054
|
import { existsSync as existsSync13, writeFileSync as writeFileSync5 } from "node:fs";
|
|
7004
|
-
import { join as
|
|
7055
|
+
import { join as join22, relative as relative4 } from "node:path";
|
|
7005
7056
|
import { privateCacheRoot } from "@hyperframes/engine";
|
|
7006
7057
|
import { suggestMatchingPreset } from "@hyperframes/core";
|
|
7007
7058
|
import { extractStandaloneEntryFromIndex, isTemplateEntry } from "@hyperframes/core/compiler";
|
|
7008
7059
|
import { readTextFile as readTextFile2 } from "@hyperframes/parsers/asset-resolution";
|
|
7009
7060
|
|
|
7010
7061
|
// src/services/compositionSizeLimit.ts
|
|
7011
|
-
import { statSync as
|
|
7062
|
+
import { statSync as statSync6 } from "node:fs";
|
|
7012
7063
|
var MAX_COMPOSITION_HTML_BYTES = 16 * 1024 * 1024;
|
|
7013
7064
|
var COMPOSITION_TOO_LARGE = "COMPOSITION_TOO_LARGE";
|
|
7014
7065
|
var megabytes = (bytes) => `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
@@ -7084,7 +7135,7 @@ var CompositionExpansionBudget = class {
|
|
|
7084
7135
|
function assertCompositionFileSize(path, file) {
|
|
7085
7136
|
let bytes;
|
|
7086
7137
|
try {
|
|
7087
|
-
const stats =
|
|
7138
|
+
const stats = statSync6(path);
|
|
7088
7139
|
if (!stats.isFile()) return;
|
|
7089
7140
|
bytes = stats.size;
|
|
7090
7141
|
} catch {
|
|
@@ -7109,19 +7160,19 @@ import {
|
|
|
7109
7160
|
stylesheetLinkMatches
|
|
7110
7161
|
} from "@hyperframes/parsers/css-url-scans";
|
|
7111
7162
|
import { createHash as createHash6 } from "node:crypto";
|
|
7112
|
-
import { createReadStream as
|
|
7113
|
-
import { join as
|
|
7163
|
+
import { createReadStream as createReadStream3, existsSync as existsSync12, mkdirSync as mkdirSync9, readFileSync as readFileSync8 } from "fs";
|
|
7164
|
+
import { join as join21, dirname as dirname9, resolve as resolve8, basename as basename6, relative as relative3, sep as sep4 } from "path";
|
|
7114
7165
|
import { parseHTML as parseHTML5 } from "linkedom";
|
|
7115
7166
|
|
|
7116
7167
|
// src/services/bundledScripts.ts
|
|
7117
7168
|
import { existsSync as existsSync9, readFileSync as readFileSync5 } from "node:fs";
|
|
7118
|
-
import { join as
|
|
7169
|
+
import { join as join17 } from "node:path";
|
|
7119
7170
|
import { gsapCdnDist } from "@hyperframes/core/gsap-cdn";
|
|
7120
7171
|
var GSAP_VENDOR_DIR_ENV = "HYPERFRAMES_GSAP_VENDOR_DIR";
|
|
7121
7172
|
function bundledScript(url) {
|
|
7122
7173
|
const dir = process.env[GSAP_VENDOR_DIR_ENV];
|
|
7123
7174
|
if (!dir || url !== `${gsapCdnDist()}gsap.min.js`) return null;
|
|
7124
|
-
const file =
|
|
7175
|
+
const file = join17(dir, "gsap.min.js");
|
|
7125
7176
|
return existsSync9(file) ? readFileSync5(file) : null;
|
|
7126
7177
|
}
|
|
7127
7178
|
|
|
@@ -7380,8 +7431,8 @@ import {
|
|
|
7380
7431
|
|
|
7381
7432
|
// src/services/animatedGifPrep.ts
|
|
7382
7433
|
import { createHash as createHash4 } from "node:crypto";
|
|
7383
|
-
import { copyFileSync as copyFileSync2, existsSync as existsSync10, mkdirSync as mkdirSync7, readFileSync as readFileSync6, rmSync as rmSync9, statSync as
|
|
7384
|
-
import { dirname as dirname6, isAbsolute as isAbsolute3, join as
|
|
7434
|
+
import { copyFileSync as copyFileSync2, existsSync as existsSync10, mkdirSync as mkdirSync7, readFileSync as readFileSync6, rmSync as rmSync9, statSync as statSync7 } from "node:fs";
|
|
7435
|
+
import { dirname as dirname6, isAbsolute as isAbsolute3, join as join18, resolve as resolve6 } from "node:path";
|
|
7385
7436
|
import { parseHTML as parseHTML3 } from "linkedom";
|
|
7386
7437
|
import { parseAnimatedGifMetadata } from "@hyperframes/core";
|
|
7387
7438
|
import {
|
|
@@ -7439,7 +7490,7 @@ function resolveLocalImageSourcePath(src, options) {
|
|
|
7439
7490
|
}
|
|
7440
7491
|
function isUsableFile(path) {
|
|
7441
7492
|
try {
|
|
7442
|
-
const stat =
|
|
7493
|
+
const stat = statSync7(path);
|
|
7443
7494
|
return stat.isFile() && stat.size > 0;
|
|
7444
7495
|
} catch {
|
|
7445
7496
|
return false;
|
|
@@ -7634,7 +7685,7 @@ function replaceImageWithVideo(input) {
|
|
|
7634
7685
|
return video;
|
|
7635
7686
|
}
|
|
7636
7687
|
async function prepareAnimatedGifInputs(html, options) {
|
|
7637
|
-
const outputDir = options.outputDir ??
|
|
7688
|
+
const outputDir = options.outputDir ?? join18(options.downloadDir, PREPARED_GIF_SUBDIR);
|
|
7638
7689
|
const outputSrcPrefix = normalizeRelPath(options.outputSrcPrefix ?? PREPARED_GIF_SUBDIR);
|
|
7639
7690
|
const cacheDir = options.cacheDir ?? outputDir;
|
|
7640
7691
|
const { document: document2 } = parseHTML3(html);
|
|
@@ -7661,8 +7712,8 @@ async function prepareAnimatedGifInputs(html, options) {
|
|
|
7661
7712
|
);
|
|
7662
7713
|
const hash = computePreparedGifHash(bytes, loopIterations, padSeconds);
|
|
7663
7714
|
const filename = `${CACHE_SCHEMA}-${hash.slice(0, 24)}.webm`;
|
|
7664
|
-
const cachePath =
|
|
7665
|
-
const outputPath =
|
|
7715
|
+
const cachePath = join18(cacheDir, filename);
|
|
7716
|
+
const outputPath = join18(outputDir, filename);
|
|
7666
7717
|
const outputSrc = `${outputSrcPrefix}/${filename}`;
|
|
7667
7718
|
await ensurePreparedWebm({
|
|
7668
7719
|
sourcePath,
|
|
@@ -7704,10 +7755,10 @@ import {
|
|
|
7704
7755
|
readFileSync as readFileSync7,
|
|
7705
7756
|
readSync as readSync3,
|
|
7706
7757
|
rmSync as rmSync10,
|
|
7707
|
-
statSync as
|
|
7758
|
+
statSync as statSync8,
|
|
7708
7759
|
writeFileSync as writeFileSync4
|
|
7709
7760
|
} from "node:fs";
|
|
7710
|
-
import { dirname as dirname7, join as
|
|
7761
|
+
import { dirname as dirname7, join as join19, resolve as resolve7 } from "node:path";
|
|
7711
7762
|
import { parseHTML as parseHTML4 } from "linkedom";
|
|
7712
7763
|
import { renameWithRetry as renameWithRetry4, runFfmpeg as runFfmpeg3, runFfprobe, urlInputArgs as urlInputArgs3 } from "@hyperframes/engine";
|
|
7713
7764
|
|
|
@@ -7948,7 +7999,7 @@ function resolveImageSource(src, options) {
|
|
|
7948
7999
|
}
|
|
7949
8000
|
function isUsableFile2(path) {
|
|
7950
8001
|
try {
|
|
7951
|
-
return
|
|
8002
|
+
return statSync8(path).size > 0;
|
|
7952
8003
|
} catch {
|
|
7953
8004
|
return false;
|
|
7954
8005
|
}
|
|
@@ -7982,7 +8033,7 @@ async function ensurePreparedJpeg(source, cachePath, outputPath, options) {
|
|
|
7982
8033
|
}
|
|
7983
8034
|
}
|
|
7984
8035
|
async function prepareHeifImageInputs(html, options) {
|
|
7985
|
-
const outputDir = options.outputDir ??
|
|
8036
|
+
const outputDir = options.outputDir ?? join19(options.downloadDir, PREPARED_HEIF_SUBDIR);
|
|
7986
8037
|
const outputSrcPrefix = normalizeRelPath(options.outputSrcPrefix ?? PREPARED_HEIF_SUBDIR);
|
|
7987
8038
|
const cacheDir = options.cacheDir ?? outputDir;
|
|
7988
8039
|
const preparedAssets = /* @__PURE__ */ new Map();
|
|
@@ -8003,7 +8054,7 @@ async function prepareHeifImageInputs(html, options) {
|
|
|
8003
8054
|
await Promise.all(
|
|
8004
8055
|
[...unique].map(
|
|
8005
8056
|
([filename, source]) => withMediaProbeSlot(
|
|
8006
|
-
() => ensurePreparedJpeg(source,
|
|
8057
|
+
() => ensurePreparedJpeg(source, join19(cacheDir, filename), join19(outputDir, filename), options)
|
|
8007
8058
|
).catch((error) => {
|
|
8008
8059
|
if (!options.onFailure) throw error;
|
|
8009
8060
|
failed.add(filename);
|
|
@@ -8015,19 +8066,22 @@ async function prepareHeifImageInputs(html, options) {
|
|
|
8015
8066
|
if (failed.has(filename)) continue;
|
|
8016
8067
|
const outputSrc = `${outputSrcPrefix}/${filename}`;
|
|
8017
8068
|
img.setAttribute("src", outputSrc);
|
|
8018
|
-
preparedAssets.set(outputSrc,
|
|
8019
|
-
preparedImages.push({ sourceSrc: src, outputSrc, outputPath:
|
|
8069
|
+
preparedAssets.set(outputSrc, join19(outputDir, filename));
|
|
8070
|
+
preparedImages.push({ sourceSrc: src, outputSrc, outputPath: join19(outputDir, filename) });
|
|
8020
8071
|
}
|
|
8021
8072
|
return { html: document2.toString(), preparedAssets, preparedImages };
|
|
8022
8073
|
}
|
|
8023
8074
|
|
|
8024
8075
|
// src/services/htmlCompiler.ts
|
|
8025
|
-
import {
|
|
8076
|
+
import {
|
|
8077
|
+
createStudioPositionSeekReapplyScript,
|
|
8078
|
+
htmlHasStudioPositionEdits
|
|
8079
|
+
} from "@hyperframes/studio-server/manual-edits-render-script";
|
|
8026
8080
|
import { getPositionEditsRenderScript } from "@hyperframes/core/runtime/position-edits-render";
|
|
8027
8081
|
|
|
8028
8082
|
// src/services/assetMediaType.ts
|
|
8029
8083
|
import { existsSync as existsSync11 } from "node:fs";
|
|
8030
|
-
import { dirname as dirname8, join as
|
|
8084
|
+
import { dirname as dirname8, join as join20 } from "node:path";
|
|
8031
8085
|
import {
|
|
8032
8086
|
fingerprintElementId,
|
|
8033
8087
|
isHttpUrl as isHttpUrl2,
|
|
@@ -8080,11 +8134,11 @@ function assertAssetMediaTypeProfile(expected, profile, elementIdentity) {
|
|
|
8080
8134
|
]);
|
|
8081
8135
|
}
|
|
8082
8136
|
function mediaAssetRoots(projectDir, compiledDir) {
|
|
8083
|
-
return [projectDir, compiledDir,
|
|
8137
|
+
return [projectDir, compiledDir, join20(dirname8(compiledDir), "downloads")];
|
|
8084
8138
|
}
|
|
8085
8139
|
function dropMediaOutsideProject(input) {
|
|
8086
8140
|
const { projectDir, workDir, composition, log } = input;
|
|
8087
|
-
const compiledDir =
|
|
8141
|
+
const compiledDir = join20(workDir, "compiled");
|
|
8088
8142
|
const roots = mediaAssetRoots(projectDir, compiledDir);
|
|
8089
8143
|
const staysInside = ({ id, src }) => {
|
|
8090
8144
|
if (!src || isHttpUrl2(src)) return true;
|
|
@@ -8435,7 +8489,7 @@ function detectShaderTransitionUsage(html) {
|
|
|
8435
8489
|
async function resolveMediaDuration(src, mediaStart, playbackRate, projectDir, baseDir, downloadDir, tagName, elementIdentity, log, urlByAbsentLocalPath, probes, assetRoot) {
|
|
8436
8490
|
let filePath = src;
|
|
8437
8491
|
if (isHttpUrl(src)) {
|
|
8438
|
-
const remoteDir =
|
|
8492
|
+
const remoteDir = join21(downloadDir, REMOTE_MEDIA_SUBDIR);
|
|
8439
8493
|
if (!existsSync12(remoteDir)) mkdirSync9(remoteDir, { recursive: true });
|
|
8440
8494
|
try {
|
|
8441
8495
|
filePath = await downloadToTemp(src, remoteDir, void 0, void 0, void 0, {
|
|
@@ -8446,7 +8500,7 @@ async function resolveMediaDuration(src, mediaStart, playbackRate, projectDir, b
|
|
|
8446
8500
|
}
|
|
8447
8501
|
} else {
|
|
8448
8502
|
filePath = decodedUrlPath(src);
|
|
8449
|
-
if (!filePath.startsWith("/")) filePath =
|
|
8503
|
+
if (!filePath.startsWith("/")) filePath = join21(baseDir, filePath);
|
|
8450
8504
|
if (escapesAssetRoot(filePath, assetRoot) || isPrivateUnderAssetRoots3(filePath, [projectDir, downloadDir])) {
|
|
8451
8505
|
return { duration: null, resolvedPath: filePath };
|
|
8452
8506
|
}
|
|
@@ -9180,7 +9234,7 @@ async function localizeRemoteMediaSources(html, downloadDir) {
|
|
|
9180
9234
|
const localized = await downloadAndRewriteUrls(
|
|
9181
9235
|
urlSet,
|
|
9182
9236
|
html,
|
|
9183
|
-
|
|
9237
|
+
join21(downloadDir, REMOTE_MEDIA_SUBDIR),
|
|
9184
9238
|
"Remote media download failed",
|
|
9185
9239
|
"Localized remote media source(s)"
|
|
9186
9240
|
);
|
|
@@ -9203,7 +9257,7 @@ async function localizeRemoteImageSources(html, downloadDir) {
|
|
|
9203
9257
|
return downloadAndRewriteUrls(
|
|
9204
9258
|
urlSet,
|
|
9205
9259
|
html,
|
|
9206
|
-
|
|
9260
|
+
join21(downloadDir, REMOTE_MEDIA_SUBDIR),
|
|
9207
9261
|
"Remote image download failed",
|
|
9208
9262
|
"Localized remote image source(s)"
|
|
9209
9263
|
);
|
|
@@ -9216,7 +9270,7 @@ async function localizeRemoteBackgroundImages(html, downloadDir) {
|
|
|
9216
9270
|
return downloadAndRewriteUrls(
|
|
9217
9271
|
urlSet,
|
|
9218
9272
|
html,
|
|
9219
|
-
|
|
9273
|
+
join21(downloadDir, REMOTE_MEDIA_SUBDIR),
|
|
9220
9274
|
"Remote background-image download failed",
|
|
9221
9275
|
"Localized remote background-image(s)",
|
|
9222
9276
|
// Quoted url('..')/url("..") are rewritten by downloadAndRewriteUrls' default
|
|
@@ -9372,7 +9426,7 @@ function localizeFontFaceUrls(html, downloadDir) {
|
|
|
9372
9426
|
return downloadAndRewriteUrls(
|
|
9373
9427
|
collectFontFaceUrls(html),
|
|
9374
9428
|
html,
|
|
9375
|
-
|
|
9429
|
+
join21(downloadDir, REMOTE_MEDIA_SUBDIR),
|
|
9376
9430
|
"Remote font download failed",
|
|
9377
9431
|
"Localized remote font face(s)",
|
|
9378
9432
|
(h, url, relPath) => h.replaceAll(`url(${url})`, `url("${relPath}")`)
|
|
@@ -9382,7 +9436,7 @@ var MAX_LOCAL_FONT_DATA_URI_BYTES = 5 * 1024 * 1024;
|
|
|
9382
9436
|
async function readLocalFont(absPath) {
|
|
9383
9437
|
const chunks = [];
|
|
9384
9438
|
let totalBytes = 0;
|
|
9385
|
-
for await (const chunk of
|
|
9439
|
+
for await (const chunk of createReadStream3(absPath)) {
|
|
9386
9440
|
const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
9387
9441
|
totalBytes += buffer.length;
|
|
9388
9442
|
if (totalBytes > MAX_LOCAL_FONT_DATA_URI_BYTES) {
|
|
@@ -9635,14 +9689,7 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
|
|
|
9635
9689
|
abortSignal: options.abortSignal
|
|
9636
9690
|
});
|
|
9637
9691
|
const assembledHtml = await inlineExternalScripts(coalescedHtml, budget);
|
|
9638
|
-
const
|
|
9639
|
-
'data-hf-studio-path-offset="true"',
|
|
9640
|
-
'data-hf-studio-box-size="true"',
|
|
9641
|
-
'data-hf-studio-rotation="true"',
|
|
9642
|
-
'data-hf-studio-motion="'
|
|
9643
|
-
];
|
|
9644
|
-
const hasPositionEdits = HF_POSITION_ATTRS.some((attr) => assembledHtml.includes(attr));
|
|
9645
|
-
const htmlWithPositionScript = hasPositionEdits ? insertBeforeCloseTag(
|
|
9692
|
+
const htmlWithPositionScript = htmlHasStudioPositionEdits(assembledHtml) ? insertBeforeCloseTag(
|
|
9646
9693
|
assembledHtml,
|
|
9647
9694
|
"body",
|
|
9648
9695
|
`<script>${createStudioPositionSeekReapplyScript()}
|
|
@@ -10142,7 +10189,7 @@ async function recompileWithResolutions(compiled, resolutions, projectDir, downl
|
|
|
10142
10189
|
function animatedGifCacheDir(extractCacheDir) {
|
|
10143
10190
|
try {
|
|
10144
10191
|
const root = extractCacheDir && privateCacheRoot(extractCacheDir);
|
|
10145
|
-
return root ?
|
|
10192
|
+
return root ? join22(root, "animated-gif") : void 0;
|
|
10146
10193
|
} catch {
|
|
10147
10194
|
return void 0;
|
|
10148
10195
|
}
|
|
@@ -10170,10 +10217,10 @@ function resolveEntryHtmlPath(input) {
|
|
|
10170
10217
|
assertCompositionFileSize(path, relative4(projectDir, path));
|
|
10171
10218
|
return readTextFile2(path);
|
|
10172
10219
|
};
|
|
10173
|
-
const htmlPath =
|
|
10220
|
+
const htmlPath = join22(projectDir, entryFile);
|
|
10174
10221
|
const rawEntry = readEntry(htmlPath);
|
|
10175
10222
|
if (entryFile === "index.html" || !isTemplateEntry(rawEntry)) return htmlPath;
|
|
10176
|
-
const projectIndexPath =
|
|
10223
|
+
const projectIndexPath = join22(projectDir, "index.html");
|
|
10177
10224
|
if (!existsSync13(projectIndexPath)) {
|
|
10178
10225
|
throw new Error(
|
|
10179
10226
|
`Template entry file "${entryFile}" requires a project index.html to extract its render shell.`
|
|
@@ -10189,7 +10236,7 @@ function resolveEntryHtmlPath(input) {
|
|
|
10189
10236
|
`Entry file "${entryFile}" is not mounted from index.html via data-composition-src, so it cannot be rendered independently.`
|
|
10190
10237
|
);
|
|
10191
10238
|
}
|
|
10192
|
-
const wrapperPath =
|
|
10239
|
+
const wrapperPath = join22(workDir, "standalone-entry.html");
|
|
10193
10240
|
writeFileSync5(wrapperPath, standaloneHtml, "utf-8");
|
|
10194
10241
|
log.info("Extracted standalone entry from index.html host context", { entryFile });
|
|
10195
10242
|
return wrapperPath;
|
|
@@ -10219,7 +10266,7 @@ async function runCompileStage(input) {
|
|
|
10219
10266
|
const assetRoot = job.config.allowOutsideProjectAssets ? void 0 : projectDir;
|
|
10220
10267
|
const htmlPath = resolveEntryHtmlPath({ projectDir, workDir, entryFile, log, assetRoot });
|
|
10221
10268
|
const compileStart = Date.now();
|
|
10222
|
-
const compiled = await compileForRender(projectDir, htmlPath,
|
|
10269
|
+
const compiled = await compileForRender(projectDir, htmlPath, join22(workDir, "downloads"), {
|
|
10223
10270
|
log,
|
|
10224
10271
|
failClosedFontFetch: failClosedFontFetch === true,
|
|
10225
10272
|
allowSystemFontCapture,
|
|
@@ -10294,7 +10341,7 @@ async function runCompileStage(input) {
|
|
|
10294
10341
|
});
|
|
10295
10342
|
await preflightCompositionAssetMediaTypes({
|
|
10296
10343
|
projectDir,
|
|
10297
|
-
compiledDir:
|
|
10344
|
+
compiledDir: join22(workDir, "compiled"),
|
|
10298
10345
|
composition,
|
|
10299
10346
|
signal: abortSignal
|
|
10300
10347
|
});
|
|
@@ -10342,7 +10389,7 @@ async function runCompileStage(input) {
|
|
|
10342
10389
|
|
|
10343
10390
|
// src/services/render/stages/probeStage.ts
|
|
10344
10391
|
import { createHash as createHash7 } from "node:crypto";
|
|
10345
|
-
import { basename as basename7, join as
|
|
10392
|
+
import { basename as basename7, join as join23 } from "node:path";
|
|
10346
10393
|
import { parseHTML as parseHTML6 } from "linkedom";
|
|
10347
10394
|
import {
|
|
10348
10395
|
closeCaptureSession as closeCaptureSession4,
|
|
@@ -10656,7 +10703,7 @@ async function runProbeStage(input) {
|
|
|
10656
10703
|
});
|
|
10657
10704
|
fileServer = await createFileServer({
|
|
10658
10705
|
projectDir,
|
|
10659
|
-
compiledDir:
|
|
10706
|
+
compiledDir: join23(workDir, "compiled"),
|
|
10660
10707
|
port: 0,
|
|
10661
10708
|
preHeadScripts: [VIRTUAL_TIME_SHIM],
|
|
10662
10709
|
fps: job.config.fps,
|
|
@@ -10693,7 +10740,7 @@ async function runProbeStage(input) {
|
|
|
10693
10740
|
log.info("Creating capture session...", { attempt, maxAttempts: PROBE_MAX_ATTEMPTS });
|
|
10694
10741
|
probeSession = await createCaptureSession4(
|
|
10695
10742
|
fileServer.url,
|
|
10696
|
-
|
|
10743
|
+
join23(workDir, "probe"),
|
|
10697
10744
|
captureOpts,
|
|
10698
10745
|
null,
|
|
10699
10746
|
probeCfg
|
|
@@ -10778,7 +10825,7 @@ async function runProbeStage(input) {
|
|
|
10778
10825
|
});
|
|
10779
10826
|
probeSession = await createCaptureSession4(
|
|
10780
10827
|
fileServer.url,
|
|
10781
|
-
|
|
10828
|
+
join23(workDir, "probe-screenshot"),
|
|
10782
10829
|
captureOpts,
|
|
10783
10830
|
null,
|
|
10784
10831
|
{ ...probeCfg, forceScreenshot: true }
|
|
@@ -10816,7 +10863,7 @@ async function runProbeStage(input) {
|
|
|
10816
10863
|
compiled,
|
|
10817
10864
|
resolutions,
|
|
10818
10865
|
projectDir,
|
|
10819
|
-
|
|
10866
|
+
join23(workDir, "downloads"),
|
|
10820
10867
|
job.config.allowOutsideProjectAssets ? void 0 : projectDir,
|
|
10821
10868
|
{ includeScripts: job.config.includeOutsideScripts }
|
|
10822
10869
|
);
|
|
@@ -11016,7 +11063,7 @@ async function runProbeStage(input) {
|
|
|
11016
11063
|
});
|
|
11017
11064
|
await preflightCompositionAssetMediaTypes({
|
|
11018
11065
|
projectDir,
|
|
11019
|
-
compiledDir:
|
|
11066
|
+
compiledDir: join23(workDir, "compiled"),
|
|
11020
11067
|
composition,
|
|
11021
11068
|
signal: abortSignal
|
|
11022
11069
|
});
|
|
@@ -11184,7 +11231,7 @@ function validateDistributedDuration(input) {
|
|
|
11184
11231
|
|
|
11185
11232
|
// src/services/render/stages/extractVideosStage.ts
|
|
11186
11233
|
import { existsSync as existsSync14 } from "node:fs";
|
|
11187
|
-
import { join as
|
|
11234
|
+
import { join as join24 } from "node:path";
|
|
11188
11235
|
import {
|
|
11189
11236
|
classifyVideoExtractionError,
|
|
11190
11237
|
createFrameLookupTable as createFrameLookupTable3,
|
|
@@ -11548,7 +11595,7 @@ async function runExtractVideosStage(input) {
|
|
|
11548
11595
|
// because short boundary counts can differ by one frame.
|
|
11549
11596
|
{
|
|
11550
11597
|
fps: job.config.fps,
|
|
11551
|
-
outputDir:
|
|
11598
|
+
outputDir: join24(compiledDir, "__hyperframes_video_frames"),
|
|
11552
11599
|
format: job.config.videoFrameFormat ?? "auto",
|
|
11553
11600
|
toneMapHdrToSdr: rendersSdrOnly(job.config, composition),
|
|
11554
11601
|
timelineEnd: composition.duration,
|
|
@@ -11556,7 +11603,7 @@ async function runExtractVideosStage(input) {
|
|
|
11556
11603
|
collectProbeFailures: extractionPolicy.failureMode === "enforce",
|
|
11557
11604
|
deferRangeExtraction,
|
|
11558
11605
|
shownBoxes,
|
|
11559
|
-
contentKeyedDirs: [
|
|
11606
|
+
contentKeyedDirs: [join24(compiledDir, REMOTE_MEDIA_SUBDIR)],
|
|
11560
11607
|
urlByAbsentLocalPath,
|
|
11561
11608
|
assetRoots,
|
|
11562
11609
|
onProgress: ({ planned = 0, done = 0 }) => {
|
|
@@ -11648,7 +11695,7 @@ async function remoteProbeSource(video, input) {
|
|
|
11648
11695
|
if (!isPublicHttpsUrl(video.src)) return null;
|
|
11649
11696
|
if (!resolveRestrictPageNetwork()) return video.src;
|
|
11650
11697
|
if (!video.hasAudio || video.hidden) return null;
|
|
11651
|
-
const downloadDir = input.downloadDir ??
|
|
11698
|
+
const downloadDir = input.downloadDir ?? join24(input.compiledDir, REMOTE_MEDIA_SUBDIR);
|
|
11652
11699
|
try {
|
|
11653
11700
|
return await downloadToTemp2(video.src, downloadDir, void 0, input.signal, void 0, {
|
|
11654
11701
|
onTelemetry: writeUrlDownloadTelemetry2
|
|
@@ -11773,7 +11820,7 @@ async function planVideoLayerPassthrough(input) {
|
|
|
11773
11820
|
|
|
11774
11821
|
// src/services/render/stages/audioStage.ts
|
|
11775
11822
|
import { existsSync as existsSync17 } from "node:fs";
|
|
11776
|
-
import { join as
|
|
11823
|
+
import { join as join27 } from "node:path";
|
|
11777
11824
|
import {
|
|
11778
11825
|
MIXED_AUDIO_FILENAME,
|
|
11779
11826
|
audioFailureDiagnostics,
|
|
@@ -11785,7 +11832,7 @@ import {
|
|
|
11785
11832
|
|
|
11786
11833
|
// src/services/render/audioDeliveryLimit.ts
|
|
11787
11834
|
import { existsSync as existsSync16 } from "node:fs";
|
|
11788
|
-
import { dirname as dirname11, join as
|
|
11835
|
+
import { dirname as dirname11, join as join26 } from "node:path";
|
|
11789
11836
|
import {
|
|
11790
11837
|
applyAudioFxChain,
|
|
11791
11838
|
describeFfmpegFailure as describeFfmpegFailure3,
|
|
@@ -11795,7 +11842,7 @@ import {
|
|
|
11795
11842
|
|
|
11796
11843
|
// src/services/render/audioPadTrim.ts
|
|
11797
11844
|
import { spawn } from "node:child_process";
|
|
11798
|
-
import { dirname as dirname10, join as
|
|
11845
|
+
import { dirname as dirname10, join as join25 } from "node:path";
|
|
11799
11846
|
import {
|
|
11800
11847
|
DEFAULT_CONFIG,
|
|
11801
11848
|
describeFfmpegFailure as describeFfmpegFailure2,
|
|
@@ -12076,7 +12123,7 @@ async function constrainAacTruePeak(input) {
|
|
|
12076
12123
|
}
|
|
12077
12124
|
async function cutSource(input, scratchDir, attenuationDb) {
|
|
12078
12125
|
if (!input.sourcePath || !input.rewriteSource) return true;
|
|
12079
|
-
const cutPath =
|
|
12126
|
+
const cutPath = join25(scratchDir, "source.wav");
|
|
12080
12127
|
try {
|
|
12081
12128
|
const result = await input.rewriteSource(input.sourcePath, cutPath, gainFilter(attenuationDb));
|
|
12082
12129
|
if (!result.success) throw new Error(result.error);
|
|
@@ -12091,7 +12138,7 @@ async function enforceAacTruePeak(input) {
|
|
|
12091
12138
|
let scratchDir;
|
|
12092
12139
|
try {
|
|
12093
12140
|
scratchDir = createStagingDir3(dirname10(input.audioPath), ".true-peak-");
|
|
12094
|
-
const correctedPath =
|
|
12141
|
+
const correctedPath = join25(scratchDir, "audio.m4a");
|
|
12095
12142
|
const measurements = [];
|
|
12096
12143
|
let attenuationDb = 0;
|
|
12097
12144
|
let sourcePeakDbfs;
|
|
@@ -12311,7 +12358,7 @@ async function limitDeliveryPeaks(input, deps = {
|
|
|
12311
12358
|
const peak = await deps.measure(audioPath, { timeoutMs, signal });
|
|
12312
12359
|
if (peak <= AAC_DELIVERY_TRUE_PEAK_DBFS) return { success: true };
|
|
12313
12360
|
const alternating = ["a", "b"].map(
|
|
12314
|
-
(k) =>
|
|
12361
|
+
(k) => join26(dirname11(sourcePath), `audio-source-limited-${k}.wav`)
|
|
12315
12362
|
);
|
|
12316
12363
|
let encodedFrom;
|
|
12317
12364
|
let ceiling = AAC_DELIVERY_TRUE_PEAK_DBFS;
|
|
@@ -12384,7 +12431,7 @@ function runAudioStage(input) {
|
|
|
12384
12431
|
}
|
|
12385
12432
|
async function runAudioStageScoped(input) {
|
|
12386
12433
|
const stageStart = Date.now();
|
|
12387
|
-
const pcmSourcePath =
|
|
12434
|
+
const pcmSourcePath = join27(input.workDir, "audio-source.wav");
|
|
12388
12435
|
const duration = input.totalFrames * input.fps.den / input.fps.num;
|
|
12389
12436
|
let deliverySourcePath;
|
|
12390
12437
|
try {
|
|
@@ -12449,7 +12496,7 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath) {
|
|
|
12449
12496
|
assertNotAborted,
|
|
12450
12497
|
log
|
|
12451
12498
|
} = input;
|
|
12452
|
-
const audioOutputPath =
|
|
12499
|
+
const audioOutputPath = join27(workDir, MIXED_AUDIO_FILENAME);
|
|
12453
12500
|
let hasAudio = false;
|
|
12454
12501
|
let audioError;
|
|
12455
12502
|
let audioFailures;
|
|
@@ -12530,7 +12577,7 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath) {
|
|
|
12530
12577
|
|
|
12531
12578
|
// src/services/render/stages/captureStage.ts
|
|
12532
12579
|
import { existsSync as existsSync18, readdirSync as readdirSync4, statfsSync as statfsSync2 } from "node:fs";
|
|
12533
|
-
import { join as
|
|
12580
|
+
import { join as join28 } from "node:path";
|
|
12534
12581
|
import {
|
|
12535
12582
|
classifyCaptureFailure as classifyCaptureFailure2,
|
|
12536
12583
|
frameFileExtension,
|
|
@@ -12603,13 +12650,13 @@ function measureCaptureFrameBytes(workDir, framesDir) {
|
|
|
12603
12650
|
if (!existsSync18(workDir)) return total;
|
|
12604
12651
|
for (const attempt of readdirSync4(workDir)) {
|
|
12605
12652
|
if (/^retry-\d+-batch-\d+-worker-\d+$/.test(attempt)) {
|
|
12606
|
-
total += sampleDirectoryBytes(
|
|
12653
|
+
total += sampleDirectoryBytes(join28(workDir, attempt));
|
|
12607
12654
|
continue;
|
|
12608
12655
|
}
|
|
12609
12656
|
if (!/^capture-attempt-\d+$/.test(attempt)) continue;
|
|
12610
|
-
const attemptDir =
|
|
12657
|
+
const attemptDir = join28(workDir, attempt);
|
|
12611
12658
|
for (const name of readdirSync4(attemptDir)) {
|
|
12612
|
-
if (/^worker-\d+$/.test(name)) total += sampleDirectoryBytes(
|
|
12659
|
+
if (/^worker-\d+$/.test(name)) total += sampleDirectoryBytes(join28(attemptDir, name));
|
|
12613
12660
|
}
|
|
12614
12661
|
}
|
|
12615
12662
|
return total;
|
|
@@ -12908,7 +12955,7 @@ async function captureSessionFrames(session, { input, rangeStart, rangeEnd, resu
|
|
|
12908
12955
|
|
|
12909
12956
|
// src/services/render/stages/captureHdrStage.ts
|
|
12910
12957
|
import { existsSync as existsSync20, mkdirSync as mkdirSync10 } from "node:fs";
|
|
12911
|
-
import { join as
|
|
12958
|
+
import { join as join32 } from "node:path";
|
|
12912
12959
|
import {
|
|
12913
12960
|
closeCaptureSession as closeCaptureSession7,
|
|
12914
12961
|
cloneCaptureWarnings as cloneCaptureWarnings2,
|
|
@@ -12980,7 +13027,7 @@ function createHdrImageTransferCache(options = {}) {
|
|
|
12980
13027
|
}
|
|
12981
13028
|
|
|
12982
13029
|
// src/services/render/stages/captureHdrSequentialLoop.ts
|
|
12983
|
-
import { join as
|
|
13030
|
+
import { join as join29 } from "node:path";
|
|
12984
13031
|
import {
|
|
12985
13032
|
TRANSITIONS,
|
|
12986
13033
|
crossfade
|
|
@@ -13105,7 +13152,7 @@ async function runSequentialLayeredFrameLoop(input) {
|
|
|
13105
13152
|
);
|
|
13106
13153
|
if (debugDumpEnabled && debugDumpDir && i % 30 === 0) {
|
|
13107
13154
|
writeFileExclusiveSync(
|
|
13108
|
-
|
|
13155
|
+
join29(debugDumpDir, `frame_${String(i).padStart(4, "0")}_final_rgb48le.bin`),
|
|
13109
13156
|
normalCanvas
|
|
13110
13157
|
);
|
|
13111
13158
|
}
|
|
@@ -13137,7 +13184,7 @@ async function runSequentialLayeredFrameLoop(input) {
|
|
|
13137
13184
|
}
|
|
13138
13185
|
|
|
13139
13186
|
// src/services/render/stages/captureHdrHybridLoop.ts
|
|
13140
|
-
import { join as
|
|
13187
|
+
import { join as join31 } from "node:path";
|
|
13141
13188
|
import {
|
|
13142
13189
|
TRANSITIONS as TRANSITIONS2,
|
|
13143
13190
|
closeCaptureSession as closeCaptureSession6,
|
|
@@ -13151,7 +13198,7 @@ import {
|
|
|
13151
13198
|
// src/services/shaderTransitionWorkerPool.ts
|
|
13152
13199
|
import { Worker } from "node:worker_threads";
|
|
13153
13200
|
import { fileURLToPath as fileURLToPath3, pathToFileURL } from "node:url";
|
|
13154
|
-
import { dirname as dirname12, join as
|
|
13201
|
+
import { dirname as dirname12, join as join30 } from "node:path";
|
|
13155
13202
|
import { createRequire } from "node:module";
|
|
13156
13203
|
import { usableCpuCount } from "@hyperframes/engine";
|
|
13157
13204
|
import { existsSync as existsSync19 } from "node:fs";
|
|
@@ -13165,9 +13212,9 @@ function resolveWorkerEntry(explicit) {
|
|
|
13165
13212
|
return { path: override, isTs };
|
|
13166
13213
|
}
|
|
13167
13214
|
const moduleDir = dirname12(fileURLToPath3(import.meta.url));
|
|
13168
|
-
const jsPath =
|
|
13215
|
+
const jsPath = join30(moduleDir, "shaderTransitionWorker.js");
|
|
13169
13216
|
if (existsSync19(jsPath)) return { path: jsPath, isTs: false };
|
|
13170
|
-
const tsPath =
|
|
13217
|
+
const tsPath = join30(moduleDir, "shaderTransitionWorker.ts");
|
|
13171
13218
|
return { path: tsPath, isTs: true };
|
|
13172
13219
|
}
|
|
13173
13220
|
function buildExecArgv(entryIsTs) {
|
|
@@ -13535,7 +13582,7 @@ async function runHybridLayeredFrameLoop(input) {
|
|
|
13535
13582
|
);
|
|
13536
13583
|
if (debugDumpEnabled && debugDumpDir && i % 30 === 0) {
|
|
13537
13584
|
writeFileExclusiveSync(
|
|
13538
|
-
|
|
13585
|
+
join31(debugDumpDir, `frame_${String(i).padStart(4, "0")}_final_rgb48le.bin`),
|
|
13539
13586
|
canvas
|
|
13540
13587
|
);
|
|
13541
13588
|
}
|
|
@@ -13731,7 +13778,7 @@ async function runCaptureHdrStage(input) {
|
|
|
13731
13778
|
if (hdrVideoFrameSources.has(v.id)) hdrVideoEndTimes.set(v.id, v.end);
|
|
13732
13779
|
}
|
|
13733
13780
|
const debugDumpEnabled = process.env.KEEP_TEMP === "1";
|
|
13734
|
-
const debugDumpDir = debugDumpEnabled ?
|
|
13781
|
+
const debugDumpDir = debugDumpEnabled ? join32(framesDir, "debug-composite") : null;
|
|
13735
13782
|
if (debugDumpDir && !existsSync20(debugDumpDir)) {
|
|
13736
13783
|
mkdirSync10(debugDumpDir, { recursive: true });
|
|
13737
13784
|
}
|
|
@@ -13896,11 +13943,11 @@ import {
|
|
|
13896
13943
|
readdirSync as readdirSync5,
|
|
13897
13944
|
readFileSync as readFileSync9,
|
|
13898
13945
|
rmSync as rmSync11,
|
|
13899
|
-
statSync as
|
|
13946
|
+
statSync as statSync9,
|
|
13900
13947
|
writeFileSync as writeFileSync6
|
|
13901
13948
|
} from "node:fs";
|
|
13902
13949
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
13903
|
-
import { dirname as dirname13, join as
|
|
13950
|
+
import { dirname as dirname13, join as join33 } from "node:path";
|
|
13904
13951
|
import {
|
|
13905
13952
|
encodeFramesChunkedConcat,
|
|
13906
13953
|
encodeFramesFromDir,
|
|
@@ -14025,7 +14072,7 @@ async function encodeGifFromDir(framesDir, framePattern, outputPath, input) {
|
|
|
14025
14072
|
const failure = await reencodeWithClearedWholeFrames(argsInput, run, startTime);
|
|
14026
14073
|
if (failure) return failure;
|
|
14027
14074
|
}
|
|
14028
|
-
const fileSize = existsSync21(outputPath) ?
|
|
14075
|
+
const fileSize = existsSync21(outputPath) ? statSync9(outputPath).size : 0;
|
|
14029
14076
|
return {
|
|
14030
14077
|
success: true,
|
|
14031
14078
|
outputPath,
|
|
@@ -14119,7 +14166,7 @@ function encodeWhileCapturing(input, totalFrames, captureBudget) {
|
|
|
14119
14166
|
await new Promise((resolve14) => wake = resolve14);
|
|
14120
14167
|
}
|
|
14121
14168
|
if (signal.aborted) return;
|
|
14122
|
-
const mergedPath =
|
|
14169
|
+
const mergedPath = join33(input.framesDir, formatCaptureFrameName(next, "jpg"));
|
|
14123
14170
|
const frame = await readLandedFrame(landed.get(next), mergedPath);
|
|
14124
14171
|
landed.delete(next);
|
|
14125
14172
|
if (!await stream.writeFrame(frame)) {
|
|
@@ -14202,11 +14249,11 @@ async function runEncodeStage(input) {
|
|
|
14202
14249
|
);
|
|
14203
14250
|
}
|
|
14204
14251
|
captured.forEach((name, i) => {
|
|
14205
|
-
const dst =
|
|
14206
|
-
copyFileSync4(
|
|
14252
|
+
const dst = join33(outputPath, formatExportFrameName(i, "png"));
|
|
14253
|
+
copyFileSync4(join33(framesDir, name), dst);
|
|
14207
14254
|
});
|
|
14208
14255
|
if (hasAudio && audioOutputPath && existsSync21(audioOutputPath)) {
|
|
14209
|
-
copyFileSync4(audioOutputPath,
|
|
14256
|
+
copyFileSync4(audioOutputPath, join33(outputPath, MIXED_AUDIO_FILENAME2));
|
|
14210
14257
|
log.info(
|
|
14211
14258
|
`[Render] png-sequence: ${MIXED_AUDIO_FILENAME2} sidecar written to ${outputPath}/${MIXED_AUDIO_FILENAME2}`
|
|
14212
14259
|
);
|
|
@@ -14226,7 +14273,7 @@ async function runEncodeStage(input) {
|
|
|
14226
14273
|
const encodeResult2 = await encodeGifFromDir(framesDir, framePattern2, outputPath, {
|
|
14227
14274
|
fps: job.config.fps,
|
|
14228
14275
|
loop,
|
|
14229
|
-
palettePath:
|
|
14276
|
+
palettePath: join33(dirname13(videoOnlyPath), "gif-palette.png"),
|
|
14230
14277
|
preserveAlpha: needsAlpha,
|
|
14231
14278
|
signal: abortSignal,
|
|
14232
14279
|
timeout: engineCfg.ffmpegEncodeTimeout
|
|
@@ -14437,9 +14484,9 @@ function sampleDirectoryBytes(dir) {
|
|
|
14437
14484
|
continue;
|
|
14438
14485
|
}
|
|
14439
14486
|
for (const name of entries) {
|
|
14440
|
-
const full =
|
|
14487
|
+
const full = join34(current, name);
|
|
14441
14488
|
try {
|
|
14442
|
-
const st =
|
|
14489
|
+
const st = statSync10(full);
|
|
14443
14490
|
if (st.isDirectory()) {
|
|
14444
14491
|
stack.push(full);
|
|
14445
14492
|
} else if (st.isFile()) {
|
|
@@ -14595,8 +14642,8 @@ function findMissingFrameRanges(totalFrames, framesDir, frameExt) {
|
|
|
14595
14642
|
const ranges = [];
|
|
14596
14643
|
let rangeStart = null;
|
|
14597
14644
|
for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
|
|
14598
|
-
const framePath =
|
|
14599
|
-
const missing = !existsSync22(framePath) ||
|
|
14645
|
+
const framePath = join34(framesDir, formatCaptureFrameName(frameIndex, frameExt));
|
|
14646
|
+
const missing = !existsSync22(framePath) || statSync10(framePath).size <= 8;
|
|
14600
14647
|
if (missing && rangeStart === null) {
|
|
14601
14648
|
rangeStart = frameIndex;
|
|
14602
14649
|
} else if (!missing && rangeStart !== null) {
|
|
@@ -14612,7 +14659,7 @@ function findMissingFrameRanges(totalFrames, framesDir, frameExt) {
|
|
|
14612
14659
|
function buildMissingFrameRetryBatches(ranges, maxWorkers, workDir, attempt, rangeStart = 0, stride = 1) {
|
|
14613
14660
|
const workersPerBatch = Math.max(1, Math.floor(maxWorkers));
|
|
14614
14661
|
const batches = [];
|
|
14615
|
-
const outputDirFor = (batchIndex, workerId) =>
|
|
14662
|
+
const outputDirFor = (batchIndex, workerId) => join34(workDir, `retry-${attempt}-batch-${batchIndex}-worker-${workerId}`);
|
|
14616
14663
|
if (stride > 1) {
|
|
14617
14664
|
const spans = /* @__PURE__ */ new Map();
|
|
14618
14665
|
for (const range of ranges) {
|
|
@@ -14672,8 +14719,8 @@ function getNextRetryWorkerCount(currentWorkers) {
|
|
|
14672
14719
|
return Math.max(1, Math.floor(currentWorkers / 2));
|
|
14673
14720
|
}
|
|
14674
14721
|
function resolveRenderWorkDirPrefix(outputPath, jobId, platform2 = process.platform, systemTempDir = tmpdir3()) {
|
|
14675
|
-
if (platform2 === "win32" || platform2 === "darwin") return
|
|
14676
|
-
return
|
|
14722
|
+
if (platform2 === "win32" || platform2 === "darwin") return join34(systemTempDir, "hf-render-");
|
|
14723
|
+
return join34(dirname14(outputPath), `work-${jobId}-`);
|
|
14677
14724
|
}
|
|
14678
14725
|
var MAX_TRANSIENT_CAPTURE_RETRIES = 1;
|
|
14679
14726
|
function isTransientCaptureRetryEligible(failureKind, missing, retriesUsed) {
|
|
@@ -14728,7 +14775,7 @@ The composition is too large for the available memory. To reduce memory pressure
|
|
|
14728
14775
|
function countCapturedFrames(totalFrames, framesDir, frameExt) {
|
|
14729
14776
|
let captured = 0;
|
|
14730
14777
|
for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
|
|
14731
|
-
const framePath =
|
|
14778
|
+
const framePath = join34(framesDir, formatCaptureFrameName(frameIndex, frameExt));
|
|
14732
14779
|
if (existsSync22(framePath)) captured++;
|
|
14733
14780
|
}
|
|
14734
14781
|
return captured;
|
|
@@ -14754,7 +14801,7 @@ async function executeDiskCaptureWithAdaptiveRetry(options) {
|
|
|
14754
14801
|
reason: attempt === 0 ? "initial" : pendingTransientRetry ? "transient-retry" : "retry"
|
|
14755
14802
|
});
|
|
14756
14803
|
pendingTransientRetry = false;
|
|
14757
|
-
const attemptWorkDir =
|
|
14804
|
+
const attemptWorkDir = join34(options.workDir, `capture-attempt-${attempt}`);
|
|
14758
14805
|
const batches = missingRanges ? buildMissingFrameRetryBatches(
|
|
14759
14806
|
missingRanges,
|
|
14760
14807
|
currentWorkers,
|
|
@@ -15402,7 +15449,7 @@ function deVerifyFallbackTelemetry(err) {
|
|
|
15402
15449
|
}
|
|
15403
15450
|
function resolveRenderDebugDir() {
|
|
15404
15451
|
const producerRoot = process.env.PRODUCER_RENDERS_DIR ? resolve9(process.env.PRODUCER_RENDERS_DIR, "..") : resolve9(dirname14(fileURLToPath4(import.meta.url)), "../..");
|
|
15405
|
-
return
|
|
15452
|
+
return join34(producerRoot, ".debug");
|
|
15406
15453
|
}
|
|
15407
15454
|
async function executeRenderJob(job, projectDir, outputPath, progressSink, abortSignal, assertRenderActive) {
|
|
15408
15455
|
validateHlsRenderConfig(job.config);
|
|
@@ -15411,10 +15458,10 @@ async function executeRenderJob(job, projectDir, outputPath, progressSink, abort
|
|
|
15411
15458
|
const debugDir = resolveRenderDebugDir();
|
|
15412
15459
|
const outputDir = dirname14(outputPath);
|
|
15413
15460
|
if (!existsSync22(outputDir)) mkdirSync12(outputDir, { recursive: true });
|
|
15414
|
-
const workDir = job.config.debug ?
|
|
15461
|
+
const workDir = job.config.debug ? join34(debugDir, job.id) : createRenderWorkDir(resolveRenderWorkDirPrefix(outputPath, job.id), outputDir);
|
|
15415
15462
|
const pipelineStart = Date.now();
|
|
15416
15463
|
const baseLog = job.config.logger ?? defaultLogger;
|
|
15417
|
-
const logPath = job.config.debug ?
|
|
15464
|
+
const logPath = job.config.debug ? join34(workDir, "render.log") : null;
|
|
15418
15465
|
const execution = new RenderExecutionContext({
|
|
15419
15466
|
request: { renderJobId: job.id, projectDir, outputPath },
|
|
15420
15467
|
logger: logPath ? createRenderFileLogger(logPath, baseLog) : baseLog,
|
|
@@ -15445,6 +15492,15 @@ async function executeRenderJob(job, projectDir, outputPath, progressSink, abort
|
|
|
15445
15492
|
await execution.dispose();
|
|
15446
15493
|
}
|
|
15447
15494
|
}
|
|
15495
|
+
function loadResumeKeyOrWarn(resume, log) {
|
|
15496
|
+
const key = segmentManifestKey();
|
|
15497
|
+
if (resume && !key) {
|
|
15498
|
+
log.warn(
|
|
15499
|
+
"[Render] --resume: no preview token could be read or created, so every segment will be captured again"
|
|
15500
|
+
);
|
|
15501
|
+
}
|
|
15502
|
+
return key;
|
|
15503
|
+
}
|
|
15448
15504
|
async function executeRenderPipeline(input) {
|
|
15449
15505
|
const {
|
|
15450
15506
|
job,
|
|
@@ -15482,7 +15538,7 @@ async function executeRenderPipeline(input) {
|
|
|
15482
15538
|
imageDecodeFailures: 0
|
|
15483
15539
|
};
|
|
15484
15540
|
let hdrPerf;
|
|
15485
|
-
const perfOutputPath =
|
|
15541
|
+
const perfOutputPath = join34(workDir, "perf-summary.json");
|
|
15486
15542
|
const cfg = { ...job.config.producerConfig ?? resolveConfig2() };
|
|
15487
15543
|
const observability = new RenderObservabilityRecorder({
|
|
15488
15544
|
pipelineStartMs: pipelineStart,
|
|
@@ -15587,7 +15643,7 @@ async function executeRenderPipeline(input) {
|
|
|
15587
15643
|
requestedWorkers: job.config.workers ?? "auto"
|
|
15588
15644
|
});
|
|
15589
15645
|
const entryFile = job.config.entryFile || "index.html";
|
|
15590
|
-
const htmlPath =
|
|
15646
|
+
const htmlPath = join34(projectDir, entryFile);
|
|
15591
15647
|
if (!existsSync22(htmlPath)) {
|
|
15592
15648
|
throw new Error(`Entry file not found: ${htmlPath}`);
|
|
15593
15649
|
}
|
|
@@ -15684,7 +15740,7 @@ async function executeRenderPipeline(input) {
|
|
|
15684
15740
|
const largerThanCanvas = await oversizedVideos(
|
|
15685
15741
|
composition.videos,
|
|
15686
15742
|
projectDir,
|
|
15687
|
-
|
|
15743
|
+
join34(workDir, "compiled"),
|
|
15688
15744
|
{ width: outputWidth, height: outputHeight }
|
|
15689
15745
|
);
|
|
15690
15746
|
const probeResult = await observeRenderStage(
|
|
@@ -15781,7 +15837,7 @@ async function executeRenderPipeline(input) {
|
|
|
15781
15837
|
canvas: { width, height },
|
|
15782
15838
|
page: probeSession.page,
|
|
15783
15839
|
projectDir,
|
|
15784
|
-
compiledDir:
|
|
15840
|
+
compiledDir: join34(workDir, "compiled")
|
|
15785
15841
|
});
|
|
15786
15842
|
if (videoLayerPlan.videoId === void 0) {
|
|
15787
15843
|
log.info(`[Render] Video layer passthrough off: ${videoLayerPlan.reason}`);
|
|
@@ -15799,7 +15855,7 @@ async function executeRenderPipeline(input) {
|
|
|
15799
15855
|
updateJobStatus(job, "preprocessing", "Extracting video frames", 10, onProgress, {
|
|
15800
15856
|
code: "extract_video"
|
|
15801
15857
|
});
|
|
15802
|
-
const compiledDir =
|
|
15858
|
+
const compiledDir = join34(workDir, "compiled");
|
|
15803
15859
|
const segmentsCapture = (layeredOrEffectRoute) => shouldSegmentCapture({
|
|
15804
15860
|
env: process.env,
|
|
15805
15861
|
durationSeconds: probeResult.duration,
|
|
@@ -15935,7 +15991,7 @@ async function executeRenderPipeline(input) {
|
|
|
15935
15991
|
try {
|
|
15936
15992
|
fileServer = await createFileServer({
|
|
15937
15993
|
projectDir,
|
|
15938
|
-
compiledDir:
|
|
15994
|
+
compiledDir: join34(workDir, "compiled"),
|
|
15939
15995
|
port: 0,
|
|
15940
15996
|
preHeadScripts: [VIRTUAL_TIME_SHIM],
|
|
15941
15997
|
fps: job.config.fps,
|
|
@@ -15955,7 +16011,7 @@ async function executeRenderPipeline(input) {
|
|
|
15955
16011
|
if (!activeFileServer) {
|
|
15956
16012
|
throw new Error("File server failed to initialize before frame capture");
|
|
15957
16013
|
}
|
|
15958
|
-
const framesDir =
|
|
16014
|
+
const framesDir = join34(workDir, "captured-frames");
|
|
15959
16015
|
if (!existsSync22(framesDir)) mkdirSync12(framesDir, { recursive: true });
|
|
15960
16016
|
updateJobStatus(job, "rendering", "Checking browser GPU", 25, onProgress, {
|
|
15961
16017
|
code: "start_browsers"
|
|
@@ -16536,7 +16592,7 @@ async function executeRenderPipeline(input) {
|
|
|
16536
16592
|
hls: ".mp4"
|
|
16537
16593
|
};
|
|
16538
16594
|
const videoExt = FORMAT_EXT[outputFormat] ?? ".mp4";
|
|
16539
|
-
const videoOnlyPath =
|
|
16595
|
+
const videoOnlyPath = join34(workDir, `video-only${videoExt}`);
|
|
16540
16596
|
let usePageSideCompositingForTransitions = (cfg.enablePageSideCompositing || isGif) && compiled.hasShaderTransitions && !hasHdrContent && outputSupportsPageSideShaderCompositing(outputFormat);
|
|
16541
16597
|
if (usePageSideCompositingForTransitions) {
|
|
16542
16598
|
activeFileServer.addPreHeadScript(HF_PAGE_SIDE_COMPOSITING_STUB);
|
|
@@ -16853,16 +16909,19 @@ async function executeRenderPipeline(input) {
|
|
|
16853
16909
|
pageMotionBlur: job.config.pageMotionBlur,
|
|
16854
16910
|
captureQuality: captureOptions.quality
|
|
16855
16911
|
});
|
|
16856
|
-
const segmentDir = segmentDirFor(
|
|
16912
|
+
const segmentDir = segmentDirFor(join34(projectDir, "renders"), segmentPlanHash);
|
|
16913
|
+
const manifestKey = loadResumeKeyOrWarn(job.config.resumeSegments === true, log);
|
|
16857
16914
|
let completedSegments = /* @__PURE__ */ new Set();
|
|
16858
16915
|
if (job.config.resumeSegments === true) {
|
|
16859
16916
|
const existing = readSegmentManifest(segmentDir);
|
|
16860
16917
|
if (existing) {
|
|
16861
|
-
completedSegments = await validateCompletedSegments(
|
|
16862
|
-
|
|
16863
|
-
|
|
16864
|
-
|
|
16865
|
-
|
|
16918
|
+
completedSegments = await validateCompletedSegments(existing, {
|
|
16919
|
+
expectedHash: segmentPlanHash,
|
|
16920
|
+
segmentDir,
|
|
16921
|
+
plan: planSegments(totalFrames, segmentFrames),
|
|
16922
|
+
key: manifestKey,
|
|
16923
|
+
probeFrames: (path) => probeSegmentFrameCount(path, extractMediaMetadata5)
|
|
16924
|
+
});
|
|
16866
16925
|
log.info(`[Render] resuming: ${completedSegments.size} segments complete`, {
|
|
16867
16926
|
segmentDir
|
|
16868
16927
|
});
|
|
@@ -16936,7 +16995,7 @@ async function executeRenderPipeline(input) {
|
|
|
16936
16995
|
...segmentManifest.completed.filter((e) => e.index !== entry.index),
|
|
16937
16996
|
{ ...entry, completedAt: (/* @__PURE__ */ new Date()).toISOString() }
|
|
16938
16997
|
];
|
|
16939
|
-
writeSegmentManifest(segmentDir, segmentManifest);
|
|
16998
|
+
writeSegmentManifest(segmentDir, segmentManifest, manifestKey);
|
|
16940
16999
|
},
|
|
16941
17000
|
updateCaptureObservability
|
|
16942
17001
|
})
|
|
@@ -17479,7 +17538,7 @@ async function executeRenderPipeline(input) {
|
|
|
17479
17538
|
}
|
|
17480
17539
|
if (job.config.debug) {
|
|
17481
17540
|
if (!isPngSequence && !isHls && existsSync22(stagedOutputPath)) {
|
|
17482
|
-
const debugOutput =
|
|
17541
|
+
const debugOutput = join34(workDir, `output${videoExt}`);
|
|
17483
17542
|
copyFileSync5(stagedOutputPath, debugOutput);
|
|
17484
17543
|
}
|
|
17485
17544
|
}
|
|
@@ -17598,14 +17657,14 @@ import {
|
|
|
17598
17657
|
referenceBackgroundResult as referenceBackgroundResult6
|
|
17599
17658
|
} from "@hyperframes/engine";
|
|
17600
17659
|
import { mkdirSync as mkdirSync20, mkdtempSync, readFileSync as readFileSync15, rmSync as rmSync18 } from "node:fs";
|
|
17601
|
-
import { join as
|
|
17660
|
+
import { join as join48 } from "node:path";
|
|
17602
17661
|
import { tmpdir as tmpdir5 } from "node:os";
|
|
17603
17662
|
|
|
17604
17663
|
// src/services/distributed/mp4Stitch.ts
|
|
17605
|
-
import { createReadStream as
|
|
17664
|
+
import { createReadStream as createReadStream4, createWriteStream, mkdirSync as mkdirSync13, rmSync as rmSync13 } from "node:fs";
|
|
17606
17665
|
import { open } from "node:fs/promises";
|
|
17607
17666
|
import { renameWithRetry as renameWithRetry7 } from "@hyperframes/engine";
|
|
17608
|
-
import { basename as basename8, dirname as dirname15, join as
|
|
17667
|
+
import { basename as basename8, dirname as dirname15, join as join35 } from "node:path";
|
|
17609
17668
|
import { finished, pipeline } from "node:stream/promises";
|
|
17610
17669
|
import { createStagingDir as createStagingDir4 } from "@hyperframes/core/atomic-file";
|
|
17611
17670
|
function boxAt(src, off, at, limit) {
|
|
@@ -17958,7 +18017,7 @@ function fileRange(path) {
|
|
|
17958
18017
|
}
|
|
17959
18018
|
async function copyPayload(path, layout, index, out) {
|
|
17960
18019
|
const { payloadStart, payloadEnd } = layout;
|
|
17961
|
-
const payload =
|
|
18020
|
+
const payload = createReadStream4(path, { start: payloadStart, end: payloadEnd - 1 });
|
|
17962
18021
|
await pipeline(payload, out, { end: false });
|
|
17963
18022
|
if (payload.bytesRead !== payloadEnd - payloadStart) {
|
|
17964
18023
|
throw new Error(
|
|
@@ -17972,13 +18031,13 @@ async function writeStitchedMp4(chunkPaths, outputPath, audioPath) {
|
|
|
17972
18031
|
const header = audioPath ? buildStitchedHeader(layouts.slice(1), layouts[0]) : buildStitchedHeader(layouts);
|
|
17973
18032
|
mkdirSync13(dirname15(outputPath), { recursive: true });
|
|
17974
18033
|
const workDir = createStagingDir4(dirname15(outputPath), `${basename8(outputPath)}.stitch-`);
|
|
17975
|
-
const out = createWriteStream(
|
|
18034
|
+
const out = createWriteStream(join35(workDir, "out.mp4"));
|
|
17976
18035
|
try {
|
|
17977
18036
|
out.write(header);
|
|
17978
18037
|
for (const [i, path] of sourcePaths.entries()) await copyPayload(path, layouts[i], i, out);
|
|
17979
18038
|
out.end();
|
|
17980
18039
|
await finished(out);
|
|
17981
|
-
renameWithRetry7(
|
|
18040
|
+
renameWithRetry7(join35(workDir, "out.mp4"), outputPath);
|
|
17982
18041
|
} finally {
|
|
17983
18042
|
out.destroy();
|
|
17984
18043
|
rmSync13(workDir, { recursive: true, force: true });
|
|
@@ -18001,7 +18060,7 @@ import {
|
|
|
18001
18060
|
rmSync as rmSync14,
|
|
18002
18061
|
writeFileSync as writeFileSync10
|
|
18003
18062
|
} from "node:fs";
|
|
18004
|
-
import { extname as extname6, isAbsolute as isAbsolute4, join as
|
|
18063
|
+
import { extname as extname6, isAbsolute as isAbsolute4, join as join43, relative as relative7, sep as sep5 } from "node:path";
|
|
18005
18064
|
import {
|
|
18006
18065
|
fpsToNumber as fpsToNumber9,
|
|
18007
18066
|
HF_COLOR_GRADING_ATTR as HF_COLOR_GRADING_ATTR2
|
|
@@ -18018,7 +18077,7 @@ import {
|
|
|
18018
18077
|
} from "@hyperframes/engine";
|
|
18019
18078
|
|
|
18020
18079
|
// src/services/distributed/planFrameCost.ts
|
|
18021
|
-
import { join as
|
|
18080
|
+
import { join as join38 } from "node:path";
|
|
18022
18081
|
import {
|
|
18023
18082
|
closeCaptureSession as closeCaptureSession9,
|
|
18024
18083
|
createCaptureSession as createCaptureSession9,
|
|
@@ -18028,7 +18087,7 @@ import {
|
|
|
18028
18087
|
|
|
18029
18088
|
// src/services/distributed/chunkFrames.ts
|
|
18030
18089
|
import { existsSync as existsSync24, readdirSync as readdirSync7 } from "node:fs";
|
|
18031
|
-
import { extname as extname4, join as
|
|
18090
|
+
import { extname as extname4, join as join37 } from "node:path";
|
|
18032
18091
|
import {
|
|
18033
18092
|
compositionRequiresWebGpu as compositionRequiresWebGpu3,
|
|
18034
18093
|
createVideoFrameInjector as createVideoFrameInjector3,
|
|
@@ -18037,7 +18096,7 @@ import {
|
|
|
18037
18096
|
|
|
18038
18097
|
// src/services/distributed/shared.ts
|
|
18039
18098
|
import { execFile as execFileCallback } from "node:child_process";
|
|
18040
|
-
import { dirname as dirname16, join as
|
|
18099
|
+
import { dirname as dirname16, join as join36 } from "node:path";
|
|
18041
18100
|
import { existsSync as existsSync23, readFileSync as readFileSync10 } from "node:fs";
|
|
18042
18101
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
18043
18102
|
import { promisify as promisify2 } from "node:util";
|
|
@@ -18053,7 +18112,7 @@ function isPlanAudioArtifactPath(path) {
|
|
|
18053
18112
|
}
|
|
18054
18113
|
function resolvePlanAudioPath(planDir) {
|
|
18055
18114
|
for (const name of [PLAN_AUDIO_RELATIVE_PATH, PLAN_AUDIO_LEGACY_RELATIVE_PATH]) {
|
|
18056
|
-
const candidate =
|
|
18115
|
+
const candidate = join36(planDir, name);
|
|
18057
18116
|
if (existsSync23(candidate)) return candidate;
|
|
18058
18117
|
}
|
|
18059
18118
|
return null;
|
|
@@ -18318,7 +18377,7 @@ function readProducerVersion() {
|
|
|
18318
18377
|
const startDir = dirname16(fileURLToPath5(import.meta.url));
|
|
18319
18378
|
let current = startDir;
|
|
18320
18379
|
for (let i = 0; i < 10; i++) {
|
|
18321
|
-
const candidate =
|
|
18380
|
+
const candidate = join36(current, "package.json");
|
|
18322
18381
|
if (existsSync23(candidate)) {
|
|
18323
18382
|
try {
|
|
18324
18383
|
const pkg = JSON.parse(readFileSync10(candidate, "utf-8"));
|
|
@@ -18373,7 +18432,7 @@ function frameNumberFromFileName(name) {
|
|
|
18373
18432
|
function rebuildExtractedFramesFromPlanDir(planDir, videos, indexMode = "dense-v1") {
|
|
18374
18433
|
const result = [];
|
|
18375
18434
|
for (const v of videos) {
|
|
18376
|
-
const outputDir =
|
|
18435
|
+
const outputDir = join37(planDir, "video-frames", mediaIdPathSegment3(v.videoId));
|
|
18377
18436
|
if (!existsSync24(outputDir)) {
|
|
18378
18437
|
throw new Error(
|
|
18379
18438
|
`[renderChunk] planDir missing extracted video frames for ${JSON.stringify(v.videoId)}: ${outputDir} not present. plan() should have written frames here; the planDir is malformed.`
|
|
@@ -18392,7 +18451,7 @@ function rebuildExtractedFramesFromPlanDir(planDir, videos, indexMode = "dense-v
|
|
|
18392
18451
|
if (!frameName) continue;
|
|
18393
18452
|
const frameNumber = indexMode === "sparse-v2" ? frameNumberFromFileName(frameName) : null;
|
|
18394
18453
|
const frameIndex = frameNumber === null ? i : frameNumber - 1;
|
|
18395
|
-
framePaths.set(frameIndex,
|
|
18454
|
+
framePaths.set(frameIndex, join37(outputDir, frameName));
|
|
18396
18455
|
}
|
|
18397
18456
|
result.push({
|
|
18398
18457
|
videoId: v.videoId,
|
|
@@ -18472,7 +18531,7 @@ async function extractDeferredVideoFramesForChunk(input) {
|
|
|
18472
18531
|
sourceOf: (video) => {
|
|
18473
18532
|
const range = planned.get(video.videoId).deferredRange;
|
|
18474
18533
|
const remoteUrl = remoteSources[range.sourcePath];
|
|
18475
|
-
const sourcePath = remoteUrl ??
|
|
18534
|
+
const sourcePath = remoteUrl ?? join37(input.planDir, ...range.sourcePath.split("/"));
|
|
18476
18535
|
if (remoteUrl === void 0 && !existsSync24(sourcePath)) {
|
|
18477
18536
|
throw new RenderChunkValidationError(
|
|
18478
18537
|
MISSING_PLAN_ARTIFACT,
|
|
@@ -18503,12 +18562,12 @@ async function measurePlanSecondsPerFrame(input) {
|
|
|
18503
18562
|
planVideos,
|
|
18504
18563
|
frames: sampled,
|
|
18505
18564
|
fps: fpsRatio,
|
|
18506
|
-
outputRoot:
|
|
18565
|
+
outputRoot: join38(workDir, "frame-cost-video-frames"),
|
|
18507
18566
|
cfg: input.cfg
|
|
18508
18567
|
})
|
|
18509
18568
|
];
|
|
18510
18569
|
const lookup = extracted.length > 0 ? createFrameLookupTable4(planVideos.videos, extracted, resolveRenderFpsConfig(fpsRatio).value) : null;
|
|
18511
|
-
const compiledDir =
|
|
18570
|
+
const compiledDir = join38(planDir, "compiled");
|
|
18512
18571
|
const fileServer = await createFileServer({
|
|
18513
18572
|
projectDir: compiledDir,
|
|
18514
18573
|
compiledDir,
|
|
@@ -18520,7 +18579,7 @@ async function measurePlanSecondsPerFrame(input) {
|
|
|
18520
18579
|
try {
|
|
18521
18580
|
session = await createCaptureSession9(
|
|
18522
18581
|
fileServer.url,
|
|
18523
|
-
|
|
18582
|
+
join38(workDir, "frame-cost"),
|
|
18524
18583
|
buildChunkCaptureOptions({
|
|
18525
18584
|
dimensions: { ...input, fpsNum: fps, fpsDen: 1 },
|
|
18526
18585
|
encoder: input,
|
|
@@ -18617,7 +18676,7 @@ function buildWeightedChunkSlices(weights, chunkCount, minFrames, maxFrames) {
|
|
|
18617
18676
|
}
|
|
18618
18677
|
|
|
18619
18678
|
// src/services/render/planReferenceBackground.ts
|
|
18620
|
-
import { join as
|
|
18679
|
+
import { join as join39 } from "node:path";
|
|
18621
18680
|
import {
|
|
18622
18681
|
closeCaptureSession as closeCaptureSession10,
|
|
18623
18682
|
createCaptureSession as createCaptureSession10,
|
|
@@ -18630,14 +18689,14 @@ async function readPlanReferenceBackground(input) {
|
|
|
18630
18689
|
try {
|
|
18631
18690
|
server = await createFileServer({
|
|
18632
18691
|
projectDir: input.projectDir,
|
|
18633
|
-
compiledDir:
|
|
18692
|
+
compiledDir: join39(input.workDir, "compiled"),
|
|
18634
18693
|
port: 0,
|
|
18635
18694
|
preHeadScripts: [VIRTUAL_TIME_SHIM],
|
|
18636
18695
|
fps: input.options.fps
|
|
18637
18696
|
});
|
|
18638
18697
|
session = await createCaptureSession10(
|
|
18639
18698
|
server.url,
|
|
18640
|
-
|
|
18699
|
+
join39(input.workDir, "reference"),
|
|
18641
18700
|
{
|
|
18642
18701
|
...input.options,
|
|
18643
18702
|
requiresWebGpu: false
|
|
@@ -18674,7 +18733,7 @@ async function readPlanReferenceBackground(input) {
|
|
|
18674
18733
|
|
|
18675
18734
|
// src/services/render/stages/freezePlan.ts
|
|
18676
18735
|
import { existsSync as existsSync25, mkdirSync as mkdirSync14, readFileSync as readFileSync11, readdirSync as readdirSync8, writeFileSync as writeFileSync8 } from "node:fs";
|
|
18677
|
-
import { join as
|
|
18736
|
+
import { join as join40, relative as relative5, resolve as resolve10 } from "node:path";
|
|
18678
18737
|
import {
|
|
18679
18738
|
REFERENCE_BACKGROUND_FIELD,
|
|
18680
18739
|
referenceBackgroundResult as referenceBackgroundResult3
|
|
@@ -18773,7 +18832,7 @@ function readPlanProtocolV1(planJson, capabilities = DISTRIBUTED_RENDER_CAPABILI
|
|
|
18773
18832
|
|
|
18774
18833
|
// src/services/render/stages/planHash.ts
|
|
18775
18834
|
import { createHash as createHash8 } from "node:crypto";
|
|
18776
|
-
import { closeSync as closeSync5, createReadStream as
|
|
18835
|
+
import { closeSync as closeSync5, createReadStream as createReadStream5, openSync as openSync5, readSync as readSync5 } from "node:fs";
|
|
18777
18836
|
var PLAN_HASH_SCHEMA_PREFIX = "hyperframes-plan-hash-v1\0";
|
|
18778
18837
|
var FIELD_DELIMITER = Buffer.from([0]);
|
|
18779
18838
|
function computePlanHash(input) {
|
|
@@ -18845,7 +18904,7 @@ function sha256File(path) {
|
|
|
18845
18904
|
}
|
|
18846
18905
|
async function sha256FileAsync(path) {
|
|
18847
18906
|
const hash = createHash8("sha256");
|
|
18848
|
-
for await (const chunk of
|
|
18907
|
+
for await (const chunk of createReadStream5(path, { highWaterMark: 1024 * 1024 })) {
|
|
18849
18908
|
hash.update(chunk);
|
|
18850
18909
|
}
|
|
18851
18910
|
return hash.digest("hex");
|
|
@@ -18892,7 +18951,7 @@ function listPlanFiles(planDir) {
|
|
|
18892
18951
|
function walk(dir) {
|
|
18893
18952
|
const entries = readdirSync8(dir, { withFileTypes: true });
|
|
18894
18953
|
for (const entry of entries) {
|
|
18895
|
-
const full =
|
|
18954
|
+
const full = join40(dir, entry.name);
|
|
18896
18955
|
if (entry.isDirectory()) {
|
|
18897
18956
|
walk(full);
|
|
18898
18957
|
} else if (entry.isFile()) {
|
|
@@ -18933,15 +18992,15 @@ var PLAN_REMOTE_FILES_RELATIVE_PATH = "meta/remote-files.json";
|
|
|
18933
18992
|
function writePlanRemoteFiles(planDir, files) {
|
|
18934
18993
|
if (files.length === 0) return;
|
|
18935
18994
|
const sorted = [...files].sort((a, b) => a.path < b.path ? -1 : 1);
|
|
18936
|
-
writeFileSync8(
|
|
18995
|
+
writeFileSync8(join40(planDir, PLAN_REMOTE_FILES_RELATIVE_PATH), JSON.stringify(sorted), "utf-8");
|
|
18937
18996
|
}
|
|
18938
18997
|
function readPlanRemoteFiles(planDir) {
|
|
18939
|
-
const path =
|
|
18998
|
+
const path = join40(planDir, PLAN_REMOTE_FILES_RELATIVE_PATH);
|
|
18940
18999
|
return existsSync25(path) ? JSON.parse(readFileSync11(path, "utf-8")) : [];
|
|
18941
19000
|
}
|
|
18942
19001
|
function recomputePlanHashFromPlanDir(planDir, digests) {
|
|
18943
|
-
const planJsonPath =
|
|
18944
|
-
const encoderJsonPath =
|
|
19002
|
+
const planJsonPath = join40(planDir, "plan.json");
|
|
19003
|
+
const encoderJsonPath = join40(planDir, "meta", "encoder.json");
|
|
18945
19004
|
if (!existsSync25(planJsonPath)) {
|
|
18946
19005
|
throw new Error(`[freezePlan] plan.json missing: ${planJsonPath}`);
|
|
18947
19006
|
}
|
|
@@ -18978,18 +19037,18 @@ async function freezePlan(input) {
|
|
|
18978
19037
|
if (!existsSync25(planDir)) {
|
|
18979
19038
|
throw new Error(`[freezePlan] planDir does not exist: ${planDir}`);
|
|
18980
19039
|
}
|
|
18981
|
-
const metaDir =
|
|
19040
|
+
const metaDir = join40(planDir, "meta");
|
|
18982
19041
|
if (!existsSync25(metaDir)) mkdirSync14(metaDir, { recursive: true });
|
|
18983
19042
|
writeFileSync8(
|
|
18984
|
-
|
|
19043
|
+
join40(metaDir, "composition.json"),
|
|
18985
19044
|
`${JSON.stringify(composition, null, 2)}
|
|
18986
19045
|
`,
|
|
18987
19046
|
"utf-8"
|
|
18988
19047
|
);
|
|
18989
19048
|
const encoderForCanonical = stripUndefined(encoder);
|
|
18990
19049
|
const encoderConfigCanonicalJson = canonicalJsonStringify(encoderForCanonical);
|
|
18991
|
-
writeFileSync8(
|
|
18992
|
-
writeFileSync8(
|
|
19050
|
+
writeFileSync8(join40(metaDir, "encoder.json"), encoderConfigCanonicalJson, "utf-8");
|
|
19051
|
+
writeFileSync8(join40(metaDir, "chunks.json"), `${JSON.stringify(chunks, null, 2)}
|
|
18993
19052
|
`, "utf-8");
|
|
18994
19053
|
const { compositionHtml, assets } = collectPlanAssetShas(planDir, digests);
|
|
18995
19054
|
const planHash = computePlanHash({
|
|
@@ -19014,7 +19073,7 @@ async function freezePlan(input) {
|
|
|
19014
19073
|
duration: durationSeconds,
|
|
19015
19074
|
hasAudio
|
|
19016
19075
|
};
|
|
19017
|
-
const planJsonPath =
|
|
19076
|
+
const planJsonPath = join40(planDir, "plan.json");
|
|
19018
19077
|
writeFileSync8(planJsonPath, `${JSON.stringify(planJson, null, 2)}
|
|
19019
19078
|
`, "utf-8");
|
|
19020
19079
|
return { planJsonPath, planHash };
|
|
@@ -19058,7 +19117,7 @@ function applyRuntimeEnvSnapshot(snapshot, env = process.env) {
|
|
|
19058
19117
|
// src/services/distributed/chunkAudio.ts
|
|
19059
19118
|
import { closeSync as closeSync6, existsSync as existsSync26, ftruncateSync, mkdirSync as mkdirSync15, openSync as openSync6, readFileSync as readFileSync12 } from "node:fs";
|
|
19060
19119
|
import { writeFileSync as writeFileSync9, writeSync } from "node:fs";
|
|
19061
|
-
import { join as
|
|
19120
|
+
import { join as join41 } from "node:path";
|
|
19062
19121
|
import { appendRenderProvenanceArgs, describeFfmpegFailure as describeFfmpegFailure4, runFfmpeg as runFfmpeg7 } from "@hyperframes/engine";
|
|
19063
19122
|
function audioCutForChunk(grid, chunks, index, fps) {
|
|
19064
19123
|
const firstPacketAt = (frame) => Math.min(
|
|
@@ -19146,7 +19205,7 @@ async function writeChunkAudioSlices(input) {
|
|
|
19146
19205
|
});
|
|
19147
19206
|
const bytes = readFileSync12(input.audioPath);
|
|
19148
19207
|
const layout = { sizeBytes: bytes.length, payloadStart, payloadEnd, partStarts: {} };
|
|
19149
|
-
mkdirSync15(
|
|
19208
|
+
mkdirSync15(join41(input.planDir, SLICE_DIR), { recursive: true });
|
|
19150
19209
|
input.chunks.forEach((_, index) => {
|
|
19151
19210
|
const cut = audioCutForChunk(grid, input.chunks, index, input.fps);
|
|
19152
19211
|
if (!cut) return;
|
|
@@ -19154,17 +19213,17 @@ async function writeChunkAudioSlices(input) {
|
|
|
19154
19213
|
const start = offsets[cut.firstPacket];
|
|
19155
19214
|
layout.partStarts[index] = start;
|
|
19156
19215
|
const end = offsets[last] + track.sizes[last];
|
|
19157
|
-
writeFileSync9(
|
|
19216
|
+
writeFileSync9(join41(input.planDir, chunkAudioSlicePath(index)), bytes.subarray(start, end));
|
|
19158
19217
|
});
|
|
19159
19218
|
const frame = [bytes.subarray(0, payloadStart), bytes.subarray(payloadEnd)];
|
|
19160
|
-
writeFileSync9(
|
|
19161
|
-
writeFileSync9(
|
|
19219
|
+
writeFileSync9(join41(input.planDir, SLICE_FRAME), Buffer.concat(frame));
|
|
19220
|
+
writeFileSync9(join41(input.planDir, SLICE_LAYOUT), JSON.stringify(layout));
|
|
19162
19221
|
}
|
|
19163
19222
|
function chunkAudioSource(planDir, chunkIndex, scratchPath) {
|
|
19164
|
-
const layoutPath =
|
|
19223
|
+
const layoutPath = join41(planDir, SLICE_LAYOUT);
|
|
19165
19224
|
if (!existsSync26(layoutPath)) return resolvePlanAudioPath(planDir);
|
|
19166
19225
|
const layout = JSON.parse(readFileSync12(layoutPath, "utf-8"));
|
|
19167
|
-
const frame = readFileSync12(
|
|
19226
|
+
const frame = readFileSync12(join41(planDir, SLICE_FRAME));
|
|
19168
19227
|
const fd = openSync6(scratchPath, "w");
|
|
19169
19228
|
try {
|
|
19170
19229
|
writeSync(fd, frame, 0, layout.payloadStart, 0);
|
|
@@ -19177,7 +19236,7 @@ function chunkAudioSource(planDir, chunkIndex, scratchPath) {
|
|
|
19177
19236
|
);
|
|
19178
19237
|
const start = layout.partStarts[chunkIndex];
|
|
19179
19238
|
if (start !== void 0) {
|
|
19180
|
-
const part = readFileSync12(
|
|
19239
|
+
const part = readFileSync12(join41(planDir, chunkAudioSlicePath(chunkIndex)));
|
|
19181
19240
|
writeSync(fd, part, 0, part.length, start);
|
|
19182
19241
|
}
|
|
19183
19242
|
ftruncateSync(fd, layout.sizeBytes);
|
|
@@ -19232,8 +19291,8 @@ async function muxChunkWithAudio(input) {
|
|
|
19232
19291
|
|
|
19233
19292
|
// src/services/distributed/planSize.ts
|
|
19234
19293
|
import { createHash as createHash9 } from "node:crypto";
|
|
19235
|
-
import { lstatSync as
|
|
19236
|
-
import { extname as extname5, join as
|
|
19294
|
+
import { lstatSync as lstatSync4, readdirSync as readdirSync9 } from "node:fs";
|
|
19295
|
+
import { extname as extname5, join as join42, relative as relative6 } from "node:path";
|
|
19237
19296
|
var MAX_TOP_COMPONENTS = 10;
|
|
19238
19297
|
var SOURCE_MEDIA_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
19239
19298
|
".aac",
|
|
@@ -19316,7 +19375,7 @@ function addCategoryBytes(result, category, filePath, sizeBytes) {
|
|
|
19316
19375
|
function recordFile(result, components, rootDir, rootKind, filePath) {
|
|
19317
19376
|
let sizeBytes;
|
|
19318
19377
|
try {
|
|
19319
|
-
const stat =
|
|
19378
|
+
const stat = lstatSync4(filePath);
|
|
19320
19379
|
if (!stat.isFile()) return;
|
|
19321
19380
|
sizeBytes = stat.size;
|
|
19322
19381
|
} catch {
|
|
@@ -19345,7 +19404,7 @@ function walkRegularFiles(dir, visit) {
|
|
|
19345
19404
|
return;
|
|
19346
19405
|
}
|
|
19347
19406
|
for (const entry of entries) {
|
|
19348
|
-
const full =
|
|
19407
|
+
const full = join42(dir, entry.name);
|
|
19349
19408
|
if (entry.isDirectory()) {
|
|
19350
19409
|
walkRegularFiles(full, visit);
|
|
19351
19410
|
} else if (entry.isFile()) {
|
|
@@ -19561,13 +19620,13 @@ function assertPositiveInteger2(name, value) {
|
|
|
19561
19620
|
}
|
|
19562
19621
|
var FREEZE_OWNED_PLAN_FILES = [
|
|
19563
19622
|
"plan.json",
|
|
19564
|
-
|
|
19565
|
-
|
|
19566
|
-
|
|
19623
|
+
join43("meta", "composition.json"),
|
|
19624
|
+
join43("meta", "encoder.json"),
|
|
19625
|
+
join43("meta", "chunks.json")
|
|
19567
19626
|
];
|
|
19568
19627
|
function removeFreezeOwnedPlanFiles(planDir) {
|
|
19569
19628
|
for (const relativePath of FREEZE_OWNED_PLAN_FILES) {
|
|
19570
|
-
rmSync14(
|
|
19629
|
+
rmSync14(join43(planDir, relativePath), { force: true });
|
|
19571
19630
|
}
|
|
19572
19631
|
}
|
|
19573
19632
|
function buildChunkSlices(totalFrames, chunkCount, effectiveChunkSize) {
|
|
@@ -19725,19 +19784,19 @@ function createVideoSourceShipper(input) {
|
|
|
19725
19784
|
const known = shipped.get(srcPath);
|
|
19726
19785
|
if (known) return known;
|
|
19727
19786
|
const stagedRel = pathInside(input.workVideoFramesDir, srcPath);
|
|
19728
|
-
const current = stagedRel === null ? srcPath :
|
|
19787
|
+
const current = stagedRel === null ? srcPath : join43(input.planDir, "video-frames", stagedRel);
|
|
19729
19788
|
let result = null;
|
|
19730
19789
|
for (const root of stagedRel === null ? [input.workCompiledDir, input.projectDir] : []) {
|
|
19731
19790
|
const rel = pathInside(root, srcPath);
|
|
19732
|
-
if (rel !== null && (existsSync27(
|
|
19791
|
+
if (rel !== null && (existsSync27(join43(input.planDir, "compiled", rel)) || input.isRemote(srcPath))) {
|
|
19733
19792
|
result = ["compiled", ...rel.split(sep5)].join("/");
|
|
19734
19793
|
break;
|
|
19735
19794
|
}
|
|
19736
19795
|
}
|
|
19737
19796
|
if (result === null) {
|
|
19738
19797
|
result = `video-sources/${shipped.size}${extname6(current)}`;
|
|
19739
|
-
const destination =
|
|
19740
|
-
mkdirSync16(
|
|
19798
|
+
const destination = join43(input.planDir, ...result.split("/"));
|
|
19799
|
+
mkdirSync16(join43(input.planDir, "video-sources"), { recursive: true });
|
|
19741
19800
|
try {
|
|
19742
19801
|
linkSync(current, destination);
|
|
19743
19802
|
} catch {
|
|
@@ -19791,14 +19850,14 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
|
|
|
19791
19850
|
includeOutsideScripts: options.includeOutsideScripts === true
|
|
19792
19851
|
});
|
|
19793
19852
|
const entryFile = config.entryFile ?? "index.html";
|
|
19794
|
-
const htmlPath =
|
|
19853
|
+
const htmlPath = join43(projectDir, entryFile);
|
|
19795
19854
|
if (!existsSync27(htmlPath)) {
|
|
19796
19855
|
throw new Error(`[plan] entry file not found: ${htmlPath}`);
|
|
19797
19856
|
}
|
|
19798
|
-
const workDir =
|
|
19857
|
+
const workDir = join43(planDir, ".plan-work");
|
|
19799
19858
|
rmSync14(workDir, { recursive: true, force: true });
|
|
19800
19859
|
mkdirSync16(workDir, { recursive: true });
|
|
19801
|
-
const compiledDir =
|
|
19860
|
+
const compiledDir = join43(workDir, "compiled");
|
|
19802
19861
|
mkdirSync16(compiledDir, { recursive: true });
|
|
19803
19862
|
let stageStarted = Date.now();
|
|
19804
19863
|
cpSync2(projectDir, compiledDir, {
|
|
@@ -19818,10 +19877,10 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
|
|
|
19818
19877
|
}
|
|
19819
19878
|
});
|
|
19820
19879
|
logPlanStage(log, "copy", stageStarted);
|
|
19821
|
-
const finalCompiledDir =
|
|
19880
|
+
const finalCompiledDir = join43(planDir, "compiled");
|
|
19822
19881
|
const needsAlpha = outputNeedsAlpha(config.format);
|
|
19823
19882
|
const remoteFiles = Object.entries(options.remoteFiles ?? {});
|
|
19824
|
-
const remoteLocalPath = (rel) =>
|
|
19883
|
+
const remoteLocalPath = (rel) => join43(projectDir, ...rel.split("/"));
|
|
19825
19884
|
for (const [, file] of remoteFiles) {
|
|
19826
19885
|
declareContentAddressedUrl(file.url, file.sha256);
|
|
19827
19886
|
if (file.probeFactsUrl) declareProbeFactsUrl(file.url, file.probeFactsUrl);
|
|
@@ -20026,10 +20085,10 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
|
|
|
20026
20085
|
let stageStarted = Date.now();
|
|
20027
20086
|
const extractResult = await extractPlanVideos(c, options.deferVideoExtraction);
|
|
20028
20087
|
logPlanStage(log, "extract", stageStarted);
|
|
20029
|
-
const stagedVideoFrames =
|
|
20030
|
-
const videoFramesDst =
|
|
20088
|
+
const stagedVideoFrames = join43(compiledDir, "__hyperframes_video_frames");
|
|
20089
|
+
const videoFramesDst = join43(planDir, "video-frames");
|
|
20031
20090
|
if (existsSync27(videoFramesDst)) rmSync14(videoFramesDst, { recursive: true, force: true });
|
|
20032
|
-
const videoSourcesDir =
|
|
20091
|
+
const videoSourcesDir = join43(planDir, "video-sources");
|
|
20033
20092
|
rmSync14(videoSourcesDir, { recursive: true, force: true });
|
|
20034
20093
|
if (existsSync27(stagedVideoFrames)) {
|
|
20035
20094
|
renameWithRetry8(stagedVideoFrames, videoFramesDst);
|
|
@@ -20066,7 +20125,7 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
|
|
|
20066
20125
|
};
|
|
20067
20126
|
})
|
|
20068
20127
|
});
|
|
20069
|
-
mkdirSync16(
|
|
20128
|
+
mkdirSync16(join43(planDir, "meta"), { recursive: true });
|
|
20070
20129
|
writePlanRemoteFiles(
|
|
20071
20130
|
planDir,
|
|
20072
20131
|
remoteFiles.map(([rel, { sha256, sizeBytes }]) => ({
|
|
@@ -20076,7 +20135,7 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
|
|
|
20076
20135
|
}))
|
|
20077
20136
|
);
|
|
20078
20137
|
writeFileSync10(
|
|
20079
|
-
|
|
20138
|
+
join43(planDir, PLAN_VIDEOS_META_RELATIVE_PATH),
|
|
20080
20139
|
JSON.stringify(planVideosJson, null, 2),
|
|
20081
20140
|
"utf-8"
|
|
20082
20141
|
);
|
|
@@ -20156,7 +20215,7 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
|
|
|
20156
20215
|
if (audioResult?.audioError) {
|
|
20157
20216
|
applyDistributedAudioWarningPolicy(job, audioResult.audioError, audioResult.audioFailures, log);
|
|
20158
20217
|
}
|
|
20159
|
-
const planAudioPath =
|
|
20218
|
+
const planAudioPath = join43(planDir, PLAN_AUDIO_RELATIVE_PATH);
|
|
20160
20219
|
if (audioResult?.hasAudio && existsSync27(audioResult.audioOutputPath)) {
|
|
20161
20220
|
renameWithRetry8(audioResult.audioOutputPath, planAudioPath);
|
|
20162
20221
|
}
|
|
@@ -20283,7 +20342,7 @@ async function plan(projectDir, config, planDir, options = {}) {
|
|
|
20283
20342
|
// src/services/distributed/renderChunk.ts
|
|
20284
20343
|
import { randomBytes } from "node:crypto";
|
|
20285
20344
|
import { existsSync as existsSync30, mkdirSync as mkdirSync19, readFileSync as readFileSync14, readdirSync as readdirSync11, rmSync as rmSync17, writeFileSync as writeFileSync13 } from "node:fs";
|
|
20286
|
-
import { join as
|
|
20345
|
+
import { join as join47 } from "node:path";
|
|
20287
20346
|
import {
|
|
20288
20347
|
assertSwiftShader,
|
|
20289
20348
|
BROWSER_GPU_NOT_SOFTWARE as BROWSER_GPU_NOT_SOFTWARE4,
|
|
@@ -20310,16 +20369,16 @@ import {
|
|
|
20310
20369
|
import {
|
|
20311
20370
|
copyFileSync as copyFileSync8,
|
|
20312
20371
|
existsSync as existsSync29,
|
|
20313
|
-
lstatSync as
|
|
20372
|
+
lstatSync as lstatSync5,
|
|
20314
20373
|
mkdirSync as mkdirSync18,
|
|
20315
20374
|
readFileSync as readFileSync13,
|
|
20316
20375
|
readdirSync as readdirSync10,
|
|
20317
20376
|
rmSync as rmSync16,
|
|
20318
|
-
statSync as
|
|
20377
|
+
statSync as statSync12,
|
|
20319
20378
|
writeFileSync as writeFileSync12
|
|
20320
20379
|
} from "node:fs";
|
|
20321
20380
|
import { tmpdir as tmpdir4 } from "node:os";
|
|
20322
|
-
import { dirname as dirname18, isAbsolute as isAbsolute5, join as
|
|
20381
|
+
import { dirname as dirname18, isAbsolute as isAbsolute5, join as join46, relative as relative8, resolve as resolve11, sep as sep6 } from "node:path";
|
|
20323
20382
|
import { DISTRIBUTED_FPS, isDistributedFps } from "@hyperframes/core";
|
|
20324
20383
|
import {
|
|
20325
20384
|
createFrameLookupTable as createFrameLookupTable5,
|
|
@@ -20334,11 +20393,11 @@ import {
|
|
|
20334
20393
|
linkSync as linkSync2,
|
|
20335
20394
|
mkdirSync as mkdirSync17,
|
|
20336
20395
|
rmSync as rmSync15,
|
|
20337
|
-
statSync as
|
|
20396
|
+
statSync as statSync11,
|
|
20338
20397
|
writeFileSync as writeFileSync11
|
|
20339
20398
|
} from "node:fs";
|
|
20340
20399
|
import { renameWithRetry as renameWithRetry9 } from "@hyperframes/engine";
|
|
20341
|
-
import { dirname as dirname17, join as
|
|
20400
|
+
import { dirname as dirname17, join as join45 } from "node:path";
|
|
20342
20401
|
|
|
20343
20402
|
// src/services/distributed/planV2Errors.ts
|
|
20344
20403
|
var PLAN_V2_INTEGRITY_UNRECOVERABLE = "PLAN_V2_INTEGRITY_UNRECOVERABLE";
|
|
@@ -20353,7 +20412,7 @@ var PlanV2IntegrityError = class extends Error {
|
|
|
20353
20412
|
};
|
|
20354
20413
|
|
|
20355
20414
|
// src/services/distributed/planV2Layout.ts
|
|
20356
|
-
import { join as
|
|
20415
|
+
import { join as join44 } from "node:path";
|
|
20357
20416
|
var SHA256_PATTERN = /^[0-9a-f]{64}$/;
|
|
20358
20417
|
function assertPlanV2Sha256(value, field) {
|
|
20359
20418
|
if (typeof value !== "string" || !SHA256_PATTERN.test(value)) {
|
|
@@ -20363,7 +20422,7 @@ function assertPlanV2Sha256(value, field) {
|
|
|
20363
20422
|
}
|
|
20364
20423
|
function planV2BlobPath(root, sha256) {
|
|
20365
20424
|
const digest = assertPlanV2Sha256(sha256, "artifact sha256");
|
|
20366
|
-
return
|
|
20425
|
+
return join44(root, "artifacts", "sha256", digest.slice(0, 2), digest);
|
|
20367
20426
|
}
|
|
20368
20427
|
|
|
20369
20428
|
// src/services/distributed/planV2Publisher.ts
|
|
@@ -20404,7 +20463,7 @@ var LocalPlanV2ArtifactPublisher = class {
|
|
|
20404
20463
|
}
|
|
20405
20464
|
async putBlob(blob) {
|
|
20406
20465
|
const digest = assertPlanV2Sha256(blob.sha256, "published blob sha256");
|
|
20407
|
-
const sourceSize =
|
|
20466
|
+
const sourceSize = statSync11(blob.sourcePath).size;
|
|
20408
20467
|
if (sourceSize !== blob.sizeBytes) {
|
|
20409
20468
|
throw new PlanV2IntegrityError(
|
|
20410
20469
|
`published blob size changed for ${digest}: expected ${blob.sizeBytes}, got ${sourceSize}`
|
|
@@ -20414,7 +20473,7 @@ var LocalPlanV2ArtifactPublisher = class {
|
|
|
20414
20473
|
if (existsSync28(destinationPath)) return;
|
|
20415
20474
|
mkdirSync17(dirname17(destinationPath), { recursive: true });
|
|
20416
20475
|
const stagingDir = createStagingDir5(dirname17(destinationPath), ".plan-v2-blob-");
|
|
20417
|
-
const temporaryPath =
|
|
20476
|
+
const temporaryPath = join45(stagingDir, "blob");
|
|
20418
20477
|
try {
|
|
20419
20478
|
try {
|
|
20420
20479
|
this.#linkFile(blob.sourcePath, temporaryPath);
|
|
@@ -20435,7 +20494,7 @@ var LocalPlanV2ArtifactPublisher = class {
|
|
|
20435
20494
|
);
|
|
20436
20495
|
}
|
|
20437
20496
|
}
|
|
20438
|
-
writeFileSync11(
|
|
20497
|
+
writeFileSync11(join45(this.temporaryDir, "plan.json"), manifestBytes, "utf-8");
|
|
20439
20498
|
renameWithRetry9(this.temporaryDir, this.destinationDir);
|
|
20440
20499
|
this.#committed = true;
|
|
20441
20500
|
}
|
|
@@ -20481,7 +20540,7 @@ function listFiles(root) {
|
|
|
20481
20540
|
const rootResolved = resolve11(root);
|
|
20482
20541
|
function walk(dir) {
|
|
20483
20542
|
for (const entry of readdirSync10(dir, { withFileTypes: true })) {
|
|
20484
|
-
const absolutePath =
|
|
20543
|
+
const absolutePath = join46(dir, entry.name);
|
|
20485
20544
|
if (entry.isDirectory()) {
|
|
20486
20545
|
walk(absolutePath);
|
|
20487
20546
|
} else if (entry.isFile()) {
|
|
@@ -20500,7 +20559,7 @@ function listFiles(root) {
|
|
|
20500
20559
|
return files.sort((a, b) => a.path.localeCompare(b.path));
|
|
20501
20560
|
}
|
|
20502
20561
|
function assertValidExtractionCacheCompleteSentinel(path) {
|
|
20503
|
-
const sentinel =
|
|
20562
|
+
const sentinel = lstatSync5(path);
|
|
20504
20563
|
if (!sentinel.isFile() || sentinel.size !== 0) {
|
|
20505
20564
|
throw new PlanV2IntegrityError(
|
|
20506
20565
|
`${EXTRACTION_CACHE_COMPLETE_SENTINEL} must be a zero-byte regular file`
|
|
@@ -20508,13 +20567,13 @@ function assertValidExtractionCacheCompleteSentinel(path) {
|
|
|
20508
20567
|
}
|
|
20509
20568
|
}
|
|
20510
20569
|
function validateExtractionCacheCompleteSentinels(executionPlanDir) {
|
|
20511
|
-
const videoRoot =
|
|
20570
|
+
const videoRoot = join46(executionPlanDir, "video-frames");
|
|
20512
20571
|
if (!existsSync29(videoRoot)) return;
|
|
20513
20572
|
for (const videoEntry of readdirSync10(videoRoot, { withFileTypes: true })) {
|
|
20514
20573
|
if (!videoEntry.isDirectory()) continue;
|
|
20515
|
-
const videoDir =
|
|
20574
|
+
const videoDir = join46(videoRoot, videoEntry.name);
|
|
20516
20575
|
if (readdirSync10(videoDir).includes(EXTRACTION_CACHE_COMPLETE_SENTINEL)) {
|
|
20517
|
-
const sentinelPath =
|
|
20576
|
+
const sentinelPath = join46(videoDir, EXTRACTION_CACHE_COMPLETE_SENTINEL);
|
|
20518
20577
|
assertValidExtractionCacheCompleteSentinel(sentinelPath);
|
|
20519
20578
|
}
|
|
20520
20579
|
}
|
|
@@ -20561,7 +20620,7 @@ function listVideoFramePaths(executionPlanDir, videos) {
|
|
|
20561
20620
|
if (video.deferredRange) {
|
|
20562
20621
|
const framePaths2 = /* @__PURE__ */ new Map();
|
|
20563
20622
|
for (let index = 0; index < video.totalFrames; index++) {
|
|
20564
|
-
framePaths2.set(index,
|
|
20623
|
+
framePaths2.set(index, join46(outputDir, String(index)));
|
|
20565
20624
|
}
|
|
20566
20625
|
return { ...video, outputDir, framePaths: framePaths2, ownedByLookup: false };
|
|
20567
20626
|
}
|
|
@@ -20569,7 +20628,7 @@ function listVideoFramePaths(executionPlanDir, videos) {
|
|
|
20569
20628
|
const framePaths = /* @__PURE__ */ new Map();
|
|
20570
20629
|
for (const frameName of frameNames) {
|
|
20571
20630
|
if (frameName === EXTRACTION_CACHE_COMPLETE_SENTINEL) {
|
|
20572
|
-
assertValidExtractionCacheCompleteSentinel(
|
|
20631
|
+
assertValidExtractionCacheCompleteSentinel(join46(outputDir, frameName));
|
|
20573
20632
|
continue;
|
|
20574
20633
|
}
|
|
20575
20634
|
const match = /(\d+)(?=\.[^.]+$)/.exec(frameName);
|
|
@@ -20588,7 +20647,7 @@ function listVideoFramePaths(executionPlanDir, videos) {
|
|
|
20588
20647
|
`duplicate extracted frame index ${frameIndex} in ${outputDir}`
|
|
20589
20648
|
);
|
|
20590
20649
|
}
|
|
20591
|
-
framePaths.set(frameIndex,
|
|
20650
|
+
framePaths.set(frameIndex, join46(outputDir, frameName));
|
|
20592
20651
|
}
|
|
20593
20652
|
return {
|
|
20594
20653
|
...video,
|
|
@@ -20609,7 +20668,7 @@ function parsePlanVideosJson2(value) {
|
|
|
20609
20668
|
}
|
|
20610
20669
|
}
|
|
20611
20670
|
function materializeExtractedVideoDirectories(planDir) {
|
|
20612
|
-
const videosPath =
|
|
20671
|
+
const videosPath = join46(planDir, PLAN_VIDEOS_META_RELATIVE_PATH);
|
|
20613
20672
|
if (!existsSync29(videosPath)) return;
|
|
20614
20673
|
const videos = parsePlanVideosJson2(readJsonFile(videosPath, PLAN_VIDEOS_META_RELATIVE_PATH));
|
|
20615
20674
|
for (const video of videos.extracted) {
|
|
@@ -20643,13 +20702,13 @@ function parseChunkSlices(value) {
|
|
|
20643
20702
|
});
|
|
20644
20703
|
}
|
|
20645
20704
|
function buildVideoChunkDependencies(executionPlanDir, dimensions) {
|
|
20646
|
-
const videoRoot =
|
|
20705
|
+
const videoRoot = join46(executionPlanDir, "video-frames");
|
|
20647
20706
|
const hasExtractedFrames = existsSync29(videoRoot) && listFiles(videoRoot).length > 0;
|
|
20648
|
-
const videosPath =
|
|
20707
|
+
const videosPath = join46(executionPlanDir, PLAN_VIDEOS_META_RELATIVE_PATH);
|
|
20649
20708
|
if (!existsSync29(videosPath)) {
|
|
20650
20709
|
return hasExtractedFrames ? { mode: "full-source-pack", dependencies: null } : { mode: "exact-rendered-frames", dependencies: /* @__PURE__ */ new Map() };
|
|
20651
20710
|
}
|
|
20652
|
-
const chunksPath =
|
|
20711
|
+
const chunksPath = join46(executionPlanDir, "meta", "chunks.json");
|
|
20653
20712
|
const videos = readJsonFile(videosPath, PLAN_VIDEOS_META_RELATIVE_PATH);
|
|
20654
20713
|
const chunks = readJsonFile(chunksPath, "meta/chunks.json");
|
|
20655
20714
|
const parsedVideos = parsePlanVideosJson2(videos);
|
|
@@ -20706,7 +20765,7 @@ function writeBlob(sourcePath, destinationPath) {
|
|
|
20706
20765
|
if (existsSync29(destinationPath)) return;
|
|
20707
20766
|
mkdirSync18(dirname18(destinationPath), { recursive: true });
|
|
20708
20767
|
const temporaryDir = createStagingDir6(dirname18(destinationPath), ".plan-v2-blob-");
|
|
20709
|
-
const temporaryPath =
|
|
20768
|
+
const temporaryPath = join46(temporaryDir, "blob");
|
|
20710
20769
|
try {
|
|
20711
20770
|
copyFileSync8(sourcePath, temporaryPath);
|
|
20712
20771
|
renameWithRetry10(temporaryPath, destinationPath);
|
|
@@ -20718,7 +20777,7 @@ function publishBlobFor(absolutePath, digests) {
|
|
|
20718
20777
|
return {
|
|
20719
20778
|
sourcePath: absolutePath,
|
|
20720
20779
|
sha256: planFileSha256(absolutePath, digests),
|
|
20721
|
-
sizeBytes:
|
|
20780
|
+
sizeBytes: statSync12(absolutePath).size
|
|
20722
20781
|
};
|
|
20723
20782
|
}
|
|
20724
20783
|
async function putBlobs(publisher, blobs) {
|
|
@@ -20742,7 +20801,7 @@ async function putTasks(tasks) {
|
|
|
20742
20801
|
if (failure) throw failure.reason;
|
|
20743
20802
|
}
|
|
20744
20803
|
function buildPlanV2Publication(executionPlanDir, digests) {
|
|
20745
|
-
const executionPlanPath =
|
|
20804
|
+
const executionPlanPath = join46(executionPlanDir, "plan.json");
|
|
20746
20805
|
if (!existsSync29(executionPlanPath)) {
|
|
20747
20806
|
throw new PlanV2IntegrityError(`execution plan is missing plan.json: ${executionPlanPath}`);
|
|
20748
20807
|
}
|
|
@@ -20770,7 +20829,7 @@ function buildPlanV2Publication(executionPlanDir, digests) {
|
|
|
20770
20829
|
}
|
|
20771
20830
|
validateExtractionCacheCompleteSentinels(executionPlanDir);
|
|
20772
20831
|
const videoDependencyPlan = buildVideoChunkDependencies(executionPlanDir, dimensions);
|
|
20773
|
-
const encoder = readJsonFile(
|
|
20832
|
+
const encoder = readJsonFile(join46(executionPlanDir, "meta", "encoder.json"), "meta/encoder.json");
|
|
20774
20833
|
const files = listFiles(executionPlanDir);
|
|
20775
20834
|
const chunkAudio = !isRecord3(encoder) || encoder.chunksCarryAudio !== true ? "none" : files.some((file) => chunkAudioSliceTarget(file.path) !== null) ? "sliced" : "whole";
|
|
20776
20835
|
for (const file of files) {
|
|
@@ -20837,7 +20896,7 @@ function createPlanV2FromExecutionPlan(executionPlanDir, planV2Dir) {
|
|
|
20837
20896
|
writeBlob(blob.sourcePath, planV2BlobPath(tempDir, blob.sha256));
|
|
20838
20897
|
}
|
|
20839
20898
|
writeFileSync12(
|
|
20840
|
-
|
|
20899
|
+
join46(tempDir, "plan.json"),
|
|
20841
20900
|
canonicalJsonStringify(publication.manifest),
|
|
20842
20901
|
"utf-8"
|
|
20843
20902
|
);
|
|
@@ -20889,7 +20948,7 @@ async function planV2WithPublisher(projectDir, config, publisher, options = {})
|
|
|
20889
20948
|
// artifactTargets ships every compiled/ file to all chunks, so each is in the manifest.
|
|
20890
20949
|
whileAudioMixes: () => putBlobs(
|
|
20891
20950
|
publisher,
|
|
20892
|
-
listFiles(
|
|
20951
|
+
listFiles(join46(stagingRoot, "compiled")).map(
|
|
20893
20952
|
(file) => publishBlobFor(file.absolutePath, digests)
|
|
20894
20953
|
)
|
|
20895
20954
|
),
|
|
@@ -20930,7 +20989,7 @@ function resultFromManifest(planV2Dir, manifest) {
|
|
|
20930
20989
|
isRecord3(executionPlan) ? executionPlan[REFERENCE_BACKGROUND_FIELD3] : void 0
|
|
20931
20990
|
),
|
|
20932
20991
|
planDir: planV2Dir,
|
|
20933
|
-
manifestPath:
|
|
20992
|
+
manifestPath: join46(planV2Dir, "plan.json"),
|
|
20934
20993
|
planProtocol: PLAN_PROTOCOL_V2,
|
|
20935
20994
|
planHash: manifest.planHash,
|
|
20936
20995
|
sourcePlanV1Hash: getPlanV2ExecutionPlanHash(manifest),
|
|
@@ -21066,7 +21125,7 @@ function parsePlanV2Manifest(value) {
|
|
|
21066
21125
|
return parsed;
|
|
21067
21126
|
}
|
|
21068
21127
|
function readPlanV2Manifest(planV2Dir) {
|
|
21069
|
-
const manifestPath =
|
|
21128
|
+
const manifestPath = join46(planV2Dir, "plan.json");
|
|
21070
21129
|
if (!existsSync29(manifestPath)) {
|
|
21071
21130
|
throw new PlanV2IntegrityError(`missing v2 manifest: ${manifestPath}`);
|
|
21072
21131
|
}
|
|
@@ -21089,7 +21148,7 @@ function verifyBlob(planV2Dir, artifact) {
|
|
|
21089
21148
|
if (!existsSync29(sourcePath)) {
|
|
21090
21149
|
throw new PlanV2IntegrityError(`missing content-addressed artifact ${artifact.sha256}`);
|
|
21091
21150
|
}
|
|
21092
|
-
const stats =
|
|
21151
|
+
const stats = statSync12(sourcePath);
|
|
21093
21152
|
if (!stats.isFile() || stats.size !== artifact.sizeBytes) {
|
|
21094
21153
|
throw new PlanV2IntegrityError(`artifact size mismatch for ${artifact.path}`);
|
|
21095
21154
|
}
|
|
@@ -21115,13 +21174,13 @@ function materializePlanV2Target(planV2Dir, target, destinationDir, options = {}
|
|
|
21115
21174
|
const tempDir = createStagingDir6(dirname18(destinationDir), ".plan-v2-materialize-");
|
|
21116
21175
|
try {
|
|
21117
21176
|
for (const { artifact, sourcePath } of verified) {
|
|
21118
|
-
const destinationPath =
|
|
21177
|
+
const destinationPath = join46(tempDir, ...artifact.path.split("/"));
|
|
21119
21178
|
mkdirSync18(dirname18(destinationPath), { recursive: true });
|
|
21120
21179
|
copyFileSync8(sourcePath, destinationPath);
|
|
21121
21180
|
}
|
|
21122
21181
|
if (target.role === "chunk") materializeExtractedVideoDirectories(tempDir);
|
|
21123
21182
|
writeFileSync12(
|
|
21124
|
-
|
|
21183
|
+
join46(tempDir, PLAN_V2_MATERIALIZATION_MARKER),
|
|
21125
21184
|
canonicalJsonStringify({
|
|
21126
21185
|
manifest,
|
|
21127
21186
|
target,
|
|
@@ -21144,7 +21203,7 @@ function materializePlanV2Target(planV2Dir, target, destinationDir, options = {}
|
|
|
21144
21203
|
// Join the artifact's OWN name, not the current constant: a plan written
|
|
21145
21204
|
// before the container change carries the legacy name, and materializing it
|
|
21146
21205
|
// under the new one would point at a file that was never written.
|
|
21147
|
-
audioPath: target.role === "assembler" ? audioArtifact ?
|
|
21206
|
+
audioPath: target.role === "assembler" ? audioArtifact ? join46(destinationDir, audioArtifact.path) : null : null
|
|
21148
21207
|
};
|
|
21149
21208
|
}
|
|
21150
21209
|
function assertRemoteSources(remoteSources, artifacts) {
|
|
@@ -21163,7 +21222,7 @@ function validatePlanV2MaterializedTarget(planDir, expectedTarget) {
|
|
|
21163
21222
|
return readValidatedPlanV2Materialization(planDir, expectedTarget)?.manifest ?? null;
|
|
21164
21223
|
}
|
|
21165
21224
|
function readValidatedPlanV2Materialization(planDir, expectedTarget) {
|
|
21166
|
-
const markerPath =
|
|
21225
|
+
const markerPath = join46(planDir, PLAN_V2_MATERIALIZATION_MARKER);
|
|
21167
21226
|
if (!existsSync29(markerPath)) return null;
|
|
21168
21227
|
const marker = readJsonFile(markerPath, "materialization marker");
|
|
21169
21228
|
if (!isRecord3(marker) || !isRecord3(marker.manifest) || !isRecord3(marker.target)) {
|
|
@@ -21181,8 +21240,8 @@ function readValidatedPlanV2Materialization(planDir, expectedTarget) {
|
|
|
21181
21240
|
assertRemoteSources(remoteSources, required);
|
|
21182
21241
|
for (const artifact of required) {
|
|
21183
21242
|
if (Object.hasOwn(remoteSources, artifact.path)) continue;
|
|
21184
|
-
const path =
|
|
21185
|
-
if (!existsSync29(path) ||
|
|
21243
|
+
const path = join46(planDir, ...artifact.path.split("/"));
|
|
21244
|
+
if (!existsSync29(path) || statSync12(path).size !== artifact.sizeBytes) {
|
|
21186
21245
|
throw new PlanV2IntegrityError(
|
|
21187
21246
|
`materialized artifact missing or truncated: ${artifact.path}`
|
|
21188
21247
|
);
|
|
@@ -21313,7 +21372,7 @@ function hashChunkOutput(outputPath, kind) {
|
|
|
21313
21372
|
if (kind === "file") return sha256Hex(readFileSync14(outputPath));
|
|
21314
21373
|
const entries = readdirSync11(outputPath).filter((name) => /\.(png|jpg|jpeg)$/i.test(name)).sort();
|
|
21315
21374
|
const lines = entries.map(
|
|
21316
|
-
(name) => `${name}\0${sha256Hex(readFileSync14(
|
|
21375
|
+
(name) => `${name}\0${sha256Hex(readFileSync14(join47(outputPath, name)))}`
|
|
21317
21376
|
);
|
|
21318
21377
|
return sha256Hex(lines.join("\0"));
|
|
21319
21378
|
}
|
|
@@ -21330,9 +21389,9 @@ function resolveLockedVp9CpuUsed(lockedEncoder) {
|
|
|
21330
21389
|
async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
21331
21390
|
const start = Date.now();
|
|
21332
21391
|
const log = defaultLogger;
|
|
21333
|
-
const planJsonPath =
|
|
21334
|
-
const encoderJsonPath =
|
|
21335
|
-
const chunksJsonPath =
|
|
21392
|
+
const planJsonPath = join47(planDir, "plan.json");
|
|
21393
|
+
const encoderJsonPath = join47(planDir, "meta", "encoder.json");
|
|
21394
|
+
const chunksJsonPath = join47(planDir, "meta", "chunks.json");
|
|
21336
21395
|
if (!existsSync30(planJsonPath)) {
|
|
21337
21396
|
throw new RenderChunkValidationError(
|
|
21338
21397
|
MISSING_PLAN_ARTIFACT,
|
|
@@ -21358,7 +21417,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
|
21358
21417
|
}
|
|
21359
21418
|
const encoder = JSON.parse(readFileSync14(encoderJsonPath, "utf-8"));
|
|
21360
21419
|
const chunks = JSON.parse(readFileSync14(chunksJsonPath, "utf-8"));
|
|
21361
|
-
const videosJsonPath =
|
|
21420
|
+
const videosJsonPath = join47(planDir, PLAN_VIDEOS_META_RELATIVE_PATH);
|
|
21362
21421
|
let planVideos = null;
|
|
21363
21422
|
if (existsSync30(videosJsonPath)) {
|
|
21364
21423
|
try {
|
|
@@ -21390,7 +21449,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
|
21390
21449
|
}
|
|
21391
21450
|
const range = resolveChunkFrameRange(slice, chunkIndex, options?.frameRange);
|
|
21392
21451
|
const framesInChunk = range.endFrame - range.startFrame;
|
|
21393
|
-
const compiledDir =
|
|
21452
|
+
const compiledDir = join47(planDir, "compiled");
|
|
21394
21453
|
if (!existsSync30(compiledDir)) {
|
|
21395
21454
|
throw new RenderChunkValidationError(
|
|
21396
21455
|
MISSING_PLAN_ARTIFACT,
|
|
@@ -21449,7 +21508,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
|
21449
21508
|
};
|
|
21450
21509
|
const workDir = `${outputChunkPath}.work.${process.pid}.${randomBytes(4).toString("hex")}`;
|
|
21451
21510
|
mkdirSync19(workDir, { recursive: true });
|
|
21452
|
-
const framesDir =
|
|
21511
|
+
const framesDir = join47(workDir, "captured-frames");
|
|
21453
21512
|
mkdirSync19(framesDir, { recursive: true });
|
|
21454
21513
|
const videoFramesDir = `${workDir}.video-frames`;
|
|
21455
21514
|
const chunkFrameNumbers = Array.from({ length: framesInChunk }, (_, i) => range.startFrame + i);
|
|
@@ -21474,7 +21533,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
|
21474
21533
|
dimensions: plan2.dimensions,
|
|
21475
21534
|
encoder,
|
|
21476
21535
|
videoCount: planVideos?.videos.length ?? 0,
|
|
21477
|
-
html: readFileSync14(
|
|
21536
|
+
html: readFileSync14(join47(compiledDir, "index.html"), "utf-8"),
|
|
21478
21537
|
// The plan ships a deferred source only to chunks that show it; don't wait on the rest.
|
|
21479
21538
|
skipReadinessVideoIds: deferredVideos.filter(
|
|
21480
21539
|
(video) => !shownFrames.get(video.videoId)?.size || remoteVideoIds.has(video.videoId)
|
|
@@ -21645,7 +21704,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
|
21645
21704
|
if (isPngSequence) {
|
|
21646
21705
|
if (!existsSync30(outputChunkPath)) mkdirSync19(outputChunkPath, { recursive: true });
|
|
21647
21706
|
} else {
|
|
21648
|
-
const outDir =
|
|
21707
|
+
const outDir = join47(outputChunkPath, "..");
|
|
21649
21708
|
if (!existsSync30(outDir)) mkdirSync19(outDir, { recursive: true });
|
|
21650
21709
|
}
|
|
21651
21710
|
const encodeInput = {
|
|
@@ -21922,10 +21981,10 @@ async function renderSpan(projectDir, config, span, outputPath, options = {}) {
|
|
|
21922
21981
|
if (config.cfr === true) {
|
|
21923
21982
|
throw new RenderSpanUnsupportedError("--start/--end cannot be combined with a cfr re-encode.");
|
|
21924
21983
|
}
|
|
21925
|
-
const workDir = mkdtempSync(
|
|
21984
|
+
const workDir = mkdtempSync(join48(tmpdir5(), "hf-render-span-"));
|
|
21926
21985
|
try {
|
|
21927
|
-
const planDir =
|
|
21928
|
-
const partsDir =
|
|
21986
|
+
const planDir = join48(workDir, "plan");
|
|
21987
|
+
const partsDir = join48(workDir, "parts");
|
|
21929
21988
|
mkdirSync20(partsDir, { recursive: true });
|
|
21930
21989
|
const planned = await plan(
|
|
21931
21990
|
projectDir,
|
|
@@ -21944,7 +22003,7 @@ async function renderSpan(projectDir, config, span, outputPath, options = {}) {
|
|
|
21944
22003
|
planned.totalFrames
|
|
21945
22004
|
);
|
|
21946
22005
|
const slices = JSON.parse(
|
|
21947
|
-
readFileSync15(
|
|
22006
|
+
readFileSync15(join48(planDir, "meta", "chunks.json"), "utf-8")
|
|
21948
22007
|
);
|
|
21949
22008
|
const parts = [];
|
|
21950
22009
|
for (const slice of slices) {
|
|
@@ -21954,7 +22013,7 @@ async function renderSpan(projectDir, config, span, outputPath, options = {}) {
|
|
|
21954
22013
|
};
|
|
21955
22014
|
if (range.endFrame <= range.startFrame) continue;
|
|
21956
22015
|
throwIfAborted(config.abortSignal);
|
|
21957
|
-
const part =
|
|
22016
|
+
const part = join48(partsDir, `part-${String(parts.length).padStart(4, "0")}.mp4`);
|
|
21958
22017
|
await renderChunk(planDir, slice.index, part, { frameRange: range });
|
|
21959
22018
|
parts.push(part);
|
|
21960
22019
|
}
|
|
@@ -22612,13 +22671,13 @@ import {
|
|
|
22612
22671
|
import {
|
|
22613
22672
|
existsSync as existsSync33,
|
|
22614
22673
|
mkdirSync as mkdirSync21,
|
|
22615
|
-
statSync as
|
|
22674
|
+
statSync as statSync14,
|
|
22616
22675
|
mkdtempSync as mkdtempSync2,
|
|
22617
22676
|
writeFileSync as writeFileSync14,
|
|
22618
22677
|
rmSync as rmSync19,
|
|
22619
|
-
createReadStream as
|
|
22678
|
+
createReadStream as createReadStream6
|
|
22620
22679
|
} from "node:fs";
|
|
22621
|
-
import { resolve as resolve13, dirname as dirname21, join as
|
|
22680
|
+
import { resolve as resolve13, dirname as dirname21, join as join51 } from "node:path";
|
|
22622
22681
|
import { tmpdir as tmpdir6 } from "node:os";
|
|
22623
22682
|
import { parseArgs } from "node:util";
|
|
22624
22683
|
import { isIP } from "node:net";
|
|
@@ -22637,13 +22696,13 @@ import { isSafePath as isSafePath3 } from "@hyperframes/core/safe-path";
|
|
|
22637
22696
|
import {
|
|
22638
22697
|
existsSync as existsSync31,
|
|
22639
22698
|
readFileSync as readFileSync16,
|
|
22640
|
-
statSync as
|
|
22699
|
+
statSync as statSync13,
|
|
22641
22700
|
openSync as openSync7,
|
|
22642
22701
|
fstatSync as fstatSync3,
|
|
22643
22702
|
closeSync as closeSync7,
|
|
22644
22703
|
constants as constants3
|
|
22645
22704
|
} from "node:fs";
|
|
22646
|
-
import { resolve as resolve12, join as
|
|
22705
|
+
import { resolve as resolve12, join as join49, relative as relative9, isAbsolute as isAbsolute6, sep as sep7, dirname as dirname19 } from "node:path";
|
|
22647
22706
|
import { fileURLToPath as fileURLToPath6 } from "node:url";
|
|
22648
22707
|
import { Worker as Worker2 } from "node:worker_threads";
|
|
22649
22708
|
function isStringRecord(value) {
|
|
@@ -22678,7 +22737,7 @@ function readEntryHtml(filePath) {
|
|
|
22678
22737
|
} catch (error) {
|
|
22679
22738
|
if (error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR"))
|
|
22680
22739
|
return null;
|
|
22681
|
-
if (!
|
|
22740
|
+
if (!statSync13(filePath, { throwIfNoEntry: false })?.isFile()) return null;
|
|
22682
22741
|
throw error;
|
|
22683
22742
|
}
|
|
22684
22743
|
try {
|
|
@@ -22694,7 +22753,7 @@ function leavesProject(absProjectDir, absoluteEntryPath, isAllowedEntry) {
|
|
|
22694
22753
|
}
|
|
22695
22754
|
function readProjectEntryFile(projectDir, preferredEntryFile, isAllowedEntry) {
|
|
22696
22755
|
const absProjectDir = resolve12(projectDir);
|
|
22697
|
-
if (!existsSync31(absProjectDir) || !
|
|
22756
|
+
if (!existsSync31(absProjectDir) || !statSync13(absProjectDir).isDirectory()) {
|
|
22698
22757
|
return { error: `Project directory not found: ${absProjectDir}` };
|
|
22699
22758
|
}
|
|
22700
22759
|
const entryCandidates = [preferredEntryFile, "index.html", "src/index.html"].filter(
|
|
@@ -22715,7 +22774,7 @@ function readProjectEntryFile(projectDir, preferredEntryFile, isAllowedEntry) {
|
|
|
22715
22774
|
}
|
|
22716
22775
|
}
|
|
22717
22776
|
return {
|
|
22718
|
-
error: `No HTML entry file found in project directory: ${
|
|
22777
|
+
error: `No HTML entry file found in project directory: ${join49(absProjectDir, preferredEntryFile || "index.html")}`
|
|
22719
22778
|
};
|
|
22720
22779
|
}
|
|
22721
22780
|
function prepareHyperframeLintBody(body, isAllowedEntry) {
|
|
@@ -22784,7 +22843,7 @@ function freeLintSlot() {
|
|
|
22784
22843
|
function resolveLintWorkerEntry() {
|
|
22785
22844
|
const here = dirname19(fileURLToPath6(import.meta.url));
|
|
22786
22845
|
for (const name of ["hyperframeLintWorker.js", "hyperframeLintWorker.ts"]) {
|
|
22787
|
-
const candidate =
|
|
22846
|
+
const candidate = join49(here, name);
|
|
22788
22847
|
if (existsSync31(candidate)) return candidate;
|
|
22789
22848
|
}
|
|
22790
22849
|
return void 0;
|
|
@@ -22855,7 +22914,7 @@ async function runHyperframeLint(prepared, options = {}) {
|
|
|
22855
22914
|
// src/services/healthWorker.ts
|
|
22856
22915
|
import { Worker as Worker3 } from "node:worker_threads";
|
|
22857
22916
|
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
22858
|
-
import { dirname as dirname20, join as
|
|
22917
|
+
import { dirname as dirname20, join as join50 } from "node:path";
|
|
22859
22918
|
import { existsSync as existsSync32 } from "node:fs";
|
|
22860
22919
|
var DEFAULT_HEALTH_PORT = 9848;
|
|
22861
22920
|
async function startHealthWorker(options = {}) {
|
|
@@ -22931,7 +22990,7 @@ function defaultLogger2() {
|
|
|
22931
22990
|
}
|
|
22932
22991
|
function resolveWorkerEntry2() {
|
|
22933
22992
|
const here = dirname20(fileURLToPath7(import.meta.url));
|
|
22934
|
-
const candidates = [
|
|
22993
|
+
const candidates = [join50(here, "healthWorkerThread.js"), join50(here, "healthWorkerThread.ts")];
|
|
22935
22994
|
for (const candidate of candidates) {
|
|
22936
22995
|
if (existsSync32(candidate)) return candidate;
|
|
22937
22996
|
}
|
|
@@ -23181,7 +23240,7 @@ function prepareProjectDirectory(projectDir, options, policy) {
|
|
|
23181
23240
|
if (!candidate) return null;
|
|
23182
23241
|
const absProjectDir = policy ? resolve13(policy.projectsDir, candidate) : resolve13(candidate);
|
|
23183
23242
|
const shown = policy ? candidate : absProjectDir;
|
|
23184
|
-
if (policy && !isAllowedProjectPath(policy.projectsDir, absProjectDir) || !existsSync33(absProjectDir) || !
|
|
23243
|
+
if (policy && !isAllowedProjectPath(policy.projectsDir, absProjectDir) || !existsSync33(absProjectDir) || !statSync14(absProjectDir).isDirectory()) {
|
|
23185
23244
|
return { error: `Project directory not found: ${shown}` };
|
|
23186
23245
|
}
|
|
23187
23246
|
const entry = options.entryFile || "index.html";
|
|
@@ -23207,8 +23266,8 @@ async function resolveInlineRenderHtml(body) {
|
|
|
23207
23266
|
}
|
|
23208
23267
|
function materializeInlineProject(html, options) {
|
|
23209
23268
|
const tempRoot = process.env.PRODUCER_TMP_PROJECT_DIR || tmpdir6();
|
|
23210
|
-
const tempProjectDir = mkdtempSync2(
|
|
23211
|
-
writeFileSync14(
|
|
23269
|
+
const tempProjectDir = mkdtempSync2(join51(tempRoot, "producer-project-"));
|
|
23270
|
+
writeFileSync14(join51(tempProjectDir, "index.html"), html, "utf-8");
|
|
23212
23271
|
return {
|
|
23213
23272
|
prepared: {
|
|
23214
23273
|
input: { projectDir: tempProjectDir, ...options },
|
|
@@ -23284,7 +23343,7 @@ function publicPerfSummary(job) {
|
|
|
23284
23343
|
return job.perfSummary ? { ...job.perfSummary, renderId: void 0 } : null;
|
|
23285
23344
|
}
|
|
23286
23345
|
function outputFileSize(path) {
|
|
23287
|
-
return existsSync33(path) ?
|
|
23346
|
+
return existsSync33(path) ? statSync14(path).size : 0;
|
|
23288
23347
|
}
|
|
23289
23348
|
function createBlockingProgressReporter(log, requestId) {
|
|
23290
23349
|
let lastLoggedPct = -10;
|
|
@@ -23615,8 +23674,8 @@ function createRenderHandlers(options = {}) {
|
|
|
23615
23674
|
store.delete(token);
|
|
23616
23675
|
return c.json({ success: false, error: "Output artifact file missing" }, 404);
|
|
23617
23676
|
}
|
|
23618
|
-
const stats =
|
|
23619
|
-
return new Response(
|
|
23677
|
+
const stats = statSync14(artifact.path);
|
|
23678
|
+
return new Response(createReadStream6(artifact.path), {
|
|
23620
23679
|
headers: {
|
|
23621
23680
|
"content-type": "video/mp4",
|
|
23622
23681
|
"content-length": String(stats.size),
|
|
@@ -23802,7 +23861,7 @@ import { quantizeTimeToFrame, MEDIA_VISUAL_STYLE_PROPERTIES } from "@hyperframes
|
|
|
23802
23861
|
// src/services/distributed/planV2Execution.ts
|
|
23803
23862
|
import { mkdtempSync as mkdtempSync3, rmSync as rmSync21 } from "node:fs";
|
|
23804
23863
|
import { tmpdir as tmpdir7 } from "node:os";
|
|
23805
|
-
import { join as
|
|
23864
|
+
import { join as join53 } from "node:path";
|
|
23806
23865
|
|
|
23807
23866
|
// src/services/distributed/assemble.ts
|
|
23808
23867
|
import {
|
|
@@ -23816,13 +23875,14 @@ import {
|
|
|
23816
23875
|
readFileSync as readFileSync17,
|
|
23817
23876
|
readdirSync as readdirSync12,
|
|
23818
23877
|
rmSync as rmSync20,
|
|
23819
|
-
statSync as
|
|
23878
|
+
statSync as statSync15,
|
|
23820
23879
|
writeFileSync as writeFileSync15
|
|
23821
23880
|
} from "node:fs";
|
|
23822
|
-
import { basename as basename9, dirname as dirname22, join as
|
|
23881
|
+
import { basename as basename9, dirname as dirname22, join as join52 } from "node:path";
|
|
23823
23882
|
import {
|
|
23824
23883
|
appendRateCapArgs as appendRateCapArgs2,
|
|
23825
23884
|
appendRenderProvenanceArgs as appendRenderProvenanceArgs2,
|
|
23885
|
+
concatListInputArgs,
|
|
23826
23886
|
describeFfmpegFailure as describeFfmpegFailure5,
|
|
23827
23887
|
getEncoderPreset as getEncoderPreset6,
|
|
23828
23888
|
MIXED_AUDIO_FILENAME as MIXED_AUDIO_FILENAME4,
|
|
@@ -23861,7 +23921,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
|
|
|
23861
23921
|
outputPath,
|
|
23862
23922
|
durationMs: Date.now() - start,
|
|
23863
23923
|
framesEncoded: plan2.totalFrames,
|
|
23864
|
-
fileSize:
|
|
23924
|
+
fileSize: statSync15(outputPath).size
|
|
23865
23925
|
};
|
|
23866
23926
|
}
|
|
23867
23927
|
const format = plan2.dimensions.format;
|
|
@@ -23889,7 +23949,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
|
|
|
23889
23949
|
};
|
|
23890
23950
|
try {
|
|
23891
23951
|
const videoSources = cfrEncoder ? [await reencodeCfr(ctx, chunkPaths, cfrEncoder)] : chunkPaths;
|
|
23892
|
-
const finalPath =
|
|
23952
|
+
const finalPath = join52(workDir, `output.${format}`);
|
|
23893
23953
|
const audio = audioPath !== null && existsSync34(audioPath) ? audioPath : null;
|
|
23894
23954
|
await writeJoined(ctx, videoSources, audio, finalPath);
|
|
23895
23955
|
renameWithRetry11(finalPath, outputPath);
|
|
@@ -23908,7 +23968,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
|
|
|
23908
23968
|
});
|
|
23909
23969
|
}
|
|
23910
23970
|
}
|
|
23911
|
-
const fileSize = existsSync34(outputPath) ?
|
|
23971
|
+
const fileSize = existsSync34(outputPath) ? statSync15(outputPath).size : 0;
|
|
23912
23972
|
return {
|
|
23913
23973
|
...referenceBackgroundResult8(plan2[REFERENCE_BACKGROUND_FIELD6]),
|
|
23914
23974
|
outputPath,
|
|
@@ -23918,8 +23978,8 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
|
|
|
23918
23978
|
};
|
|
23919
23979
|
}
|
|
23920
23980
|
function readAssemblePlan(planDir, chunkPaths) {
|
|
23921
|
-
const planJsonPath =
|
|
23922
|
-
const chunksJsonPath =
|
|
23981
|
+
const planJsonPath = join52(planDir, "plan.json");
|
|
23982
|
+
const chunksJsonPath = join52(planDir, "meta", "chunks.json");
|
|
23923
23983
|
if (!existsSync34(planJsonPath)) {
|
|
23924
23984
|
throw new Error(`[assemble] planDir missing plan.json: ${planJsonPath}`);
|
|
23925
23985
|
}
|
|
@@ -23970,7 +24030,7 @@ function cfrEncodeArgs(inputArgs, encoder, fpsArg) {
|
|
|
23970
24030
|
return args;
|
|
23971
24031
|
}
|
|
23972
24032
|
async function reencodeCfr(ctx, chunkPaths, encoder) {
|
|
23973
|
-
const cfrOutputPath =
|
|
24033
|
+
const cfrOutputPath = join52(ctx.workDir, `cfr.${ctx.format}`);
|
|
23974
24034
|
const cfrArgs = cfrEncodeArgs(videoInputArgs(ctx, chunkPaths), encoder, ctx.fpsArg);
|
|
23975
24035
|
appendRenderProvenanceArgs2(cfrArgs, cfrOutputPath);
|
|
23976
24036
|
cfrArgs.push("-y", cfrOutputPath);
|
|
@@ -23997,7 +24057,7 @@ async function writeJoined(ctx, videoSources, audioPath, finalPath) {
|
|
|
23997
24057
|
);
|
|
23998
24058
|
return;
|
|
23999
24059
|
}
|
|
24000
|
-
const paddedAudioPath =
|
|
24060
|
+
const paddedAudioPath = join52(ctx.workDir, "audio-padded.m4a");
|
|
24001
24061
|
const padTrimResult = await ctx.timed(
|
|
24002
24062
|
"audioMs",
|
|
24003
24063
|
() => padOrTrimAudioToVideoFrameCount({
|
|
@@ -24037,11 +24097,11 @@ async function writeJoined(ctx, videoSources, audioPath, finalPath) {
|
|
|
24037
24097
|
}
|
|
24038
24098
|
}
|
|
24039
24099
|
function concatDemuxerInput(chunkPaths, workDir, fpsArg) {
|
|
24040
|
-
const listPath =
|
|
24100
|
+
const listPath = join52(workDir, "concat-list.txt");
|
|
24041
24101
|
const body = chunkPaths.map((path) => `file '${path.replace(/'/g, "'\\''")}'`).join("\n");
|
|
24042
24102
|
writeFileSync15(listPath, `${body}
|
|
24043
24103
|
`, "utf-8");
|
|
24044
|
-
return ["-r", fpsArg,
|
|
24104
|
+
return ["-r", fpsArg, ...concatListInputArgs(listPath)];
|
|
24045
24105
|
}
|
|
24046
24106
|
async function probeJoinedFrameInfo(videoPaths, fps, signal) {
|
|
24047
24107
|
const infos = await Promise.all(
|
|
@@ -24075,11 +24135,11 @@ function stitchesSeparateAudio(planDir) {
|
|
|
24075
24135
|
return lockedAudio(planDir).separateAudio === true;
|
|
24076
24136
|
}
|
|
24077
24137
|
function planFormat(planDir) {
|
|
24078
|
-
const plan2 = JSON.parse(readFileSync17(
|
|
24138
|
+
const plan2 = JSON.parse(readFileSync17(join52(planDir, "plan.json"), "utf-8"));
|
|
24079
24139
|
return plan2.dimensions.format;
|
|
24080
24140
|
}
|
|
24081
24141
|
function lockedAudio(planDir) {
|
|
24082
|
-
const encoderJsonPath =
|
|
24142
|
+
const encoderJsonPath = join52(planDir, "meta", "encoder.json");
|
|
24083
24143
|
if (!existsSync34(encoderJsonPath)) return {};
|
|
24084
24144
|
return JSON.parse(readFileSync17(encoderJsonPath, "utf-8"));
|
|
24085
24145
|
}
|
|
@@ -24089,7 +24149,7 @@ function readCfrEncoder(planDir, format) {
|
|
|
24089
24149
|
`[assemble] cfr=true is only supported for format="mp4" (got "${format}"). Stream-copy paths for webm and mov already produce exact avg_frame_rate; cfr re-encode is not needed.`
|
|
24090
24150
|
);
|
|
24091
24151
|
}
|
|
24092
|
-
const encoderJsonPath =
|
|
24152
|
+
const encoderJsonPath = join52(planDir, "meta", "encoder.json");
|
|
24093
24153
|
if (!existsSync34(encoderJsonPath)) {
|
|
24094
24154
|
throw new Error(`[assemble] planDir missing meta/encoder.json: ${encoderJsonPath}`);
|
|
24095
24155
|
}
|
|
@@ -24106,7 +24166,7 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
|
|
|
24106
24166
|
mkdirSync22(outputPath, { recursive: true });
|
|
24107
24167
|
let globalIdx = 0;
|
|
24108
24168
|
for (const chunkDir of chunkPaths) {
|
|
24109
|
-
if (!
|
|
24169
|
+
if (!statSync15(chunkDir).isDirectory()) {
|
|
24110
24170
|
throw new Error(
|
|
24111
24171
|
`[assemble] png-sequence chunk must be a directory: ${chunkDir} (got a file)`
|
|
24112
24172
|
);
|
|
@@ -24116,8 +24176,8 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
|
|
|
24116
24176
|
throw new Error(`[assemble] png-sequence chunk has no frames: ${chunkDir}`);
|
|
24117
24177
|
}
|
|
24118
24178
|
for (const frame of frames) {
|
|
24119
|
-
const dst =
|
|
24120
|
-
cpSync3(
|
|
24179
|
+
const dst = join52(outputPath, formatExportFrameName(globalIdx, "png"));
|
|
24180
|
+
cpSync3(join52(chunkDir, frame), dst);
|
|
24121
24181
|
globalIdx += 1;
|
|
24122
24182
|
}
|
|
24123
24183
|
}
|
|
@@ -24127,13 +24187,13 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
|
|
|
24127
24187
|
);
|
|
24128
24188
|
}
|
|
24129
24189
|
if (audioPath !== null && existsSync34(audioPath)) {
|
|
24130
|
-
const sidecar =
|
|
24190
|
+
const sidecar = join52(outputPath, MIXED_AUDIO_FILENAME4);
|
|
24131
24191
|
cpSync3(audioPath, sidecar);
|
|
24132
24192
|
}
|
|
24133
24193
|
let fileSize = 0;
|
|
24134
24194
|
for (const name of readdirSync12(outputPath)) {
|
|
24135
24195
|
try {
|
|
24136
|
-
fileSize +=
|
|
24196
|
+
fileSize += statSync15(join52(outputPath, name)).size;
|
|
24137
24197
|
} catch {
|
|
24138
24198
|
}
|
|
24139
24199
|
}
|
|
@@ -24147,8 +24207,8 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
|
|
|
24147
24207
|
|
|
24148
24208
|
// src/services/distributed/planV2Execution.ts
|
|
24149
24209
|
async function renderChunkV2(planV2Dir, chunkIndex, outputChunkPath, options) {
|
|
24150
|
-
const workRoot = mkdtempSync3(
|
|
24151
|
-
const materializedPlanDir =
|
|
24210
|
+
const workRoot = mkdtempSync3(join53(tmpdir7(), "hf-plan-v2-chunk-"));
|
|
24211
|
+
const materializedPlanDir = join53(workRoot, "plan");
|
|
24152
24212
|
try {
|
|
24153
24213
|
materializePlanV2Target(planV2Dir, { role: "chunk", chunkIndex }, materializedPlanDir);
|
|
24154
24214
|
return await renderChunk(materializedPlanDir, chunkIndex, outputChunkPath, options);
|
|
@@ -24157,8 +24217,8 @@ async function renderChunkV2(planV2Dir, chunkIndex, outputChunkPath, options) {
|
|
|
24157
24217
|
}
|
|
24158
24218
|
}
|
|
24159
24219
|
async function assembleV2(planV2Dir, chunkPaths, outputPath, options) {
|
|
24160
|
-
const workRoot = mkdtempSync3(
|
|
24161
|
-
const materializedPlanDir =
|
|
24220
|
+
const workRoot = mkdtempSync3(join53(tmpdir7(), "hf-plan-v2-assembler-"));
|
|
24221
|
+
const materializedPlanDir = join53(workRoot, "plan");
|
|
24162
24222
|
try {
|
|
24163
24223
|
const materialized = materializePlanV2Target(
|
|
24164
24224
|
planV2Dir,
|