@hyperframes/producer 0.9.31 → 0.9.32
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/README.md +1 -0
- package/dist/distributed.js +61 -15
- package/dist/index.js +182 -40
- package/dist/public-server.js +203 -50
- package/dist/renderRequest.d.ts +1 -0
- package/dist/server.d.ts +1 -0
- package/dist/services/distributed/projectHash.d.ts +1 -1
- package/dist/services/render/captureImageFormat.d.ts +14 -3
- package/dist/services/render/chromaSubsampling.d.ts +18 -0
- package/dist/services/render/shared.d.ts +1 -1
- package/dist/services/renderOrchestrator.d.ts +6 -2
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -56,6 +56,7 @@ are rejected before a render starts. This is separate from engine sub-frame
|
|
|
56
56
|
| `format` | `"mp4"` | Output container — `"mp4"`, `"webm"`, `"mov"`, `"gif"`, `"png-sequence"`, or `"hls"`. See [Transparent Video Output](#transparent-video-output) and [HLS Output](#hls-output) below. |
|
|
57
57
|
| `hlsSegmentSeconds` | `4` | HLS target segment length in whole seconds. Ignored for every other format. |
|
|
58
58
|
| `videoFrameFormat` | `"auto"` | Source video frame extraction format — `"auto"`, `"jpg"`, or `"png"`. Use `"png"` for UI recordings, screen captures, and color-sensitive source videos. |
|
|
59
|
+
| `chromaSubsampling` | `"420"` | MP4 chroma, `"420"` or `"444"`. `"444"` encodes yuv444p from lossless PNG capture for text/UI masters; SDR MP4 and software encoder only. Many players cannot decode it. |
|
|
59
60
|
|
|
60
61
|
## Transparent Video Output
|
|
61
62
|
|
package/dist/distributed.js
CHANGED
|
@@ -964,6 +964,9 @@ import {
|
|
|
964
964
|
CANVAS_DIMENSIONS,
|
|
965
965
|
checkOutputResolutionCompatibility
|
|
966
966
|
} from "@hyperframes/core";
|
|
967
|
+
import {
|
|
968
|
+
mediaIdPathSegment
|
|
969
|
+
} from "@hyperframes/engine";
|
|
967
970
|
|
|
968
971
|
// src/utils/paths.ts
|
|
969
972
|
import {
|
|
@@ -1041,6 +1044,10 @@ function writeCompiledArtifacts(compiled, workDir, includeSummary) {
|
|
|
1041
1044
|
writeFileSync(join3(compileDir, "index.html"), compiled.html, "utf-8");
|
|
1042
1045
|
for (const [srcPath, html] of compiled.subCompositions) {
|
|
1043
1046
|
const outPath = join3(compileDir, srcPath);
|
|
1047
|
+
if (!isPathInside2(outPath, compileDir)) {
|
|
1048
|
+
console.warn(`[Render] Skipping sub-composition with unsafe path: ${srcPath}`);
|
|
1049
|
+
continue;
|
|
1050
|
+
}
|
|
1044
1051
|
mkdirSync(dirname2(outPath), { recursive: true });
|
|
1045
1052
|
writeFileSync(outPath, html, "utf-8");
|
|
1046
1053
|
}
|
|
@@ -1251,7 +1258,7 @@ function materializeExtractedFramesForCompiledDir(extracted, compiledDir, option
|
|
|
1251
1258
|
for (const ext of extracted) {
|
|
1252
1259
|
const resolvedOut = pathModule.resolve(ext.outputDir);
|
|
1253
1260
|
if (isPathInside2(resolvedOut, resolvedCompiledDir, { pathModule })) continue;
|
|
1254
|
-
const linkPath = pathModule.join(compiledFrameRoot, ext.videoId);
|
|
1261
|
+
const linkPath = pathModule.join(compiledFrameRoot, mediaIdPathSegment(ext.videoId));
|
|
1255
1262
|
if (!fileSystem.existsSync(linkPath)) {
|
|
1256
1263
|
fileSystem.mkdirSync(pathModule.dirname(linkPath), { recursive: true });
|
|
1257
1264
|
stageExtractedFrameDir(
|
|
@@ -1703,6 +1710,7 @@ import { dirname as dirname3, join as join4 } from "node:path";
|
|
|
1703
1710
|
import {
|
|
1704
1711
|
createFrameLookupTable,
|
|
1705
1712
|
extractVideoFramesRange,
|
|
1713
|
+
mediaIdPathSegment as mediaIdPathSegment2,
|
|
1706
1714
|
runVideoExtractionWithRetry
|
|
1707
1715
|
} from "@hyperframes/engine";
|
|
1708
1716
|
function contiguousRuns(sortedIndexes) {
|
|
@@ -1743,7 +1751,7 @@ async function extractDeferredFrames(input) {
|
|
|
1743
1751
|
const shown = shownDeferredFrameIndexes(input, input.frames, input.fps);
|
|
1744
1752
|
return Promise.all(
|
|
1745
1753
|
deferred.map(async (video) => {
|
|
1746
|
-
const outputDir = join4(input.outputRoot, video.videoId);
|
|
1754
|
+
const outputDir = join4(input.outputRoot, mediaIdPathSegment2(video.videoId));
|
|
1747
1755
|
const indexes = [...shown.get(video.videoId) ?? []].sort((a, b) => a - b);
|
|
1748
1756
|
if (indexes.length === 0) {
|
|
1749
1757
|
return { ...video, outputDir, framePaths: /* @__PURE__ */ new Map(), ownedByLookup: false };
|
|
@@ -4915,6 +4923,14 @@ function resolveEntryHtmlPath(input) {
|
|
|
4915
4923
|
log.info("Extracted standalone entry from index.html host context", { entryFile });
|
|
4916
4924
|
return wrapperPath;
|
|
4917
4925
|
}
|
|
4926
|
+
function applyChroma444Gate(cfg, chromaSubsampling, gate, log) {
|
|
4927
|
+
if (!cfg.useDrawElement || chromaSubsampling !== "444") return gate;
|
|
4928
|
+
cfg.useDrawElement = false;
|
|
4929
|
+
log.info(
|
|
4930
|
+
"[Render] Fast capture: chromaSubsampling 444 captures lossless PNG frames, so disabling drawElementImage for this render. Capture uses the platform's baseline route."
|
|
4931
|
+
);
|
|
4932
|
+
return "chroma_444";
|
|
4933
|
+
}
|
|
4918
4934
|
async function runCompileStage(input) {
|
|
4919
4935
|
const {
|
|
4920
4936
|
projectDir,
|
|
@@ -4966,6 +4982,7 @@ async function runCompileStage(input) {
|
|
|
4966
4982
|
"[Render] Fast capture: composition uses shader transitions, so disabling drawElementImage so page-side compositing stays available."
|
|
4967
4983
|
);
|
|
4968
4984
|
}
|
|
4985
|
+
deCompileGate = applyChroma444Gate(cfg, job.config.chromaSubsampling, deCompileGate, log);
|
|
4969
4986
|
if (!cfg.useDrawElement && cfg.pageSideCompositingAutoDisabled) {
|
|
4970
4987
|
cfg.enablePageSideCompositing = true;
|
|
4971
4988
|
cfg.pageSideCompositingAutoDisabled = false;
|
|
@@ -5077,11 +5094,19 @@ function isActionableProbeFailure(line) {
|
|
|
5077
5094
|
|
|
5078
5095
|
// src/services/render/captureImageFormat.ts
|
|
5079
5096
|
function resolveCaptureImageFormat(input) {
|
|
5080
|
-
return input.needsAlpha || input.motionBlur ? "png" : "jpeg";
|
|
5097
|
+
return input.needsAlpha || input.motionBlur || input.chromaSubsampling === "444" ? "png" : "jpeg";
|
|
5081
5098
|
}
|
|
5082
5099
|
function resolveCaptureJpegQuality(quality) {
|
|
5083
5100
|
return quality === "draft" ? 80 : 100;
|
|
5084
5101
|
}
|
|
5102
|
+
function resolveCaptureSurface(input, quality) {
|
|
5103
|
+
const format = resolveCaptureImageFormat(input);
|
|
5104
|
+
return {
|
|
5105
|
+
format,
|
|
5106
|
+
quality: format === "png" ? void 0 : resolveCaptureJpegQuality(quality),
|
|
5107
|
+
transparent: input.needsAlpha
|
|
5108
|
+
};
|
|
5109
|
+
}
|
|
5085
5110
|
|
|
5086
5111
|
// src/services/render/stages/probeStage.ts
|
|
5087
5112
|
var FRAME_BOUNDARY_EPSILON = 1e-3;
|
|
@@ -5258,15 +5283,15 @@ async function runProbeStage(input) {
|
|
|
5258
5283
|
});
|
|
5259
5284
|
assertNotAborted();
|
|
5260
5285
|
const motionBlur = job.config.motionBlur;
|
|
5261
|
-
const captureFormat = resolveCaptureImageFormat({ needsAlpha, motionBlur });
|
|
5262
5286
|
const captureOpts = {
|
|
5263
5287
|
recordReferenceBackground: input.recordReferenceBackground,
|
|
5264
5288
|
width,
|
|
5265
5289
|
height,
|
|
5266
5290
|
fps: job.config.fps,
|
|
5267
|
-
|
|
5268
|
-
|
|
5269
|
-
|
|
5291
|
+
...resolveCaptureSurface(
|
|
5292
|
+
{ needsAlpha, motionBlur, chromaSubsampling: job.config.chromaSubsampling },
|
|
5293
|
+
job.config.quality
|
|
5294
|
+
),
|
|
5270
5295
|
variables: job.config.variables,
|
|
5271
5296
|
deviceScaleFactor,
|
|
5272
5297
|
motionBlur,
|
|
@@ -7893,13 +7918,20 @@ function captureAttemptMadeProgress(attemptTargetFrameCount, remainingFrameCount
|
|
|
7893
7918
|
return remainingFrameCount < attemptTargetFrameCount;
|
|
7894
7919
|
}
|
|
7895
7920
|
var FIRST_FRAME_STALL_MS = 3e5;
|
|
7921
|
+
var FIRST_FRAME_STARTUP_FACTOR = 2;
|
|
7922
|
+
var FIRST_FRAME_STALL_CEILING_MS = 9e5;
|
|
7896
7923
|
var TAIL_STALL_MS = FIRST_FRAME_STALL_MS;
|
|
7897
|
-
function
|
|
7924
|
+
function firstFrameWindowMs(probeStartupMs) {
|
|
7925
|
+
const fromStartup = (probeStartupMs ?? 0) * FIRST_FRAME_STARTUP_FACTOR;
|
|
7926
|
+
if (!Number.isFinite(fromStartup)) return FIRST_FRAME_STALL_MS;
|
|
7927
|
+
return Math.max(FIRST_FRAME_STALL_MS, Math.min(FIRST_FRAME_STALL_CEILING_MS, fromStartup));
|
|
7928
|
+
}
|
|
7929
|
+
function frameStallRule(job, totalFrames, probeStartupMs) {
|
|
7898
7930
|
const noProgressMs = resolveCaptureStallTimeoutMs();
|
|
7899
7931
|
return {
|
|
7900
7932
|
progress: () => job.framesRendered ?? 0,
|
|
7901
7933
|
noProgressMs,
|
|
7902
|
-
firstProgressMs: Math.max(
|
|
7934
|
+
firstProgressMs: Math.max(firstFrameWindowMs(probeStartupMs), noProgressMs),
|
|
7903
7935
|
complete: () => (job.framesRendered ?? 0) >= totalFrames,
|
|
7904
7936
|
tailMs: Math.max(TAIL_STALL_MS, noProgressMs),
|
|
7905
7937
|
detail: () => describeWorkerPhases(job),
|
|
@@ -8148,7 +8180,8 @@ import { existsSync as existsSync17, readdirSync as readdirSync4 } from "node:fs
|
|
|
8148
8180
|
import { extname as extname2, join as join19 } from "node:path";
|
|
8149
8181
|
import {
|
|
8150
8182
|
compositionRequiresWebGpu as compositionRequiresWebGpu3,
|
|
8151
|
-
createVideoFrameInjector as createVideoFrameInjector3
|
|
8183
|
+
createVideoFrameInjector as createVideoFrameInjector3,
|
|
8184
|
+
mediaIdPathSegment as mediaIdPathSegment3
|
|
8152
8185
|
} from "@hyperframes/engine";
|
|
8153
8186
|
|
|
8154
8187
|
// src/services/distributed/shared.ts
|
|
@@ -8485,7 +8518,7 @@ function frameNumberFromFileName(name) {
|
|
|
8485
8518
|
function rebuildExtractedFramesFromPlanDir(planDir, videos, indexMode = "dense-v1") {
|
|
8486
8519
|
const result = [];
|
|
8487
8520
|
for (const v of videos) {
|
|
8488
|
-
const outputDir = join19(planDir, "video-frames", v.videoId);
|
|
8521
|
+
const outputDir = join19(planDir, "video-frames", mediaIdPathSegment3(v.videoId));
|
|
8489
8522
|
if (!existsSync17(outputDir)) {
|
|
8490
8523
|
throw new Error(
|
|
8491
8524
|
`[renderChunk] planDir missing extracted video frames for ${JSON.stringify(v.videoId)}: ${outputDir} not present. plan() should have written frames here; the planDir is malformed.`
|
|
@@ -10787,7 +10820,11 @@ import {
|
|
|
10787
10820
|
import { tmpdir } from "node:os";
|
|
10788
10821
|
import { dirname as dirname14, isAbsolute as isAbsolute4, join as join29, relative as relative6, resolve as resolve9, sep as sep4 } from "node:path";
|
|
10789
10822
|
import { DISTRIBUTED_FPS, isDistributedFps } from "@hyperframes/core";
|
|
10790
|
-
import {
|
|
10823
|
+
import {
|
|
10824
|
+
createFrameLookupTable as createFrameLookupTable5,
|
|
10825
|
+
mediaIdPathSegment as mediaIdPathSegment4,
|
|
10826
|
+
renameWithRetry as renameWithRetry10
|
|
10827
|
+
} from "@hyperframes/engine";
|
|
10791
10828
|
|
|
10792
10829
|
// src/services/distributed/planV2Publisher.ts
|
|
10793
10830
|
import {
|
|
@@ -10992,7 +11029,7 @@ function isExtractionCacheCompleteSentinelPath(path) {
|
|
|
10992
11029
|
}
|
|
10993
11030
|
function resolveExtractedVideoOutputDir(planDir, videoId) {
|
|
10994
11031
|
const videoRoot = resolve9(planDir, "video-frames");
|
|
10995
|
-
const outputDir = resolve9(videoRoot, videoId);
|
|
11032
|
+
const outputDir = resolve9(videoRoot, mediaIdPathSegment4(videoId));
|
|
10996
11033
|
if (outputDir === videoRoot || !outputDir.startsWith(`${videoRoot}${sep4}`)) {
|
|
10997
11034
|
throw new PlanV2IntegrityError(`unsafe extracted video id: ${JSON.stringify(videoId)}`);
|
|
10998
11035
|
}
|
|
@@ -12581,7 +12618,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
|
12581
12618
|
openAttempt,
|
|
12582
12619
|
verifyFirstSession: forceScreenshot || !verifyInWorker ? void 0 : verifyFirstWorker
|
|
12583
12620
|
}),
|
|
12584
|
-
{ stall: frameStallRule(job, framesInChunk) }
|
|
12621
|
+
{ stall: frameStallRule(job, framesInChunk, void 0) }
|
|
12585
12622
|
).catch(async (captureError) => {
|
|
12586
12623
|
await overlap.current?.abort();
|
|
12587
12624
|
overlap.current = null;
|
|
@@ -12936,6 +12973,13 @@ function validateDistributedRenderConfig(config) {
|
|
|
12936
12973
|
`distributed mode supports only ${ALLOWED_HDR_MODES.join(", ")}; got ${String(config.hdrMode)}`
|
|
12937
12974
|
);
|
|
12938
12975
|
}
|
|
12976
|
+
const chromaSubsampling = config.chromaSubsampling;
|
|
12977
|
+
if (chromaSubsampling !== void 0 && chromaSubsampling !== "420") {
|
|
12978
|
+
throw new InvalidConfigError(
|
|
12979
|
+
"config.chromaSubsampling",
|
|
12980
|
+
`distributed mode encodes 4:2:0 only; got ${String(chromaSubsampling)}`
|
|
12981
|
+
);
|
|
12982
|
+
}
|
|
12939
12983
|
if (config.variables !== void 0) {
|
|
12940
12984
|
validateVariablesPayload(config.variables);
|
|
12941
12985
|
}
|
|
@@ -13037,12 +13081,14 @@ import { createHash as createHash8 } from "node:crypto";
|
|
|
13037
13081
|
import { join as join33 } from "node:path";
|
|
13038
13082
|
var SITE_ID_SCHEME = "site-v2\0";
|
|
13039
13083
|
var READ_CHUNK_BYTES = 256 * 1024;
|
|
13084
|
+
var ENV_FILE = /^\.env([._-].*|rc)?$/i;
|
|
13085
|
+
var leftOut = (rel, name) => rel === "" && PLAN_PROJECT_DIR_SKIP_SEGMENTS.has(name) || ENV_FILE.test(name);
|
|
13040
13086
|
function listSiteFiles(projectDir) {
|
|
13041
13087
|
const files = [];
|
|
13042
13088
|
const ancestors = /* @__PURE__ */ new Set([realpathSync2(projectDir)]);
|
|
13043
13089
|
function walk(dir, rel) {
|
|
13044
13090
|
for (const name of readdirSync10(dir).sort()) {
|
|
13045
|
-
if (rel
|
|
13091
|
+
if (leftOut(rel, name)) continue;
|
|
13046
13092
|
const full = join33(dir, name);
|
|
13047
13093
|
const relPath = rel === "" ? name : `${rel}/${name}`;
|
|
13048
13094
|
let stat;
|