@hyperframes/producer 0.4.39 → 0.4.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -101674,6 +101674,27 @@ async function pollPageExpression(page, expression, timeoutMs, intervalMs = 100)
|
|
|
101674
101674
|
}
|
|
101675
101675
|
return Boolean(await page.evaluate(expression));
|
|
101676
101676
|
}
|
|
101677
|
+
async function applyVideoMetadataHints(page, hints) {
|
|
101678
|
+
if (!hints || hints.length === 0) return;
|
|
101679
|
+
await page.evaluate(
|
|
101680
|
+
(metadataHints) => {
|
|
101681
|
+
for (const hint of metadataHints) {
|
|
101682
|
+
if (!hint.id || !Number.isFinite(hint.width) || !Number.isFinite(hint.height) || hint.width <= 0 || hint.height <= 0) {
|
|
101683
|
+
continue;
|
|
101684
|
+
}
|
|
101685
|
+
const video = document.getElementById(hint.id);
|
|
101686
|
+
if (!video) continue;
|
|
101687
|
+
if (!video.hasAttribute("width")) video.setAttribute("width", String(hint.width));
|
|
101688
|
+
if (!video.hasAttribute("height")) video.setAttribute("height", String(hint.height));
|
|
101689
|
+
const computed = window.getComputedStyle(video);
|
|
101690
|
+
if (!video.style.aspectRatio && (!computed.aspectRatio || computed.aspectRatio === "auto")) {
|
|
101691
|
+
video.style.aspectRatio = `${hint.width} / ${hint.height}`;
|
|
101692
|
+
}
|
|
101693
|
+
}
|
|
101694
|
+
},
|
|
101695
|
+
[...hints]
|
|
101696
|
+
);
|
|
101697
|
+
}
|
|
101677
101698
|
async function initializeSession(session) {
|
|
101678
101699
|
const { page, serverUrl } = session;
|
|
101679
101700
|
page.on("console", (msg) => {
|
|
@@ -101717,6 +101738,7 @@ async function initializeSession(session) {
|
|
|
101717
101738
|
`[FrameCapture] window.__hf not ready after ${pageReadyTimeout2}ms. Page must expose window.__hf = { duration, seek }.`
|
|
101718
101739
|
);
|
|
101719
101740
|
}
|
|
101741
|
+
await applyVideoMetadataHints(page, session.options.videoMetadataHints);
|
|
101720
101742
|
const skipIdsLiteral = JSON.stringify(session.options.skipReadinessVideoIds ?? []);
|
|
101721
101743
|
const videosReady = await pollPageExpression(
|
|
101722
101744
|
page,
|
|
@@ -101783,6 +101805,7 @@ async function initializeSession(session) {
|
|
|
101783
101805
|
`[FrameCapture] window.__hf not ready after ${pageReadyTimeout}ms. Page must expose window.__hf = { duration, seek }.`
|
|
101784
101806
|
);
|
|
101785
101807
|
}
|
|
101808
|
+
await applyVideoMetadataHints(page, session.options.videoMetadataHints);
|
|
101786
101809
|
const beginframeSkipIdsLiteral = JSON.stringify(session.options.skipReadinessVideoIds ?? []);
|
|
101787
101810
|
const videoDeadline = Date.now() + (session.config?.playerReadyTimeout ?? DEFAULT_CONFIG.playerReadyTimeout);
|
|
101788
101811
|
while (Date.now() < videoDeadline) {
|
|
@@ -110764,6 +110787,24 @@ function applyRenderModeHints(cfg, compiled, log = defaultLogger) {
|
|
|
110764
110787
|
reasons: compiled.renderModeHints.reasons.map((reason) => reason.message)
|
|
110765
110788
|
});
|
|
110766
110789
|
}
|
|
110790
|
+
function collectVideoReadinessSkipIds(nativeHdrVideoIds, extractedVideos) {
|
|
110791
|
+
return Array.from(
|
|
110792
|
+
/* @__PURE__ */ new Set([
|
|
110793
|
+
...nativeHdrVideoIds,
|
|
110794
|
+
...extractedVideos.filter((video) => hasUsableVideoDimensions(video.metadata)).map((video) => video.videoId)
|
|
110795
|
+
])
|
|
110796
|
+
).sort();
|
|
110797
|
+
}
|
|
110798
|
+
function hasUsableVideoDimensions(metadata) {
|
|
110799
|
+
return Number.isFinite(metadata.width) && Number.isFinite(metadata.height) && metadata.width > 0 && metadata.height > 0;
|
|
110800
|
+
}
|
|
110801
|
+
function collectVideoMetadataHints(extractedVideos) {
|
|
110802
|
+
return extractedVideos.filter((video) => hasUsableVideoDimensions(video.metadata)).map((video) => ({
|
|
110803
|
+
id: video.videoId,
|
|
110804
|
+
width: video.metadata.width,
|
|
110805
|
+
height: video.metadata.height
|
|
110806
|
+
})).sort((a, b) => a.id.localeCompare(b.id));
|
|
110807
|
+
}
|
|
110767
110808
|
function resolveRenderWorkerCount(totalFrames, requestedWorkers, cfg, compiled, composition, log = defaultLogger, measuredCaptureCost) {
|
|
110768
110809
|
const captureCost = combineCaptureCostEstimates(
|
|
110769
110810
|
estimateCaptureCostMultiplier(compiled, composition),
|
|
@@ -111778,6 +111819,8 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
|
|
|
111778
111819
|
let frameLookup = null;
|
|
111779
111820
|
const compiledDir = join16(workDir, "compiled");
|
|
111780
111821
|
let extractionResult = null;
|
|
111822
|
+
let videoReadinessSkipIds = [];
|
|
111823
|
+
let videoMetadataHints = [];
|
|
111781
111824
|
const nativeHdrVideoIds = /* @__PURE__ */ new Set();
|
|
111782
111825
|
const videoTransfers = /* @__PURE__ */ new Map();
|
|
111783
111826
|
if (job.config.hdrMode !== "force-sdr" && composition.videos.length > 0) {
|
|
@@ -111834,6 +111877,11 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
|
|
|
111834
111877
|
if (extractionResult.extracted.length > 0) {
|
|
111835
111878
|
frameLookup = createFrameLookupTable(composition.videos, extractionResult.extracted);
|
|
111836
111879
|
}
|
|
111880
|
+
videoReadinessSkipIds = collectVideoReadinessSkipIds(
|
|
111881
|
+
nativeHdrVideoIds,
|
|
111882
|
+
extractionResult.extracted
|
|
111883
|
+
);
|
|
111884
|
+
videoMetadataHints = collectVideoMetadataHints(extractionResult.extracted);
|
|
111837
111885
|
perfStages.videoExtractMs = Date.now() - stage2Start;
|
|
111838
111886
|
const existingAudioSrcs = new Set(composition.audios.map((a) => a.src));
|
|
111839
111887
|
for (const ext of extractionResult.extracted) {
|
|
@@ -111947,9 +111995,10 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
|
|
|
111947
111995
|
format: needsAlpha ? "png" : "jpeg",
|
|
111948
111996
|
quality: needsAlpha ? void 0 : job.config.quality === "draft" ? 80 : 95
|
|
111949
111997
|
};
|
|
111950
|
-
const
|
|
111998
|
+
const buildCaptureOptions = () => ({
|
|
111951
111999
|
...captureOptions,
|
|
111952
|
-
|
|
112000
|
+
videoMetadataHints,
|
|
112001
|
+
skipReadinessVideoIds: videoReadinessSkipIds
|
|
111953
112002
|
});
|
|
111954
112003
|
let captureCalibration;
|
|
111955
112004
|
let switchedToScreenshotAfterCalibration = false;
|
|
@@ -111962,7 +112011,7 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
|
|
|
111962
112011
|
calibrationSession = await createCaptureSession(
|
|
111963
112012
|
fileServer.url,
|
|
111964
112013
|
calibrationDir,
|
|
111965
|
-
|
|
112014
|
+
buildCaptureOptions(),
|
|
111966
112015
|
videoInjector,
|
|
111967
112016
|
calibrationCfg
|
|
111968
112017
|
);
|
|
@@ -112086,7 +112135,7 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
|
|
|
112086
112135
|
const domSession = await createCaptureSession(
|
|
112087
112136
|
fileServer.url,
|
|
112088
112137
|
framesDir,
|
|
112089
|
-
|
|
112138
|
+
buildCaptureOptions(),
|
|
112090
112139
|
createVideoFrameInjector(frameLookup),
|
|
112091
112140
|
cfg
|
|
112092
112141
|
);
|
|
@@ -112619,7 +112668,7 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
|
|
|
112619
112668
|
fileServer.url,
|
|
112620
112669
|
workDir,
|
|
112621
112670
|
tasks,
|
|
112622
|
-
|
|
112671
|
+
buildCaptureOptions(),
|
|
112623
112672
|
() => createVideoFrameInjector(frameLookup),
|
|
112624
112673
|
abortSignal,
|
|
112625
112674
|
(progress) => {
|
|
@@ -112649,7 +112698,7 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
|
|
|
112649
112698
|
const session = probeSession ?? await createCaptureSession(
|
|
112650
112699
|
fileServer.url,
|
|
112651
112700
|
framesDir,
|
|
112652
|
-
|
|
112701
|
+
buildCaptureOptions(),
|
|
112653
112702
|
videoInjector,
|
|
112654
112703
|
cfg
|
|
112655
112704
|
);
|
|
@@ -112704,7 +112753,7 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
|
|
|
112704
112753
|
initialWorkerCount: workerCount,
|
|
112705
112754
|
allowRetry: job.config.workers === void 0,
|
|
112706
112755
|
frameExt: needsAlpha ? "png" : "jpg",
|
|
112707
|
-
captureOptions:
|
|
112756
|
+
captureOptions: buildCaptureOptions(),
|
|
112708
112757
|
createBeforeCaptureHook: () => createVideoFrameInjector(frameLookup),
|
|
112709
112758
|
abortSignal,
|
|
112710
112759
|
onProgress: (progress) => {
|
|
@@ -112739,7 +112788,7 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
|
|
|
112739
112788
|
const session = probeSession ?? await createCaptureSession(
|
|
112740
112789
|
fileServer.url,
|
|
112741
112790
|
framesDir,
|
|
112742
|
-
|
|
112791
|
+
buildCaptureOptions(),
|
|
112743
112792
|
videoInjector,
|
|
112744
112793
|
cfg
|
|
112745
112794
|
);
|