hyperframes 0.8.199 → 0.8.201

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.
Files changed (192) hide show
  1. package/dist/{add-7LA5CGDM.js → add-33XNCMY4.js} +15 -18
  2. package/dist/{animatedGifPrep-NB2MZTMQ.js → animatedGifPrep-MI7Z4OYQ.js} +9 -12
  3. package/dist/api.js +17 -20
  4. package/dist/{asset-4BIOI6GN.js → asset-RMRQN24O.js} +2 -2
  5. package/dist/{assetCataloger-TX5KL5VV.js → assetCataloger-KWTQNFUU.js} +9 -12
  6. package/dist/{audio-ZGMIIDNU.js → audio-SQDZZS6X.js} +34 -32
  7. package/dist/{auth-OQ5PWEUG.js → auth-PNC6K5ZD.js} +2 -2
  8. package/dist/{autoUpdate-QREPD6I4.js → autoUpdate-MBZFLUF2.js} +2 -2
  9. package/dist/{backgroundChecks-5CJPJX2O.js → backgroundChecks-ZMSPA6TK.js} +3 -3
  10. package/dist/backgroundChecksWorker.js +3 -3
  11. package/dist/{batchRender-BW2ZK4MA.js → batchRender-2MMOZRMW.js} +5 -7
  12. package/dist/{beats-I5XARMDB.js → beats-GDLNPR4A.js} +33 -24
  13. package/dist/{benchmark-S2WWY4U7.js → benchmark-AUKB3XDF.js} +12 -14
  14. package/dist/{browser-PAXVQYQZ.js → browser-C3AU5TST.js} +6 -6
  15. package/dist/{bundleWithLocalizedFonts-3ED26VCR.js → bundleWithLocalizedFonts-G3UT65XI.js} +2 -2
  16. package/dist/{capture-23574YLP.js → capture-EKNPCFPF.js} +16 -18
  17. package/dist/{capture-OVITDMKK.js → capture-XGBPNGC5.js} +2 -2
  18. package/dist/{captureCompositionFrame-KAUUHCOL.js → captureCompositionFrame-4HHLPTDH.js} +14 -17
  19. package/dist/{catalog-CM3VXSQE.js → catalog-HLDNEJX3.js} +15 -18
  20. package/dist/{catch-up-HMFREOC2.js → catch-up-LRFV4LJO.js} +6 -6
  21. package/dist/{check-CYJZ6CGT.js → check-XWHWGNYE.js} +40 -43
  22. package/dist/{checkBrowser-GZJ3W2OP.js → checkBrowser-KSOBXPJ3.js} +35 -38
  23. package/dist/{chunk-MMQ52NIZ.js → chunk-2BGOB2QK.js} +500 -17
  24. package/dist/{chunk-D5CZCYYT.js → chunk-2FA53V5S.js} +2 -2
  25. package/dist/{chunk-FV5GKRAO.js → chunk-3J5KO4EJ.js} +8 -10
  26. package/dist/{chunk-UMBCYIFE.js → chunk-47NZWTJL.js} +2 -2
  27. package/dist/{chunk-JFIEV2J4.js → chunk-53E45AKI.js} +60 -34
  28. package/dist/{chunk-BFYDVTD3.js → chunk-6UFEOVR5.js} +2 -2
  29. package/dist/{chunk-M6IMQBK6.js → chunk-6XGO7ZKS.js} +1 -1
  30. package/dist/{chunk-UVQLSMAR.js → chunk-74UH2KGI.js} +30 -6
  31. package/dist/{chunk-TVR744AS.js → chunk-7EJ7OZGC.js} +16 -3
  32. package/dist/{chunk-7QB46WTF.js → chunk-7WEGIXI3.js} +2 -2
  33. package/dist/{chunk-TTWFTEUG.js → chunk-A7YO6YSD.js} +6 -6
  34. package/dist/{chunk-HK45GJMI.js → chunk-AK2MOAJY.js} +192 -65
  35. package/dist/{chunk-TF7LCULS.js → chunk-B67P2WP3.js} +2 -2
  36. package/dist/chunk-B7CYKBXQ.js +36 -0
  37. package/dist/{chunk-DMRDGGNM.js → chunk-CD5ZU6PN.js} +9 -7
  38. package/dist/{chunk-IC6BO4GU.js → chunk-CV32PRH3.js} +65 -21
  39. package/dist/{chunk-UBSAHYWA.js → chunk-DS3XITZ5.js} +2 -2
  40. package/dist/{chunk-ILFDFMYJ.js → chunk-DWULQYOQ.js} +3 -3
  41. package/dist/{chunk-VHBBV5DH.js → chunk-ERUINDRT.js} +62 -25
  42. package/dist/{chunk-FMTJ4I6I.js → chunk-FDWN4XAD.js} +1 -1
  43. package/dist/{chunk-K5O6JTJQ.js → chunk-GC6N2LH5.js} +10 -12
  44. package/dist/{chunk-5CTORVUM.js → chunk-GHROWWUN.js} +32 -1
  45. package/dist/{chunk-T4IJMVCB.js → chunk-GKXH4C2B.js} +1 -1
  46. package/dist/{chunk-QYOUK3UO.js → chunk-GNX3BCQP.js} +2 -2
  47. package/dist/{chunk-IELYOY6S.js → chunk-I4DHHX7E.js} +3 -3
  48. package/dist/{chunk-FZ2VPLXL.js → chunk-IDRUJFT4.js} +2 -2
  49. package/dist/{chunk-KFZPWUPN.js → chunk-IFOZZYHK.js} +7 -7
  50. package/dist/{chunk-3CFTCM7X.js → chunk-IHQBTZHE.js} +3 -3
  51. package/dist/{chunk-OZVRCLEN.js → chunk-IIH24PKY.js} +2 -2
  52. package/dist/{chunk-K65XUUJX.js → chunk-ITJAHKYO.js} +1 -1
  53. package/dist/{chunk-6JR2XUEE.js → chunk-IXXVS2Z4.js} +1 -1
  54. package/dist/{chunk-IMVTN367.js → chunk-JOI7TNCX.js} +2 -2
  55. package/dist/{chunk-KG3BVLA4.js → chunk-JXLHLR26.js} +1 -1
  56. package/dist/{chunk-DY53XJ3P.js → chunk-K2AUGELJ.js} +1 -1
  57. package/dist/{chunk-VWPU6URV.js → chunk-L33EDCSR.js} +5 -5
  58. package/dist/{chunk-BYLC52GJ.js → chunk-LVEXHBSH.js} +1 -1
  59. package/dist/{chunk-XOTUPVIF.js → chunk-MSGWR7WP.js} +9 -1
  60. package/dist/{chunk-DWUOGV3M.js → chunk-ORMTNJBS.js} +3 -3
  61. package/dist/{chunk-Z6Q4ASCD.js → chunk-Q537KXWA.js} +153 -44
  62. package/dist/{chunk-YAMRODVV.js → chunk-Q6SHXSZX.js} +3 -2
  63. package/dist/{chunk-GQVTTWZF.js → chunk-QB4K2EWI.js} +1 -1
  64. package/dist/{chunk-T6AGUTZJ.js → chunk-QSFWGZG6.js} +7 -38
  65. package/dist/{chunk-XP55QWOB.js → chunk-QTWSMJ22.js} +15 -15
  66. package/dist/{chunk-M2GO2AAS.js → chunk-QXBZ6VBL.js} +1 -1
  67. package/dist/{chunk-65HUC64P.js → chunk-QYTGUWNF.js} +1 -1
  68. package/dist/{chunk-CMHVLASW.js → chunk-RVKJDAYE.js} +1 -1
  69. package/dist/{chunk-HRZ6ZBKO.js → chunk-SEAHCCQ4.js} +70 -51
  70. package/dist/{chunk-7SKOZHIY.js → chunk-SGKG7DNX.js} +3 -3
  71. package/dist/{chunk-6RRO4GE3.js → chunk-SIZYTGG4.js} +1 -1
  72. package/dist/{chunk-4QG64APO.js → chunk-SZNCAINN.js} +1 -1
  73. package/dist/{chunk-S5WSJVHP.js → chunk-T33GLS6C.js} +3 -3
  74. package/dist/{chunk-SQQZUUK6.js → chunk-TAXGZAXM.js} +10 -10
  75. package/dist/{chunk-GQACWAOC.js → chunk-TOT3CLUK.js} +1 -1
  76. package/dist/{chunk-2KZSKIYY.js → chunk-TYRDDIIH.js} +1 -1
  77. package/dist/{chunk-HOAXHVRR.js → chunk-U2EK5MFR.js} +10 -10
  78. package/dist/{chunk-QXPZGDTI.js → chunk-UIIGEPYY.js} +3 -3
  79. package/dist/{chunk-W2LGJSEN.js → chunk-UIOZIIB7.js} +33 -3
  80. package/dist/{chunk-L6FG62QM.js → chunk-UKB62QOT.js} +446 -151
  81. package/dist/{chunk-JN63IPHT.js → chunk-UOSTDTBF.js} +1 -1
  82. package/dist/{chunk-LPDNR3R4.js → chunk-VCVUEK65.js} +3 -3
  83. package/dist/{chunk-PO5PAROC.js → chunk-VF2VMKNI.js} +3 -3
  84. package/dist/{chunk-XVZZQVT4.js → chunk-VKTUZP7U.js} +1 -1
  85. package/dist/{chunk-NY2OH5XD.js → chunk-WO3XZ6HC.js} +1 -1
  86. package/dist/{chunk-7YZME6DE.js → chunk-X72DJZCM.js} +1 -1
  87. package/dist/{chunk-PGDWNIOK.js → chunk-XDMZY3H7.js} +57 -5
  88. package/dist/{chunk-QH4425AL.js → chunk-XG365L6T.js} +1 -1
  89. package/dist/{chunk-NUZMP7SV.js → chunk-XHVQIOOF.js} +19 -19
  90. package/dist/{chunk-FHDKRWQN.js → chunk-XONIZ5CH.js} +13 -13
  91. package/dist/{chunk-RYCANWOM.js → chunk-YBJECXQJ.js} +5 -5
  92. package/dist/{chunk-AHZLNYZY.js → chunk-YTBE4JCX.js} +1 -1
  93. package/dist/{chunk-VLVQQJOX.js → chunk-ZDVJXWEG.js} +22 -3
  94. package/dist/chunk-ZKHXN2BV.js +3983 -0
  95. package/dist/{clean-QX6LKOWJ.js → clean-EUKURSX2.js} +22 -25
  96. package/dist/cli.js +54 -54
  97. package/dist/{cloud-ASA7Y3HA.js → cloud-LJDRNQ2N.js} +4 -4
  98. package/dist/{cloudrun-LK4GJWUZ.js → cloudrun-AXVFD6KV.js} +7 -9
  99. package/dist/{compare-426Z2ND6.js → compare-T3LMATAF.js} +32 -35
  100. package/dist/{compiler-WER7FC5O.js → compiler-KH6DMHIJ.js} +6 -10
  101. package/dist/{component-HTDWZMEG.js → component-2FOHCMP2.js} +3 -3
  102. package/dist/{compositions-EKRLQ5TU.js → compositions-REQ6ARAO.js} +14 -17
  103. package/dist/{delete-KHXM6R7A.js → delete-KEPP2QAZ.js} +2 -2
  104. package/dist/{deploy-WJ5JQJBD.js → deploy-N756FEME.js} +1 -1
  105. package/dist/{deterministicFonts-RMA7GDJC.js → deterministicFonts-4FULD3AS.js} +2 -2
  106. package/dist/{dist-EYJATCTF.js → dist-5ULOGA6A.js} +30 -16
  107. package/dist/{dist-ONHJ6ZDA.js → dist-TFHABY7N.js} +2 -4
  108. package/dist/{doctor-NB3G2GDG.js → doctor-2SJPC4WZ.js} +15 -18
  109. package/dist/{dotEnv-64S3VKGH.js → dotEnv-RPHCAUBZ.js} +1 -1
  110. package/dist/{events-LH6W5ZCV.js → events-24ZE2PKB.js} +5 -5
  111. package/dist/{events-6EL5NIJV.js → events-U53QH4XZ.js} +4 -4
  112. package/dist/{feedback-2GNY725M.js → feedback-QFMLDLUN.js} +11 -13
  113. package/dist/{ffmpeg-XX3O53B3.js → ffmpeg-7XNWNO7M.js} +9 -12
  114. package/dist/{figma-X7KKOOXB.js → figma-B4JO44CV.js} +3 -3
  115. package/dist/fontLocalizeCli.js +12 -15
  116. package/dist/{get-M57U7QCX.js → get-7CFVCINR.js} +2 -2
  117. package/dist/{gpuPolicy-GIBBYBI5.js → gpuPolicy-MU7CFSAF.js} +9 -12
  118. package/dist/{grade-compare-XNY37UYQ.js → grade-compare-Q23U2HGS.js} +33 -36
  119. package/dist/{help-ZXSPZBUG.js → help-M67MEDV3.js} +1 -1
  120. package/dist/{history-G5B4IPBH.js → history-I2PZXOFL.js} +9 -9
  121. package/dist/hyperframe.manifest.json +1 -1
  122. package/dist/hyperframe.runtime.iife.js +66 -62
  123. package/dist/hyperframes-player.global.js +3 -3
  124. package/dist/{info-ZWZDG54W.js → info-Z2MX54IE.js} +11 -13
  125. package/dist/{init-F4XMU6SV.js → init-SWH5KZO2.js} +30 -33
  126. package/dist/{inspect-6VXFMQRR.js → inspect-WBBDB3YS.js} +33 -36
  127. package/dist/{installer-4M3Y5T5F.js → installer-DQIHGUBJ.js} +6 -9
  128. package/dist/{keyframes-3U466AWX.js → keyframes-PSNEUS6P.js} +8 -8
  129. package/dist/{lambda-OPSTAEF6.js → lambda-KSZFMQ3L.js} +9 -11
  130. package/dist/{layout-B3MXD3F3.js → layout-AAOI7W2M.js} +33 -36
  131. package/dist/{lint-TVOEGW63.js → lint-GGNVITIK.js} +10 -12
  132. package/dist/{lintProject-FKPKSU6M.js → lintProject-Q36Y3AHA.js} +2 -4
  133. package/dist/{list-M5GQSFVT.js → list-OFPDL2AM.js} +2 -2
  134. package/dist/{login-HBHGZIDN.js → login-MZAHGGP4.js} +4 -4
  135. package/dist/{manager-COSJVRAE.js → manager-F34TSFV6.js} +3 -3
  136. package/dist/{manager-VLIJARMF.js → manager-ZOFTZTRY.js} +10 -13
  137. package/dist/{media-treatment-RQZ437VS.js → media-treatment-PF67GSUD.js} +67 -43
  138. package/dist/{models-2CCKVBTR.js → models-WR7CL54R.js} +13 -16
  139. package/dist/{motionShot-3IFRSICA.js → motionShot-ISLDWLIU.js} +18 -21
  140. package/dist/{normalize-audio-23H2MBDP.js → normalize-audio-D7AH5GFZ.js} +45 -27
  141. package/dist/{open-J33KT3G7.js → open-HPVBB2CX.js} +15 -18
  142. package/dist/{parakeetRunner-QTXNEMVY.js → parakeetRunner-P6PE4WXG.js} +14 -17
  143. package/dist/{pipeline-2ECWWEBD.js → pipeline-XKBZG2CM.js} +10 -13
  144. package/dist/{play-G5777L7A.js → play-QXHO47ZH.js} +24 -27
  145. package/dist/{preflight-NVFB4HXQ.js → preflight-KZCU66ES.js} +12 -15
  146. package/dist/{present-4EI2BE4Z.js → present-ERGC5PR4.js} +20 -23
  147. package/dist/{preview-HYCIDZ52.js → preview-AGTOQIE7.js} +21 -24
  148. package/dist/{producer-6JAATJVD.js → producer-4ONVM5A2.js} +1 -1
  149. package/dist/{projectConfig-XPGN76VV.js → projectConfig-7T4VY6RJ.js} +8 -11
  150. package/dist/{publication-YRZ7EBUV.js → publication-J5TS5VR3.js} +4 -6
  151. package/dist/{publish-UIDHN7KD.js → publish-BSOVXRF4.js} +11 -14
  152. package/dist/{remove-background-LPQP4WBN.js → remove-background-645NVCGL.js} +11 -14
  153. package/dist/{render-LFJQNVCK.js → render-55TYPJ5U.js} +7 -9
  154. package/dist/{render-NZSNQFYW.js → render-IAVH33YG.js} +38 -34
  155. package/dist/{render-DT3OCUCV.js → render-R3L44QAP.js} +36 -38
  156. package/dist/{render-batch-QI2A45WH.js → render-batch-JWWLQ7ZC.js} +7 -9
  157. package/dist/renderSetupWorker.js +5 -7
  158. package/dist/{resolver-4YDXG4PP.js → resolver-DBAFWC4F.js} +6 -8
  159. package/dist/{sherpa-XLKWFYFO.js → sherpa-UPWG6TKY.js} +13 -16
  160. package/dist/skills/hyperframes/references/runtimes.md +26 -0
  161. package/dist/skills/media-use/references/mixing.md +1 -1
  162. package/dist/skills/media-use/scripts/lib/grade-analyzer.mjs +38 -26
  163. package/dist/{skills-OVVLZHF5.js → skills-ILH52UL4.js} +7 -7
  164. package/dist/{skillsUpdateCheck-Y2UQA7I5.js → skillsUpdateCheck-ZHFDGMEL.js} +3 -3
  165. package/dist/{snapshot-7NVB5WSO.js → snapshot-WMVHIQVQ.js} +94 -61
  166. package/dist/{src-ACAFJXAJ.js → src-46QTOHZE.js} +11 -14
  167. package/dist/{src-QQPHMIJ7.js → src-HPLELQRK.js} +12 -11
  168. package/dist/{staticProjectServer-JUN6BRTW.js → staticProjectServer-FHP2YQFV.js} +19 -22
  169. package/dist/{status-H5WLKQDS.js → status-LR7VXITS.js} +2 -2
  170. package/dist/studio/assets/{hyperframes-player-BDtBfwof.js → hyperframes-player-BNeO6YSP.js} +1 -1
  171. package/dist/studio/assets/{index-BFfBBQMu.js → index-CZWE0FI8.js} +162 -162
  172. package/dist/studio/assets/{index--W_0fuR8.js → index-DiNYtcMK.js} +1 -1
  173. package/dist/studio/index.html +1 -1
  174. package/dist/{studio-api-D76Q4Q2N.js → studio-api-5YHQ4Y2D.js} +12 -15
  175. package/dist/{studioServer-HG3RFAOY.js → studioServer-P6IC76SV.js} +54 -57
  176. package/dist/{system-7F3UEHQT.js → system-YD4AW5ZX.js} +4 -3
  177. package/dist/{telemetry-Q2EHWVO4.js → telemetry-WZ7OGFWQ.js} +5 -5
  178. package/dist/{timeline-WDQCCETQ.js → timeline-U6S7BGMI.js} +24 -26
  179. package/dist/{tokens-2GJWP2HY.js → tokens-FPUYNZSV.js} +2 -2
  180. package/dist/{transcribe-Z63Y53GQ.js → transcribe-DJX4E2PE.js} +19 -22
  181. package/dist/{transcribe-SRLAY6RG.js → transcribe-DZHTKXI5.js} +12 -15
  182. package/dist/{updateCheck-MJ6NDE3T.js → updateCheck-2LHWRDE7.js} +2 -2
  183. package/dist/{upgrade-D5XEX3XE.js → upgrade-WAQHCAUS.js} +2 -2
  184. package/dist/{urlDownloader-R7BZ47TY.js → urlDownloader-HZQPXQET.js} +8 -11
  185. package/dist/{validate-F5BIDZLN.js → validate-D6XJ7OSS.js} +27 -30
  186. package/dist/{video-QUG5OG5Q.js → video-A4CQ4WDL.js} +9 -12
  187. package/dist/warmCheck.js +40 -43
  188. package/package.json +1 -1
  189. package/dist/chunk-2ONVJ7NT.js +0 -3901
  190. package/dist/chunk-BSQ7XANM.js +0 -210
  191. package/dist/chunk-PKZ7RK5N.js +0 -281
  192. package/dist/chunk-X7HBSTCZ.js +0 -53
