hyperframes 0.8.206 → 0.8.208

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 (240) hide show
  1. package/bin/hyperframes.mjs +1 -0
  2. package/dist/{add-FFMNAJXJ.js → add-XMWRBMBR.js} +22 -20
  3. package/dist/{agentPromptGenerator-KYO5MKTW.js → agentPromptGenerator-4NJ252MR.js} +6 -2
  4. package/dist/{animatedGifPrep-BIIIIVWL.js → animatedGifPrep-6XURJIPV.js} +14 -13
  5. package/dist/api.js +33 -32
  6. package/dist/{appHistory-QVCSAOI4.js → appHistory-HIBH6XZW.js} +3 -1
  7. package/dist/{asset-IPUHGZSL.js → asset-I5GGEOB2.js} +2 -2
  8. package/dist/{assetCataloger-M5FWXLAJ.js → assetCataloger-YBPXUNUP.js} +17 -14
  9. package/dist/{audio-VYWWM4DB.js → audio-GFJCHH5W.js} +420 -138
  10. package/dist/{auth-GZQZCUPL.js → auth-QOA55RYR.js} +4 -4
  11. package/dist/{autoUpdate-GJUDDLLO.js → autoUpdate-SPS4QPJU.js} +4 -4
  12. package/dist/{backgroundChecks-BTMSW34Z.js → backgroundChecks-HRJO7YK7.js} +5 -5
  13. package/dist/backgroundChecksWorker.js +5 -5
  14. package/dist/{batchRender-LI2BJRGO.js → batchRender-FBP3RKUF.js} +11 -10
  15. package/dist/{beats-H73CSYT4.js → beats-VNGJ7F6W.js} +32 -25
  16. package/dist/{benchmark-XT3A5REC.js → benchmark-NZ3N3MIV.js} +16 -16
  17. package/dist/{browser-VIOK66YK.js → browser-BD5BKRJ5.js} +9 -9
  18. package/dist/{bundleWithLocalizedFonts-PFRVWYOO.js → bundleWithLocalizedFonts-WXVNPAWD.js} +3 -3
  19. package/dist/{capture-KKD5GMAF.js → capture-CXWXKWS5.js} +120 -54
  20. package/dist/{capture-252WNPCD.js → capture-LMJ4TQRL.js} +63 -17
  21. package/dist/{captureCompositionFrame-YLYVGNN2.js → captureCompositionFrame-ZKVCRYYU.js} +21 -20
  22. package/dist/{captureFile-LYOJOUIE.js → captureFile-VIVGKFY4.js} +2 -1
  23. package/dist/{catalog-6IJGNN3T.js → catalog-WRXQSCAU.js} +28 -26
  24. package/dist/{catch-up-BFW7Z35W.js → catch-up-MDSPABFC.js} +7 -7
  25. package/dist/{check-XUWBZASR.js → check-SIBBK5HA.js} +53 -52
  26. package/dist/{checkAudio-2NRR3VHQ.js → checkAudio-QQBR4HR7.js} +19 -18
  27. package/dist/{checkBrowser-JW74KWTF.js → checkBrowser-4EBJLLIH.js} +45 -44
  28. package/dist/{chunk-XDMZY3H7.js → chunk-3O2E4Q66.js} +15 -20
  29. package/dist/{chunk-VEA7Z4PZ.js → chunk-43MW4SY7.js} +15 -7
  30. package/dist/{chunk-HJAJ6W4V.js → chunk-4F5NRJ6M.js} +2 -2
  31. package/dist/{chunk-2RT7MXFL.js → chunk-4HT2L6W2.js} +1 -1
  32. package/dist/{chunk-QVTCXN42.js → chunk-4KG3ESVO.js} +30 -4
  33. package/dist/{chunk-42KN6I6A.js → chunk-4LTBQEPD.js} +2 -2
  34. package/dist/{chunk-C6KE4AFW.js → chunk-56ANHX5U.js} +1 -1
  35. package/dist/{chunk-NVLPW3DG.js → chunk-5HB4JM7H.js} +2 -2
  36. package/dist/{chunk-2ST4WAFY.js → chunk-5PCALX6G.js} +13 -1
  37. package/dist/{chunk-AYH5ANVS.js → chunk-5YHQBCWH.js} +52 -3
  38. package/dist/{chunk-X5HHHFTX.js → chunk-6CWKORZO.js} +3 -3
  39. package/dist/{chunk-ZF3R2IPC.js → chunk-6DSYBW7Z.js} +1 -0
  40. package/dist/{chunk-VHVSBOZH.js → chunk-6JNSYFOH.js} +4 -4
  41. package/dist/{chunk-AJSU6KGS.js → chunk-6N7D2GUV.js} +15 -15
  42. package/dist/{chunk-F2ASNL2K.js → chunk-6PWQH77E.js} +1 -1
  43. package/dist/{chunk-ZNAOBFU5.js → chunk-6WRN4WC6.js} +1 -1
  44. package/dist/{chunk-GAV56VJL.js → chunk-7CPI2DWL.js} +2 -2
  45. package/dist/{chunk-CMDVJP4T.js → chunk-7PAK7LZ5.js} +11 -11
  46. package/dist/{chunk-3CISA3OS.js → chunk-AF3L5JJX.js} +1 -1
  47. package/dist/{chunk-X7RXXBYM.js → chunk-B5MPMIKQ.js} +2 -2
  48. package/dist/{chunk-RW4DMP2Y.js → chunk-BKDQFOKK.js} +4 -4
  49. package/dist/{chunk-DZG565OO.js → chunk-BLCKQPBE.js} +1 -1
  50. package/dist/chunk-BQMAPNDA.js +4830 -0
  51. package/dist/{chunk-CPSGXAYD.js → chunk-CP225S5H.js} +3 -3
  52. package/dist/{chunk-3R6SXPHD.js → chunk-CSWCZA6V.js} +3 -3
  53. package/dist/{chunk-4CY5RXXC.js → chunk-D2CE2J2A.js} +4 -4
  54. package/dist/{chunk-FMWACL3L.js → chunk-DHQSDCWD.js} +6 -2
  55. package/dist/chunk-DROFHVQD.js +240 -0
  56. package/dist/{chunk-OZUAVHFE.js → chunk-DXACKQ3F.js} +3 -3
  57. package/dist/{chunk-5QKJPCQ4.js → chunk-EGOXYG3M.js} +2 -2
  58. package/dist/{chunk-QL4ZYSIB.js → chunk-ENRFKCI6.js} +5 -71
  59. package/dist/{chunk-MRF4AMKD.js → chunk-EQBDKYXR.js} +5 -10
  60. package/dist/{chunk-4UMPIPCQ.js → chunk-ERUQ3S6D.js} +2 -2
  61. package/dist/{chunk-T2EUWCJE.js → chunk-EU7MVORF.js} +13 -1
  62. package/dist/{chunk-FULMZCDW.js → chunk-EYEEZXLI.js} +11 -11
  63. package/dist/{chunk-2MLMO25E.js → chunk-FC4WT5FX.js} +105 -7
  64. package/dist/{chunk-PLGGKTCB.js → chunk-FFDYRJBE.js} +37 -21
  65. package/dist/{chunk-7SXL476O.js → chunk-G2A6RC5R.js} +72 -28
  66. package/dist/{chunk-HTIUNMTP.js → chunk-GDZA4ALG.js} +8 -2
  67. package/dist/{chunk-CZYS6UKP.js → chunk-GEO6THL3.js} +61 -30
  68. package/dist/{chunk-MFHYBSJC.js → chunk-GHSO62LK.js} +3 -3
  69. package/dist/{chunk-P2I4RLJE.js → chunk-HTZJNQYI.js} +1 -1
  70. package/dist/{chunk-4DGLKB2H.js → chunk-HUKQW4YE.js} +1 -1
  71. package/dist/{chunk-WYB3VKLK.js → chunk-HZN7ICAF.js} +8 -8
  72. package/dist/{chunk-6ZFDNEMY.js → chunk-IIJVSCSH.js} +16 -16
  73. package/dist/{chunk-VDVVQNTK.js → chunk-IL2TMC6F.js} +5 -5
  74. package/dist/{chunk-L5MFWGGU.js → chunk-J67FSI3Q.js} +623 -376
  75. package/dist/chunk-JLCAHJUO.js +91 -0
  76. package/dist/{chunk-N7ZMDVAK.js → chunk-JLGVBK5M.js} +1 -1
  77. package/dist/{chunk-SFYLZX5C.js → chunk-K4PHB3YQ.js} +59 -15
  78. package/dist/{chunk-G6W55MTX.js → chunk-KTWGVEN6.js} +40 -11
  79. package/dist/{chunk-FNNGQ3DB.js → chunk-LSMFOZ4F.js} +2 -2
  80. package/dist/{chunk-ELP5QZWL.js → chunk-M4QZFUMW.js} +1 -1
  81. package/dist/{chunk-PNKLOMHQ.js → chunk-MBGM26P5.js} +17 -22
  82. package/dist/{chunk-ZTEKVSZ6.js → chunk-MMJAHBH2.js} +1 -1
  83. package/dist/{chunk-RDDVQSNQ.js → chunk-MPO25DQW.js} +451 -208
  84. package/dist/{chunk-E2ZZSDDQ.js → chunk-MW2NQQ6Z.js} +2 -2
  85. package/dist/{chunk-TSJVPPXT.js → chunk-MYO77JWR.js} +1 -1
  86. package/dist/{chunk-PSX5SF2N.js → chunk-NEASABW6.js} +1 -1
  87. package/dist/{chunk-OFRRUYBA.js → chunk-NHA4NRBE.js} +135 -24
  88. package/dist/{chunk-NNLQTG3M.js → chunk-NZ6G5YWZ.js} +2 -2
  89. package/dist/{chunk-WHD5IAHI.js → chunk-ORFRUZPB.js} +2 -2
  90. package/dist/{chunk-Z3XXLTVB.js → chunk-OTXXDONS.js} +3 -3
  91. package/dist/{chunk-2S263R6D.js → chunk-P7WGVXR7.js} +9 -9
  92. package/dist/{chunk-AXEEZKIL.js → chunk-PKVA6MPV.js} +6 -6
  93. package/dist/{chunk-FJW757TF.js → chunk-PSOAGSNO.js} +2 -2
  94. package/dist/{chunk-AEC4T4IF.js → chunk-PWEOSJ3E.js} +12 -12
  95. package/dist/{chunk-X7A7C4JS.js → chunk-Q43YUROE.js} +3 -3
  96. package/dist/{chunk-PQYWYBEQ.js → chunk-QP2MJYTJ.js} +1 -1
  97. package/dist/{chunk-VW2LVMKB.js → chunk-QWBVPWUI.js} +47 -55
  98. package/dist/{chunk-AAX2A7LQ.js → chunk-S2OLTAEL.js} +2 -2
  99. package/dist/{chunk-CNVHMLPI.js → chunk-S4KHJERB.js} +1 -1
  100. package/dist/{chunk-2BGOB2QK.js → chunk-SE2MXV2N.js} +136 -25
  101. package/dist/{chunk-3CS6QYL7.js → chunk-SI7QCT2J.js} +8 -8
  102. package/dist/{chunk-CIHW6VM2.js → chunk-SKKQMW5X.js} +1 -1
  103. package/dist/{chunk-3B2DBUQX.js → chunk-TNTGGDSD.js} +1 -1
  104. package/dist/chunk-TSYRN646.js +84 -0
  105. package/dist/{chunk-XOM3XTJ4.js → chunk-U6KN6OIP.js} +2 -2
  106. package/dist/{chunk-63DGZRZP.js → chunk-ULL3U6PV.js} +1 -1
  107. package/dist/{chunk-IXXVS2Z4.js → chunk-VQB7G5BM.js} +1 -1
  108. package/dist/{chunk-UMUVGNOH.js → chunk-VR3JLTZD.js} +3 -3
  109. package/dist/{chunk-DEVZJ4AL.js → chunk-VS4SK7BN.js} +17 -11
  110. package/dist/{chunk-6N65ZMC5.js → chunk-VYRJAQGC.js} +1 -1
  111. package/dist/{chunk-FLREUEHW.js → chunk-W4DMQZL5.js} +1 -1
  112. package/dist/chunk-WABB4LZS.js +62 -0
  113. package/dist/{chunk-RXATE6FZ.js → chunk-WC4MTXGN.js} +22 -0
  114. package/dist/{chunk-36QE3P6B.js → chunk-WNMVC3IT.js} +1 -1
  115. package/dist/{chunk-T6SD37JZ.js → chunk-X6MCIK7L.js} +103 -16
  116. package/dist/chunk-XFMO3BEN.js +71 -0
  117. package/dist/{chunk-BBUK6A7Q.js → chunk-XG3IZV62.js} +7 -7
  118. package/dist/chunk-XMRA7CQG.js +22 -0
  119. package/dist/{chunk-G6QDFWDN.js → chunk-XOFBXLMG.js} +2 -2
  120. package/dist/{chunk-H4JO7VSI.js → chunk-XUQYC5DD.js} +12 -12
  121. package/dist/chunk-Z5J67X44.js +40 -0
  122. package/dist/{chunk-HEP5XMXV.js → chunk-Z5TGBEPJ.js} +9 -2
  123. package/dist/{chunk-7JAD4MEW.js → chunk-ZA5TNF4R.js} +1 -0
  124. package/dist/{clean-N5VSKUVS.js → clean-6GX7WAEC.js} +32 -31
  125. package/dist/cli.js +58 -58
  126. package/dist/{cloud-74NF5FXC.js → cloud-6PFJKLNL.js} +4 -4
  127. package/dist/{cloudrun-7UOH335V.js → cloudrun-UGG3ZFH7.js} +13 -12
  128. package/dist/commands/layout-audit.browser.js +3 -15
  129. package/dist/{compare-AY2LS2TZ.js → compare-P4EBOP4B.js} +46 -45
  130. package/dist/{compiler-4MHMC777.js → compiler-PG4RKX6K.js} +8 -8
  131. package/dist/{component-CFWQOAZI.js → component-SQPMI3W7.js} +3 -3
  132. package/dist/{compositions-DXLJTDSP.js → compositions-KRIHY3IY.js} +20 -19
  133. package/dist/{contactSheet-5APX35L3.js → contactSheet-RYAE7Y5D.js} +3 -2
  134. package/dist/{delete-GB4MS7LM.js → delete-T5TO4SV6.js} +7 -7
  135. package/dist/{deploy-NXD3Q3KD.js → deploy-AO6LQR5G.js} +6 -6
  136. package/dist/{deterministicFonts-775YXAQ2.js → deterministicFonts-LKAGUNE5.js} +3 -3
  137. package/dist/{dist-3ZJMZU75.js → dist-23AAB5X2.js} +36 -36
  138. package/dist/{dist-ZY6IFESG.js → dist-6IMEDVMC.js} +6 -3
  139. package/dist/docker/Dockerfile.render +1 -1
  140. package/dist/docs/rendering.md +3 -0
  141. package/dist/{doctor-CVY2XXKS.js → doctor-QBUJQ655.js} +23 -22
  142. package/dist/{events-RYQYEWBV.js → events-J7CESLKQ.js} +4 -4
  143. package/dist/{events-T3CLIYRG.js → events-SIZO7YHI.js} +5 -5
  144. package/dist/{feedback-K5ZMMLTA.js → feedback-74WOJ5PN.js} +22 -22
  145. package/dist/{ffmpeg-UNDAJ2IC.js → ffmpeg-AKUP6U2S.js} +17 -16
  146. package/dist/{figma-MYYCX635.js → figma-GGMYRR4Q.js} +3 -3
  147. package/dist/fontLocalizeCli.js +21 -19
  148. package/dist/{get-JVIDYMVP.js → get-PLKAI6JM.js} +7 -7
  149. package/dist/{gpuPolicy-KEX7GDRJ.js → gpuPolicy-EYDAAPJF.js} +14 -13
  150. package/dist/{grade-compare-QEF6VASJ.js → grade-compare-UADJP4AV.js} +44 -43
  151. package/dist/{gsapParserAcorn-LZJKCFQI.js → gsapParserAcorn-5YD4N6HQ.js} +2 -2
  152. package/dist/hangReport.js +47 -0
  153. package/dist/{heifImagePrep-A3ZPVQGU.js → heifImagePrep-KDF3OPOK.js} +15 -14
  154. package/dist/{help-XPPSLIRY.js → help-WSQQ555Q.js} +1 -1
  155. package/dist/{history-OFOPRD27.js → history-VSQ2DQ3V.js} +110 -62
  156. package/dist/hyperframe.manifest.json +1 -1
  157. package/dist/hyperframe.runtime.iife.js +76 -71
  158. package/dist/hyperframes-player.global.js +3 -3
  159. package/dist/{info-7RF6FQX5.js → info-MOQ4LRC3.js} +18 -18
  160. package/dist/{init-NTIXWA3D.js → init-EONQSZJG.js} +62 -60
  161. package/dist/{inspect-MYMCV5E7.js → inspect-OLCVLHOU.js} +43 -42
  162. package/dist/{installer-PYJIJ3PJ.js → installer-GHISA75B.js} +10 -10
  163. package/dist/{keyframes-UJ52PYE4.js → keyframes-DGQYCY24.js} +13 -13
  164. package/dist/{lambda-SBNUYEQE.js → lambda-AMMWF2YH.js} +35 -15
  165. package/dist/{layout-IOMCOABO.js → layout-R6CAPGRO.js} +43 -42
  166. package/dist/{lint-AQWHHMPS.js → lint-QZJEYPHD.js} +14 -11
  167. package/dist/{lintProject-5A4SCW3S.js → lintProject-W3YVHAGP.js} +6 -3
  168. package/dist/{list-WKAJ5SP3.js → list-KCJID4SP.js} +7 -7
  169. package/dist/localPage-V3HBGM3Z.js +27 -0
  170. package/dist/{login-3ZDK5JOA.js → login-7HKBEPJS.js} +7 -7
  171. package/dist/{logout-JYFWWUGK.js → logout-3IID4KXD.js} +3 -3
  172. package/dist/{manager-QYFYWZOK.js → manager-6YSKJMVD.js} +19 -18
  173. package/dist/{manager-F2YREC5X.js → manager-Z7W4GQGF.js} +9 -5
  174. package/dist/{media-treatment-4OLWVHUY.js → media-treatment-E3DL6LEZ.js} +34 -31
  175. package/dist/{models-MR55FAUX.js → models-URWI7YEG.js} +30 -29
  176. package/dist/{motionShot-DC47S7BT.js → motionShot-27IXMDJK.js} +25 -24
  177. package/dist/{normalize-audio-M2TK4NG5.js → normalize-audio-WGRLPR3P.js} +16 -16
  178. package/dist/{open-YXWBWTKL.js → open-LQ35PLEN.js} +21 -21
  179. package/dist/{parakeetRunner-J6QR3GTG.js → parakeetRunner-XASVIDTI.js} +27 -26
  180. package/dist/{pipeline-7MJ5H4SW.js → pipeline-GA7QVCHS.js} +18 -17
  181. package/dist/{play-S562STR4.js → play-RYZP77CI.js} +31 -31
  182. package/dist/{policies-GHVXA5PE.js → policies-PKLD4UW5.js} +1 -1
  183. package/dist/{preflight-QWGXMISC.js → preflight-HJFSJXXF.js} +19 -18
  184. package/dist/{present-PGOHZT3L.js → present-YBMLOWZV.js} +26 -26
  185. package/dist/{preview-JU75H4QN.js → preview-QIRKJCRV.js} +52 -39
  186. package/dist/{producer-H66OMZLW.js → producer-524FDOLX.js} +1 -1
  187. package/dist/{projectConfig-COSP24YT.js → projectConfig-IDQN5ZRW.js} +14 -13
  188. package/dist/{publication-J3XYHPGB.js → publication-3X3IGSDO.js} +8 -8
  189. package/dist/{publish-7GCCEPJZ.js → publish-2BF7K6HX.js} +21 -20
  190. package/dist/{refresh-USSFPJAU.js → refresh-3IRHJEQA.js} +3 -3
  191. package/dist/{remove-background-WRCGIU32.js → remove-background-EZBCEFT6.js} +22 -21
  192. package/dist/{render-QS3YJCBR.js → render-EFUA2A6A.js} +15 -11
  193. package/dist/{render-VUVTK2JM.js → render-JFMTAXHD.js} +87 -53
  194. package/dist/{render-5J5PP3UK.js → render-TEEBI2UT.js} +49 -43
  195. package/dist/{render-batch-Q2LQ3D4P.js → render-batch-XTYNXVSW.js} +16 -12
  196. package/dist/renderSetupWorker.js +12 -9
  197. package/dist/{resolver-QCBWPRSC.js → resolver-FZS6TN6B.js} +10 -10
  198. package/dist/{screenshotCapture-I5EDCITF.js → screenshotCapture-HOW4VSV6.js} +3 -2
  199. package/dist/{sherpa-IZ22SC5W.js → sherpa-TQIAIKTH.js} +26 -25
  200. package/dist/skills/hyperframes/SKILL.md +1 -1
  201. package/dist/skills/hyperframes/references/format.md +1 -0
  202. package/dist/skills/hyperframes-cli/references/beats.md +2 -0
  203. package/dist/skills/hyperframes-cli/references/init-and-scaffold.md +1 -0
  204. package/dist/skills/hyperframes-cli/references/lambda.md +3 -0
  205. package/dist/skills/hyperframes-cli/references/preview-render.md +3 -0
  206. package/dist/skills/media-use/references/grading.md +2 -0
  207. package/dist/skills/media-use/references/local.md +1 -0
  208. package/dist/{skills-3RFMPMJA.js → skills-S6ZG5KKH.js} +10 -10
  209. package/dist/{skillsUpdateCheck-DWBFVUBT.js → skillsUpdateCheck-XC7JQL3F.js} +5 -5
  210. package/dist/{snapshot-5PHA43DK.js → snapshot-ERYZIM32.js} +152 -80
  211. package/dist/{src-4YJKYMNF.js → src-6XOMREMS.js} +21 -12
  212. package/dist/{src-36BQVJL3.js → src-OL6RHPE4.js} +22 -20
  213. package/dist/{staticProjectServer-3XFB76XS.js → staticProjectServer-JYDDGPAH.js} +26 -26
  214. package/dist/{status-LR7VXITS.js → status-DTP6ZYDU.js} +3 -3
  215. package/dist/studio/assets/hyperframes-player-5dRdMVOq.js +478 -0
  216. package/dist/studio/assets/{index-CwreIGoq.js → index-Bu3mJUU2.js} +131 -131
  217. package/dist/studio/assets/{index-BNuxGFZK.js → index-ZqyQ91pm.js} +1 -1
  218. package/dist/studio/index.html +1 -1
  219. package/dist/{studio-api-WL6EZ4KE.js → studio-api-GRU4SHKD.js} +18 -18
  220. package/dist/{studioServer-ZS5RA6U3.js → studioServer-OYPBEI5B.js} +76 -73
  221. package/dist/{synthesize-QCRP3NI7.js → synthesize-QZHRXGRY.js} +26 -4
  222. package/dist/{telemetry-IHU4HL3R.js → telemetry-6BPSGY5W.js} +2 -2
  223. package/dist/{telemetry-W3LRO3TB.js → telemetry-CPYINR63.js} +5 -5
  224. package/dist/{timeline-BDO5DYWP.js → timeline-RGK5BMPD.js} +34 -33
  225. package/dist/{tokens-47CEMYFV.js → tokens-EX4BOWRW.js} +2 -2
  226. package/dist/{transcribe-XF3NL6JI.js → transcribe-MK367I6A.js} +24 -23
  227. package/dist/{transcribe-GEPVJO3A.js → transcribe-RI52JMVW.js} +35 -34
  228. package/dist/{tts-QM4RFE7U.js → tts-AY4JO5NQ.js} +2 -2
  229. package/dist/{updateCheck-BON6ZFYP.js → updateCheck-BIEJKQI4.js} +4 -4
  230. package/dist/{upgrade-KIF5Z4J3.js → upgrade-ES3UUI7O.js} +4 -4
  231. package/dist/upstreamProxy-W5FWAT5Z.js +17 -0
  232. package/dist/{urlDownloader-UDRHVUWR.js → urlDownloader-XAGYSTAG.js} +13 -12
  233. package/dist/{validate-2OPSQT3W.js → validate-A6GZHNEI.js} +36 -35
  234. package/dist/{video-ECWXMY4F.js → video-OEMGR3MN.js} +19 -15
  235. package/dist/warmCheck.js +53 -52
  236. package/package.json +2 -1
  237. package/dist/chunk-4YYJOFKS.js +0 -28
  238. package/dist/chunk-KLIPVNCO.js +0 -4824
  239. package/dist/studio/assets/hyperframes-player-lCVwx9d3.js +0 -478
  240. package/dist/{destroy-SSPAKADI.js → destroy-CGAZIL2C.js} +4 -4
