@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.
@@ -104463,6 +104463,27 @@ async function pollPageExpression(page, expression, timeoutMs, intervalMs = 100)
104463
104463
  }
104464
104464
  return Boolean(await page.evaluate(expression));
104465
104465
  }
104466
+ async function applyVideoMetadataHints(page, hints) {
104467
+ if (!hints || hints.length === 0) return;
104468
+ await page.evaluate(
104469
+ (metadataHints) => {
104470
+ for (const hint of metadataHints) {
104471
+ if (!hint.id || !Number.isFinite(hint.width) || !Number.isFinite(hint.height) || hint.width <= 0 || hint.height <= 0) {
104472
+ continue;
104473
+ }
104474
+ const video = document.getElementById(hint.id);
104475
+ if (!video) continue;
104476
+ if (!video.hasAttribute("width")) video.setAttribute("width", String(hint.width));
104477
+ if (!video.hasAttribute("height")) video.setAttribute("height", String(hint.height));
104478
+ const computed = window.getComputedStyle(video);
104479
+ if (!video.style.aspectRatio && (!computed.aspectRatio || computed.aspectRatio === "auto")) {
104480
+ video.style.aspectRatio = `${hint.width} / ${hint.height}`;
104481
+ }
104482
+ }
104483
+ },
104484
+ [...hints]
104485
+ );
104486
+ }
104466
104487
  async function initializeSession(session) {
104467
104488
  const { page, serverUrl } = session;
104468
104489
  page.on("console", (msg) => {
@@ -104506,6 +104527,7 @@ async function initializeSession(session) {
104506
104527
  `[FrameCapture] window.__hf not ready after ${pageReadyTimeout2}ms. Page must expose window.__hf = { duration, seek }.`
104507
104528
  );
104508
104529
  }
104530
+ await applyVideoMetadataHints(page, session.options.videoMetadataHints);
104509
104531
  const skipIdsLiteral = JSON.stringify(session.options.skipReadinessVideoIds ?? []);
104510
104532
  const videosReady = await pollPageExpression(
104511
104533
  page,
@@ -104572,6 +104594,7 @@ async function initializeSession(session) {
104572
104594
  `[FrameCapture] window.__hf not ready after ${pageReadyTimeout}ms. Page must expose window.__hf = { duration, seek }.`
104573
104595
  );
104574
104596
  }
104597
+ await applyVideoMetadataHints(page, session.options.videoMetadataHints);
104575
104598
  const beginframeSkipIdsLiteral = JSON.stringify(session.options.skipReadinessVideoIds ?? []);
104576
104599
  const videoDeadline = Date.now() + (session.config?.playerReadyTimeout ?? DEFAULT_CONFIG.playerReadyTimeout);
104577
104600
  while (Date.now() < videoDeadline) {
@@ -110929,6 +110952,24 @@ function applyRenderModeHints(cfg, compiled, log = defaultLogger) {
110929
110952
  reasons: compiled.renderModeHints.reasons.map((reason) => reason.message)
110930
110953
  });
110931
110954
  }
110955
+ function collectVideoReadinessSkipIds(nativeHdrVideoIds, extractedVideos) {
110956
+ return Array.from(
110957
+ /* @__PURE__ */ new Set([
110958
+ ...nativeHdrVideoIds,
110959
+ ...extractedVideos.filter((video) => hasUsableVideoDimensions(video.metadata)).map((video) => video.videoId)
110960
+ ])
110961
+ ).sort();
110962
+ }
110963
+ function hasUsableVideoDimensions(metadata) {
110964
+ return Number.isFinite(metadata.width) && Number.isFinite(metadata.height) && metadata.width > 0 && metadata.height > 0;
110965
+ }
110966
+ function collectVideoMetadataHints(extractedVideos) {
110967
+ return extractedVideos.filter((video) => hasUsableVideoDimensions(video.metadata)).map((video) => ({
110968
+ id: video.videoId,
110969
+ width: video.metadata.width,
110970
+ height: video.metadata.height
110971
+ })).sort((a, b) => a.id.localeCompare(b.id));
110972
+ }
110932
110973
  function resolveRenderWorkerCount(totalFrames, requestedWorkers, cfg, compiled, composition, log = defaultLogger, measuredCaptureCost) {
110933
110974
  const captureCost = combineCaptureCostEstimates(
110934
110975
  estimateCaptureCostMultiplier(compiled, composition),
@@ -111943,6 +111984,8 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
111943
111984
  let frameLookup = null;
111944
111985
  const compiledDir = join16(workDir, "compiled");
111945
111986
  let extractionResult = null;
111987
+ let videoReadinessSkipIds = [];
111988
+ let videoMetadataHints = [];
111946
111989
  const nativeHdrVideoIds = /* @__PURE__ */ new Set();
111947
111990
  const videoTransfers = /* @__PURE__ */ new Map();
111948
111991
  if (job.config.hdrMode !== "force-sdr" && composition.videos.length > 0) {
@@ -111999,6 +112042,11 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
111999
112042
  if (extractionResult.extracted.length > 0) {
112000
112043
  frameLookup = createFrameLookupTable(composition.videos, extractionResult.extracted);
112001
112044
  }
112045
+ videoReadinessSkipIds = collectVideoReadinessSkipIds(
112046
+ nativeHdrVideoIds,
112047
+ extractionResult.extracted
112048
+ );
112049
+ videoMetadataHints = collectVideoMetadataHints(extractionResult.extracted);
112002
112050
  perfStages.videoExtractMs = Date.now() - stage2Start;
112003
112051
  const existingAudioSrcs = new Set(composition.audios.map((a) => a.src));
112004
112052
  for (const ext of extractionResult.extracted) {
@@ -112112,9 +112160,10 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
112112
112160
  format: needsAlpha ? "png" : "jpeg",
112113
112161
  quality: needsAlpha ? void 0 : job.config.quality === "draft" ? 80 : 95
112114
112162
  };
112115
- const buildHdrCaptureOptions = () => ({
112163
+ const buildCaptureOptions = () => ({
112116
112164
  ...captureOptions,
112117
- skipReadinessVideoIds: Array.from(nativeHdrVideoIds)
112165
+ videoMetadataHints,
112166
+ skipReadinessVideoIds: videoReadinessSkipIds
112118
112167
  });
112119
112168
  let captureCalibration;
112120
112169
  let switchedToScreenshotAfterCalibration = false;
@@ -112127,7 +112176,7 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
112127
112176
  calibrationSession = await createCaptureSession(
112128
112177
  fileServer.url,
112129
112178
  calibrationDir,
112130
- buildHdrCaptureOptions(),
112179
+ buildCaptureOptions(),
112131
112180
  videoInjector,
112132
112181
  calibrationCfg
112133
112182
  );
@@ -112251,7 +112300,7 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
112251
112300
  const domSession = await createCaptureSession(
112252
112301
  fileServer.url,
112253
112302
  framesDir,
112254
- buildHdrCaptureOptions(),
112303
+ buildCaptureOptions(),
112255
112304
  createVideoFrameInjector(frameLookup),
112256
112305
  cfg
112257
112306
  );
@@ -112784,7 +112833,7 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
112784
112833
  fileServer.url,
112785
112834
  workDir,
112786
112835
  tasks,
112787
- buildHdrCaptureOptions(),
112836
+ buildCaptureOptions(),
112788
112837
  () => createVideoFrameInjector(frameLookup),
112789
112838
  abortSignal,
112790
112839
  (progress) => {
@@ -112814,7 +112863,7 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
112814
112863
  const session = probeSession ?? await createCaptureSession(
112815
112864
  fileServer.url,
112816
112865
  framesDir,
112817
- buildHdrCaptureOptions(),
112866
+ buildCaptureOptions(),
112818
112867
  videoInjector,
112819
112868
  cfg
112820
112869
  );
@@ -112869,7 +112918,7 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
112869
112918
  initialWorkerCount: workerCount,
112870
112919
  allowRetry: job.config.workers === void 0,
112871
112920
  frameExt: needsAlpha ? "png" : "jpg",
112872
- captureOptions: buildHdrCaptureOptions(),
112921
+ captureOptions: buildCaptureOptions(),
112873
112922
  createBeforeCaptureHook: () => createVideoFrameInjector(frameLookup),
112874
112923
  abortSignal,
112875
112924
  onProgress: (progress) => {
@@ -112904,7 +112953,7 @@ async function executeRenderJob(job, projectDir, outputPath, onProgress, abortSi
112904
112953
  const session = probeSession ?? await createCaptureSession(
112905
112954
  fileServer.url,
112906
112955
  framesDir,
112907
- buildHdrCaptureOptions(),
112956
+ buildCaptureOptions(),
112908
112957
  videoInjector,
112909
112958
  cfg
112910
112959
  );