@@ -14,6 +14,7 @@ import {
14
14
  MEDIA_VISUAL_STYLE_PROPERTIES,
15
15
  RENDER_FRAME_ID_PREFIX,
16
16
  RENDER_FRAME_ID_SUFFIX,
17
+ SCENE_CALLBACK_ERROR_PREFIX,
17
18
  exportClipWindow,
18
19
  firstFrameColourArgs,
19
20
  fpsToFfmpegArg,
@@ -27,7 +28,7 @@ import {
27
28
  renderFrameIdForRenderId,
28
29
  resolveAuthoredTimingWindow,
29
30
  toFps
30
- } from "./chunk-UVQLSMAR.js";
31
+ } from "./chunk-74UH2KGI.js";
31
32
  import {
32
33
  AUDIO_GROUP_RENDER_ID_ATTR,
33
34
  COLOR_GRADING_SOURCE_HIDDEN_ATTR,
@@ -42,11 +43,14 @@ import {
42
43
  PAGE_MOTION_BLUR_OFF_GLOBAL,
43
44
  VOLUME_TARGET,
44
45
  acceleratedCanvasTrackerSource,
46
+ clampAudioGain,
47
+ clipGain,
45
48
  enabledAudioFxNodes,
46
49
  fxAutomationTarget,
47
50
  gainedVolume,
48
51
  gainedVolumePoints,
49
52
  injectScriptsIntoHtml,
53
+ isAudibleVideoElement,
50
54
  isBentSegment,
51
55
  normalizeAudioFxParams,
52
56
  normalizePlaybackRate,
@@ -64,12 +68,7 @@ import {
64
68
  sourceTimeAt,
65
69
  timeAtSourceTime,
66
70
  volumeSegmentSampleCount
67
- } from "./chunk-2ONVJ7NT.js";
68
- import {
69
- clampAudioGain,
70
- clipGain,
71
- isAudibleVideoElement
72
- } from "./chunk-X7HBSTCZ.js";
71
+ } from "./chunk-ZKHXN2BV.js";
73
72
  import {
74
73
  redactTelemetryString,
75
74
  redactUrlQueryStrings
@@ -87,7 +86,7 @@ import {
87
86
  } from "./chunk-4UMPIPCQ.js";
88
87
  import {
89
88
  resolveReferencedStart
90
- } from "./chunk-IC6BO4GU.js";
89
+ } from "./chunk-CV32PRH3.js";
91
90
  import {
92
91
  FFMPEG_PATH_ENV,
93
92
  FFPROBE_PATH_ENV,
@@ -99,7 +98,7 @@ import {
99
98
  } from "./chunk-6BNTGNGD.js";
100
99
  import {
101
100
  isPathInside
102
- } from "./chunk-BSQ7XANM.js";
101
+ } from "./chunk-2BGOB2QK.js";
103
102
  import {
104
103
  parseHTML
105
104
  } from "./chunk-SDYDNHEE.js";
@@ -107,9 +106,10 @@ import {
107
106
  LOW_MEMORY_TOTAL_MB_THRESHOLD,
108
107
  describeWslGpuAccess,
109
108
  detectWsl,
109
+ getAvailableMemoryMb,
110
110
  getSystemTotalMb,
111
111
  isLowMemorySystem
112
- } from "./chunk-W2LGJSEN.js";
112
+ } from "./chunk-UIOZIIB7.js";
113
113
 