@@ -8,7 +8,12 @@ import {
8
8
  Semaphore,
9
9
  prepareHeifImageInputs,
10
10
  withMediaProbeSlot
11
- } from "./chunk-G6QDFWDN.js";
11
+ } from "./chunk-XOFBXLMG.js";
12
+ import {
13
+ EncoderInterruptedError,
14
+ encoderFailureError,
15
+ prepareAnimatedGifInputs
16
+ } from "./chunk-5HB4JM7H.js";
12
17
  import {
13
18
  GENERIC_FAMILIES,
14
19
  collectFontFamilyCustomProperties,
@@ -16,15 +21,10 @@ import {
16
21
  iterateFontFamilyDeclarations,
17
22
  normalizeSystemFontPrimaryFamilies,
18
23
  resolveFontFamilyDeclarationFamilies
19
- } from "./chunk-N7ZMDVAK.js";
20
- import {
21
- EncoderInterruptedError,
22
- encoderFailureError,
23
- prepareAnimatedGifInputs
24
- } from "./chunk-NVLPW3DG.js";
24
+ } from "./chunk-JLGVBK5M.js";
25
25
  import {
26
26
  parseEncoderOptions
27
- } from "./chunk-AYH5ANVS.js";
27
+ } from "./chunk-5YHQBCWH.js";
28
28
  import {
29
29
  RENDER_TEMP_DIR,
30
30
  createStudioPositionSeekReapplyScript
@@ -45,6 +45,7 @@ import {
45
45
  aacSegmentCount,
46
46
  analyzeCompositionHdr,
47
47
  analyzeKeyframeIntervals,
48
+ appendRateCapArgs,
48
49
  appendRenderProvenanceArgs,
49
50
  appendSoftwareEncoderThreadsArg,
50
51
  applyConcreteGpuScreenshotClamp,
@@ -70,6 +71,7 @@ import {
70
71
  cloneCaptureWarning,
71
72
  cloneCaptureWarnings,
72
73
  closeCaptureSession,
74
+ collectScratchLeftovers,
73
75
  completeDeferredDrawElementInit,
74
76
  compositionRequiresWebGpu,
75
77
  computeWorkerSizing,
@@ -124,6 +126,7 @@ import {
124
126
  isVideoFrameFormat,
125
127
  isVideoHiddenBeforeStreamStart,
126
128
  isVideoPastTimelineEnd,
129
+ keyframeIntervalToGopSize,
127
130
  measureVideoShownBoxes,
128
131
  mergeWorkerFrames,
129
132
  muxVideoWithAudio,
@@ -144,6 +147,7 @@ import {
144
147
  readWebGlVendorInfoFromCanvas,
145
148
  recaptureDrawElementFrameForVerify,
146
149
  removeDomLayerMask,
150
+ removeScratch,
147
151
  renameWithRetry,
148
152
  resampleRgb48leObjectFit,
149
153
  resolveBrowserGpuMode,
@@ -167,7 +171,19 @@ import {
167
171
  verifyDiskDrawElementSamples,
168
172
  videoAudioId,
169
173
  writeCapturedFrame
170
- } from "./chunk-RDDVQSNQ.js";
174
+ } from "./chunk-MPO25DQW.js";
175
+ import {
176
+ assignBundledRuntimeCompositionIds,
177
+ emitMountedModuleScripts,
178
+ emitRootCompositionVariableStyles,
179
+ ensureExternalLinkTag,
180
+ ensureExternalScriptTag,
181
+ extractStandaloneEntryFromIndex,
182
+ inlineSubCompositions,
183
+ parsesAsScript,
184
+ prepareFlattenedInnerRoot,
185
+ stripSdrPngColourTags
186
+ } from "./chunk-GHSO62LK.js";
171
187
  import {
172
188
  DISTRIBUTED_FPS,
173
189
  HF_VFX_ATTR,
@@ -183,19 +199,7 @@ import {
183
199
  parseVfxChain,
184
200
  resolveAuthoredTimingWindow,
185
201
  toFps
186
- } from "./chunk-VW2LVMKB.js";
187
- import {
188
- assignBundledRuntimeCompositionIds,
189
- emitMountedModuleScripts,
190
- emitRootCompositionVariableStyles,
191
- ensureExternalLinkTag,
192
- ensureExternalScriptTag,
193
- extractStandaloneEntryFromIndex,
194
- inlineSubCompositions,
195
- parsesAsScript,
196
- prepareFlattenedInnerRoot,
197
- stripSdrPngColourTags
198
- } from "./chunk-MFHYBSJC.js";
202
+ } from "./chunk-QWBVPWUI.js";
199
203
  import {
200
204
  COMPOSITION_SOURCE_URL,
201
205
  HF_COLOR_GRADING_ATTR,
@@ -230,18 +234,7 @@ import {
230
234
  sourceTimeAt,
231
235
  styleElementsFor,
232
236
  timeAtSourceTime
233
- } from "./chunk-KLIPVNCO.js";
234
- import {
235
- CANVAS_DIMENSIONS,
236
- HTML_BODY_CSS_HEIGHT_FIRST_RE,
237
- HTML_BODY_CSS_WIDTH_FIRST_RE,
238
- VALID_CANVAS_RESOLUTIONS,
239
- checkOutputResolutionCompatibility,
240
- extractMediaSrcMutations,
241
- isAspectAgnosticResolutionAlias,
242
- normalizeResolutionFlag,
243
- suggestMatchingPreset
244
- } from "./chunk-OFRRUYBA.js";
237
+ } from "./chunk-BQMAPNDA.js";
245
238
  import {
246
239
  TRANSITIONS,
247
240
  convertTransfer,
@@ -253,11 +246,11 @@ import {
253
246
  } from "./chunk-634HSJ3J.js";
254
247
  import {
255
248
  chromeMajorCeiling
256
- } from "./chunk-4UMPIPCQ.js";
249
+ } from "./chunk-ERUQ3S6D.js";
257
250
  import {
258
251
  lintHyperframeHtml,
259
252
  resolveReferencedStart
260
- } from "./chunk-2MLMO25E.js";
253
+ } from "./chunk-FC4WT5FX.js";
261
254
  import {
262
255
  isUnresolvedAssetPlaceholder,
263
256
  readProjectFile,
@@ -279,7 +272,18 @@ import {
279
272
  rewriteAssetPaths,
280
273
  rewriteCssAssetUrls,
281
274
  rewriteInlineStyleAssetUrls
282
- } from "./chunk-2BGOB2QK.js";
275
+ } from "./chunk-SE2MXV2N.js";
276
+ import {
277
+ CANVAS_DIMENSIONS,
278
+ HTML_BODY_CSS_HEIGHT_FIRST_RE,
279
+ HTML_BODY_CSS_WIDTH_FIRST_RE,
280
+ VALID_CANVAS_RESOLUTIONS,
281
+ checkOutputResolutionCompatibility,
282
+ extractMediaSrcMutations,
283
+ isAspectAgnosticResolutionAlias,
284
+ normalizeResolutionFlag,
285
+ suggestMatchingPreset
286
+ } from "./chunk-NHA4NRBE.js";
283
287
  import {
284
288
  parseHTML
285
289
  } from "./chunk-GWTIFRF5.js";
@@ -295,7 +299,7 @@ import {
295
299
  mkdirSync as mkdirSync8,
296
300
  readFileSync as readFileSync7,
297
301
  readdirSync as readdirSync5,
298
- rmSync as rmSync10,
302
+ rmSync as rmSync8,
299
303
  statSync as statSync6,
300
304
  writeFileSync as writeFileSync5,
301
305
  copyFileSync as copyFileSync3,
@@ -1077,7 +1081,7 @@ function resolveHlsSegmentSeconds(config) {
1077
1081
  return config.hlsSegmentSeconds ?? DEFAULT_HLS_SEGMENT_SECONDS;
1078
1082
  }
1079
1083
  function resolveHlsGopSize(fps, segmentSeconds) {
1080
- return Math.max(1, Math.round(fpsToNumber(fps) * segmentSeconds));
1084
+ return keyframeIntervalToGopSize(fps, segmentSeconds);
1081
1085
  }
1082
1086
  function resolveHlsEncoderGopLock(outputFormat, fps, segmentSeconds) {
1083
1087
  if (outputFormat !== "hls") return { lockGopForChunkConcat: false, gopSize: void 0 };
@@ -1087,6 +1091,40 @@ function resolveHlsEncoderGopLock(outputFormat, fps, segmentSeconds) {
1087
1091
  };
1088
1092
  }
1089
1093
 
1094
+ // ../producer/src/services/render/deliveryEncoder.ts
1095
+ function validateDeliveryEncoderConfig(config) {
1096
+ const { keyframeIntervalSeconds, maxBitrate, bufferSize, format } = config;
1097
+ if (keyframeIntervalSeconds === void 0 && maxBitrate === void 0 && bufferSize === void 0)
1098
+ return;
1099
+ if (keyframeIntervalSeconds !== void 0) {
1100
+ if (!Number.isFinite(keyframeIntervalSeconds) || keyframeIntervalSeconds <= 0) {
1101
+ throw new Error(
1102
+ `keyframeIntervalSeconds must be a positive number of seconds; got ${keyframeIntervalSeconds}`
1103
+ );
1104
+ }
1105
+ if (format === "hls") {
1106
+ throw new Error(
1107
+ "keyframeIntervalSeconds does not apply to hls; hlsSegmentSeconds sets its keyframes"
1108
+ );
1109
+ }
1110
+ }
1111
+ if (format !== void 0 && format !== "mp4") {
1112
+ throw new Error(`keyframeIntervalSeconds and maxBitrate apply to mp4 renders, not ${format}`);
1113
+ }
1114
+ appendRateCapArgs([], { maxBitrate, bufferSize });
1115
+ }
1116
+ function chunkGopFrames(framesInChunk, intervalFrames) {
1117
+ return Math.min(framesInChunk, intervalFrames ?? framesInChunk);
1118
+ }
1119
+ function resolveDeliveryEncoderOptions(config) {
1120
+ const { maxBitrate, bufferSize, keyframeIntervalSeconds } = config;
1121
+ const gop = keyframeIntervalSeconds === void 0 ? resolveHlsEncoderGopLock(config.format ?? "mp4", config.fps, config.hlsSegmentSeconds) : {
1122
+ lockGopForChunkConcat: true,
1123
+ gopSize: keyframeIntervalToGopSize(config.fps, keyframeIntervalSeconds)
1124
+ };
1125
+ return { maxBitrate, bufferSize, ...gop };
1126
+ }
1127
+
1090
1128
  // ../producer/src/services/render/shared.ts
1091
1129
  import {
1092
1130
  copyFileSync,
@@ -2071,7 +2109,7 @@ function replanSegmentedAfterFailure(plan2, failure) {
2071
2109
  const keepSegmenting = failure.kind === "draw_element_verification" || failure.kind === "draw_element_capture";
2072
2110
  return createCapturePlan({
2073
2111
  ...plan2,
2074
- forceScreenshot: keepSegmenting || failure.kind === "capture_failure",
2112
+ forceScreenshot: plan2.forceScreenshot || keepSegmenting || failure.kind === "capture_failure",
2075
2113
  useStreamingEncode: true,
2076
2114
  useLayeredComposite: false,
2077
2115
  useSegmentedCapture: keepSegmenting,
@@ -4066,7 +4104,6 @@ async function runCaptureStreamingStage(input) {
4066
4104
  const reorderBuffer = createFrameReorderBuffer(0, totalFrames);
4067
4105
  if (workerCount > 1) {
4068
4106
  const deParallelStream = forceParallelStream === true || process.env.HF_DE_PARALLEL_STREAM === "true";
4069
- const tasks = deParallelStream ? distributeFramesInterleaved(totalFrames, workerCount, workDir) : distributeFrames(totalFrames, workerCount, workDir);
4070
4107
  const parallelStats = {
4071
4108
  verifyChecked: 0,
4072
4109
  blankSuspects: 0,
@@ -4079,143 +4116,158 @@ async function runCaptureStreamingStage(input) {
4079
4116
  frameTime: (i) => i * job.config.fps.den / job.config.fps.num
4080
4117
  });
4081
4118
  let parallelGuardRan = false;
4082
- let parallelDrainError = null;
4083
- const onFrameBuffer = async (frameIndex, buffer, workerSession) => {
4084
- try {
4085
- if (deParallelStream && workerSession.captureMode === "drawelement") {
4086
- parallelGuardRan = true;
4087
- buffer = await parallelGuard(workerSession, frameIndex, buffer);
4088
- }
4089
- await reorderBuffer.waitForFrame(frameIndex);
4090
- ensureFrameWritten(await currentEncoder.writeFrame(buffer), frameIndex, currentEncoder);
4091
- reorderBuffer.advanceTo(frameIndex + 1);
4092
- } catch (err) {
4093
- const e = err instanceof Error ? err : new Error(String(err));
4094
- if (!parallelDrainError) {
4095
- parallelDrainError = e;
4096
- reorderBuffer.abort(e);
4119
+ let writtenFrames = 0;
4120
+ let resumeFrom = 0;
4121
+ let resumedAfterStall = false;
4122
+ let workerResults;
4123
+ for (; ; ) {
4124
+ const parallelReorder = createFrameReorderBuffer(resumeFrom, totalFrames);
4125
+ const tasks = deParallelStream ? distributeFramesInterleaved(totalFrames - resumeFrom, workerCount, workDir, resumeFrom) : distributeFrames(totalFrames - resumeFrom, workerCount, workDir, resumeFrom);
4126
+ let parallelDrainError = null;
4127
+ const onFrameBuffer = async (frameIndex, buffer, workerSession) => {
4128
+ try {
4129
+ if (deParallelStream && workerSession.captureMode === "drawelement") {
4130
+ parallelGuardRan = true;
4131
+ buffer = await parallelGuard(workerSession, frameIndex, buffer);
4132
+ }
4133
+ await parallelReorder.waitForFrame(frameIndex);
4134
+ ensureFrameWritten(await currentEncoder.writeFrame(buffer), frameIndex, currentEncoder);
4135
+ parallelReorder.advanceTo(frameIndex + 1);
4136
+ writtenFrames = frameIndex + 1;
4137
+ } catch (err) {
4138
+ const e = err instanceof Error ? err : new Error(String(err));
4139
+ if (!parallelDrainError) {
4140
+ parallelDrainError = e;
4141
+ parallelReorder.abort(e);
4142
+ }
4143
+ throw e;
4097
4144
  }
4098
- throw e;
4145
+ };
4146
+ const captureLabel = input.parallelCaptureLabel ?? "worker";
4147
+ let watchdogArmed = false;
4148
+ const stallController = new AbortController();
4149
+ const forwardParentAbort = () => stallController.abort();
4150
+ if (abortSignal) {
4151
+ if (abortSignal.aborted) stallController.abort();
4152
+ else abortSignal.addEventListener("abort", forwardParentAbort, { once: true });
4099
4153
  }
4100
- };
4101
- const captureLabel = input.parallelCaptureLabel ?? "worker";
4102
- let watchdogArmed = false;
4103
- const stallController = new AbortController();
4104
- const forwardParentAbort = () => stallController.abort();
4105
- if (abortSignal) {
4106
- if (abortSignal.aborted) stallController.abort();
4107
- else abortSignal.addEventListener("abort", forwardParentAbort, { once: true });
4108
- }
4109
- const stallTimeoutMs = resolveCaptureStallTimeoutMs();
4110
- let lastCapturedFrames = 0;
4111
- let lastProgressAt = Date.now();
4112
- const workerPhases = /* @__PURE__ */ new Map();
4113
- const phaseSummary = () => [...workerPhases.entries()].sort(([left], [right]) => left - right).map(([workerId, detail]) => `worker=${workerId} ${detail}`).join("; ");
4114
- let stalled = false;
4115
- const stallTimer = setInterval(
4116
- () => {
4117
- if (!watchdogArmed || Date.now() - lastProgressAt <= stallTimeoutMs) return;
4118
- stalled = true;
4119
- const stallErr = new ParallelCaptureStallError({
4120
- variant: "drain",
4121
- captureLabel,
4122
- stallTimeoutMs,
4123
- lastCapturedFrames,
4124
- totalFrames,
4125
- phaseSummary: phaseSummary()
4126
- });
4127
- reorderBuffer.abort(stallErr);
4128
- stallController.abort();
4129
- },
4130
- Math.min(stallTimeoutMs, DE_STALL_POLL_MS)
4131
- );
4132
- let workerResults;
4133
- try {
4134
- workerResults = await executeParallelCapture(
4135
- fileServer.url,
4136
- workDir,
4137
- tasks,
4138
- buildCaptureOptions(),
4139
- createRenderVideoFrameInjector,
4140
- stallController.signal,
4141
- (progress) => {
4142
- if (progress.latestWorkerPhase) {
4143
- const phase = progress.latestWorkerPhase;
4144
- const detail = `phase=${phase.phase} frame=${phase.frameIndex ?? "n/a"} browser=${phase.browserExecutable} version=${phase.browserVersion} CanvasDrawElement=${phase.canvasDrawElement} gpu=${phase.gpuBackend}`;
4145
- workerPhases.set(phase.workerId, detail);
4146
- if (phase.phase === "frame_capture" && !watchdogArmed) {
4147
- watchdogArmed = true;
4154
+ const stallTimeoutMs = resolveCaptureStallTimeoutMs();
4155
+ let lastCapturedFrames = 0;
4156
+ let lastProgressAt = Date.now();
4157
+ const workerPhases = /* @__PURE__ */ new Map();
4158
+ const phaseDetail = (phase) => `phase=${phase.phase} frame=${phase.frameIndex ?? "n/a"} step=${phase.readStep?.() ?? "n/a"} browser=${phase.browserExecutable} version=${phase.browserVersion} CanvasDrawElement=${phase.canvasDrawElement} gpu=${phase.gpuBackend}`;
4159
+ const phaseSummary = () => [...workerPhases.entries()].sort(([left], [right]) => left - right).map(([workerId, detail]) => `worker=${workerId} ${detail}`).join("; ");
4160
+ let stalled = false;
4161
+ const stallTimer = setInterval(
4162
+ () => {
4163
+ if (!watchdogArmed || Date.now() - lastProgressAt <= stallTimeoutMs) return;
4164
+ stalled = true;
4165
+ const stallErr = new ParallelCaptureStallError({
4166
+ variant: "drain",
4167
+ captureLabel,
4168
+ stallTimeoutMs,
4169
+ lastCapturedFrames: resumeFrom + lastCapturedFrames,
4170
+ totalFrames,
4171
+ phaseSummary: phaseSummary()
4172
+ });
4173
+ parallelReorder.abort(stallErr);
4174
+ stallController.abort();
4175
+ },
4176
+ Math.min(stallTimeoutMs, DE_STALL_POLL_MS)
4177
+ );
4178
+ try {
4179
+ workerResults = await executeParallelCapture(
4180
+ fileServer.url,
4181
+ workDir,
4182
+ tasks,
4183
+ buildCaptureOptions(),
4184
+ createRenderVideoFrameInjector,
4185
+ stallController.signal,
4186
+ (progress) => {
4187
+ if (progress.latestWorkerPhase) {
4188
+ const phase = progress.latestWorkerPhase;
4189
+ workerPhases.set(phase.workerId, phaseDetail(phase));
4190
+ if (phase.phase === "frame_capture" && !watchdogArmed) {
4191
+ watchdogArmed = true;
4192
+ lastProgressAt = Date.now();
4193
+ }
4194
+ log.info("[Render] Parallel capture worker phase", {
4195
+ workerId: phase.workerId,
4196
+ phase: phase.phase,
4197
+ frameIndex: phase.frameIndex,
4198
+ browserExecutable: phase.browserExecutable,
4199
+ browserVersion: phase.browserVersion,
4200
+ canvasDrawElement: phase.canvasDrawElement,
4201
+ gpuBackend: phase.gpuBackend
4202
+ });
4203
+ if (progress.capturedFrames === 0) reportWorkerStartup(job, progress, onProgress);
4204
+ return;
4205
+ }
4206
+ if (progress.capturedFrames > lastCapturedFrames) {
4207
+ lastCapturedFrames = progress.capturedFrames;
4148
4208
  lastProgressAt = Date.now();
4209
+ watchdogArmed = true;
4210
+ }
4211
+ const doneFrames = resumeFrom + progress.capturedFrames;
4212
+ job.framesRendered = doneFrames;
4213
+ const frameProgress = doneFrames / totalFrames;
4214
+ reportFrameProgress(
4215
+ job,
4216
+ `Streaming frame ${doneFrames}/${totalFrames} (${workerCount} workers)`,
4217
+ Math.round(25 + frameProgress * 55),
4218
+ onProgress,
4219
+ doneFrames,
4220
+ totalFrames
4221
+ );
4222
+ },
4223
+ onFrameBuffer,
4224
+ // Interleaved DE workers each get their own browser process: co-tenant pages starve
4225
+ // each other's paint events.
4226
+ deParallelStream ? { ...captureCfg, enableBrowserPool: false } : captureCfg,
4227
+ {
4228
+ // A worker died: release parked peers with its original failure, not the stall the
4229
+ // watchdog raises later.
4230
+ onWorkerOperation: (phase) => workerPhases.set(phase.workerId, phaseDetail(phase)),
4231
+ onWorkerFailure: (failure) => {
4232
+ if (parallelDrainError) return;
4233
+ parallelDrainError = failure;
4234
+ parallelReorder.abort(failure);
4149
4235
  }
4150
- log.info("[Render] Parallel capture worker phase", {
4151
- workerId: phase.workerId,
4152
- phase: phase.phase,
4153
- frameIndex: phase.frameIndex,
4154
- browserExecutable: phase.browserExecutable,
4155
- browserVersion: phase.browserVersion,
4156
- canvasDrawElement: phase.canvasDrawElement,
4157
- gpuBackend: phase.gpuBackend
4158
- });
4159
- if (progress.capturedFrames === 0) reportWorkerStartup(job, progress, onProgress);
4160
- return;
4161
- }
4162
- if (progress.capturedFrames > lastCapturedFrames) {
4163
- lastCapturedFrames = progress.capturedFrames;
4164
- lastProgressAt = Date.now();
4165
- watchdogArmed = true;
4166
4236
  }
4167
- job.framesRendered = progress.capturedFrames;
4168
- const frameProgress = progress.capturedFrames / progress.totalFrames;
4169
- reportFrameProgress(
4170
- job,
4171
- `Streaming frame ${progress.capturedFrames}/${progress.totalFrames} (${workerCount} workers)`,
4172
- Math.round(25 + frameProgress * 55),
4173
- onProgress,
4174
- progress.capturedFrames,
4175
- progress.totalFrames
4237
+ );
4238
+ } catch (err) {
4239
+ if (stalled && abortSignal?.aborted !== true && captureLabel === "BeginFrame" && !resumedAfterStall && writtenFrames > resumeFrom) {
4240
+ resumedAfterStall = true;
4241
+ log.warn(
4242
+ "[Render] Parallel BeginFrame capture stalled; resuming from the first unwritten frame",
4243
+ {
4244
+ resumeFrom: writtenFrames,
4245
+ totalFrames,
4246
+ workerPhases: phaseSummary()
4247
+ }
4176
4248
  );
4177
- },
4178
- onFrameBuffer,
4179
- // Interleaved DE workers each need their own browser PROCESS:
4180
- // pages co-tenant in one browser share one compositor, whose
4181
- // internal frame scheduling deprioritizes non-active pages — their
4182
- // canvas `paint` events starve and the drawElement paint-wait slows
4183
- // ~3x (measured: 86s vs 30s on a 3,245-frame rAF comp). This is
4184
- // Chromium's internal frame-production scheduling on ALL platforms,
4185
- // NOT the Linux-only HeadlessExperimental.beginFrame capture mode.
4186
- deParallelStream ? { ...captureCfg, enableBrowserPool: false } : captureCfg,
4187
- {
4188
- // A worker died (Target closed, Page crashed, launch failure).
4189
- // Its frames are gone and peers are parked in waitForFrame on the
4190
- // first of them; release them with the ORIGINAL failure so the
4191
- // orchestrator sees a transient browser error it knows how to
4192
- // retry, not the stall the watchdog would have raised a minute
4193
- // later. First failure wins, same as the drain guard above.
4194
- onWorkerFailure: (failure) => {
4195
- if (parallelDrainError) return;
4196
- parallelDrainError = failure;
4197
- reorderBuffer.abort(failure);
4198
- }
4249
+ resumeFrom = writtenFrames;
4250
+ continue;
4199
4251
  }
4200
- );
4201
- } catch (err) {
4202
- if (parallelDrainError) throw poolFailure(parallelDrainError, probeSession);
4203
- if (stalled && abortSignal?.aborted !== true) {
4204
- throw new ParallelCaptureStallError({
4205
- variant: "pool",
4206
- captureLabel,
4207
- stallTimeoutMs,
4208
- lastCapturedFrames,
4209
- totalFrames,
4210
- phaseSummary: phaseSummary()
4211
- });
4252
+ if (parallelDrainError) throw poolFailure(parallelDrainError, probeSession);
4253
+ if (stalled && abortSignal?.aborted !== true) {
4254
+ throw new ParallelCaptureStallError({
4255
+ variant: "pool",
4256
+ captureLabel,
4257
+ stallTimeoutMs,
4258
+ lastCapturedFrames: resumeFrom + lastCapturedFrames,
4259
+ totalFrames,
4260
+ phaseSummary: phaseSummary()
4261
+ });
4262
+ }
4263
+ throw poolFailure(err, probeSession);
4264
+ } finally {
4265
+ clearInterval(stallTimer);
4266
+ abortSignal?.removeEventListener("abort", forwardParentAbort);
4212
4267
  }
4213
- throw poolFailure(err, probeSession);
4214
- } finally {
4215
- clearInterval(stallTimer);
4216
- abortSignal?.removeEventListener("abort", forwardParentAbort);
4268
+ if (parallelDrainError) throw poolFailure(parallelDrainError, probeSession);
4269
+ break;
4217
4270
  }
4218
- if (parallelDrainError) throw poolFailure(parallelDrainError, probeSession);
4219
4271
  pushWorkerDedupPerfs(workerResults, dedupPerfs);
4220
4272
  const workerPageErrors = [];
4221
4273
  pushWorkerPageErrors(workerResults, workerPageErrors);
@@ -4376,7 +4428,7 @@ function segmentEncoderOptions(base, segment) {
4376
4428
  return {
4377
4429
  ...base,
4378
4430
  lockGopForChunkConcat: true,
4379
- gopSize: segment.endFrame - segment.startFrame
4431
+ gopSize: Math.min(base.gopSize ?? Infinity, segment.endFrame - segment.startFrame)
4380
4432
  };
4381
4433
  }
4382
4434
  var SegmentEncoderSpawnError = class extends Error {
@@ -4470,6 +4522,12 @@ function defaultSessionFactory(input) {
4470
4522
  let probeSession = input.probeSession;
4471
4523
  return {
4472
4524
  create: async () => {
4525
+ const probeCannotCaptureEveryFrame = Boolean(probeSession?.deRiskFrames?.size);
4526
+ if (probeSession && probeCannotCaptureEveryFrame) {
4527
+ await closeCaptureSession(probeSession).catch(() => {
4528
+ });
4529
+ probeSession = null;
4530
+ }
4473
4531
  const session = probeSession ?? await openSegmentedSession(input);
4474
4532
  if (probeSession) {
4475
4533
  openSegmentedSessionReuse(input, probeSession);
@@ -4799,8 +4857,10 @@ function computeSegmentPlanHash(input) {
4799
4857
  input.motionBlur,
4800
4858
  input.pageMotionBlur ?? "",
4801
4859
  input.captureQuality === void 0 ? "" : String(input.captureQuality)
4802
- ].join(" ");
4803
- return createHash2("sha256").update(ordered).digest("hex").slice(0, 16);
4860
+ ];
4861
+ const delivery = [input.maxBitrate, input.bufferSize, input.gopSize].map((v) => v ?? "");
4862
+ if (delivery.some((v) => v !== "")) ordered.push(...delivery.map(String));
4863
+ return createHash2("sha256").update(ordered.join(" ")).digest("hex").slice(0, 16);
4804
4864
  }
4805
4865
  function segmentDirFor(projectRendersDir, planHash) {
4806
4866
  return join11(projectRendersDir, ".hf-segments", planHash);
@@ -6140,7 +6200,7 @@ function detectShaderTransitionUsage(html) {
6140
6200
  }
6141
6201
  return false;
6142
6202
  }
6143
- async function resolveMediaDuration(src, mediaStart, playbackRate, baseDir, downloadDir, tagName, elementIdentity, log, urlByAbsentLocalPath) {
6203
+ async function resolveMediaDuration(src, mediaStart, playbackRate, baseDir, downloadDir, tagName, elementIdentity, log, urlByAbsentLocalPath, probes) {
6144
6204
  let filePath = src;
6145
6205
  if (isHttpUrl(src)) {
6146
6206
  if (!existsSync9(downloadDir)) mkdirSync5(downloadDir, { recursive: true });
@@ -6167,45 +6227,52 @@ async function resolveMediaDuration(src, mediaStart, playbackRate, baseDir, down
6167
6227
  if (error instanceof Error && error.stack) wrapped.stack = error.stack;
6168
6228
  return wrapped;
6169
6229
  };
6170
- return withMediaProbeSlot(async () => {
6171
- let profile;
6230
+ const probe = () => withMediaProbeSlot(async () => {
6172
6231
  try {
6173
6232
  await assertMediaPayload(filePath, elementIdentity);
6174
- profile = await probeMediaProfile(filePath);
6175
- } catch (error) {
6176
- if (tagName !== "video") {
6177
- if (error instanceof NotMediaPayloadError) {
6178
- log?.warn(
6179
- `[compile] Audio "${elementIdentity}" (${src}) is a text document, not a media file, so the element is dropped from the render. Point it at a rendered media file.`
6180
- );
6181
- }
6182
- return { duration: null, resolvedPath: filePath };
6233
+ const profile = await probeMediaProfile(filePath);
6234
+ if (tagName === "video") {
6235
+ return { profile, fileDuration: (await extractMediaMetadata(filePath)).durationSeconds };
6183
6236
  }
6184
- throw withSrcContext(error);
6185
- }
6186
- assertAssetMediaTypeProfile(tagName === "video" ? "video" : "audio", profile, elementIdentity);
6187
- let metadata;
6188
- if (tagName === "video") {
6189
6237
  try {
6190
- metadata = await extractMediaMetadata(filePath);
6191
- } catch (error) {
6192
- throw withSrcContext(error);
6193
- }
6194
- } else {
6195
- try {
6196
- metadata = await extractAudioMetadata(filePath);
6238
+ return { profile, fileDuration: (await extractAudioMetadata(filePath)).durationSeconds };
6197
6239
  } catch {
6198
- return { duration: null, resolvedPath: filePath };
6240
+ return { profile, fileDuration: null };
6199
6241
  }
6242
+ } catch (error) {
6243
+ return { error };
6200
6244
  }
6201
- const fileDuration = metadata.durationSeconds;
6202
- const duration = resolveNaturalMediaTimelineDurationFromValues(
6203
- fileDuration,
6204
- mediaStart,
6205
- playbackRate
6206
- );
6207
- return { duration, resolvedPath: filePath };
6208
6245
  });
6246
+ const key = `${tagName}\0${filePath}`;
6247
+ let probed = probes?.get(key);
6248
+ if (!probed) {
6249
+ probed = probe();
6250
+ probes?.set(key, probed);
6251
+ }
6252
+ const outcome = await probed;
6253
+ if ("error" in outcome) {
6254
+ if (tagName !== "video") {
6255
+ if (outcome.error instanceof NotMediaPayloadError) {
6256
+ log?.warn(
6257
+ `[compile] Audio "${elementIdentity}" (${src}) is a text document, not a media file, so the element is dropped from the render. Point it at a rendered media file.`
6258
+ );
6259
+ }
6260
+ return { duration: null, resolvedPath: filePath };
6261
+ }
6262
+ throw withSrcContext(outcome.error);
6263
+ }
6264
+ assertAssetMediaTypeProfile(
6265
+ tagName === "video" ? "video" : "audio",
6266
+ outcome.profile,
6267
+ elementIdentity
6268
+ );
6269
+ if (outcome.fileDuration === null) return { duration: null, resolvedPath: filePath };
6270
+ const duration = resolveNaturalMediaTimelineDurationFromValues(
6271
+ outcome.fileDuration,
6272
+ mediaStart,
6273
+ playbackRate
6274
+ );
6275
+ return { duration, resolvedPath: filePath };
6209
6276
  }
6210
6277
  function markInferredVariableMediaDurations(html, unresolvedMedia) {
6211
6278
  const unresolvedIds = new Set(unresolvedMedia.map((element) => element.id));
@@ -6219,7 +6286,7 @@ function markInferredVariableMediaDurations(html, unresolvedMedia) {
6219
6286
  }
6220
6287
  return changed ? document2.toString() : html;
6221
6288
  }
6222
- async function compileHtmlFile(html, baseDir, downloadDir, log, urlByAbsentLocalPath) {
6289
+ async function compileHtmlFile(html, baseDir, downloadDir, log, urlByAbsentLocalPath, probes) {
6223
6290
  const { html: staticCompiled, unresolved } = compileTimingAttrs(html);
6224
6291
  const mediaUnresolved = unresolved.filter(
6225
6292
  (el) => (el.tagName === "video" || el.tagName === "audio") && el.src
@@ -6236,7 +6303,8 @@ async function compileHtmlFile(html, baseDir, downloadDir, log, urlByAbsentLocal
6236
6303
  el.tagName,
6237
6304
  el.id,
6238
6305
  log,
6239
- urlByAbsentLocalPath
6306
+ urlByAbsentLocalPath,
6307
+ probes
6240
6308
  ).then(({ duration }) => ({ id: el.id, duration }))
6241
6309
  )
6242
6310
  );
@@ -6257,7 +6325,9 @@ async function compileHtmlFile(html, baseDir, downloadDir, log, urlByAbsentLocal
6257
6325
  downloadDir,
6258
6326
  el.tagName,
6259
6327
  el.id,
6260
- log
6328
+ log,
6329
+ void 0,
6330
+ probes
6261
6331
  );
6262
6332
  return { id: el.id, tagName: el.tagName, duration: el.duration, maxDuration, src: el.src };
6263
6333
  })
@@ -6279,7 +6349,7 @@ async function compileHtmlFile(html, baseDir, downloadDir, log, urlByAbsentLocal
6279
6349
  compiledHtml = compiledHtml.replace(/(<audio\b[^>]*)\s+crossorigin(?:=["'][^"']*["'])?/gi, "$1");
6280
6350
  return { html: compiledHtml, unresolvedCompositions };
6281
6351
  }
6282
- async function parseSubCompositions(html, projectDir, downloadDir, visited = /* @__PURE__ */ new Set(), urlByAbsentLocalPath) {
6352
+ async function parseSubCompositions(html, projectDir, downloadDir, visited = /* @__PURE__ */ new Set(), urlByAbsentLocalPath, probes) {
6283
6353
  const subCompositions = /* @__PURE__ */ new Map();
6284
6354
  const { document: document2 } = parseHTML(html);
6285
6355
  const compEls = document2.querySelectorAll("[data-composition-src]");
@@ -6307,14 +6377,16 @@ async function parseSubCompositions(html, projectDir, downloadDir, visited = /*
6307
6377
  dirname5(item.filePath),
6308
6378
  downloadDir,
6309
6379
  void 0,
6310
- urlByAbsentLocalPath
6380
+ urlByAbsentLocalPath,
6381
+ probes
6311
6382
  );
6312
6383
  const nested = await parseSubCompositions(
6313
6384
  compiledSub,
6314
6385
  projectDir,
6315
6386
  downloadDir,
6316
6387
  item.nestedVisited,
6317
- urlByAbsentLocalPath
6388
+ urlByAbsentLocalPath,
6389
+ probes
6318
6390
  );
6319
6391
  return {
6320
6392
  srcPath: item.srcPath,
@@ -6971,7 +7043,7 @@ async function readLocalFont(absPath) {
6971
7043
  return { kind: "inline", buffer: Buffer.concat(chunks, totalBytes) };
6972
7044
  }
6973
7045
  async function embedLocalFontFaces(html, projectDir) {
6974
- const { fontToDataUri: toDataUri } = await import("./deterministicFonts-775YXAQ2.js");
7046
+ const { fontToDataUri: toDataUri } = await import("./deterministicFonts-LKAGUNE5.js");
6975
7047
  const styleBlockRe = /<style\b[^>]*>([\s\S]*?)<\/style>/gi;
6976
7048
  const fontFaceRe = /@font-face\s*\{([^}]*)\}/gi;
6977
7049
  let result = html;
@@ -7084,19 +7156,22 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
7084
7156
  );
7085
7157
  const rawHtml = rewriteUnresolvableGsapToCdn(entryHtml, projectDir);
7086
7158
  assertSubCompositionsUsable(rawHtml, projectDir);
7159
+ const probes = /* @__PURE__ */ new Map();
7087
7160
  const { html: compiledHtml, unresolvedCompositions } = await compileHtmlFile(
7088
7161
  rawHtml,
7089
7162
  projectDir,
7090
7163
  downloadDir,
7091
7164
  options.log,
7092
- options.urlByAbsentLocalPath
7165
+ options.urlByAbsentLocalPath,
7166
+ probes
7093
7167
  );
7094
7168
  const { subCompositions } = await parseSubCompositions(
7095
7169
  compiledHtml,
7096
7170
  projectDir,
7097
7171
  downloadDir,
7098
7172
  void 0,
7099
- options.urlByAbsentLocalPath
7173
+ options.urlByAbsentLocalPath,
7174
+ probes
7100
7175
  );
7101
7176
  const fullHtml = ensureFullDocument(compiledHtml);
7102
7177
  const inlinedHtml = inlineSubCompositions2(
@@ -7199,9 +7274,12 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
7199
7274
  }
7200
7275
  const { videos, audios, images, droppedMediaIds } = collectRenderMedia(html);
7201
7276
  const masterFxChain = parseMasterFxChain(html);
7277
+ const advised = /* @__PURE__ */ new Set();
7202
7278
  for (const video of videos) {
7203
7279
  if (isHttpUrl(video.src)) continue;
7204
7280
  const videoPath = resolve5(projectDir, video.src);
7281
+ if (advised.has(videoPath)) continue;
7282
+ advised.add(videoPath);
7205
7283
  const reencode = `ffmpeg -i "${video.src}" -c:v libx264 -r 30 -g 30 -keyint_min 30 -movflags +faststart -c:a copy output.mp4`;
7206
7284
  (async () => {
7207
7285
  const metadata = await withMediaProbeSlot(() => extractMediaMetadata(videoPath));
@@ -7774,8 +7852,15 @@ function hasAutoStartVideos(html) {
7774
7852
  const { document: document2 } = parseHTML(html);
7775
7853
  return document2.querySelector("video[data-hf-auto-start]") !== null;
7776
7854
  }
7855
+ function variableHasValue(element, variableId, variables) {
7856
+ if (variables && Object.hasOwn(variables, variableId)) return true;
7857
+ for (let scope = element.parentElement; scope; scope = scope.parentElement) {
7858
+ if (Object.hasOwn(parseHostVariableValues(scope), variableId)) return true;
7859
+ if (Object.hasOwn(readDeclaredDefaults(scope), variableId)) return true;
7860
+ }
7861
+ return Object.hasOwn(readDeclaredDefaults(element.ownerDocument.documentElement), variableId);
7862
+ }
7777
7863
  function hasVariableBoundMedia(html, variables) {
7778
- if (!variables || Object.keys(variables).length === 0) return false;
7779
7864
  const { document: document2 } = parseHTML(html);
7780
7865
  return Array.from(
7781
7866
  document2.querySelectorAll(
@@ -7783,7 +7868,7 @@ function hasVariableBoundMedia(html, variables) {
7783
7868
  )
7784
7869
  ).some((element) => {
7785
7870
  const variableId = element.getAttribute("data-var-src")?.trim();
7786
- return Boolean(variableId && Object.hasOwn(variables, variableId));
7871
+ return Boolean(variableId && variableHasValue(element, variableId, variables));
7787
7872
  });
7788
7873
  }
7789
7874
  function authoredMediaStarts(html) {
@@ -8491,10 +8576,11 @@ var VideoExtractionStageError = class extends Error {
8491
8576
  kind: failure.kind,
8492
8577
  affectedElementCount: failure.count
8493
8578
  }))
8494
- )) {
8579
+ ), ffmpegReason) {
8495
8580
  const total = failures.reduce((sum2, failure) => sum2 + failure.count, 0);
8496
8581
  const breakdown = failures.map((failure) => `${failure.kind}=${failure.count}`).join(",");
8497
- super(`Video extraction failed for ${total} source(s) [${code}; ${breakdown}]`);
8582
+ const reason = ffmpegReason ? `: ffmpeg said: ${ffmpegReason}` : "";
8583
+ super(`Video extraction failed for ${total} source(s) [${code}; ${breakdown}]${reason}`);
8498
8584
  this.code = code;
8499
8585
  this.retryable = retryable;
8500
8586
  this.failures = failures;
@@ -8541,7 +8627,8 @@ function buildVideoExtractionStageError(result) {
8541
8627
  retryable ? "VIDEO_EXTRACTION_FAILED" : "VIDEO_SOURCE_UNRENDERABLE",
8542
8628
  retryable,
8543
8629
  failures,
8544
- extractionFailureMetadataFromResult(result)
8630
+ extractionFailureMetadataFromResult(result),
8631
+ result.errors.find((failure) => failure.ffmpegReason)?.ffmpegReason
8545
8632
  );
8546
8633
  }
8547
8634
  function buildHdrProbeStageError(failures) {
@@ -8782,11 +8869,10 @@ function appendAutoDetectedVideoAudio(composition, extracted) {
8782
8869
 
8783
8870
  // ../producer/src/services/render/stages/audioStage.ts
8784
8871
  import { join as join18 } from "path";
8785
- import { rmSync as rmSync8 } from "fs";
8786
8872
 
8787
8873
  // ../producer/src/services/render/audioPadTrim.ts
8788
8874
  import { spawn } from "child_process";
8789
- import { mkdtempSync as mkdtempSync3, rmSync as rmSync7 } from "fs";
8875
+ import { mkdtempSync as mkdtempSync3 } from "fs";
8790
8876
  import { dirname as dirname6, join as join17 } from "path";
8791
8877
 
8792
8878
  // ../producer/src/services/render/audioTruePeak.ts
@@ -8972,7 +9058,7 @@ async function padOrTrimAudioToVideoFrameCount(input) {
8972
9058
  error: `audioPadTrim: failed to materialize ${plan2.operation}: ${err instanceof Error ? err.message : String(err)}`
8973
9059
  };
8974
9060
  } finally {
8975
- for (const path of plan2.cleanupPaths) rmSync7(path, { force: true });
9061
+ for (const path of plan2.cleanupPaths) removeScratch(path);
8976
9062
  }
8977
9063
  let loweredDb = 0;
8978
9064
  if (probeTruePeak) {
@@ -9035,7 +9121,7 @@ async function enforceAacTruePeak(input) {
9035
9121
  }
9036
9122
  if (truePeakDbfs <= AAC_DELIVERY_TRUE_PEAK_DBFS) {
9037
9123
  if (measuredPath !== correctedPath) return { success: true };
9038
- renameWithRetry(correctedPath, input.audioPath);
9124
+ renameWithRetry(correctedPath, input.audioPath, { copyFallback: true });
9039
9125
  return { success: true, loweredDb: Number((-attenuationDb).toFixed(2)) };
9040
9126
  }
9041
9127
  if (pass === MAX_TRUE_PEAK_CORRECTION_PASSES) break;
@@ -9076,7 +9162,7 @@ async function enforceAacTruePeak(input) {
9076
9162
  )}`
9077
9163
  };
9078
9164
  } finally {
9079
- if (scratchDir) rmSync7(scratchDir, { recursive: true, force: true });
9165
+ if (scratchDir) removeScratch(scratchDir);
9080
9166
  }
9081
9167
  }
9082
9168
  function failResult(outputPath, target, source, error) {
@@ -9221,7 +9307,15 @@ function assertAudioNotInterrupted(failures) {
9221
9307
  ])
9222
9308
  });
9223
9309
  }
9224
- async function runAudioStage(input) {
9310
+ function runAudioStage(input) {
9311
+ return collectScratchLeftovers(
9312
+ () => runAudioStageScoped(input),
9313
+ (left) => {
9314
+ if (left.length > 0) input.log?.warn("[audio] scratch left behind", { count: left.length });
9315
+ }
9316
+ );
9317
+ }
9318
+ async function runAudioStageScoped(input) {
9225
9319
  const stageStart = Date.now();
9226
9320
  const pcmSourcePath = join18(input.workDir, "audio-source.wav");
9227
9321
  const duration = input.totalFrames * input.fps.den / input.fps.num;
@@ -9243,7 +9337,7 @@ async function runAudioStage(input) {
9243
9337
  }
9244
9338
  return { ...result, audioLoweredDb, audioProcessMs: Date.now() - stageStart };
9245
9339
  } finally {
9246
- rmSync8(pcmSourcePath, { force: true });
9340
+ removeScratch(pcmSourcePath);
9247
9341
  }
9248
9342
  }
9249
9343
  async function mixAudioForDelivery(input, duration, pcmSourcePath) {
@@ -9491,6 +9585,7 @@ async function runCaptureStage(input) {
9491
9585
  dedupPerfs,
9492
9586
  pageErrorLines: workerPageErrors,
9493
9587
  openAttempt: input.openAttempt,
9588
+ verifyFirstSession: input.verifyFirstSession,
9494
9589
  onProgress: (progress) => {
9495
9590
  if (progress.latestWorkerPhase) {
9496
9591
  if (progress.capturedFrames === 0) reportWorkerStartup(job, progress, onProgress);
@@ -10360,6 +10455,7 @@ async function runCaptureHdrStage(input) {
10360
10455
  preset,
10361
10456
  effectiveQuality,
10362
10457
  effectiveBitrate,
10458
+ deliveryEncoder,
10363
10459
  fileServer,
10364
10460
  buildCaptureOptions,
10365
10461
  createRenderVideoFrameInjector,
@@ -10449,6 +10545,7 @@ async function runCaptureHdrStage(input) {
10449
10545
  preset: preset.preset,
10450
10546
  quality: effectiveQuality,
10451
10547
  bitrate: effectiveBitrate,
10548
+ ...deliveryEncoder,
10452
10549
  pixelFormat: preset.pixelFormat,
10453
10550
  hdr: preset.hdr,
10454
10551
  rawInputFormat: "rgb48le"
@@ -10652,7 +10749,7 @@ import {
10652
10749
  mkdirSync as mkdirSync7,
10653
10750
  readdirSync as readdirSync4,
10654
10751
  readFileSync as readFileSync6,
10655
- rmSync as rmSync9,
10752
+ rmSync as rmSync7,
10656
10753
  statSync as statSync5,
10657
10754
  writeFileSync as writeFileSync4
10658
10755
  } from "fs";
@@ -10776,7 +10873,7 @@ async function encodeGifFromDir(framesDir, framePattern, outputPath, input) {
10776
10873
  fileSize
10777
10874
  };
10778
10875
  } finally {
10779
- rmSync9(input.palettePath, { force: true });
10876
+ rmSync7(input.palettePath, { force: true });
10780
10877
  }
10781
10878
  }
10782
10879
  function startEncodeProgress(job, stage, onProgress) {
@@ -10800,6 +10897,8 @@ function videoEncoderOptions(input, engineCfg) {
10800
10897
  preset: preset.preset,
10801
10898
  quality: input.effectiveQuality,
10802
10899
  bitrate: input.effectiveBitrate,
10900
+ maxBitrate: input.maxBitrate,
10901
+ bufferSize: input.bufferSize,
10803
10902
  pixelFormat: preset.pixelFormat,
10804
10903
  vp9CpuUsed: engineCfg.vp9CpuUsed,
10805
10904
  useGpu: job.config.useGpu,
@@ -11507,7 +11606,8 @@ async function executeDiskCaptureWithAdaptiveRetry(options) {
11507
11606
  });
11508
11607
  } : void 0,
11509
11608
  void 0,
11510
- options.cfg
11609
+ options.cfg,
11610
+ { verifyFirstSession: options.verifyFirstSession }
11511
11611
  );
11512
11612
  pushWorkerDedupPerfs(workerResults, options.dedupPerfs);
11513
11613
  if (options.pageErrorLines) pushWorkerPageErrors(workerResults, options.pageErrorLines);
@@ -12073,6 +12173,7 @@ function resolveRenderDebugDir() {
12073
12173
  }
12074
12174
  async function executeRenderJob(job, projectDir, outputPath, progressSink, abortSignal, assertRenderActive) {
12075
12175
  validateHlsRenderConfig(job.config);
12176
+ validateDeliveryEncoderConfig(job.config);
12076
12177
  const debugDir = resolveRenderDebugDir();
12077
12178
  const outputDir = dirname9(outputPath);
12078
12179
  if (!existsSync15(outputDir)) mkdirSync8(outputDir, { recursive: true });
@@ -12093,7 +12194,7 @@ async function executeRenderJob(job, projectDir, outputPath, progressSink, abort
12093
12194
  log.info("KEEP_TEMP=1, leaving workDir on disk for inspection", { workDir });
12094
12195
  return;
12095
12196
  }
12096
- rmSync10(workDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
12197
+ rmSync8(workDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
12097
12198
  });
12098
12199
  try {
12099
12200
  await executeRenderPipeline({
@@ -12151,11 +12252,14 @@ async function executeRenderPipeline(input) {
12151
12252
  const isGif = outputFormat === "gif";
12152
12253
  const isHls = outputFormat === "hls";
12153
12254
  const hlsSegmentSeconds = isHls ? resolveHlsSegmentSeconds(job.config) : void 0;
12154
- const hlsEncoderGopLock = resolveHlsEncoderGopLock(
12155
- outputFormat,
12156
- job.config.fps,
12157
- job.config.hlsSegmentSeconds
12158
- );
12255
+ const deliveryEncoder = resolveDeliveryEncoderOptions({
12256
+ format: outputFormat,
12257
+ fps: job.config.fps,
12258
+ hlsSegmentSeconds: job.config.hlsSegmentSeconds,
12259
+ keyframeIntervalSeconds: job.config.keyframeIntervalSeconds,
12260
+ maxBitrate: job.config.maxBitrate,
12261
+ bufferSize: job.config.bufferSize
12262
+ });
12159
12263
  const artifactTransaction = new ArtifactTransaction(
12160
12264
  outputPath,
12161
12265
  isPngSequence || isHls ? "directory" : "file",
@@ -13238,6 +13342,7 @@ async function executeRenderPipeline(input) {
13238
13342
  preset,
13239
13343
  effectiveQuality,
13240
13344
  effectiveBitrate,
13345
+ deliveryEncoder,
13241
13346
  fileServer: activeFileServer,
13242
13347
  buildCaptureOptions,
13243
13348
  createRenderVideoFrameInjector,
@@ -13262,9 +13367,7 @@ async function executeRenderPipeline(input) {
13262
13367
  } else {
13263
13368
  let streamingHandled = false;
13264
13369
  if (capturePlan.kind === "sdr_segmented") {
13265
- const segmentedPlan = capturePlan;
13266
13370
  const captureFrameStart = Date.now();
13267
- resetCaptureAttemptProgress(job);
13268
13371
  const segmentFrames = resolveSegmentFrames(process.env);
13269
13372
  const segmentImageFormat = captureOptions.format || "jpeg";
13270
13373
  const segmentPlanHash = computeSegmentPlanHash({
@@ -13279,6 +13382,9 @@ async function executeRenderPipeline(input) {
13279
13382
  preset: preset.preset,
13280
13383
  quality: effectiveQuality,
13281
13384
  bitrate: effectiveBitrate,
13385
+ maxBitrate: deliveryEncoder.maxBitrate,
13386
+ bufferSize: deliveryEncoder.bufferSize,
13387
+ gopSize: deliveryEncoder.gopSize,
13282
13388
  pixelFormat: preset.pixelFormat,
13283
13389
  imageFormat: segmentImageFormat,
13284
13390
  useGpu: job.config.useGpu === true,
@@ -13304,71 +13410,129 @@ async function executeRenderPipeline(input) {
13304
13410
  });
13305
13411
  }
13306
13412
  if (completedSegments.size === 0) {
13307
- rmSync10(segmentDir, { recursive: true, force: true });
13413
+ rmSync8(segmentDir, { recursive: true, force: true });
13308
13414
  }
13309
13415
  } else {
13310
- rmSync10(segmentDir, { recursive: true, force: true });
13416
+ rmSync8(segmentDir, { recursive: true, force: true });
13311
13417
  }
13312
- const segmentManifest = readSegmentManifest(segmentDir) ?? {
13418
+ const emptySegmentManifest = () => ({
13313
13419
  version: 1,
13314
13420
  planHash: segmentPlanHash,
13315
13421
  totalFrames,
13316
13422
  segmentFrames,
13317
13423
  completed: []
13424
+ });
13425
+ let segmentManifest = readSegmentManifest(segmentDir) ?? emptySegmentManifest();
13426
+ const invokeSegmented = () => {
13427
+ if (capturePlan.kind !== "sdr_segmented") {
13428
+ throw new Error(`Cannot invoke segmented stage with ${capturePlan.kind} plan`);
13429
+ }
13430
+ const segmentedPlan = capturePlan;
13431
+ resetCaptureAttemptProgress(job);
13432
+ return observeRenderStage(
13433
+ observability,
13434
+ "capture_segmented",
13435
+ captureStageObservationData(),
13436
+ () => runCaptureSegmentedStage({
13437
+ fileServer: activeFileServer,
13438
+ workDir,
13439
+ framesDir,
13440
+ videoOnlyPath,
13441
+ job,
13442
+ totalFrames,
13443
+ cfg,
13444
+ plan: segmentedPlan,
13445
+ log,
13446
+ probeSession,
13447
+ outputFormat,
13448
+ streamingEncoderOptions: {
13449
+ fps: job.config.fps,
13450
+ width: captureCompositionWidth ?? width,
13451
+ height: captureCompositionHeight ?? height,
13452
+ codec: preset.codec,
13453
+ preset: preset.preset,
13454
+ quality: effectiveQuality,
13455
+ bitrate: effectiveBitrate,
13456
+ pixelFormat: preset.pixelFormat,
13457
+ vp9CpuUsed: cfg.vp9CpuUsed,
13458
+ useGpu: job.config.useGpu,
13459
+ imageFormat: segmentImageFormat,
13460
+ hdr: preset.hdr,
13461
+ // Each segment sets its own GOP (at most the interval); hls never reaches this route.
13462
+ ...deliveryEncoder
13463
+ },
13464
+ buildCaptureOptions,
13465
+ createRenderVideoFrameInjector,
13466
+ abortSignal: executionSignal,
13467
+ assertNotAborted,
13468
+ onProgress,
13469
+ dedupPerfs,
13470
+ segmentFrames,
13471
+ segmentDir,
13472
+ workerCount: segmentedPlan.workerCount,
13473
+ browserRecycleEverySegments: resolveSegmentBrowserRecycle(process.env),
13474
+ completedSegments,
13475
+ onSegmentComplete: (entry) => {
13476
+ segmentManifest.completed = [
13477
+ ...segmentManifest.completed.filter((e) => e.index !== entry.index),
13478
+ { ...entry, completedAt: (/* @__PURE__ */ new Date()).toISOString() }
13479
+ ];
13480
+ writeSegmentManifest(segmentDir, segmentManifest);
13481
+ },
13482
+ updateCaptureObservability
13483
+ })
13484
+ );
13318
13485
  };
13319
- const segmentedRes = await observeRenderStage(
13320
- observability,
13321
- "capture_segmented",
13322
- captureStageObservationData(),
13323
- () => runCaptureSegmentedStage({
13324
- fileServer: activeFileServer,
13325
- workDir,
13326
- framesDir,
13327
- videoOnlyPath,
13328
- job,
13329
- totalFrames,
13330
- cfg,
13331
- plan: segmentedPlan,
13332
- log,
13333
- probeSession,
13334
- outputFormat,
13335
- streamingEncoderOptions: {
13336
- fps: job.config.fps,
13337
- width: captureCompositionWidth ?? width,
13338
- height: captureCompositionHeight ?? height,
13339
- codec: preset.codec,
13340
- preset: preset.preset,
13341
- quality: effectiveQuality,
13342
- bitrate: effectiveBitrate,
13343
- pixelFormat: preset.pixelFormat,
13344
- vp9CpuUsed: cfg.vp9CpuUsed,
13345
- useGpu: job.config.useGpu,
13346
- imageFormat: segmentImageFormat,
13347
- hdr: preset.hdr
13348
- // No hlsEncoderGopLock here: each segment sets its own GOP to
13349
- // its own length, and hls never reaches this route.
13350
- },
13351
- buildCaptureOptions,
13352
- createRenderVideoFrameInjector,
13353
- abortSignal: executionSignal,
13354
- assertNotAborted,
13355
- onProgress,
13356
- dedupPerfs,
13357
- segmentFrames,
13358
- segmentDir,
13359
- workerCount: segmentedPlan.workerCount,
13360
- browserRecycleEverySegments: resolveSegmentBrowserRecycle(process.env),
13361
- completedSegments,
13362
- onSegmentComplete: (entry) => {
13363
- segmentManifest.completed = [
13364
- ...segmentManifest.completed.filter((e) => e.index !== entry.index),
13365
- { ...entry, completedAt: (/* @__PURE__ */ new Date()).toISOString() }
13366
- ];
13367
- writeSegmentManifest(segmentDir, segmentManifest);
13368
- },
13369
- updateCaptureObservability
13370
- })
13371
- );
13486
+ let segmentedRes;
13487
+ try {
13488
+ segmentedRes = await invokeSegmented();
13489
+ } catch (err) {
13490
+ const isVerifyError = isDrawElementVerificationError(err);
13491
+ const isDeStall = isDeRendererStallError(err);
13492
+ if (!isVerifyError && !isDrawElementCaptureError(err) && !isDeStall || err instanceof RenderCancelledError || executionSignal?.aborted === true) {
13493
+ throw err;
13494
+ }
13495
+ deSelfVerifyFallback = isVerifyError;
13496
+ const t = deVerifyFallbackTelemetry(err);
13497
+ deFallbackReason = isVerifyError ? t.reason : isDeStall ? "de_renderer_stall" : "capture_error";
13498
+ deFallbackFailedDb = t.failedDb;
13499
+ deFallbackFrameIndex = t.frameIndex;
13500
+ deFallbackThresholdDb = t.thresholdDb;
13501
+ log.warn(
13502
+ "[Render] drawElement capture failed on the segmented path; re-rendering via screenshot",
13503
+ {
13504
+ error: err instanceof Error ? err.message : String(err)
13505
+ }
13506
+ );
13507
+ observability.checkpoint(
13508
+ "capture_segmented",
13509
+ "drawElement capture failed; retrying with a fresh screenshot session"
13510
+ );
13511
+ if (probeSession) {
13512
+ lastBrowserConsole = probeSession.browserConsoleBuffer;
13513
+ const orphaned = probeSession;
13514
+ probeSession = null;
13515
+ await closeOrphanedProbeForRetry(orphaned, closeCaptureSession, log, "segmented");
13516
+ }
13517
+ rmSync8(segmentDir, { recursive: true, force: true });
13518
+ completedSegments = /* @__PURE__ */ new Set();
13519
+ segmentManifest = emptySegmentManifest();
13520
+ dedupPerfs.length = 0;
13521
+ capturePlan = replanAfterFailure(capturePlan, {
13522
+ kind: isVerifyError ? "draw_element_verification" : "draw_element_capture"
13523
+ });
13524
+ syncCapturePlan();
13525
+ updateCaptureObservability({
13526
+ forceScreenshot: capturePlan.forceScreenshot,
13527
+ deSelfVerifyFallback,
13528
+ deFallbackReason,
13529
+ deFallbackFailedDb,
13530
+ deFallbackFrameIndex,
13531
+ deFallbackThresholdDb
13532
+ });
13533
+ segmentedRes = await invokeSegmented();
13534
+ observability.clearFailure("capture_segmented");
13535
+ }
13372
13536
  if (segmentedRes.success) {
13373
13537
  streamingHandled = true;
13374
13538
  workerCount = segmentedRes.workerCount;
@@ -13388,7 +13552,7 @@ async function executeRenderPipeline(input) {
13388
13552
  );
13389
13553
  updateCaptureObservability({ segmentRetries: segmentedRes.segmentRetries });
13390
13554
  if (job.config.keepSegments !== true) {
13391
- rmSync10(segmentDir, { recursive: true, force: true });
13555
+ rmSync8(segmentDir, { recursive: true, force: true });
13392
13556
  }
13393
13557
  } else {
13394
13558
  capturePlan = replanAfterFailure(capturePlan, { kind: "streaming_unavailable" });
@@ -13441,7 +13605,7 @@ async function executeRenderPipeline(input) {
13441
13605
  // assemble stage's `-c copy` segmentation cuts exactly on
13442
13606
  // the segment boundary. Every other format leaves the
13443
13607
  // encoder's open-GOP output untouched.
13444
- ...hlsEncoderGopLock
13608
+ ...deliveryEncoder
13445
13609
  },
13446
13610
  buildCaptureOptions,
13447
13611
  createRenderVideoFrameInjector,
@@ -13604,7 +13768,7 @@ async function executeRenderPipeline(input) {
13604
13768
  engineConfig: cfg,
13605
13769
  // Same value the streaming encoder above spreads — the disk and
13606
13770
  // chunked-concat encoders need an identical GOP lock for HLS.
13607
- ...hlsEncoderGopLock,
13771
+ ...deliveryEncoder,
13608
13772
  abortSignal: executionSignal,
13609
13773
  assertNotAborted,
13610
13774
  onProgress
@@ -13660,7 +13824,7 @@ async function executeRenderPipeline(input) {
13660
13824
  "capture_disk",
13661
13825
  "drawElement capture failed; retrying with a fresh screenshot session"
13662
13826
  );
13663
- rmSync10(framesDir, { recursive: true, force: true });
13827
+ rmSync8(framesDir, { recursive: true, force: true });
13664
13828
  mkdirSync8(framesDir, { recursive: true });
13665
13829
  resetCaptureAttemptProgress(job);
13666
13830
  dedupPerfs.length = 0;
@@ -13957,7 +14121,7 @@ import {
13957
14121
  existsSync as existsSync20,
13958
14122
  linkSync,
13959
14123
  mkdirSync as mkdirSync12,
13960
- rmSync as rmSync12,
14124
+ rmSync as rmSync10,
13961
14125
  writeFileSync as writeFileSync8
13962
14126
  } from "fs";
13963
14127
  import { extname as extname6, isAbsolute as isAbsolute2, join as join33, relative as relative5, sep as sep2 } from "path";
@@ -14962,7 +15126,7 @@ import { writeFileSync as writeFileSync7, writeSync } from "fs";
14962
15126
  import { join as join31 } from "path";
14963
15127
 
14964
15128
  // ../producer/src/services/distributed/mp4Stitch.ts
14965
- import { createReadStream as createReadStream4, createWriteStream, mkdirSync as mkdirSync10, mkdtempSync as mkdtempSync4, rmSync as rmSync11 } from "fs";
15129
+ import { createReadStream as createReadStream4, createWriteStream, mkdirSync as mkdirSync10, mkdtempSync as mkdtempSync4, rmSync as rmSync9 } from "fs";
14966
15130
  import { open } from "fs/promises";
14967
15131
  import { dirname as dirname11, join as join30 } from "path";
14968
15132
  import { finished, pipeline } from "stream/promises";
@@ -15339,7 +15503,7 @@ async function writeStitchedMp4(chunkPaths, outputPath, audioPath) {
15339
15503
  renameWithRetry(join30(workDir, "out.mp4"), outputPath);
15340
15504
  } finally {
15341
15505
  out.destroy();
15342
- rmSync11(workDir, { recursive: true, force: true });
15506
+ rmSync9(workDir, { recursive: true, force: true });
15343
15507
  }
15344
15508
  }
15345
15509
 
@@ -15847,7 +16011,7 @@ var FREEZE_OWNED_PLAN_FILES = [
15847
16011
  ];
15848
16012
  function removeFreezeOwnedPlanFiles(planDir) {
15849
16013
  for (const relativePath of FREEZE_OWNED_PLAN_FILES) {
15850
- rmSync12(join33(planDir, relativePath), { force: true });
16014
+ rmSync10(join33(planDir, relativePath), { force: true });
15851
16015
  }
15852
16016
  }
15853
16017
  function buildChunkSlices(totalFrames, chunkCount, effectiveChunkSize) {
@@ -15907,6 +16071,9 @@ function buildLockedRenderConfig(input) {
15907
16071
  preset,
15908
16072
  crf: config.crf,
15909
16073
  bitrate: config.bitrate,
16074
+ maxBitrate: config.maxBitrate,
16075
+ bufferSize: config.bufferSize,
16076
+ keyframeIntervalFrames: config.keyframeIntervalSeconds === void 0 ? void 0 : keyframeIntervalToGopSize({ num: config.fps, den: 1 }, config.keyframeIntervalSeconds),
15910
16077
  ...locksVp9CpuUsed,
15911
16078
  // GOP === chunkSize so every chunk's first frame is an IDR keyframe and
15912
16079
  // ffmpeg concat-copy round-trips losslessly.
@@ -16058,7 +16225,7 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
16058
16225
  throw new Error(`[plan] entry file not found: ${htmlPath}`);
16059
16226
  }
16060
16227
  const workDir = join33(planDir, ".plan-work");
16061
- rmSync12(workDir, { recursive: true, force: true });
16228
+ rmSync10(workDir, { recursive: true, force: true });
16062
16229
  mkdirSync12(workDir, { recursive: true });
16063
16230
  const compiledDir = join33(workDir, "compiled");
16064
16231
  mkdirSync12(compiledDir, { recursive: true });
@@ -16156,7 +16323,7 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
16156
16323
  if (probeResult.fileServer) closeFileServerSafely(probeResult.fileServer, "plan", log);
16157
16324
  if (probeResult.probeSession) {
16158
16325
  try {
16159
- const { closeCaptureSession: closeCaptureSession2 } = await import("./src-4YJKYMNF.js");
16326
+ const { closeCaptureSession: closeCaptureSession2 } = await import("./src-6XOMREMS.js");
16160
16327
  await closeCaptureSession2(probeResult.probeSession);
16161
16328
  } catch (err) {
16162
16329
  log.warn("[plan] probe session close failed", {
@@ -16265,15 +16432,15 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
16265
16432
  logPlanStage(log, "extract", stageStarted);
16266
16433
  const stagedVideoFrames = join33(compiledDir, "__hyperframes_video_frames");
16267
16434
  const videoFramesDst = join33(planDir, "video-frames");
16268
- if (existsSync20(videoFramesDst)) rmSync12(videoFramesDst, { recursive: true, force: true });
16435
+ if (existsSync20(videoFramesDst)) rmSync10(videoFramesDst, { recursive: true, force: true });
16269
16436
  const videoSourcesDir = join33(planDir, "video-sources");
16270
- rmSync12(videoSourcesDir, { recursive: true, force: true });
16437
+ rmSync10(videoSourcesDir, { recursive: true, force: true });
16271
16438
  if (existsSync20(stagedVideoFrames)) {
16272
16439
  renameWithRetry(stagedVideoFrames, videoFramesDst);
16273
16440
  } else {
16274
16441
  mkdirSync12(videoFramesDst, { recursive: true });
16275
16442
  }
16276
- if (existsSync20(finalCompiledDir)) rmSync12(finalCompiledDir, { recursive: true, force: true });
16443
+ if (existsSync20(finalCompiledDir)) rmSync10(finalCompiledDir, { recursive: true, force: true });
16277
16444
  renameWithRetry(compiledDir, finalCompiledDir);
16278
16445
  const shipVideoSource = createVideoSourceShipper({
16279
16446
  planDir,
@@ -16441,7 +16608,7 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
16441
16608
  format: config.format
16442
16609
  };
16443
16610
  try {
16444
- rmSync12(workDir, { recursive: true, force: true });
16611
+ rmSync10(workDir, { recursive: true, force: true });
16445
16612
  } catch (err) {
16446
16613
  log.warn("[plan] failed to remove temp work dir", {
16447
16614
  workDir,
@@ -16592,6 +16759,20 @@ function validateDistributedRenderConfig(config) {
16592
16759
  `must look like "10M" or "5000k"; got ${JSON.stringify(config.bitrate)}`
16593
16760
  );
16594
16761
  }
16762
+ try {
16763
+ validateDeliveryEncoderConfig({
16764
+ format: config.format,
16765
+ fps: { num: config.fps, den: 1 },
16766
+ keyframeIntervalSeconds: config.keyframeIntervalSeconds,
16767
+ maxBitrate: config.maxBitrate,
16768
+ bufferSize: config.bufferSize
16769
+ });
16770
+ } catch (error) {
16771
+ throw new InvalidConfigError(
16772
+ "config.maxBitrate",
16773
+ error instanceof Error ? error.message : String(error)
16774
+ );
16775
+ }
16595
16776
  if (config.chunkSize !== void 0) {
16596
16777
  if (!Number.isInteger(config.chunkSize) || config.chunkSize < 1) {
16597
16778
  throw new InvalidConfigError(
@@ -16771,6 +16952,12 @@ function assertOptionalInteger(options, field, min = 0) {
16771
16952
  throw new Error(`Render request ${field} must be an integer >= ${min}`);
16772
16953
  }
16773
16954
  }
16955
+ function assertOptionalPositiveNumber(options, field) {
16956
+ const value = options[field];
16957
+ if (value !== void 0 && !(typeof value === "number" && value > 0)) {
16958
+ throw new Error(`Render request ${field} must be a positive number`);
16959
+ }
16960
+ }
16774
16961
  function assertOptionalString(options, field) {
16775
16962
  if (options[field] !== void 0 && typeof options[field] !== "string") {
16776
16963
  throw new Error(`Render request ${field} must be a string`);
@@ -16818,10 +17005,11 @@ function assertRequestOptionScalars(options) {
16818
17005
  assertOptionalInteger(options, "workers", 1);
16819
17006
  assertOptionalInteger(options, "maxRenderMs");
16820
17007
  assertOptionalInteger(options, "crf");
17008
+ assertOptionalPositiveNumber(options, "keyframeIntervalSeconds");
16821
17009
  for (const field of ["useGpu", "debug", "outputResolutionAspectAgnostic"]) {
16822
17010
  assertOptionalBoolean(options, field);
16823
17011
  }
16824
- for (const field of ["entryFile", "videoBitrate"]) {
17012
+ for (const field of ["entryFile", "videoBitrate", "maxBitrate", "bufferSize"]) {
16825
17013
  assertOptionalString(options, field);
16826
17014
  }
16827
17015
  assertOptionalEnum(options, "strictness", ["strict", "best-effort"]);
@@ -16924,6 +17112,9 @@ function distributedConfigFromRequest(request, runtime = {}) {
16924
17112
  crf: options.crf,
16925
17113
  pageMotionBlur: options.pageMotionBlur,
16926
17114
  bitrate: options.videoBitrate,
17115
+ keyframeIntervalSeconds: options.keyframeIntervalSeconds,
17116
+ maxBitrate: options.maxBitrate,
17117
+ bufferSize: options.bufferSize,
16927
17118
  videoFrameFormat: options.videoFrameFormat,
16928
17119
  outputResolution: options.outputResolution,
16929
17120
  outputResolutionAspectAgnostic: options.outputResolutionAspectAgnostic,
@@ -16971,6 +17162,9 @@ function renderRequestFromDistributedConfig(input) {
16971
17162
  ...optionalProperty("crf", config.crf),
16972
17163
  ...optionalProperty("pageMotionBlur", config.pageMotionBlur),
16973
17164
  ...optionalProperty("videoBitrate", config.bitrate),
17165
+ ...optionalProperty("keyframeIntervalSeconds", config.keyframeIntervalSeconds),
17166
+ ...optionalProperty("maxBitrate", config.maxBitrate),
17167
+ ...optionalProperty("bufferSize", config.bufferSize),
16974
17168
  ...optionalProperty("videoFrameFormat", config.videoFrameFormat),
16975
17169
  ...optionalProperty("outputResolution", config.outputResolution),
16976
17170
  ...optionalProperty("outputResolutionAspectAgnostic", config.outputResolutionAspectAgnostic),
@@ -16994,7 +17188,7 @@ import {
16994
17188
  statSync as statSync8,
16995
17189
  mkdtempSync as mkdtempSync5,
16996
17190
  writeFileSync as writeFileSync9,
16997
- rmSync as rmSync13,
17191
+ rmSync as rmSync11,
16998
17192
  createReadStream as createReadStream5
16999
17193
  } from "fs";
17000
17194
  import { resolve as resolve9, dirname as dirname13, join as join36 } from "path";
@@ -17292,7 +17486,7 @@ function parseRenderOptions(body) {
17292
17486
  const format = parseServerFormat(body.format);
17293
17487
  const outputDynamicRange = parseServerOutputDynamicRange(body.outputDynamicRange) ?? fromRenderHdrMode(parseLegacyServerHdrMode(body.hdrMode));
17294
17488
  const encoder = parseEncoderOptions(body, format ?? "mp4");
17295
- const { crf, videoBitrate, videoFrameFormat } = encoder.ok ? encoder.options : {};
17489
+ const { crf, videoBitrate, videoFrameFormat, keyframeIntervalSeconds, maxBitrate, bufferSize } = encoder.ok ? encoder.options : {};
17296
17490
  const { variables, outputResolution, outputResolutionAspectAgnostic } = parseRenderOverrides(body);
17297
17491
  return {
17298
17492
  outputPath,
@@ -17302,6 +17496,9 @@ function parseRenderOptions(body) {
17302
17496
  maxRenderMs,
17303
17497
  crf,
17304
17498
  videoBitrate,
17499
+ keyframeIntervalSeconds,
17500
+ maxBitrate,
17501
+ bufferSize,
17305
17502
  useGpu,
17306
17503
  debug,
17307
17504
  strictness,
@@ -17336,6 +17533,9 @@ function buildRenderJobConfig(input, outputPath, log) {
17336
17533
  maxRenderMs: input.maxRenderMs,
17337
17534
  crf: input.crf,
17338
17535
  videoBitrate: input.videoBitrate,
17536
+ keyframeIntervalSeconds: input.keyframeIntervalSeconds,
17537
+ maxBitrate: input.maxBitrate,
17538
+ bufferSize: input.bufferSize,
17339
17539
  useGpu: input.useGpu,
17340
17540
  debug: input.debug,
17341
17541
  strictness: input.strictness,
@@ -17482,7 +17682,7 @@ function createArtifactStore(ttlMs) {
17482
17682
  function cleanupTempDir(dir, log) {
17483
17683
  if (!dir) return;
17484
17684
  try {
17485
- rmSync13(dir, { recursive: true, force: true });
17685
+ rmSync11(dir, { recursive: true, force: true });
17486
17686
  } catch (error) {
17487
17687
  log.warn("Failed to cleanup temp project dir", {
17488
17688
  cleanupProjectDir: dir,
@@ -17840,7 +18040,7 @@ function startServer(options = {}) {
17840
18040
  });
17841
18041
  async function shutdown(signal) {
17842
18042
  log.info(`Received ${signal}, shutting down`);
17843
- const { drainBrowserPool } = await import("./src-4YJKYMNF.js");
18043
+ const { drainBrowserPool } = await import("./src-6XOMREMS.js");
17844
18044
  await drainBrowserPool().catch(() => {
17845
18045
  });
17846
18046
  const handle = await Promise.race([
@@ -17884,7 +18084,7 @@ import {
17884
18084
  mkdtempSync as mkdtempSync7,
17885
18085
  readFileSync as readFileSync12,
17886
18086
  readdirSync as readdirSync9,
17887
- rmSync as rmSync15,
18087
+ rmSync as rmSync13,
17888
18088
  statSync as statSync10,
17889
18089
  writeFileSync as writeFileSync11
17890
18090
  } from "fs";
@@ -17898,7 +18098,7 @@ import {
17898
18098
  linkSync as linkSync2,
17899
18099
  mkdirSync as mkdirSync14,
17900
18100
  mkdtempSync as mkdtempSync6,
17901
- rmSync as rmSync14,
18101
+ rmSync as rmSync12,
17902
18102
  statSync as statSync9,
17903
18103
  writeFileSync as writeFileSync10
17904
18104
  } from "fs";
@@ -17992,7 +18192,7 @@ var LocalPlanV2ArtifactPublisher = class {
17992
18192
  }
17993
18193
  renameWithRetry(temporaryPath, destinationPath);
17994
18194
  } finally {
17995
- rmSync14(stagingDir, { recursive: true, force: true });
18195
+ rmSync12(stagingDir, { recursive: true, force: true });
17996
18196
  }
17997
18197
  }
17998
18198
  async commitManifest(manifestBytes) {
@@ -18009,7 +18209,7 @@ var LocalPlanV2ArtifactPublisher = class {
18009
18209
  }
18010
18210
  async abort() {
18011
18211
  if (!this.#committed) {
18012
- rmSync14(this.temporaryDir, { recursive: true, force: true });
18212
+ rmSync12(this.temporaryDir, { recursive: true, force: true });
18013
18213
  }
18014
18214
  }
18015
18215
  };
@@ -18278,7 +18478,7 @@ function writeBlob(sourcePath, destinationPath) {
18278
18478
  copyFileSync6(sourcePath, temporaryPath);
18279
18479
  renameWithRetry(temporaryPath, destinationPath);
18280
18480
  } finally {
18281
- rmSync15(temporaryDir, { recursive: true, force: true });
18481
+ rmSync13(temporaryDir, { recursive: true, force: true });
18282
18482
  }
18283
18483
  }
18284
18484
  function publishBlobFor(absolutePath, digests) {
@@ -18411,7 +18611,7 @@ function createPlanV2FromExecutionPlan(executionPlanDir, planV2Dir) {
18411
18611
  renameWithRetry(tempDir, planV2Dir);
18412
18612
  return resultFromManifest(planV2Dir, publication.manifest);
18413
18613
  } catch (error) {
18414
- rmSync15(tempDir, { recursive: true, force: true });
18614
+ rmSync13(tempDir, { recursive: true, force: true });
18415
18615
  throw error;
18416
18616
  }
18417
18617
  }
@@ -18478,7 +18678,7 @@ async function planV2WithPublisher(projectDir, config, publisher, options = {})
18478
18678
  }
18479
18679
  throw error;
18480
18680
  } finally {
18481
- rmSync15(stagingRoot, { recursive: true, force: true });
18681
+ rmSync13(stagingRoot, { recursive: true, force: true });
18482
18682
  }
18483
18683
  }
18484
18684
  async function planV2(projectDir, config, planV2Dir) {
@@ -18695,7 +18895,7 @@ function materializePlanV2Target(planV2Dir, target, destinationDir, options = {}
18695
18895
  );
18696
18896
  renameWithRetry(tempDir, destinationDir);
18697
18897
  } catch (error) {
18698
- rmSync15(tempDir, { recursive: true, force: true });
18898
+ rmSync13(tempDir, { recursive: true, force: true });
18699
18899
  throw error;
18700
18900
  }
18701
18901
  return {
@@ -18759,7 +18959,7 @@ function readValidatedPlanV2Materialization(planDir, expectedTarget) {
18759
18959
  }
18760
18960
 
18761
18961
  // ../producer/src/services/distributed/planV2Execution.ts
18762
- import { mkdtempSync as mkdtempSync9, rmSync as rmSync18 } from "fs";
18962
+ import { mkdtempSync as mkdtempSync9, rmSync as rmSync16 } from "fs";
18763
18963
  import { tmpdir as tmpdir5 } from "os";
18764
18964
  import { join as join42 } from "path";
18765
18965
 
@@ -18771,7 +18971,7 @@ import {
18771
18971
  mkdtempSync as mkdtempSync8,
18772
18972
  readFileSync as readFileSync13,
18773
18973
  readdirSync as readdirSync10,
18774
- rmSync as rmSync16,
18974
+ rmSync as rmSync14,
18775
18975
  statSync as statSync11,
18776
18976
  writeFileSync as writeFileSync12
18777
18977
  } from "fs";
@@ -18838,7 +19038,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
18838
19038
  });
18839
19039
  } finally {
18840
19040
  try {
18841
- rmSync16(workDir, { recursive: true, force: true });
19041
+ rmSync14(workDir, { recursive: true, force: true });
18842
19042
  } catch (err) {
18843
19043
  log.warn("[assemble] failed to remove work dir", {
18844
19044
  workDir,
@@ -18900,6 +19100,9 @@ function cfrEncodeArgs(inputArgs, encoder, fpsArg) {
18900
19100
  "-r",
18901
19101
  fpsArg
18902
19102
  ];
19103
+ if (encoder.keyframeIntervalFrames !== void 0)
19104
+ args.push("-g", String(encoder.keyframeIntervalFrames));
19105
+ appendRateCapArgs(args, encoder);
18903
19106
  appendSoftwareEncoderThreadsArg(args, "libx264");
18904
19107
  return args;
18905
19108
  }
@@ -19036,7 +19239,7 @@ function readCfrEncoder(planDir, format) {
19036
19239
  return encoderJson;
19037
19240
  }
19038
19241
  function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, startTimeMs) {
19039
- if (existsSync26(outputPath)) rmSync16(outputPath, { recursive: true, force: true });
19242
+ if (existsSync26(outputPath)) rmSync14(outputPath, { recursive: true, force: true });
19040
19243
  mkdirSync16(outputPath, { recursive: true });
19041
19244
  let globalIdx = 0;
19042
19245
  for (const chunkDir of chunkPaths) {
@@ -19081,7 +19284,7 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
19081
19284
 
19082
19285
  // ../producer/src/services/distributed/renderChunk.ts
19083
19286
  import { randomBytes } from "crypto";
19084
- import { existsSync as existsSync27, mkdirSync as mkdirSync17, readFileSync as readFileSync14, readdirSync as readdirSync11, rmSync as rmSync17, writeFileSync as writeFileSync13 } from "fs";
19287
+ import { existsSync as existsSync27, mkdirSync as mkdirSync17, readFileSync as readFileSync14, readdirSync as readdirSync11, rmSync as rmSync15, writeFileSync as writeFileSync13 } from "fs";
19085
19288
  import { cpus as cpus3 } from "os";
19086
19289
  import { join as join41 } from "path";
19087
19290
  var LEGACY_DISTRIBUTED_VP9_CPU_USED = 2;
@@ -19160,16 +19363,18 @@ function observedChunkCaptureMode(perfs) {
19160
19363
  }
19161
19364
  return mode;
19162
19365
  }
19366
+ var PROBE_SELECTED_SCREENSHOT = "[renderChunk] probe selected screenshot capture";
19163
19367
  function shouldRetryChunkCaptureWithScreenshot(error) {
19164
19368
  const failure = classifyCaptureFailure(error);
19165
19369
  if (failure.kind === "cancelled" || failure.kind === "memory_exhaustion") return false;
19166
- return /HeadlessExperimental\.beginFrame/i.test(failure.message) || /beginFrame probe timeout/i.test(failure.message) || /Another frame is pending|Frame still pending/i.test(failure.message);
19370
+ return /HeadlessExperimental\.beginFrame/i.test(failure.message) || /beginFrame probe timeout/i.test(failure.message) || failure.message.includes(PROBE_SELECTED_SCREENSHOT) || /Another frame is pending|Frame still pending/i.test(failure.message);
19167
19371
  }
19168
19372
  async function runCaptureWithScreenshotFallback(input) {
19169
19373
  try {
19170
19374
  return await input.run(input.forceScreenshot);
19171
19375
  } catch (error) {
19172
- if (input.forceScreenshot || !shouldRetryChunkCaptureWithScreenshot(error)) throw error;
19376
+ if (input.forceScreenshot || await input.canRetry?.() === false) throw error;
19377
+ if (!shouldRetryChunkCaptureWithScreenshot(error)) throw error;
19173
19378
  input.onFallback?.(error);
19174
19379
  await input.resetForScreenshotRetry();
19175
19380
  return await input.run(true);
@@ -19378,7 +19583,24 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
19378
19583
  let extraction;
19379
19584
  const overlap = { current: null };
19380
19585
  try {
19381
- if (chunkWorkerCount === 1 || !forceScreenshotForChunk) {
19586
+ const verifyInWorker = chunkWorkerCount > 1 && !forceScreenshotForChunk;
19587
+ let boxesMeasured;
19588
+ let boxesFailed;
19589
+ const boxesReady = new Promise((resolve11, reject) => {
19590
+ boxesMeasured = resolve11;
19591
+ boxesFailed = reject;
19592
+ });
19593
+ boxesReady.catch(() => {
19594
+ });
19595
+ const measureBoxes = async (page) => {
19596
+ shownBoxes = await measureVideoShownBoxes(
19597
+ page,
19598
+ [...shownFrames.keys()],
19599
+ chunkFrameNumbers.map((frame) => frame * chunkFps.den / chunkFps.num)
19600
+ );
19601
+ boxesMeasured();
19602
+ };
19603
+ if (chunkWorkerCount === 1) {
19382
19604
  const bootStarted = Date.now();
19383
19605
  session = await createVerifiedDistributedCaptureSession(
19384
19606
  fileServer.url,
@@ -19387,11 +19609,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
19387
19609
  cfg
19388
19610
  );
19389
19611
  sessionBootMs = Date.now() - bootStarted;
19390
- shownBoxes = await measureVideoShownBoxes(
19391
- session.page,
19392
- [...shownFrames.keys()],
19393
- chunkFrameNumbers.map((frame) => frame * chunkFps.den / chunkFps.num)
19394
- );
19612
+ await measureBoxes(session.page);
19395
19613
  const browserSelectedScreenshot = session.launchCaptureMode === "screenshot";
19396
19614
  const beginFrameStalled = !browserSelectedScreenshot && await beginFrameSessionNeedsScreenshotFallback(session);
19397
19615
  if (browserSelectedScreenshot) {
@@ -19400,10 +19618,6 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
19400
19618
  "[renderChunk] Browser capability probe selected screenshot capture for the entire chunk",
19401
19619
  { chunkIndex }
19402
19620
  );
19403
- if (chunkWorkerCount > 1) {
19404
- await closeCaptureSession(session);
19405
- session = null;
19406
- }
19407
19621
  } else if (beginFrameStalled) {
19408
19622
  forceScreenshotForChunk = true;
19409
19623
  log.warn(
@@ -19413,41 +19627,66 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
19413
19627
  await closeCaptureSession(session).catch(() => {
19414
19628
  });
19415
19629
  session = null;
19416
- if (chunkWorkerCount === 1) {
19417
- const screenshotBootStarted = Date.now();
19418
- const screenshotCfg = {
19419
- ...cfg,
19420
- forceScreenshot: true,
19421
- forceScreenshotExplicitlyOptedOut: false
19422
- };
19423
- session = await createVerifiedDistributedCaptureSession(
19424
- fileServer.url,
19425
- framesDir,
19426
- captureOptions,
19427
- screenshotCfg
19630
+ const screenshotBootStarted = Date.now();
19631
+ const screenshotCfg = {
19632
+ ...cfg,
19633
+ forceScreenshot: true,
19634
+ forceScreenshotExplicitlyOptedOut: false
19635
+ };
19636
+ session = await createVerifiedDistributedCaptureSession(
19637
+ fileServer.url,
19638
+ framesDir,
19639
+ captureOptions,
19640
+ screenshotCfg
19641
+ );
19642
+ sessionBootMs += Date.now() - screenshotBootStarted;
19643
+ }
19644
+ } else if (!verifyInWorker) {
19645
+ boxesMeasured();
19646
+ }
19647
+ let verification;
19648
+ const verifyFirstWorker = (first) => verification ??= (async () => {
19649
+ sessionBootMs = Date.now() - verifyStarted;
19650
+ try {
19651
+ await measureBoxes(first.page);
19652
+ const selectedScreenshot = first.launchCaptureMode === "screenshot";
19653
+ if (selectedScreenshot || await beginFrameSessionNeedsScreenshotFallback(first)) {
19654
+ forceScreenshotForChunk = true;
19655
+ log.warn(
19656
+ selectedScreenshot ? "[renderChunk] Browser capability probe selected screenshot capture for the entire chunk" : "[renderChunk] BeginFrame liveness probe failed; using screenshot capture for the entire chunk",
19657
+ { chunkIndex }
19428
19658
  );
19429
- sessionBootMs += Date.now() - screenshotBootStarted;
19659
+ throw new Error(PROBE_SELECTED_SCREENSHOT);
19430
19660
  }
19431
- } else if (chunkWorkerCount > 1) {
19432
- await closeCaptureSession(session);
19433
- session = null;
19661
+ } catch (error) {
19662
+ if (!forceScreenshotForChunk) {
19663
+ verifyFailure = error;
19664
+ boxesFailed(error);
19665
+ }
19666
+ throw error;
19434
19667
  }
19435
- }
19436
- const extractStarted = Date.now();
19437
- const deferredVideoFrames = planVideos ? extractDeferredVideoFramesForChunk({
19438
- planDir,
19439
- planVideos,
19440
- frames: chunkFrameNumbers,
19441
- fps: chunkFps,
19442
- outputRoot: videoFramesDir,
19443
- cfg,
19444
- remoteSources,
19445
- shownBoxes
19446
- }).then((frames) => {
19447
- videoExtractMs = Date.now() - extractStarted;
19448
- return frames;
19449
- }) : Promise.resolve([]);
19668
+ })();
19669
+ let verifyStarted = 0;
19670
+ let verifyFailure;
19671
+ const deferredVideoFrames = planVideos ? boxesReady.then(() => {
19672
+ const extractStarted = Date.now();
19673
+ return extractDeferredVideoFramesForChunk({
19674
+ planDir,
19675
+ planVideos,
19676
+ frames: chunkFrameNumbers,
19677
+ fps: chunkFps,
19678
+ outputRoot: videoFramesDir,
19679
+ cfg,
19680
+ remoteSources,
19681
+ shownBoxes
19682
+ }).then((frames) => {
19683
+ videoExtractMs = Date.now() - extractStarted;
19684
+ return frames;
19685
+ });
19686
+ }) : boxesReady.then(() => []);
19450
19687
  extraction = deferredVideoFrames;
19688
+ deferredVideoFrames.catch(() => {
19689
+ });
19451
19690
  const videoFrameLookup = planVideos && planVideos.extracted.length > 0 ? deferredVideoFrames.then(
19452
19691
  (deferred) => createFrameLookupTable(
19453
19692
  planVideos.videos,
@@ -19519,11 +19758,14 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
19519
19758
  // first frame is an IDR keyframe and concat-copy at assemble time
19520
19759
  // round-trips losslessly.
19521
19760
  lockGopForChunkConcat: !isPngSequence,
19522
- gopSize: framesInChunk
19761
+ gopSize: chunkGopFrames(framesInChunk, encoder.keyframeIntervalFrames),
19762
+ maxBitrate: encoder.maxBitrate,
19763
+ bufferSize: encoder.bufferSize
19523
19764
  };
19524
19765
  const captureStarted = Date.now();
19525
19766
  captureMode = await runCaptureWithScreenshotFallback({
19526
19767
  forceScreenshot: forceScreenshotForChunk,
19768
+ canRetry: () => verifyFailure === void 0,
19527
19769
  // fallow-ignore-next-line complexity
19528
19770
  run: async (forceScreenshot) => {
19529
19771
  const captureCfg = cfg.forceScreenshot === forceScreenshot ? cfg : {
@@ -19553,6 +19795,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
19553
19795
  }
19554
19796
  const captureSession = session;
19555
19797
  session = null;
19798
+ verifyStarted = Date.now();
19556
19799
  overlap.current = canEncodeWhileCapturing(encodeInput, chunkWorkerCount, cpus3().length) ? encodeWhileCapturing(encodeInput, framesInChunk) : null;
19557
19800
  await observeRenderStage(
19558
19801
  new RenderObservabilityRecorder({ pipelineStartMs: start, log }),
@@ -19580,7 +19823,8 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
19580
19823
  frameRange: range,
19581
19824
  onFrameLanded: (frame) => overlap.current?.onFrameLanded(frame),
19582
19825
  interleaveFrames: interleavesCapture(overlap.current !== null, options),
19583
- openAttempt
19826
+ openAttempt,
19827
+ verifyFirstSession: forceScreenshot || !verifyInWorker ? void 0 : verifyFirstWorker
19584
19828
  }),
19585
19829
  { stall: frameStallRule(job) }
19586
19830
  ).catch(async (captureError) => {
@@ -19591,7 +19835,8 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
19591
19835
  return observedChunkCaptureMode(capturePerfs);
19592
19836
  },
19593
19837
  resetForScreenshotRetry: () => {
19594
- rmSync17(workDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
19838
+ rmSync15(workDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
19839
+ boxesMeasured();
19595
19840
  mkdirSync17(framesDir, { recursive: true });
19596
19841
  capturePerfs.length = 0;
19597
19842
  captureAttempts.length = 0;
@@ -19607,6 +19852,8 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
19607
19852
  );
19608
19853
  }
19609
19854
  }).catch(async (captureError) => {
19855
+ if (verifyFailure !== void 0) throw verifyFailure;
19856
+ boxesFailed(captureError);
19610
19857
  await deferredVideoFrames;
19611
19858
  throw captureError;
19612
19859
  });
@@ -19634,8 +19881,8 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
19634
19881
  fps: { num: plan2.dimensions.fpsNum, den: plan2.dimensions.fpsDen },
19635
19882
  timeoutMs: cfg.ffmpegProcessTimeout
19636
19883
  });
19637
- rmSync17(videoOnlyPath, { force: true });
19638
- rmSync17(audioScratchPath, { force: true });
19884
+ rmSync15(videoOnlyPath, { force: true });
19885
+ rmSync15(audioScratchPath, { force: true });
19639
19886
  }
19640
19887
  encodeStageMs = Date.now() - encodeStarted;
19641
19888
  } finally {
@@ -19685,8 +19932,8 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
19685
19932
  writeFileSync13(perfPath, `${JSON.stringify(perfPayload, null, 2)}
19686
19933
  `, "utf-8");
19687
19934
  try {
19688
- rmSync17(workDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
19689
- rmSync17(videoFramesDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
19935
+ rmSync15(workDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
19936
+ rmSync15(videoFramesDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
19690
19937
  } catch (err) {
19691
19938
  log.warn("[renderChunk] failed to remove work dir", {
19692
19939
  workDir,
@@ -19721,7 +19968,7 @@ async function renderChunkV2(planV2Dir, chunkIndex, outputChunkPath, options) {
19721
19968
  materializePlanV2Target(planV2Dir, { role: "chunk", chunkIndex }, materializedPlanDir);
19722
19969
  return await renderChunk(materializedPlanDir, chunkIndex, outputChunkPath, options);
19723
19970
  } finally {
19724
- rmSync18(workRoot, { recursive: true, force: true });
19971
+ rmSync16(workRoot, { recursive: true, force: true });
19725
19972
  }
19726
19973
  }
19727
19974
  async function assembleV2(planV2Dir, chunkPaths, outputPath, options) {
@@ -19741,7 +19988,7 @@ async function assembleV2(planV2Dir, chunkPaths, outputPath, options) {
19741
19988
  options
19742
19989
  );
19743
19990
  } finally {
19744
- rmSync18(workRoot, { recursive: true, force: true });
19991
+ rmSync16(workRoot, { recursive: true, force: true });
19745
19992
  }
19746
19993
  }
19747
19994