114
114
  // ../engine/src/config.ts
115
115
  import { tmpdir } from "os";
@@ -1397,7 +1397,7 @@ async function launchBrowser(fingerprint) {
1397
1397
  const gpuFlags = fingerprint.args.filter(
1398
1398
  (a) => a.startsWith("--use-gl=") || a.startsWith("--use-angle=")
1399
1399
  );
1400
- console.log(
1400
+ console.error(
1401
1401
  `[BrowserManager] Browser launched (${browserVersion}, ${captureMode}, gl=${gpuFlags.join(" ") || "default"}, headlessShell=${!!fingerprint.executablePath}, platform=${process.platform})`
1402
1402
  );
1403
1403
  if (captureMode === "beginframe") {
@@ -1590,31 +1590,50 @@ function compositionRequiresWebGpu(html) {
1590
1590
  var WebGpuUnavailableError = class extends Error {
1591
1591
  constructor() {
1592
1592
  super(
1593
- "This composition declares data-requires-webgpu, but no hardware WebGPU adapter could be obtained on this browser launch. Run on a host with a GPU, set PRODUCER_ALLOW_SOFTWARE_WEBGPU=true to render it on SwiftShader (slow), or remove data-requires-webgpu."
1593
+ "This composition declares data-requires-webgpu, but a usable WebGPU device could not be created on this browser launch. Run on a host with a GPU, set PRODUCER_ALLOW_SOFTWARE_WEBGPU=true to render it on SwiftShader (slow), or remove data-requires-webgpu."
1594
1594
  );
1595
1595
  this.name = "WebGpuUnavailableError";
1596
1596
  }
1597
1597
  };
1598
- var WEBGPU_ADAPTER_PROBE_TIMEOUT_MS = 1e4;
1598
+ var WEBGPU_DEVICE_PROBE_TIMEOUT_MS = 1e4;
1599
1599
  async function assertWebGpuAdapterAvailable(page, requiresWebGpu, softwareWebGpu = false) {
1600
1600
  if (!requiresWebGpu) return;
1601
- const hasUsableAdapter = await page.evaluate(
1601
+ const hasUsableDevice = await page.evaluate(
1602
1602
  async (timeoutMs, acceptFallback) => {
1603
1603
  if (typeof navigator === "undefined" || !navigator.gpu) return false;
1604
+ let expired = false;
1605
+ let timer;
1604
1606
  try {
1605
- const adapter = await Promise.race([
1606
- navigator.gpu.requestAdapter(),
1607
- new Promise((resolve2) => setTimeout(() => resolve2(null), timeoutMs))
1607
+ const probe = async () => {
1608
+ const adapter = await navigator.gpu.requestAdapter();
1609
+ if (!adapter || expired || !acceptFallback && adapter.info.isFallbackAdapter)
1610
+ return false;
1611
+ const device = await adapter.requestDevice();
1612
+ try {
1613
+ return !expired;
1614
+ } finally {
1615
+ device.destroy();
1616
+ }
1617
+ };
1618
+ return await Promise.race([
1619
+ probe(),
1620
+ new Promise((resolve2) => {
1621
+ timer = setTimeout(() => {
1622
+ expired = true;
1623
+ resolve2(false);
1624
+ }, timeoutMs);
1625
+ })
1608
1626
  ]);
1609
- return !!adapter && (acceptFallback || !adapter.info.isFallbackAdapter);
1610
1627
  } catch {
1611
1628
  return false;
1629
+ } finally {
1630
+ clearTimeout(timer);
1612
1631
  }
1613
1632
  },
1614
- WEBGPU_ADAPTER_PROBE_TIMEOUT_MS,
1633
+ WEBGPU_DEVICE_PROBE_TIMEOUT_MS,
1615
1634
  softwareWebGpu
1616
1635
  );
1617
- if (!hasUsableAdapter) throw new WebGpuUnavailableError();
1636
+ if (!hasUsableDevice) throw new WebGpuUnavailableError();
1618
1637
  }
1619
1638
  function getBrowserGpuArgs(mode, platform) {
1620
1639
  if (mode === "software") {
@@ -2832,6 +2851,9 @@ async function captureScreenshotWithAlpha(page, width, height) {
2832
2851
  });
2833
2852
  }
2834
2853
  }
2854
+ function capturesAlpha(options) {
2855
+ return options.transparent ?? options.format === "png";
2856
+ }
2835
2857
  var TRANSPARENT_BG_STYLE_ID = "__hf_transparent_bg__";
2836
2858
  async function initTransparentBackground(page, { clearCompositionRoot = false } = {}) {
2837
2859
  const client = await getCdpSession(page);
@@ -4507,29 +4529,60 @@ async function initThreeDProjection(page) {
4507
4529
  return { ok: false, groups: 0, quads: 0, reason: e instanceof Error ? e.message : String(e) };
4508
4530
  }
4509
4531
  }
4510
- async function detectCssEffectRisk(page) {
4532
+ async function scanCssEffects(page, collect) {
4511
4533
  try {
4512
- return await page.evaluate(() => {
4534
+ return await page.evaluate((collectAll) => {
4513
4535
  const root = document.querySelector("[data-composition-id]");
4514
- if (!root) return null;
4536
+ if (!root) return { reason: null, bounded: true, callbackFrom: null };
4537
+ let reason = null;
4538
+ let bounded = true;
4539
+ const targets = /* @__PURE__ */ new Set();
4540
+ const hit = (name, els) => {
4541
+ reason = reason ?? name;
4542
+ if (els && els.length > 0) for (const el of Array.from(els)) targets.add(el);
4543
+ else bounded = false;
4544
+ return !collectAll;
4545
+ };
4515
4546
  const scanComputed = () => {
4516
4547
  const els = [root, ...Array.from(root.querySelectorAll("*"))];
4517
4548
  for (const el of els) {
4518
4549
  const cs = getComputedStyle(el);
4519
4550
  const bf = cs.backdropFilter || cs.webkitBackdropFilter || "";
4520
- if (bf && bf !== "none") return "backdrop-filter";
4551
+ if (bf && bf !== "none" && hit("backdrop-filter", [el])) return true;
4521
4552
  const f = cs.filter || "";
4522
- if (f && f !== "none" && f.indexOf("blur(") !== -1) return "filter:blur";
4523
- if (f && f !== "none" && f.indexOf("drop-shadow(") !== -1) return "filter:drop-shadow";
4553
+ if (f && f !== "none" && f.indexOf("blur(") !== -1 && hit("filter:blur", [el])) {
4554
+ return true;
4555
+ }
4556
+ if (f && f !== "none" && f.indexOf("drop-shadow(") !== -1 && hit("filter:drop-shadow", [el])) {
4557
+ return true;
4558
+ }
4524
4559
  const mbm = cs.mixBlendMode || "";
4525
- if (mbm && mbm !== "normal") return "mix-blend-mode";
4560
+ if (mbm && mbm !== "normal" && hit("mix-blend-mode", [el])) return true;
4526
4561
  const an = cs.animationName || "";
4527
4562
  const ad = cs.animationDuration || "0s";
4528
- if (an && an !== "none" && ad !== "0s" && parseFloat(ad) > 0) return "css-animation";
4563
+ if (an && an !== "none" && ad !== "0s" && parseFloat(ad) > 0 && hit("css-animation", null)) {
4564
+ return true;
4565
+ }
4529
4566
  }
4530
- return null;
4567
+ return false;
4531
4568
  };
4532
4569
  const scanStyleSheets = () => {
4570
+ const ruleTargets = (rule) => {
4571
+ const selector = rule.selectorText;
4572
+ if (!selector) return [];
4573
+ try {
4574
+ return Array.from(
4575
+ root.querySelectorAll(
4576
+ selector.replace(
4577
+ /::?(before|after|first-line|first-letter|marker|placeholder|selection|backdrop)/g,
4578
+ ""
4579
+ )
4580
+ )
4581
+ );
4582
+ } catch {
4583
+ return [];
4584
+ }
4585
+ };
4533
4586
  for (const sheet of Array.from(document.styleSheets)) {
4534
4587
  let rules = null;
4535
4588
  try {
@@ -4539,54 +4592,153 @@ async function detectCssEffectRisk(page) {
4539
4592
  }
4540
4593
  for (const rule of Array.from(rules ?? [])) {
4541
4594
  const txt = rule.cssText || "";
4542
- if (/backdrop-filter\s*:\s*(?!none)/i.test(txt)) return "backdrop-filter";
4543
- if (/(?:^|[^-])filter\s*:[^;{}]*blur\(/i.test(txt)) return "filter:blur";
4544
- if (/(?:^|[^-])filter\s*:[^;{}]*drop-shadow\(/i.test(txt)) {
4545
- return "filter:drop-shadow";
4546
- }
4547
- if (/mix-blend-mode\s*:\s*(?!normal)/i.test(txt)) return "mix-blend-mode";
4595
+ let name = null;
4596
+ if (/backdrop-filter\s*:\s*(?!none)/i.test(txt)) name = "backdrop-filter";
4597
+ else if (/(?:^|[^-])filter\s*:[^;{}]*blur\(/i.test(txt)) name = "filter:blur";
4598
+ else if (/(?:^|[^-])filter\s*:[^;{}]*drop-shadow\(/i.test(txt)) {
4599
+ name = "filter:drop-shadow";
4600
+ } else if (/mix-blend-mode\s*:\s*(?!normal)/i.test(txt)) name = "mix-blend-mode";
4601
+ if (name && hit(name, ruleTargets(rule))) return true;
4548
4602
  }
4549
4603
  }
4550
- return null;
4604
+ return false;
4551
4605
  };
4552
4606
  const scanTweenVars = () => {
4553
4607
  const walk = (tl) => {
4554
- if (typeof tl.getChildren !== "function") return null;
4608
+ if (typeof tl.getChildren !== "function") return false;
4555
4609
  for (const c of tl.getChildren(false, true, true)) {
4556
- const sub = walk(c);
4557
- if (sub) return sub;
4610
+ if (walk(c)) return true;
4558
4611
  const vars = c.vars || {};
4559
4612
  for (const k of Object.keys(vars)) {
4560
4613
  const kl = k.toLowerCase();
4561
- if (kl.includes("blend")) return "mix-blend-mode";
4562
- if (kl.includes("backdrop")) return "backdrop-filter";
4563
- if (kl === "filter" && /blur\(/i.test(String(vars[k] ?? ""))) return "filter:blur";
4564
- if (kl === "filter" && /drop-shadow\(/i.test(String(vars[k] ?? ""))) {
4565
- return "filter:drop-shadow";
4614
+ let name = null;
4615
+ if (kl.includes("blend")) name = "mix-blend-mode";
4616
+ else if (kl.includes("backdrop")) name = "backdrop-filter";
4617
+ else if (kl === "filter" && /blur\(/i.test(String(vars[k] ?? ""))) {
4618
+ name = "filter:blur";
4619
+ } else if (kl === "filter" && /drop-shadow\(/i.test(String(vars[k] ?? ""))) {
4620
+ name = "filter:drop-shadow";
4566
4621
  }
4622
+ if (!name) continue;
4623
+ const els = (typeof c.targets === "function" ? c.targets() : []).filter(
4624
+ (t) => t instanceof Element
4625
+ );
4626
+ if (hit(name, els)) return true;
4567
4627
  }
4568
4628
  }
4569
- return null;
4629
+ return false;
4570
4630
  };
4571
4631
  const tls = window.__timelines || {};
4572
4632
  for (const tl of Object.values(tls)) {
4573
- const r = walk(tl);
4574
- if (r) return r;
4633
+ if (walk(tl)) return true;
4575
4634
  }
4576
- return null;
4635
+ return false;
4577
4636
  };
4578
4637
  const scanWebgl = () => {
4579
4638
  const aw = window;
4580
4639
  const accel = (aw.__hf_accel_canvases ?? []).filter((c) => root.contains(c));
4581
- return accel.length > 0 ? "webgl-context" : null;
4640
+ return accel.length > 0 && hit("webgl-context", null);
4582
4641
  };
4583
- return scanComputed() || scanStyleSheets() || scanTweenVars() || scanWebgl();
4584
- });
4642
+ for (const scan of [scanComputed, scanStyleSheets, scanTweenVars, scanWebgl]) {
4643
+ if (scan()) break;
4644
+ }
4645
+ const calls = ["onStart", "onUpdate", "onComplete", "onRepeat", "onReverseComplete"];
4646
+ const firstCallback = (node, offset) => {
4647
+ const start = offset + (typeof node.startTime === "function" ? node.startTime() : 0);
4648
+ let first = calls.some((k) => typeof node.vars?.[k] === "function") ? start : Infinity;
4649
+ if (typeof node.getChildren === "function") {
4650
+ for (const child of node.getChildren(false, true, true)) {
4651
+ first = Math.min(first, firstCallback(child, start));
4652
+ }
4653
+ }
4654
+ return first;
4655
+ };
4656
+ const timelines = window.__timelines;
4657
+ const callbackStart = reason ? Math.min(Infinity, ...Object.values(timelines ?? {}).map((tl) => firstCallback(tl, 0))) : Infinity;
4658
+ window.__hfCssFxTargets = [...targets];
4659
+ return {
4660
+ reason,
4661
+ bounded,
4662
+ callbackFrom: Number.isFinite(callbackStart) ? callbackStart : null
4663
+ };
4664
+ }, collect);
4585
4665
  } catch {
4586
- return null;
4666
+ return { reason: null, bounded: true, callbackFrom: null };
4587
4667
  }
4588
4668
  }
4589
4669
 
4670
+ // ../engine/src/services/riskFrames.ts
4671
+ var SCAN_CHUNK_FRAMES = 240;
4672
+ var MAX_RISK_FRAME_FRACTION = 0.6;
4673
+ var RISK_RENDER_ADDED_BYTES = 1e9;
4674
+ var RISK_RENDER_HEADROOM_BYTES = 15e8;
4675
+ var PIXELS_1080P = 1920 * 1080;
4676
+ var RISK_RANGE_HYSTERESIS_FRAMES = 12;
4677
+ async function scanCssEffectLiveFrames(page, fps, totalFrames, maxFrames) {
4678
+ const live = /* @__PURE__ */ new Set();
4679
+ for (let from = 0; from < totalFrames; from += SCAN_CHUNK_FRAMES) {
4680
+ const times = [];
4681
+ for (let f = from; f < Math.min(totalFrames, from + SCAN_CHUNK_FRAMES); f++) {
4682
+ times.push(quantizeTimeToFrame(f / fps, fps));
4683
+ }
4684
+ const hits = await page.evaluate(async (ts) => {
4685
+ const w = window;
4686
+ const targets = w.__hfCssFxTargets ?? [];
4687
+ const paints = (el) => getComputedStyle(el).visibility !== "hidden" || Array.from(el.querySelectorAll("*")).some(
4688
+ (d) => getComputedStyle(d).visibility === "visible"
4689
+ );
4690
+ const shows = (el) => {
4691
+ for (let n = el; n; n = n.parentElement) {
4692
+ const cs = getComputedStyle(n);
4693
+ if (cs.display === "none" || Number(cs.opacity) === 0) return false;
4694
+ }
4695
+ return paints(el);
4696
+ };
4697
+ const out = [];
4698
+ for (let i = 0; i < ts.length; i++) {
4699
+ w.__hf?.seek?.(ts[i]);
4700
+ await w.__hfWaitForSeekCompletion?.();
4701
+ if (targets.some(shows)) out.push(i);
4702
+ }
4703
+ return out;
4704
+ }, times);
4705
+ for (const i of hits) live.add(from + i);
4706
+ if (live.size > maxFrames) break;
4707
+ }
4708
+ return live.size > maxFrames ? null : live;
4709
+ }
4710
+ function planRiskFrames(frames, totalFrames) {
4711
+ const sorted = [...new Set(frames)].sort((a, b) => a - b);
4712
+ const plan = /* @__PURE__ */ new Set();
4713
+ let rangeStart = -1;
4714
+ let rangeEnd = -1;
4715
+ const flush = () => {
4716
+ for (let f = Math.max(0, rangeStart - 1); f <= Math.min(totalFrames - 1, rangeEnd + 1); f++) {
4717
+ plan.add(f);
4718
+ }
4719
+ };
4720
+ for (const f of sorted) {
4721
+ if (rangeStart >= 0 && f - rangeEnd <= RISK_RANGE_HYSTERESIS_FRAMES) {
4722
+ rangeEnd = f;
4723
+ continue;
4724
+ }
4725
+ if (rangeStart >= 0) flush();
4726
+ rangeStart = f;
4727
+ rangeEnd = f;
4728
+ }
4729
+ if (rangeStart >= 0) flush();
4730
+ return plan.size > totalFrames * MAX_RISK_FRAME_FRACTION ? null : plan;
4731
+ }
4732
+ function withFramesAfterCallback(live, callbackFrom, fps, totalFrames) {
4733
+ if (callbackFrom === null) return live;
4734
+ for (let f = Math.max(0, Math.floor(callbackFrom * fps) - 1); f < totalFrames; f++) live.add(f);
4735
+ return live;
4736
+ }
4737
+ function riskSessionFits(availableMb, outputPixels) {
4738
+ const rss = RISK_RENDER_ADDED_BYTES * Math.max(1, outputPixels / PIXELS_1080P);
4739
+ return availableMb * 1024 * 1024 - rss >= RISK_RENDER_HEADROOM_BYTES;
4740
+ }
4741
+
4590
4742
  // ../engine/src/utils/psnrFilterAvailability.ts
4591
4743
  import { execFile } from "child_process";
4592
4744
  import { promisify } from "util";
@@ -4619,19 +4771,26 @@ function pathEncodingHint(configuredPath) {
4619
4771
  }
4620
4772
 
4621
4773
  // ../engine/src/utils/psnrFilterAvailability.ts
4622
- var cachedFilterList = null;
4774
+ var cachedLists = /* @__PURE__ */ new Map();
4775
+ function listed(flag) {
4776
+ let list = cachedLists.get(flag);
4777
+ if (!list) cachedLists.set(flag, list = listFfmpeg(flag));
4778
+ return list;
4779
+ }
4780
+ var listsWord = (stdout, name) => stdout !== null && new RegExp(`(^|\\s)${name}(\\s|$)`, "m").test(stdout);
4623
4781
  function isPsnrFilterAvailable() {
4624
4782
  return isFfmpegFilterAvailable("psnr");
4625
4783
  }
4626
4784
  async function isFfmpegFilterAvailable(name) {
4627
- if (cachedFilterList === null) cachedFilterList = listFilters();
4628
- const stdout = await cachedFilterList;
4629
- return stdout !== null && new RegExp(`(^|\\s)${name}(\\s|$)`, "m").test(stdout);
4785
+ return listsWord(await listed("-filters"), name);
4630
4786
  }
4631
- async function listFilters() {
4787
+ async function isFfmpegHwaccelAvailable(name) {
4788
+ return listsWord(await listed("-hwaccels"), name);
4789
+ }
4790
+ async function listFfmpeg(flag) {
4632
4791
  const execFileP = promisify(execFile);
4633
4792
  try {
4634
- const { stdout } = await execFileP(getFfmpegBinary(), ["-hide_banner", "-filters"], {
4793
+ const { stdout } = await execFileP(getFfmpegBinary(), ["-hide_banner", flag], {
4635
4794
  maxBuffer: 4 * 1024 * 1024,
4636
4795
  timeout: 5e3,
4637
4796
  windowsHide: true
@@ -5276,14 +5435,14 @@ async function initDrawElementOrTransparentBackground(session, page, logInitPhas
5276
5435
  if ((session.config?.useDrawElement ?? false) && supersampling) {
5277
5436
  session.deGateReason = "supersampling";
5278
5437
  session.deFallbackTrigger = "supersampling";
5279
- console.log(
5438
+ console.error(
5280
5439
  "[engine] --experimental-fast-capture disabled for this render: drawElementImage ignores deviceScaleFactor, so scaled (DPR other than 1) output uses screenshot capture."
5281
5440
  );
5282
5441
  }
5283
5442
  if ((session.config?.useDrawElement ?? false) && !supersampling && forceScreenshot) {
5284
5443
  session.deGateReason = "render_mode_hint";
5285
5444
  session.deFallbackTrigger = "render_mode_hint";
5286
- console.log(
5445
+ console.error(
5287
5446
  "[engine] fast capture falls back to screenshot: render-mode compatibility hint forced screenshot capture (e.g. raw requestAnimationFrame composition)."
5288
5447
  );
5289
5448
  }
@@ -5291,7 +5450,7 @@ async function initDrawElementOrTransparentBackground(session, page, logInitPhas
5291
5450
  const gpuBackend = await detectGpuBackend(page);
5292
5451
  session.isSwiftShader = gpuBackend.isSwiftShader;
5293
5452
  session.gpuRenderer = classifyGpuRenderer(gpuBackend.renderer);
5294
- const transparent = session.options.format === "png";
5453
+ const transparent = capturesAlpha(session.options);
5295
5454
  async function routeToFallback() {
5296
5455
  session.captureMode = session.launchCaptureMode;
5297
5456
  if (transparent) {
@@ -5309,7 +5468,7 @@ async function initDrawElementOrTransparentBackground(session, page, logInitPhas
5309
5468
  if (!supportsDrawElement) {
5310
5469
  session.deGateReason = "unsupported_chrome";
5311
5470
  session.deFallbackTrigger = "unsupported_chrome";
5312
- console.log(
5471
+ console.error(
5313
5472
  `[engine] fast capture falls back to ${session.launchCaptureMode} capture: this Chrome build does not implement canvas.drawElementImage (Dev/Canary-only feature); run \`hyperframes browser ensure --force\` to fetch a supported build, or set HYPERFRAMES_BROWSER_PATH to one.`
5314
5473
  );
5315
5474
  await routeToFallback();
@@ -5328,21 +5487,36 @@ async function initDrawElementOrTransparentBackground(session, page, logInitPhas
5328
5487
  if (mode === "screenshot") {
5329
5488
  session.deGateReason = "swiftshader";
5330
5489
  session.deFallbackTrigger = "swiftshader";
5331
- console.log(
5490
+ console.error(
5332
5491
  `[engine] fast capture falls back to ${session.launchCaptureMode} capture: SwiftShader (software rasterizer, no GPU egress to skip, drawElement is parity-or-slower; see fast-capture-limitations.md)`
5333
5492
  );
5334
5493
  await routeToFallback();
5335
5494
  } else {
5495
+ const perFrame = session.options.deFrameFallback === true && drawElementWorkerEncodeEligible(session, transparent) && !forceDE;
5496
+ const riskFrames = /* @__PURE__ */ new Set();
5497
+ const riskReasons = [];
5498
+ let cssFrames = 0;
5499
+ const routeWholeRender = async (reason, trigger, message) => {
5500
+ session.deGateReason = reason;
5501
+ session.deFallbackTrigger = trigger;
5502
+ console.error(
5503
+ `[engine] fast capture falls back to ${session.launchCaptureMode} capture: ${message}`
5504
+ );
5505
+ await routeToFallback();
5506
+ };
5336
5507
  if (!forceDE && process.env.HF_FAST_CAPTURE_CSSFX !== "true") {
5337
- const cssFx = await detectCssEffectRisk(page);
5508
+ const cssFx = (await scanCssEffects(page, false)).reason;
5338
5509
  if (cssFx) {
5339
- session.deGateReason = `css_effect:${(cssFx.split(":")[0] ?? "").replace(/[^a-z-]/gi, "")}`;
5340
- session.deFallbackTrigger = cssFx;
5341
- console.log(
5342
- `[engine] fast capture falls back to ${session.launchCaptureMode} capture: ${cssFx} detected (drawElementImage cannot reproduce it; see fast-capture-limitations.md)`
5343
- );
5344
- await routeToFallback();
5345
- return;
5510
+ const gateReason = `css_effect:${(cssFx.split(":")[0] ?? "").replace(/[^a-z-]/gi, "")}`;
5511
+ const gateMessage = `${cssFx} detected (drawElementImage cannot reproduce it; see fast-capture-limitations.md)`;
5512
+ cssFrames = perFrame ? await renderFrameCount(session, page) : 0;
5513
+ const live = cssFrames > 0 ? await cssEffectRiskFrames(session, cssFrames) : null;
5514
+ if (!live) {
5515
+ await routeWholeRender(gateReason, cssFx, gateMessage);
5516
+ return;
5517
+ }
5518
+ for (const f of live) riskFrames.add(f);
5519
+ riskReasons.push(cssFx);
5346
5520
  }
5347
5521
  }
5348
5522
  if (!forceDE && process.env.HF_FAST_CAPTURE_INTERVAL_SS !== "false") {
@@ -5354,20 +5528,49 @@ async function initDrawElementOrTransparentBackground(session, page, logInitPhas
5354
5528
  `timeline at-risk predictor: ${atRisk.size}/${totalFrames} frames (${Math.round(atRiskFraction * 100)}%)`
5355
5529
  );
5356
5530
  if (atRisk.size > 0 && atRiskFraction > fractionFloor) {
5357
- session.deGateReason = "at_risk_timeline";
5358
- session.deFallbackTrigger = "at_risk_timeline";
5359
- console.log(
5360
- `[engine] fast capture falls back to ${session.launchCaptureMode} capture: ${atRisk.size}/${totalFrames} frames animate a compositor-incompatible prop (blend/3D/clip/mask); drawElementImage drops these mid-animation (deterministic timeline gate; see fast-capture-limitations.md Lim 7)`
5531
+ if (perFrame) {
5532
+ for (const f of atRisk) riskFrames.add(f);
5533
+ riskReasons.push("at_risk_timeline");
5534
+ } else {
5535
+ await routeWholeRender(
5536
+ "at_risk_timeline",
5537
+ "at_risk_timeline",
5538
+ `${atRisk.size}/${totalFrames} frames animate a compositor-incompatible prop (blend/3D/clip/mask); drawElementImage drops these mid-animation (deterministic timeline gate; see fast-capture-limitations.md Lim 7)`
5539
+ );
5540
+ return;
5541
+ }
5542
+ }
5543
+ }
5544
+ if (riskFrames.size > 0) {
5545
+ const total = cssFrames > 0 ? cssFrames : await renderFrameCount(session, page);
5546
+ const plan = total > 0 ? planRiskFrames(riskFrames, total) : null;
5547
+ if (!plan) {
5548
+ await routeWholeRender(
5549
+ "risk_frames",
5550
+ riskReasons.join("+"),
5551
+ `${riskFrames.size}/${total} frames need screenshot capture (${riskReasons.join(", ")}), too many to keep fast capture for the rest`
5361
5552
  );
5362
- await routeToFallback();
5363
5553
  return;
5364
5554
  }
5555
+ if (!riskSessionFits(getAvailableMemoryMb(), session.options.width * session.options.height)) {
5556
+ await routeWholeRender(
5557
+ "risk_session_memory",
5558
+ riskReasons.join("+"),
5559
+ `${plan.size} frames need screenshot capture (${riskReasons.join(", ")}) but too little memory is available for per-frame capture`
5560
+ );
5561
+ return;
5562
+ }
5563
+ session.deRiskFrames = plan;
5564
+ session.deRiskReason = riskReasons.join("+");
5565
+ logInitPhase(
5566
+ `fast capture keeps ${total - plan.size}/${total} frames; ${plan.size} frame(s) capture by screenshot (${session.deRiskReason})`
5567
+ );
5365
5568
  }
5366
5569
  const threeD = await initThreeDProjection(page);
5367
5570
  if (!forceDE && !threeD.ok) {
5368
5571
  session.deGateReason = "3d_init_failed";
5369
5572
  session.deFallbackTrigger = "3d_init_failed";
5370
- console.log(
5573
+ console.error(
5371
5574
  `[engine] fast capture falls back to ${session.launchCaptureMode} capture: 3D projection init failed (${threeD.reason ?? "unknown"})`
5372
5575
  );
5373
5576
  await routeToFallback();
@@ -5379,6 +5582,7 @@ async function initDrawElementOrTransparentBackground(session, page, logInitPhas
5379
5582
  );
5380
5583
  }
5381
5584
  await armStaticDedup(session, page, logInitPhase);
5585
+ for (const f of session.deRiskFrames ?? []) session.staticFrames?.delete(f);
5382
5586
  if (!session.onBeforeCapture && !forceDE) {
5383
5587
  const hasVideos = await page.evaluate(() => document.querySelector("video") !== null);
5384
5588
  if (hasVideos) {
@@ -5389,10 +5593,56 @@ async function initDrawElementOrTransparentBackground(session, page, logInitPhas
5389
5593
  }
5390
5594
  await finalizeDrawElementInit(session, page, logInitPhase, { transparent, forceDE });
5391
5595
  }
5392
- } else if (session.options.format === "png") {
5596
+ } else if (capturesAlpha(session.options)) {
5393
5597
  await initTransparentBackground(session.page);
5394
5598
  }
5395
5599
  }
5600
+ function drawElementWorkerEncodeEligible(session, transparent) {
5601
+ return (session.config?.enableDrawElementWorkerEncode ?? false) && !transparent && session.beginFrameTimeTicks === 0;
5602
+ }
5603
+ async function cssEffectRiskFrames(session, totalFrames) {
5604
+ let scratch = null;
5605
+ try {
5606
+ scratch = await createCaptureSession(
5607
+ session.serverUrl,
5608
+ session.outputDir,
5609
+ { ...session.options, onMemorySample: void 0 },
5610
+ null,
5611
+ {
5612
+ ...session.config,
5613
+ useDrawElement: false,
5614
+ staticFrameDedup: false,
5615
+ enableBrowserPool: false
5616
+ }
5617
+ );
5618
+ await initializeSession(scratch);
5619
+ const scan = await scanCssEffects(scratch.page, true);
5620
+ if (!scan.reason || !scan.bounded) return null;
5621
+ const fps = fpsToNumber(session.options.fps);
5622
+ const live = await scanCssEffectLiveFrames(
5623
+ scratch.page,
5624
+ fps,
5625
+ totalFrames,
5626
+ totalFrames * MAX_RISK_FRAME_FRACTION
5627
+ );
5628
+ return live && withFramesAfterCallback(live, scan.callbackFrom, fps, totalFrames);
5629
+ } catch (error) {
5630
+ console.error(
5631
+ `[engine] fast capture: effect scan failed (${error instanceof Error ? error.message : String(error)})`
5632
+ );
5633
+ return null;
5634
+ } finally {
5635
+ if (scratch) await closeCaptureSession(scratch).catch(() => {
5636
+ });
5637
+ }
5638
+ }
5639
+ async function renderFrameCount(session, page) {
5640
+ const duration = session.options.compositionDurationSeconds ?? await page.evaluate(
5641
+ () => window.__hf?.duration ?? 0
5642
+ );
5643
+ const total = Math.ceil(duration * fpsToNumber(session.options.fps));
5644
+ return isStaticDedupFrameAnalysisSafe(total) ? total : 0;
5645
+ }
5396
5646
  async function finalizeDrawElementInit(session, page, logInitPhase, opts) {
5397
5647
  const { transparent, forceDE } = opts;
5398
5648
  await decodeDynamicCssBackgroundImages(page);
@@ -5416,7 +5666,7 @@ async function finalizeDrawElementInit(session, page, logInitPhase, opts) {
5416
5666
  logInitPhase(`screenshot fallback: ${boundaryFrames.size} clip-boundary frame(s)`);
5417
5667
  }
5418
5668
  }
5419
- const workerEncodeEnabled = (session.config?.enableDrawElementWorkerEncode ?? false) && !transparent && session.beginFrameTimeTicks === 0;
5669
+ const workerEncodeEnabled = drawElementWorkerEncodeEligible(session, transparent);
5420
5670
  if (workerEncodeEnabled) {
5421
5671
  await initDrawElementWorkerEncode(page);
5422
5672
  session.workerEncodeEnabled = true;
@@ -5426,20 +5676,30 @@ async function finalizeDrawElementInit(session, page, logInitPhase, opts) {
5426
5676
  async function completeDeferredDrawElementInit(session) {
5427
5677
  if (!session.deInitDeferred || !session.onBeforeCapture) return;
5428
5678
  const page = session.page;
5429
- const logInitPhase = (phase) => console.log(`[initSession:${session.captureMode}] ${phase} (deferred drawElement init)`);
5679
+ const logInitPhase = (phase) => console.error(`[initSession:${session.captureMode}] ${phase} (deferred drawElement init)`);
5430
5680
  await finalizeDrawElementInit(session, page, logInitPhase, {
5431
- transparent: session.options.format === "png",
5681
+ transparent: capturesAlpha(session.options),
5432
5682
  forceDE: process.env.HF_FORCE_DRAWELEMENT === "1"
5433
5683
  });
5434
5684
  session.deInitDeferred = false;
5435
5685
  }
5686
+ async function installMediaPageHooks(page, options) {
5687
+ await installMediaRenderIdBridge(page);
5688
+ if (options.skipReadinessVideoIds?.length) {
5689
+ await page.evaluateOnNewDocument(
5690
+ holdRenderFrameVideos,
5691
+ options.skipReadinessVideoIds,
5692
+ MEDIA_RENDER_ID_ATTR
5693
+ );
5694
+ }
5695
+ }
5436
5696
  async function createCaptureSession(serverUrl, outputDir, options, onBeforeCapture = null, config) {
5437
5697
  if (!existsSync3(outputDir)) mkdirSync(outputDir, { recursive: true });
5438
5698
  const headlessShell = resolveHeadlessShellPath(config);
5439
5699
  const isLinux = process.platform === "linux";
5440
5700
  const forceScreenshot = config?.forceScreenshot ?? DEFAULT_CONFIG.forceScreenshot;
5441
5701
  const useDrawElement = config?.useDrawElement ?? false;
5442
- const drawElementTransparent = useDrawElement && options.format === "png";
5702
+ const drawElementTransparent = useDrawElement && capturesAlpha(options);
5443
5703
  if (useDrawElement && (config?.enablePageSideCompositing ?? DEFAULT_CONFIG.enablePageSideCompositing)) {
5444
5704
  console.warn(
5445
5705
  "[engine] useDrawElement is incompatible with page-side shader compositing, ignoring enablePageSideCompositing for this render. Prefer resolveConfig, which disables page-side compositing automatically for fast-capture renders."
@@ -5544,14 +5804,7 @@ async function constructCaptureSession(input) {
5544
5804
  w.__name = (fn, _name) => fn;
5545
5805
  }
5546
5806
  });
5547
- await installMediaRenderIdBridge(page);
5548
- if (options.skipReadinessVideoIds?.length) {
5549
- await page.evaluateOnNewDocument(
5550
- holdRenderFrameVideos,
5551
- options.skipReadinessVideoIds,
5552
- MEDIA_RENDER_ID_ATTR
5553
- );
5554
- }
5807
+ await installMediaPageHooks(page, options);
5555
5808
  if (useDrawElement) {
5556
5809
  await page.evaluateOnNewDocument(instrumentAcceleratedCanvases);
5557
5810
  }
@@ -6157,6 +6410,13 @@ function recordConsoleScriptError(session, error) {
6157
6410
  const message = new VfxFailureError(error).message;
6158
6411
  recordCaptureWarnings(session, [{ code: "vfx_failure", message, details: { sources: [error] } }]);
6159
6412
  }
6413
+ function loggedEarlierInRender(session, text) {
6414
+ if (!text.startsWith(SCENE_CALLBACK_ERROR_PREFIX)) return false;
6415
+ const logged = session.subTimelineWaitMemo.loggedSceneCallbackErrors ??= [];
6416
+ if (logged.includes(text)) return true;
6417
+ logged.push(text);
6418
+ return false;
6419
+ }
6160
6420
  function recordPageError(session, error) {
6161
6421
  if (error && !session.pageErrors.includes(error)) session.pageErrors.push(error);
6162
6422
  }
@@ -6199,7 +6459,9 @@ async function initializeSession(session) {
6199
6459
  const text = msg.text();
6200
6460
  const locationUrl = msg.location()?.url ?? "";
6201
6461
  const diagnostic = formatConsoleDiagnostic(type, text, locationUrl);
6202
- if (!diagnostic.suppressHostLog) console.log(diagnostic.text);
6462
+ if (!diagnostic.suppressHostLog && !loggedEarlierInRender(session, text)) {
6463
+ console.error(diagnostic.text);
6464
+ }
6203
6465
  appendBrowserDiagnostic(session, diagnostic.text);
6204
6466
  const scriptFailure = classifyConsoleScriptFailure(type, text);
6205
6467
  if (scriptFailure) recordScriptLoadFailure(session, scriptFailure);
@@ -6260,7 +6522,7 @@ async function initializeSession(session) {
6260
6522
  const pageNavigationTimeout = session.config?.pageNavigationTimeout ?? DEFAULT_CONFIG.pageNavigationTimeout;
6261
6523
  const initStart = Date.now();
6262
6524
  const logInitPhase = (phase) => {
6263
- console.log(`[initSession:${session.captureMode}] ${phase} (${Date.now() - initStart}ms)`);
6525
+ console.error(`[initSession:${session.captureMode}] ${phase} (${Date.now() - initStart}ms)`);
6264
6526
  };
6265
6527
  const gotoEntryPage = async () => {
6266
6528
  appendBrowserDiagnostic(
@@ -6814,6 +7076,7 @@ async function createStaticVerificationPage(session) {
6814
7076
  w.__name = (fn, _name) => fn;
6815
7077
  }
6816
7078
  });
7079
+ await installMediaPageHooks(page, session.options);
6817
7080
  if (session.options.variables && Object.keys(session.options.variables).length > 0) {
6818
7081
  const variablesJson = JSON.stringify(session.options.variables);
6819
7082
  await page.evaluateOnNewDocument((json) => {
@@ -6846,7 +7109,7 @@ async function createStaticVerificationPage(session) {
6846
7109
  page.evaluate(`document.fonts?.ready`),
6847
7110
  waitForOptionalTailwindReady(page, pageReadyTimeout)
6848
7111
  ]);
6849
- if (session.options.format === "png") await initTransparentBackground(page);
7112
+ if (capturesAlpha(session.options)) await initTransparentBackground(page);
6850
7113
  return page;
6851
7114
  } catch (error) {
6852
7115
  await page.close().catch(() => {
@@ -7171,6 +7434,14 @@ async function redrawDrawElementFrame(session, frameIndex, time, seekOptions, he
7171
7434
  true
7172
7435
  );
7173
7436
  }
7437
+ function assertNotRiskFrame(session, frameIndex) {
7438
+ if (session.deRiskFrames?.has(frameIndex)) {
7439
+ throw new DrawElementCaptureError(
7440
+ frameIndex,
7441
+ "frame needs screenshot capture, which this capture path cannot hand over"
7442
+ );
7443
+ }
7444
+ }
7174
7445
  async function captureFrameSurface(session, frameIndex, time, seekOptions, heldVideoTime) {
7175
7446
  const { page, options } = session;
7176
7447
  const { quantizedTime, seekMs, beforeCaptureMs } = await prepareFrameForCapture(
@@ -7208,6 +7479,7 @@ async function captureFrameSurface(session, frameIndex, time, seekOptions, heldV
7208
7479
  "boundary screenshot requested on an injected canvas page"
7209
7480
  );
7210
7481
  } else if (session.captureMode === "drawelement") {
7482
+ assertNotRiskFrame(session, frameIndex);
7211
7483
  if (session.beginFrameTimeTicks > 0) {
7212
7484
  const client = await getCdpSession(page);
7213
7485
  await client.send("HeadlessExperimental.beginFrame", {
@@ -7374,11 +7646,17 @@ async function captureAccumulatedFrame(session, frameIndex, absFrameIndex, plan)
7374
7646
  ...totals
7375
7647
  };
7376
7648
  }
7649
+ function framesAreStatic(staticFrames, from, to) {
7650
+ for (let frame = from; frame <= to; frame++) {
7651
+ if (!staticFrames.has(frame)) return false;
7652
+ }
7653
+ return true;
7654
+ }
7377
7655
  async function captureFrameCore(session, frameIndex, time) {
7378
7656
  const { options } = session;
7379
7657
  const startTime = Date.now();
7380
7658
  const absFrameIndex = Math.floor(time * fpsToNumber(options.fps) + 1e-9);
7381
- if (session.staticFrames?.has(absFrameIndex) && session.lastFrameBuffer && session.lastFrameAbsoluteIndex === absFrameIndex - 1 && (!session.motionBlur || motionBlurWindowIsStatic(session.motionBlur, absFrameIndex, session.staticFrames))) {
7659
+ if (session.staticFrames?.has(absFrameIndex) && session.lastFrameBuffer && session.lastFrameAbsoluteIndex !== void 0 && framesAreStatic(session.staticFrames, session.lastFrameAbsoluteIndex + 1, absFrameIndex) && (!session.motionBlur || motionBlurWindowIsStatic(session.motionBlur, absFrameIndex, session.staticFrames))) {
7382
7660
  session.staticDedupCount = (session.staticDedupCount ?? 0) + 1;
7383
7661
  session.lastFrameAbsoluteIndex = absFrameIndex;
7384
7662
  return {
@@ -7399,7 +7677,7 @@ async function captureFrameCore(session, frameIndex, time) {
7399
7677
  session.capturePerf.frameMs.push(captureTimeMs);
7400
7678
  if (session.capturePerf.frames === 1) {
7401
7679
  const blur = await describePageMotionBlur(session.page).catch(() => null);
7402
- if (blur) console.log(blur);
7680
+ if (blur) console.error(blur);
7403
7681
  }
7404
7682
  if (session.staticFrames) {
7405
7683
  session.lastFrameBuffer = buffer;
@@ -7443,7 +7721,7 @@ async function captureFrameToBuffer(session, frameIndex, time) {
7443
7721
  DE_FRAME_TIMEOUT_MS,
7444
7722
  () => {
7445
7723
  session.deFrameTimeouts = (session.deFrameTimeouts ?? 0) + 1;
7446
- console.log(
7724
+ console.error(
7447
7725
  `[engine] fast capture frame ${frameIndex}: capture exceeded ${DE_FRAME_TIMEOUT_MS}ms; renderer stalled after drawElementImage (PRINFRA-488). Failing the drawElement attempt so the whole render retries via screenshot.`
7448
7726
  );
7449
7727
  }
@@ -7453,15 +7731,10 @@ async function captureFrameToBuffer(session, frameIndex, time) {
7453
7731
  async function captureFrameToBufferPipelined(session, frameIndex, time) {
7454
7732
  const { page, options } = session;
7455
7733
  const startTime = Date.now();
7734
+ assertNotRiskFrame(session, frameIndex);
7456
7735
  if (session.staticFrames?.has(frameIndex) && session.lastEncodeResult) {
7457
7736
  const lastIdx = session.lastEncodeResultFrame ?? frameIndex - 1;
7458
- let gapStatic = true;
7459
- for (let j = lastIdx + 1; j <= frameIndex; j++) {
7460
- if (!session.staticFrames.has(j)) {
7461
- gapStatic = false;
7462
- break;
7463
- }
7464
- }
7737
+ const gapStatic = framesAreStatic(session.staticFrames, lastIdx + 1, frameIndex);
7465
7738
  if (gapStatic) {
7466
7739
  session.staticDedupCount = (session.staticDedupCount ?? 0) + 1;
7467
7740
  session.capturePerf.frames += 1;
@@ -7539,6 +7812,7 @@ async function captureFramesBatchPipelined(session, frameIndices, times) {
7539
7812
  throw new Error("[FrameCapture] Session not initialized");
7540
7813
  }
7541
7814
  assertVfxIntact(session);
7815
+ for (const frameIndex of frameIndices) assertNotRiskFrame(session, frameIndex);
7542
7816
  const startTime = Date.now();
7543
7817
  const fps = fpsToNumber(options.fps);
7544
7818
  const quantized = times.map((t) => quantizeTimeToFrame(t, fps));
@@ -7574,7 +7848,7 @@ async function captureFramesBatchPipelined(session, frameIndices, times) {
7574
7848
  session.deNcprFallbacks = (session.deNcprFallbacks ?? 0) + 1;
7575
7849
  throw new DrawElementCaptureError(frameIndices[failedAt] ?? failedAt, reason, error);
7576
7850
  } else {
7577
- console.log(
7851
+ console.error(
7578
7852
  `[engine] fast capture: batch produce failed at frame ${frameIndices[failedAt] ?? "?"} (${error ?? "?"}); re-capturing ${frameIndices.length - failedAt} frame(s) per-frame`
7579
7853
  );
7580
7854
  for (let i = failedAt; i < frameIndices.length; i++) {
@@ -7615,7 +7889,7 @@ async function closeCaptureSession(session) {
7615
7889
  }
7616
7890
  if (session.page && !session.pageReleased) {
7617
7891
  const blur = await describePageMotionBlurAtEnd(session.page);
7618
- if (blur) console.log(blur);
7892
+ if (blur) console.error(blur);
7619
7893
  }
7620
7894
  const reused = session.staticDedupCount ?? 0;
7621
7895
  if (session.staticFrames && reused > 0) {
@@ -7623,7 +7897,7 @@ async function closeCaptureSession(session) {
7623
7897
  const total = captured + reused;
7624
7898
  const pct = total > 0 ? Math.round(reused / total * 100) : 0;
7625
7899
  const avgTotalMs = captured > 0 ? Math.round(session.capturePerf.totalMs / captured) : 0;
7626
- console.log(
7900
+ console.error(
7627
7901
  `[static-dedup] reused ${reused}/${total} frame(s) (${pct}%), est. ~${reused * avgTotalMs}ms saved (avg ${avgTotalMs}ms/frame)`
7628
7902
  );
7629
7903
  session.staticDedupCount = 0;
@@ -7719,12 +7993,14 @@ async function captureDeVerificationFrames(session, page, logInitPhase) {
7719
7993
  }
7720
7994
  const boundary = await computeClipBoundaryFrames(page, fps);
7721
7995
  const fractions = computeDeVerifySampleFractions(k);
7722
- const disposable = session.onBeforeCapture ? null : await createStaticVerificationPage(session).catch(() => {
7996
+ const truthInjector = session.onBeforeCapture?.fresh?.() ?? null;
7997
+ const disposable = session.onBeforeCapture && truthInjector === null ? null : await createStaticVerificationPage(session).catch(() => {
7723
7998
  logInitPhase("self-verify truth page unavailable; reading it on the render page");
7724
7999
  return null;
7725
8000
  });
7726
8001
  const isolated = disposable !== null;
7727
8002
  const truthPage = disposable ?? page;
8003
+ const injectFrames = isolated ? truthInjector ?? session.onBeforeCapture : session.onBeforeCapture;
7728
8004
  const seekTo = (t) => seekDeVerifyTruth(truthPage, t, !isolated);
7729
8005
  const frames = /* @__PURE__ */ new Map();
7730
8006
  try {
@@ -7733,12 +8009,13 @@ async function captureDeVerificationFrames(session, page, logInitPhase) {
7733
8009
  for (const f of fractions) {
7734
8010
  let idx = Math.min(totalFrames - 1, Math.max(1, Math.round(totalFrames * f)));
7735
8011
  let guard = 0;
7736
- while (boundary.has(idx) && guard++ < 6) idx = Math.min(totalFrames - 1, idx + 2);
7737
- if (boundary.has(idx)) continue;
8012
+ const skip = (i) => boundary.has(i) || session.deRiskFrames?.has(i) === true;
8013
+ while (skip(idx) && guard++ < 6) idx = Math.min(totalFrames - 1, idx + 2);
8014
+ if (skip(idx)) continue;
7738
8015
  if (frames.has(idx)) continue;
7739
8016
  const t = quantizeTimeToFrame(idx / fps, fps);
7740
8017
  await seekTo(t);
7741
- if (session.onBeforeCapture) await session.onBeforeCapture(truthPage, t);
8018
+ await injectFrames?.(truthPage, t);
7742
8019
  await pageScreenshotCapture(truthPage, session.options);
7743
8020
  frames.set(idx, await pageScreenshotCapture(truthPage, session.options));
7744
8021
  }
@@ -7816,6 +8093,7 @@ function getCapturePerfSummary(session) {
7816
8093
  deVerifyArmed: session.deVerifyFrames?.size ?? 0,
7817
8094
  deVerifyInitMs: session.deVerifyInitMs ?? 0,
7818
8095
  deBoundaryFrames: session.clipBoundaryFrames?.size ?? 0,
8096
+ deRiskFrames: session.deRiskFrames?.size ?? 0,
7819
8097
  deNcprFallbacks: ncprFallbacks,
7820
8098
  deFrameTimeouts: session.deFrameTimeouts ?? 0
7821
8099
  };
@@ -8394,8 +8672,8 @@ ${tail}` : `FFmpeg exited with code ${exitCode}`;
8394
8672
  }
8395
8673
  function describeFfmpegFailure(result, timeoutMs) {
8396
8674
  const error = formatFfmpegError(result.exitCode, result.stderr);
8397
- if (result.terminationReason === "deadline") {
8398
- return `FFmpeg timed out after ${timeoutMs} ms (ffmpegProcessTimeout; long renders can raise FFMPEG_PROCESS_TIMEOUT_MS). ${error}`;
8675
+ if (result.terminationReason === "inactivity") {
8676
+ return `FFmpeg timed out after ${timeoutMs} ms without progress (ffmpegProcessTimeout, FFMPEG_PROCESS_TIMEOUT_MS). ${error}`;
8399
8677
  }
8400
8678
  if (result.exitCode !== null) return error;
8401
8679
  const signalOrRequestedStop = result.terminationReason === "exit" ? result.signal : result.terminationReason;
@@ -8434,17 +8712,18 @@ var ABORTED_BEFORE_START = {
8434
8712
  };
8435
8713
  async function runFfmpeg(args, opts) {
8436
8714
  if (opts?.signal?.aborted) return { ...ABORTED_BEFORE_START };
8437
- const stallTimeout = opts?.stallTimeout;
8438
8715
  let framesWritten = 0;
8439
- const readStats = ffmpegStatsReader(({ frames }) => {
8440
- if (frames === void 0 || frames <= framesWritten) return;
8441
- framesWritten = frames;
8716
+ let secondsWritten = 0;
8717
+ const readStats = ffmpegStatsReader(({ frames = 0, seconds = 0 }) => {
8718
+ if (frames <= framesWritten && seconds <= secondsWritten) return;
8719
+ framesWritten = Math.max(frames, framesWritten);
8720
+ secondsWritten = Math.max(seconds, secondsWritten);
8442
8721
  managed.markActivity();
8443
8722
  });
8444
8723
  const managed = new ManagedChildProcess(spawnFfmpeg(args), {
8445
8724
  signal: opts?.signal,
8446
- ...stallTimeout === void 0 ? { deadlineAtMs: Date.now() + (opts?.timeout ?? DEFAULT_TIMEOUT) } : { inactivityTimeoutMs: stallTimeout },
8447
- onStderr: stallTimeout === void 0 ? opts?.onStderr : (chunk) => {
8725
+ inactivityTimeoutMs: opts?.timeout ?? DEFAULT_TIMEOUT,
8726
+ onStderr: (chunk) => {
8448
8727
  readStats(chunk);
8449
8728
  opts?.onStderr?.(chunk);
8450
8729
  }
@@ -9435,7 +9714,7 @@ var ENCODER_PRESETS = {
9435
9714
  function appendEncodeTimeoutMessage(error, timedOut, timeoutMs) {
9436
9715
  if (!timedOut) return error;
9437
9716
  return `${error}
9438
- FFmpeg killed after exceeding ffmpegEncodeTimeout (${timeoutMs} ms). Long or high-frame-count renders may need more time: set FFMPEG_ENCODE_TIMEOUT_MS to a higher value (ms), or set PRODUCER_ENABLE_CHUNKED_ENCODE=true to encode in smaller chunks instead of one long-running ffmpeg process.`;
9717
+ FFmpeg killed after writing no new frame for ffmpegEncodeTimeout (${timeoutMs} ms). An encode that is still writing frames is never stopped; if this encoder legitimately pauses longer between frames, raise FFMPEG_ENCODE_TIMEOUT_MS (ms).`;
9439
9718
  }
9440
9719
  function isAacSidecar(audioPath) {
9441
9720
  return extname(audioPath).toLowerCase() === ".aac";
@@ -9750,7 +10029,7 @@ async function encodeFramesFromDir(framesDir, framePattern, outputPath, options,
9750
10029
  fileSize: 0,
9751
10030
  error: appendEncodeTimeoutMessage(
9752
10031
  frameReadFailure(result.stderr, framePattern, 0, framesRead, frameCount) + formatFfmpegError(result.exitCode, result.stderr),
9753
- result.terminationReason === "deadline",
10032
+ result.terminationReason === "inactivity",
9754
10033
  encodeTimeout
9755
10034
  ),
9756
10035
  failureReason: isExternalFfmpegInterruption(result) ? "external_interruption" : void 0
@@ -9796,7 +10075,7 @@ async function concatVideoFiles(inputPaths, outputPath, signal, config) {
9796
10075
  success: false,
9797
10076
  error: appendEncodeTimeoutMessage(
9798
10077
  `Chunk concat failed: ${result.stderr.slice(-400)}`,
9799
- result.terminationReason === "deadline",
10078
+ result.terminationReason === "inactivity",
9800
10079
  encodeTimeout
9801
10080
  ),
9802
10081
  externalInterruption: isExternalFfmpegInterruption(result)
@@ -9869,7 +10148,7 @@ async function encodeFramesChunkedConcat(framesDir, framePattern, outputPath, op
9869
10148
  framesRead,
9870
10149
  framesInChunk
9871
10150
  ) + `Chunk ${i} encode failed: ${processResult.stderr.slice(-400)}`,
9872
- processResult.terminationReason === "deadline",
10151
+ processResult.terminationReason === "inactivity",
9873
10152
  encodeTimeout
9874
10153
  )
9875
10154
  };
@@ -11237,7 +11516,7 @@ function checksumMismatchError(source, status, telemetry) {
11237
11516
  true
11238
11517
  );
11239
11518
  }
11240
- async function fetchToPartial(url, partialPath, controller, options) {
11519
+ async function fetchToPartial(url, partialPath, controller, options, onSizedBodyBytes) {
11241
11520
  const { response, finalUrl } = await fetchWithValidatedRedirects(url, controller);
11242
11521
  const finalIdentity = safeDownloadUrlIdentity(finalUrl);
11243
11522
  const rangeDisposition = classifyRangeDisposition(response);
@@ -11305,6 +11584,7 @@ async function fetchToPartial(url, partialPath, controller, options) {
11305
11584
  const inspector = new Transform({
11306
11585
  transform(chunk, _encoding, callback) {
11307
11586
  const bytes = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
11587
+ if (declaredLength !== void 0) onSizedBodyBytes();
11308
11588
  receivedBytes += bytes.length;
11309
11589
  sha256.update(bytes);
11310
11590
  md5.update(bytes);
@@ -11429,16 +11709,26 @@ async function runDownloadAttempt(url, localPath, timeoutMs, attempt, options, s
11429
11709
  controller.abort();
11430
11710
  };
11431
11711
  signal?.addEventListener("abort", onCallerAbort, { once: true });
11432
- const timeoutId = setTimeout(() => {
11433
- timedOut = true;
11434
- controller.abort();
11435
- }, timeoutMs);
11712
+ let timeoutId;
11713
+ const armTimeout = () => {
11714
+ clearTimeout(timeoutId);
11715
+ timeoutId = setTimeout(() => {
11716
+ timedOut = true;
11717
+ controller.abort();
11718
+ }, timeoutMs);
11719
+ };
11720
+ armTimeout();
11721
+ let sizedBodyStarted = false;
11722
+ const extendTimeout = () => {
11723
+ sizedBodyStarted = true;
11724
+ armTimeout();
11725
+ };
11436
11726
  const identity = safeDownloadUrlIdentity(url);
11437
11727
  try {
11438
11728
  if (callerAborted) {
11439
11729
  throw new UrlDownloadError("cancelled", false, "Download cancelled");
11440
11730
  }
11441
- const integrity = await fetchToPartial(url, partialPath, controller, options);
11731
+ const integrity = await fetchToPartial(url, partialPath, controller, options, extendTimeout);
11442
11732
  let outcome = syncAndPublishPartial(partialPath, localPath);
11443
11733
  let publishedIntegrity = integrity;
11444
11734
  if (outcome === "race_reused") {
@@ -11497,7 +11787,7 @@ async function runDownloadAttempt(url, localPath, timeoutMs, attempt, options, s
11497
11787
  const classified2 = new UrlDownloadError(
11498
11788
  "timeout",
11499
11789
  true,
11500
- `Download timeout after ${timeoutMs / 1e3}s`
11790
+ sizedBodyStarted ? `Download stalled: no data for ${timeoutMs / 1e3}s` : `Download timeout after ${timeoutMs / 1e3}s`
11501
11791
  );
11502
11792
  emitDownloadTelemetry(options, {
11503
11793
  urlFingerprint: identity.urlFingerprint,
@@ -12555,7 +12845,8 @@ async function extractVideoFramesRangeUnredacted(videoPath, videoId, startTime,
12555
12845
  const isHdr = isHdrColorSpace(metadata.colorSpace);
12556
12846
  const isMacOS = process.platform === "darwin";
12557
12847
  const toneMappedToSdr = options.toneMapHdrToSdr === true && isHdr && await toneMapsWithZscale();
12558
- const decodeWithVideoToolbox = isHdr && isMacOS && !toneMappedToSdr;
12848
+ const keepsHdrForChrome = isHdr && isMacOS && !toneMappedToSdr;
12849
+ const decodeWithVideoToolbox = keepsHdrForChrome || isMacOS && !metadata.hasAlpha && !codecMayHaveAlpha(metadata.videoCodec) && await isFfmpegHwaccelAvailable("videotoolbox");
12559
12850
  const sampleAtOutputFps = !options.finalFrameOnly;
12560
12851
  if (options.frameRanges && (!sampleAtOutputFps || metadata.isVFR)) {
12561
12852
  throw new Error("frameRanges extraction needs a constant-frame-rate source");
@@ -12575,7 +12866,7 @@ async function extractVideoFramesRangeUnredacted(videoPath, videoId, startTime,
12575
12866
  args.push("-ss", String(startTime), "-i", videoPath, "-t", String(duration));
12576
12867
  }
12577
12868
  const vfFilters = [];
12578
- if (decodeWithVideoToolbox) {
12869
+ if (keepsHdrForChrome) {
12579
12870
  vfFilters.push("format=nv12");
12580
12871
  }
12581
12872
  const samplingAt = vfFilters.length;
@@ -12605,7 +12896,7 @@ async function extractVideoFramesRangeUnredacted(videoPath, videoId, startTime,
12605
12896
  const encodeArgs = ["-q:v", format === "jpg" ? String(Math.ceil((100 - quality) / 3)) : "0"];
12606
12897
  if (format === "png") encodeArgs.push("-compression_level", "1");
12607
12898
  encodeArgs.push("-y", outputPattern);
12608
- const runOptions = { signal, stallTimeout: ffmpegProcessTimeout };
12899
+ const runOptions = { signal, timeout: ffmpegProcessTimeout };
12609
12900
  const filterArgsFor = (seek) => {
12610
12901
  const filters = [...vfFilters];
12611
12902
  filters.splice(samplingAt, 0, ...samplingFilters(seek));
@@ -13947,7 +14238,7 @@ function createVideoFrameInjector(frameLookup, config) {
13947
14238
  touchCacheDir(cacheDir);
13948
14239
  lastCacheTouchByDir.set(cacheDir, now);
13949
14240
  }
13950
- return async (page, time, heldVideoTime) => {
14241
+ const inject = async (page, time, heldVideoTime) => {
13951
14242
  for (const cacheDir of frameLookup.frameDirs()) renewCacheLease(cacheDir);
13952
14243
  const activePayloads = frameLookup.getActiveFramePayloads(time);
13953
14244
  if (heldVideoTime !== void 0) {
@@ -13994,6 +14285,7 @@ function createVideoFrameInjector(frameLookup, config) {
13994
14285
  }
13995
14286
  }
13996
14287
  };
14288
+ return Object.assign(inject, { fresh: () => createVideoFrameInjector(frameLookup, config) });
13997
14289
  }
13998
14290
  async function hideVideoElements(page, videoIds) {
13999
14291
  await setVideoElementsVisibility(page, videoIds, false);
@@ -14348,10 +14640,10 @@ var NotMediaPayloadError = class extends Error {
14348
14640
  retryable = false;
14349
14641
  elementFingerprints;
14350
14642
  constructor(elementFingerprints) {
14351
- const listed = elementFingerprints.slice(0, MAX_LISTED_FINGERPRINTS).join(",");
14643
+ const listed2 = elementFingerprints.slice(0, MAX_LISTED_FINGERPRINTS).join(",");
14352
14644
  const elided = elementFingerprints.length - MAX_LISTED_FINGERPRINTS;
14353
14645
  super(
14354
- `${elementFingerprints.length} media source(s) are text documents (HTML/XML/JSON), not media containers [elements=${listed}${elided > 0 ? `,+${elided}` : ""}]. Either an unresolved nested-composition preview URL was authored as a media src, or the source answered with an error page or API error body carrying a success status.`
14646
+ `${elementFingerprints.length} media source(s) are text documents (HTML/XML/JSON), not media containers [elements=${listed2}${elided > 0 ? `,+${elided}` : ""}]. Either an unresolved nested-composition preview URL was authored as a media src, or the source answered with an error page or API error body carrying a success status.`
14355
14647
  );
14356
14648
  this.name = "NotMediaPayloadError";
14357
14649
  this.elementFingerprints = elementFingerprints;
@@ -15751,7 +16043,7 @@ function ffmpegFailure(stage, result, timeoutMs, elementId) {
15751
16043
  } else if (result.terminationReason === "abort") {
15752
16044
  reason = "cancelled";
15753
16045
  owner = "user";
15754
- } else if (result.terminationReason === "deadline" || result.terminationReason === "inactivity") {
16046
+ } else if (result.terminationReason === "inactivity") {
15755
16047
  reason = "ffmpeg_timeout";
15756
16048
  retryable = true;
15757
16049
  } else if (result.terminationReason === "spawn_error") {
@@ -16048,13 +16340,8 @@ async function generateSilence(outputPath, duration, signal, config) {
16048
16340
  failure
16049
16341
  };
16050
16342
  }
16051
- var MIX_TIMEOUT_MS_PER_FILM_SECOND = 100;
16052
- function mixProcessTimeout(config, totalDuration) {
16053
- const configured = config?.ffmpegProcessTimeout ?? DEFAULT_CONFIG.ffmpegProcessTimeout;
16054
- return Math.max(configured, Math.ceil(totalDuration * MIX_TIMEOUT_MS_PER_FILM_SECOND));
16055
- }
16056
16343
  async function mixAudioTracksFlat(tracks, outputPath, totalDuration, signal, config) {
16057
- const ffmpegProcessTimeout = mixProcessTimeout(config, totalDuration);
16344
+ const ffmpegProcessTimeout = config?.ffmpegProcessTimeout ?? DEFAULT_CONFIG.ffmpegProcessTimeout;
16058
16345
  const masterOutputGain = config?.audioGain ?? DEFAULT_CONFIG.audioGain;
16059
16346
  if (tracks.length === 0) {
16060
16347
  const result2 = await generateSilence(outputPath, totalDuration, signal, config);
@@ -16175,7 +16462,7 @@ function groupNormalizeOptionUnsupported(stderr) {
16175
16462
  return /normalize/i.test(stderr) && /(?:unrecognized option|option (?:was )?not found|no option name)/i.test(stderr);
16176
16463
  }
16177
16464
  async function mixGroupMembersFlat(memberTracks, outputPath, totalDuration, signal, config) {
16178
- const ffmpegProcessTimeout = mixProcessTimeout(config, totalDuration);
16465
+ const ffmpegProcessTimeout = config?.ffmpegProcessTimeout ?? DEFAULT_CONFIG.ffmpegProcessTimeout;
16179
16466
  const outputDir = dirname7(outputPath);
16180
16467
  if (!existsSync11(outputDir)) mkdirSync7(outputDir, { recursive: true });
16181
16468
  const buildInputFilters = (ignoreKeyframes, padMembers) => memberTracks.map((track, i) => {
@@ -17150,7 +17437,7 @@ async function captureFrameRange(session, task, captureOptions, signal, onFrameC
17150
17437
  if (signal?.aborted) throw new Error("Parallel worker cancelled");
17151
17438
  const time = i * captureOptions.fps.den / captureOptions.fps.num;
17152
17439
  if (dbg && i < task.startFrame + dbgWin) {
17153
- console.log(`[par:w${task.workerId}] +${Date.now() - dbgT0}ms produce ${i} start`);
17440
+ console.error(`[par:w${task.workerId}] +${Date.now() - dbgT0}ms produce ${i} start`);
17154
17441
  }
17155
17442
  const { encodeResult } = await runCaptureOperation(
17156
17443
  "frame_capture",
@@ -17160,23 +17447,25 @@ async function captureFrameRange(session, task, captureOptions, signal, onFrameC
17160
17447
  encodeResult.catch(() => {
17161
17448
  });
17162
17449
  if (dbg && i < task.startFrame + dbgWin) {
17163
- console.log(`[par:w${task.workerId}] +${Date.now() - dbgT0}ms produce ${i} kicked`);
17450
+ console.error(`[par:w${task.workerId}] +${Date.now() - dbgT0}ms produce ${i} kicked`);
17164
17451
  }
17165
17452
  if (prev) {
17166
17453
  if (dbg && prev.idx < task.startFrame + dbgWin) {
17167
- console.log(
17454
+ console.error(
17168
17455
  `[par:w${task.workerId}] +${Date.now() - dbgT0}ms drain ${prev.idx} await-encode`
17169
17456
  );
17170
17457
  }
17171
17458
  const buf = await awaitEncode(prev.idx, prev.encodeResult);
17172
17459
  if (dbg && prev.idx < task.startFrame + dbgWin) {
17173
- console.log(
17460
+ console.error(
17174
17461
  `[par:w${task.workerId}] +${Date.now() - dbgT0}ms drain ${prev.idx} encoded ${buf.length}B`
17175
17462
  );
17176
17463
  }
17177
17464
  await onFrameBuffer(prev.idx, buf, session);
17178
17465
  if (dbg && prev.idx < task.startFrame + dbgWin) {
17179
- console.log(`[par:w${task.workerId}] +${Date.now() - dbgT0}ms drain ${prev.idx} written`);
17466
+ console.error(
17467
+ `[par:w${task.workerId}] +${Date.now() - dbgT0}ms drain ${prev.idx} written`
17468
+ );
17180
17469
  }
17181
17470
  framesCaptured++;
17182
17471
  if (onFrameCaptured) onFrameCaptured(task.workerId, prev.idx);
@@ -17226,7 +17515,7 @@ function selectVerifySampleIndicesForTask(sampleIndices, task) {
17226
17515
  return selected.sort((a, b) => a - b);
17227
17516
  }
17228
17517
  function logParDebug(message) {
17229
- if (process.env.HF_DE_PAR_DEBUG === "1") console.log(message());
17518
+ if (process.env.HF_DE_PAR_DEBUG === "1") console.error(message());
17230
17519
  }
17231
17520
  function assertDiskSampleAboveFloor(db, verifyMinDb, idx, workerId) {
17232
17521
  if (db < verifyMinDb) {
@@ -17235,7 +17524,7 @@ function assertDiskSampleAboveFloor(db, verifyMinDb, idx, workerId) {
17235
17524
  { kind: "psnr", frameIndex: idx, failedDb: db, verifyThresholdDb: verifyMinDb }
17236
17525
  );
17237
17526
  }
17238
- console.log(
17527
+ console.error(
17239
17528
  `[Parallel] drawElement disk self-verify passed (worker ${workerId}, frame ${idx}, ${db === Infinity ? "inf" : db.toFixed(1)}dB)`
17240
17529
  );
17241
17530
  }
@@ -17469,7 +17758,11 @@ async function executeParallelCapture(serverUrl, workDir, tasks, captureOptions,
17469
17758
  captureOptions.deVerifySamples,
17470
17759
  tasks.length
17471
17760
  );
17472
- const workerCaptureOptions = deVerifySamples === captureOptions.deVerifySamples ? captureOptions : { ...captureOptions, deVerifySamples };
17761
+ const workerCaptureOptions = {
17762
+ ...captureOptions,
17763
+ deVerifySamples,
17764
+ deFrameFallback: false
17765
+ };
17473
17766
  const peerController = new AbortController();
17474
17767
  const workerSignal = signal ? AbortSignal.any([signal, peerController.signal]) : peerController.signal;
17475
17768
  const failureHandler = createPoolFailureHandler({
@@ -18013,6 +18306,7 @@ export {
18013
18306
  beginFrameCapture,
18014
18307
  pageScreenshotCapture,
18015
18308
  captureScreenshotWithAlpha,
18309
+ capturesAlpha,
18016
18310
  initTransparentBackground,
18017
18311
  captureAlphaPng,
18018
18312
  DOM_LAYER_MASK_STYLE_ID,
@@ -18110,6 +18404,7 @@ export {
18110
18404
  spawnStreamingEncoder,
18111
18405
  HF_AUDIO_GROUP_TAG,
18112
18406
  HF_AUDIO_GROUP_ATTR,
18407
+ isSelfOrAncestorHidden,
18113
18408
  safeDownloadUrlIdentity,
18114
18409
  writeUrlDownloadTelemetry,
18115
18410
  isBlockedNetworkHost,