hyperframes 0.8.206 → 0.8.207

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 (213) hide show
  1. package/bin/hyperframes.mjs +1 -0
  2. package/dist/{add-FFMNAJXJ.js → add-LXFWHBE3.js} +19 -18
  3. package/dist/{agentPromptGenerator-KYO5MKTW.js → agentPromptGenerator-D2E62ZP5.js} +1 -1
  4. package/dist/{animatedGifPrep-BIIIIVWL.js → animatedGifPrep-VBPJZKFT.js} +12 -12
  5. package/dist/api.js +30 -30
  6. package/dist/{appHistory-QVCSAOI4.js → appHistory-HIBH6XZW.js} +3 -1
  7. package/dist/{asset-IPUHGZSL.js → asset-JX4RW3GO.js} +2 -2
  8. package/dist/{assetCataloger-M5FWXLAJ.js → assetCataloger-JKKOPBCF.js} +14 -13
  9. package/dist/{audio-VYWWM4DB.js → audio-OXQ3L6DW.js} +22 -22
  10. package/dist/{auth-GZQZCUPL.js → auth-JAL7P7ZA.js} +1 -1
  11. package/dist/{autoUpdate-GJUDDLLO.js → autoUpdate-MRI2AICE.js} +2 -2
  12. package/dist/{backgroundChecks-BTMSW34Z.js → backgroundChecks-ORR46PBY.js} +3 -3
  13. package/dist/backgroundChecksWorker.js +3 -3
  14. package/dist/{batchRender-LI2BJRGO.js → batchRender-IFZYPGIW.js} +9 -9
  15. package/dist/{beats-H73CSYT4.js → beats-UDLOEW6U.js} +19 -19
  16. package/dist/{benchmark-XT3A5REC.js → benchmark-VTVDNKSO.js} +14 -14
  17. package/dist/{browser-VIOK66YK.js → browser-QJC4BL2Y.js} +6 -6
  18. package/dist/{bundleWithLocalizedFonts-PFRVWYOO.js → bundleWithLocalizedFonts-Z2JTBNDS.js} +2 -2
  19. package/dist/{capture-252WNPCD.js → capture-2P4JERSX.js} +14 -3
  20. package/dist/{capture-KKD5GMAF.js → capture-GLM2ACPM.js} +73 -33
  21. package/dist/{captureCompositionFrame-YLYVGNN2.js → captureCompositionFrame-A2A5MGQB.js} +18 -18
  22. package/dist/{captureFile-LYOJOUIE.js → captureFile-RPUEOZO6.js} +1 -1
  23. package/dist/{catalog-6IJGNN3T.js → catalog-5ZLVUQVJ.js} +25 -24
  24. package/dist/{catch-up-BFW7Z35W.js → catch-up-FRMVYJHZ.js} +5 -5
  25. package/dist/{check-XUWBZASR.js → check-WVY7SM7C.js} +47 -47
  26. package/dist/{checkAudio-2NRR3VHQ.js → checkAudio-PLEQY3SZ.js} +16 -16
  27. package/dist/{checkBrowser-JW74KWTF.js → checkBrowser-XSZUA2DQ.js} +40 -40
  28. package/dist/{chunk-2S263R6D.js → chunk-526VSRZ4.js} +9 -9
  29. package/dist/{chunk-SFYLZX5C.js → chunk-5KBMYSF2.js} +54 -15
  30. package/dist/{chunk-2ST4WAFY.js → chunk-5PCALX6G.js} +13 -1
  31. package/dist/{chunk-AJSU6KGS.js → chunk-5PYRU5DT.js} +13 -13
  32. package/dist/{chunk-AYH5ANVS.js → chunk-5YHQBCWH.js} +52 -3
  33. package/dist/{chunk-QVTCXN42.js → chunk-63DP5CB2.js} +29 -3
  34. package/dist/{chunk-FNNGQ3DB.js → chunk-6IYIS2U7.js} +2 -2
  35. package/dist/{chunk-VDVVQNTK.js → chunk-6KCFVLO6.js} +5 -5
  36. package/dist/{chunk-DEVZJ4AL.js → chunk-6KOHY5EP.js} +7 -7
  37. package/dist/{chunk-CIHW6VM2.js → chunk-6Z7XDUUJ.js} +1 -1
  38. package/dist/{chunk-PQYWYBEQ.js → chunk-7PJ3AJB2.js} +1 -1
  39. package/dist/{chunk-VW2LVMKB.js → chunk-7RWUY3BJ.js} +47 -55
  40. package/dist/{chunk-3CISA3OS.js → chunk-AF3L5JJX.js} +1 -1
  41. package/dist/chunk-BDJIQZN2.js +4830 -0
  42. package/dist/{chunk-4CY5RXXC.js → chunk-C53ZNJDZ.js} +4 -4
  43. package/dist/{chunk-FULMZCDW.js → chunk-CVZO6TFE.js} +10 -10
  44. package/dist/{chunk-6ZFDNEMY.js → chunk-DJQZ7DEH.js} +15 -15
  45. package/dist/{chunk-E2ZZSDDQ.js → chunk-DML6BD4K.js} +2 -2
  46. package/dist/{chunk-PNKLOMHQ.js → chunk-EG3B2VWK.js} +2 -2
  47. package/dist/{chunk-XOM3XTJ4.js → chunk-EGRIVMCQ.js} +1 -1
  48. package/dist/{chunk-3CS6QYL7.js → chunk-FEO7YW7V.js} +8 -8
  49. package/dist/{chunk-H4JO7VSI.js → chunk-FVAI7AHF.js} +12 -12
  50. package/dist/{chunk-PLGGKTCB.js → chunk-GXUONASF.js} +13 -20
  51. package/dist/{chunk-CZYS6UKP.js → chunk-H3LQ5X6Q.js} +19 -19
  52. package/dist/{chunk-AXEEZKIL.js → chunk-HA3V4XAF.js} +6 -6
  53. package/dist/{chunk-G6W55MTX.js → chunk-HM7SUIQD.js} +38 -9
  54. package/dist/{chunk-VEA7Z4PZ.js → chunk-HVOTYAS4.js} +15 -7
  55. package/dist/{chunk-3R6SXPHD.js → chunk-I2TDHVFV.js} +2 -2
  56. package/dist/{chunk-36QE3P6B.js → chunk-I3TYUQLB.js} +1 -1
  57. package/dist/{chunk-63DGZRZP.js → chunk-IBZHSU2J.js} +1 -1
  58. package/dist/{chunk-AEC4T4IF.js → chunk-ID766OZB.js} +12 -12
  59. package/dist/{chunk-5QKJPCQ4.js → chunk-IK4JY2LI.js} +2 -2
  60. package/dist/{chunk-UMUVGNOH.js → chunk-IW5P4KK7.js} +3 -3
  61. package/dist/{chunk-AAX2A7LQ.js → chunk-IYZT62UR.js} +1 -1
  62. package/dist/chunk-JKE24AG7.js +62 -0
  63. package/dist/chunk-JLCAHJUO.js +91 -0
  64. package/dist/{chunk-N7ZMDVAK.js → chunk-JLGVBK5M.js} +1 -1
  65. package/dist/{chunk-2RT7MXFL.js → chunk-JQ32262N.js} +1 -1
  66. package/dist/{chunk-RW4DMP2Y.js → chunk-KDHHPJOG.js} +4 -4
  67. package/dist/{chunk-DZG565OO.js → chunk-LCCYYTEK.js} +1 -1
  68. package/dist/{chunk-RDDVQSNQ.js → chunk-LK6KPVX2.js} +167 -55
  69. package/dist/{chunk-42KN6I6A.js → chunk-LPI7HX4G.js} +2 -2
  70. package/dist/{chunk-WHD5IAHI.js → chunk-LXP6XWJL.js} +2 -2
  71. package/dist/{chunk-T6SD37JZ.js → chunk-MAUGXKSI.js} +4 -4
  72. package/dist/{chunk-ZTEKVSZ6.js → chunk-MMJAHBH2.js} +1 -1
  73. package/dist/{chunk-TSJVPPXT.js → chunk-MSHL6CF2.js} +1 -1
  74. package/dist/{chunk-OFRRUYBA.js → chunk-NHA4NRBE.js} +135 -24
  75. package/dist/{chunk-OZUAVHFE.js → chunk-NHL5CMO2.js} +3 -3
  76. package/dist/{chunk-7SXL476O.js → chunk-NJNC2DQV.js} +27 -26
  77. package/dist/{chunk-FMWACL3L.js → chunk-NSC5A4IR.js} +1 -1
  78. package/dist/{chunk-MRF4AMKD.js → chunk-NWGXTUYS.js} +32 -10
  79. package/dist/{chunk-X5HHHFTX.js → chunk-PL36HK3U.js} +3 -3
  80. package/dist/{chunk-BBUK6A7Q.js → chunk-PUIG6DHT.js} +5 -5
  81. package/dist/{chunk-CPSGXAYD.js → chunk-QE4WRS3N.js} +3 -3
  82. package/dist/{chunk-FJW757TF.js → chunk-QTWXVOZI.js} +1 -1
  83. package/dist/{chunk-WYB3VKLK.js → chunk-QZ2JQ6O4.js} +6 -6
  84. package/dist/{chunk-MFHYBSJC.js → chunk-RPZNQV6D.js} +3 -3
  85. package/dist/{chunk-2BGOB2QK.js → chunk-SE2MXV2N.js} +136 -25
  86. package/dist/{chunk-GAV56VJL.js → chunk-SXOD5J7T.js} +2 -2
  87. package/dist/{chunk-VHVSBOZH.js → chunk-T4JGFCXU.js} +3 -3
  88. package/dist/{chunk-HJAJ6W4V.js → chunk-TSTONNOD.js} +2 -2
  89. package/dist/chunk-TSYRN646.js +84 -0
  90. package/dist/{chunk-CNVHMLPI.js → chunk-U32PA6DI.js} +1 -1
  91. package/dist/{chunk-ZNAOBFU5.js → chunk-UAT2UMTP.js} +1 -1
  92. package/dist/{chunk-QL4ZYSIB.js → chunk-UKM3JYNB.js} +5 -71
  93. package/dist/{chunk-Z3XXLTVB.js → chunk-UUOIH4RW.js} +3 -3
  94. package/dist/{chunk-CMDVJP4T.js → chunk-UYPWH7PH.js} +10 -10
  95. package/dist/{chunk-3B2DBUQX.js → chunk-VAVDAOUA.js} +1 -1
  96. package/dist/{chunk-G6QDFWDN.js → chunk-VBPNCOD7.js} +2 -2
  97. package/dist/{chunk-NNLQTG3M.js → chunk-VH4PNYOS.js} +1 -1
  98. package/dist/{chunk-IXXVS2Z4.js → chunk-VQB7G5BM.js} +1 -1
  99. package/dist/{chunk-FLREUEHW.js → chunk-W4DMQZL5.js} +1 -1
  100. package/dist/{chunk-RXATE6FZ.js → chunk-WC4MTXGN.js} +22 -0
  101. package/dist/{chunk-F2ASNL2K.js → chunk-WL263XM2.js} +1 -1
  102. package/dist/{chunk-HEP5XMXV.js → chunk-XAGBSYIQ.js} +9 -2
  103. package/dist/{chunk-4DGLKB2H.js → chunk-XKW4Z7BU.js} +1 -1
  104. package/dist/chunk-XMRA7CQG.js +22 -0
  105. package/dist/{chunk-NVLPW3DG.js → chunk-XULJBZ7K.js} +2 -2
  106. package/dist/{chunk-X7RXXBYM.js → chunk-YJK6HOL5.js} +2 -2
  107. package/dist/{chunk-2MLMO25E.js → chunk-ZCJ5EGLU.js} +26 -6
  108. package/dist/{chunk-L5MFWGGU.js → chunk-ZYGIDXAK.js} +528 -327
  109. package/dist/{clean-N5VSKUVS.js → clean-TL3IPJDN.js} +27 -27
  110. package/dist/cli.js +55 -55
  111. package/dist/{cloud-74NF5FXC.js → cloud-EYMRPJNY.js} +4 -4
  112. package/dist/{cloudrun-7UOH335V.js → cloudrun-TOJ36NLX.js} +11 -11
  113. package/dist/commands/layout-audit.browser.js +3 -15
  114. package/dist/{compare-AY2LS2TZ.js → compare-MP5EOW4D.js} +41 -41
  115. package/dist/{compiler-4MHMC777.js → compiler-NOPVLJ2S.js} +8 -8
  116. package/dist/{component-CFWQOAZI.js → component-ASACDCZK.js} +3 -3
  117. package/dist/{compositions-DXLJTDSP.js → compositions-WKNZJY34.js} +16 -16
  118. package/dist/{contactSheet-5APX35L3.js → contactSheet-YOBPATEM.js} +2 -2
  119. package/dist/{delete-GB4MS7LM.js → delete-DQTFHP3G.js} +2 -2
  120. package/dist/{deploy-NXD3Q3KD.js → deploy-HHCFOUFM.js} +1 -1
  121. package/dist/{deterministicFonts-775YXAQ2.js → deterministicFonts-LKAGUNE5.js} +3 -3
  122. package/dist/{dist-ZY6IFESG.js → dist-L4Z4ZEYW.js} +6 -3
  123. package/dist/{dist-3ZJMZU75.js → dist-NQEYA4ZX.js} +36 -36
  124. package/dist/docs/rendering.md +3 -0
  125. package/dist/{doctor-CVY2XXKS.js → doctor-JDM65CP7.js} +19 -19
  126. package/dist/{events-T3CLIYRG.js → events-MBRNA3UF.js} +3 -3
  127. package/dist/{events-RYQYEWBV.js → events-RKRHRLJD.js} +2 -2
  128. package/dist/{feedback-K5ZMMLTA.js → feedback-LZWIWV5J.js} +17 -17
  129. package/dist/{ffmpeg-UNDAJ2IC.js → ffmpeg-4PZKSIGE.js} +14 -14
  130. package/dist/{figma-MYYCX635.js → figma-QFNYUT3F.js} +3 -3
  131. package/dist/fontLocalizeCli.js +19 -18
  132. package/dist/{get-JVIDYMVP.js → get-2B5ENJOH.js} +2 -2
  133. package/dist/{gpuPolicy-KEX7GDRJ.js → gpuPolicy-E5FB2GFR.js} +12 -12
  134. package/dist/{grade-compare-QEF6VASJ.js → grade-compare-4GUAPJHE.js} +39 -39
  135. package/dist/{gsapParserAcorn-LZJKCFQI.js → gsapParserAcorn-5YD4N6HQ.js} +2 -2
  136. package/dist/hangReport.js +47 -0
  137. package/dist/{heifImagePrep-A3ZPVQGU.js → heifImagePrep-C2RYIEER.js} +13 -13
  138. package/dist/{help-XPPSLIRY.js → help-XGDAXV67.js} +1 -1
  139. package/dist/{history-OFOPRD27.js → history-WNFF6HGU.js} +107 -59
  140. package/dist/hyperframe.manifest.json +1 -1
  141. package/dist/hyperframe.runtime.iife.js +74 -69
  142. package/dist/hyperframes-player.global.js +3 -3
  143. package/dist/{info-7RF6FQX5.js → info-BR2LKGJD.js} +16 -16
  144. package/dist/{init-NTIXWA3D.js → init-P6UWPUY3.js} +58 -57
  145. package/dist/{inspect-MYMCV5E7.js → inspect-MSRPF7ZO.js} +38 -38
  146. package/dist/{installer-PYJIJ3PJ.js → installer-MPUQS3ZX.js} +10 -10
  147. package/dist/{keyframes-UJ52PYE4.js → keyframes-J6K66QTO.js} +11 -11
  148. package/dist/{lambda-SBNUYEQE.js → lambda-LJ2OSWFJ.js} +32 -13
  149. package/dist/{layout-IOMCOABO.js → layout-CDY65XGA.js} +38 -38
  150. package/dist/{lint-AQWHHMPS.js → lint-CAUNBGPX.js} +12 -9
  151. package/dist/{lintProject-5A4SCW3S.js → lintProject-ZTSX3AWT.js} +6 -3
  152. package/dist/{list-WKAJ5SP3.js → list-33BYQNRZ.js} +2 -2
  153. package/dist/{login-3ZDK5JOA.js → login-5QMRKOHK.js} +4 -4
  154. package/dist/{manager-QYFYWZOK.js → manager-3JOHHPVR.js} +16 -16
  155. package/dist/{manager-F2YREC5X.js → manager-RMYSZ3KI.js} +7 -3
  156. package/dist/{media-treatment-4OLWVHUY.js → media-treatment-4WP22CFN.js} +22 -22
  157. package/dist/{models-MR55FAUX.js → models-HPWCHAZX.js} +27 -27
  158. package/dist/{motionShot-DC47S7BT.js → motionShot-I7GDIROQ.js} +22 -22
  159. package/dist/{normalize-audio-M2TK4NG5.js → normalize-audio-VTMXPSC7.js} +14 -14
  160. package/dist/{open-YXWBWTKL.js → open-SAO7OQTT.js} +19 -19
  161. package/dist/{parakeetRunner-J6QR3GTG.js → parakeetRunner-ZYPBIA73.js} +24 -24
  162. package/dist/{pipeline-7MJ5H4SW.js → pipeline-VNBMR6QU.js} +15 -15
  163. package/dist/{play-S562STR4.js → play-7VI6A7KN.js} +28 -28
  164. package/dist/{preflight-QWGXMISC.js → preflight-VWV7L45J.js} +16 -16
  165. package/dist/{present-PGOHZT3L.js → present-CSJGYOFF.js} +23 -23
  166. package/dist/{preview-JU75H4QN.js → preview-B246ZTVO.js} +48 -36
  167. package/dist/{producer-H66OMZLW.js → producer-WJLFDVQJ.js} +1 -1
  168. package/dist/{projectConfig-COSP24YT.js → projectConfig-OMR46ZWQ.js} +14 -13
  169. package/dist/{publication-J3XYHPGB.js → publication-AA7NNYET.js} +8 -8
  170. package/dist/{publish-7GCCEPJZ.js → publish-TJ4QVVSP.js} +17 -16
  171. package/dist/{remove-background-WRCGIU32.js → remove-background-LQ2V7W7N.js} +19 -19
  172. package/dist/{render-5J5PP3UK.js → render-AWEEPG3F.js} +34 -32
  173. package/dist/{render-QS3YJCBR.js → render-E5QJG74D.js} +14 -11
  174. package/dist/{render-VUVTK2JM.js → render-JLTNZ36U.js} +80 -48
  175. package/dist/{render-batch-Q2LQ3D4P.js → render-batch-U4T4VSCM.js} +14 -11
  176. package/dist/renderSetupWorker.js +10 -7
  177. package/dist/{resolver-QCBWPRSC.js → resolver-GXCTUKPV.js} +10 -10
  178. package/dist/{screenshotCapture-I5EDCITF.js → screenshotCapture-X6OKIXCB.js} +1 -1
  179. package/dist/{sherpa-IZ22SC5W.js → sherpa-4VZWVHWZ.js} +23 -23
  180. package/dist/skills/hyperframes-cli/references/init-and-scaffold.md +1 -0
  181. package/dist/skills/hyperframes-cli/references/lambda.md +3 -0
  182. package/dist/skills/hyperframes-cli/references/preview-render.md +3 -0
  183. package/dist/{skills-3RFMPMJA.js → skills-WUKR7SUE.js} +8 -8
  184. package/dist/{skillsUpdateCheck-DWBFVUBT.js → skillsUpdateCheck-YXRBY3JC.js} +3 -3
  185. package/dist/{snapshot-5PHA43DK.js → snapshot-Q7S2FTNG.js} +123 -70
  186. package/dist/{src-36BQVJL3.js → src-CLAALR5W.js} +20 -19
  187. package/dist/{src-4YJKYMNF.js → src-ZOXUSGAP.js} +19 -11
  188. package/dist/{staticProjectServer-3XFB76XS.js → staticProjectServer-DQ7PIDPA.js} +25 -25
  189. package/dist/studio/assets/hyperframes-player-Cm5aBiKq.js +478 -0
  190. package/dist/studio/assets/{index-CwreIGoq.js → index-BF9YeBnC.js} +131 -131
  191. package/dist/studio/assets/{index-BNuxGFZK.js → index-BrqAmMRt.js} +1 -1
  192. package/dist/studio/index.html +1 -1
  193. package/dist/{studio-api-WL6EZ4KE.js → studio-api-NUE227JM.js} +17 -17
  194. package/dist/{studioServer-ZS5RA6U3.js → studioServer-HVOKP4VI.js} +71 -69
  195. package/dist/{synthesize-QCRP3NI7.js → synthesize-QZHRXGRY.js} +26 -4
  196. package/dist/{telemetry-W3LRO3TB.js → telemetry-2Y5JXLDB.js} +3 -3
  197. package/dist/{timeline-BDO5DYWP.js → timeline-WOQGXFRV.js} +27 -27
  198. package/dist/{tokens-47CEMYFV.js → tokens-T3OHTWUC.js} +2 -2
  199. package/dist/{transcribe-XF3NL6JI.js → transcribe-4U74P5TG.js} +21 -21
  200. package/dist/{transcribe-GEPVJO3A.js → transcribe-JZ3BO546.js} +31 -31
  201. package/dist/{tts-QM4RFE7U.js → tts-AY4JO5NQ.js} +2 -2
  202. package/dist/{updateCheck-BON6ZFYP.js → updateCheck-6EUAGAM4.js} +2 -2
  203. package/dist/{upgrade-KIF5Z4J3.js → upgrade-55K6F4MP.js} +2 -2
  204. package/dist/upstreamProxy-W5FWAT5Z.js +17 -0
  205. package/dist/{urlDownloader-UDRHVUWR.js → urlDownloader-47JMOLNN.js} +11 -11
  206. package/dist/{validate-2OPSQT3W.js → validate-QBJ3SBS4.js} +31 -31
  207. package/dist/{video-ECWXMY4F.js → video-3ZAUNAR3.js} +16 -14
  208. package/dist/warmCheck.js +47 -47
  209. package/package.json +2 -1
  210. package/dist/chunk-4YYJOFKS.js +0 -28
  211. package/dist/chunk-KLIPVNCO.js +0 -4824
  212. package/dist/studio/assets/hyperframes-player-lCVwx9d3.js +0 -478
  213. package/dist/{chunk-X7A7C4JS.js → chunk-EHFZEKQM.js} +3 -3
@@ -8,7 +8,12 @@ import {
8
8
  Semaphore,
9
9
  prepareHeifImageInputs,
10
10
  withMediaProbeSlot
11
- } from "./chunk-G6QDFWDN.js";
11
+ } from "./chunk-VBPNCOD7.js";
12
+ import {
13
+ EncoderInterruptedError,
14
+ encoderFailureError,
15
+ prepareAnimatedGifInputs
16
+ } from "./chunk-XULJBZ7K.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-LK6KPVX2.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-RPZNQV6D.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-7RWUY3BJ.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-BDJIQZN2.js";
245
238
  import {
246
239
  TRANSITIONS,
247
240
  convertTransfer,
@@ -257,7 +250,7 @@ import {
257
250
  import {
258
251
  lintHyperframeHtml,
259
252
  resolveReferencedStart
260
- } from "./chunk-2MLMO25E.js";
253
+ } from "./chunk-ZCJ5EGLU.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 };
6183
- }
6184
- throw withSrcContext(error);
6185
- }
6186
- assertAssetMediaTypeProfile(tagName === "video" ? "video" : "audio", profile, elementIdentity);
6187
- let metadata;
6188
- if (tagName === "video") {
6189
- try {
6190
- metadata = await extractMediaMetadata(filePath);
6191
- } catch (error) {
6192
- throw withSrcContext(error);
6233
+ const profile = await probeMediaProfile(filePath);
6234
+ if (tagName === "video") {
6235
+ return { profile, fileDuration: (await extractMediaMetadata(filePath)).durationSeconds };
6193
6236
  }
6194
- } else {
6195
6237
  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) {
@@ -8782,11 +8867,10 @@ function appendAutoDetectedVideoAudio(composition, extracted) {
8782
8867
 
8783
8868
  // ../producer/src/services/render/stages/audioStage.ts
8784
8869
  import { join as join18 } from "path";
8785
- import { rmSync as rmSync8 } from "fs";
8786
8870
 
8787
8871
  // ../producer/src/services/render/audioPadTrim.ts
8788
8872
  import { spawn } from "child_process";
8789
- import { mkdtempSync as mkdtempSync3, rmSync as rmSync7 } from "fs";
8873
+ import { mkdtempSync as mkdtempSync3 } from "fs";
8790
8874
  import { dirname as dirname6, join as join17 } from "path";
8791
8875
 
8792
8876
  // ../producer/src/services/render/audioTruePeak.ts
@@ -8972,7 +9056,7 @@ async function padOrTrimAudioToVideoFrameCount(input) {
8972
9056
  error: `audioPadTrim: failed to materialize ${plan2.operation}: ${err instanceof Error ? err.message : String(err)}`
8973
9057
  };
8974
9058
  } finally {
8975
- for (const path of plan2.cleanupPaths) rmSync7(path, { force: true });
9059
+ for (const path of plan2.cleanupPaths) removeScratch(path);
8976
9060
  }
8977
9061
  let loweredDb = 0;
8978
9062
  if (probeTruePeak) {
@@ -9035,7 +9119,7 @@ async function enforceAacTruePeak(input) {
9035
9119
  }
9036
9120
  if (truePeakDbfs <= AAC_DELIVERY_TRUE_PEAK_DBFS) {
9037
9121
  if (measuredPath !== correctedPath) return { success: true };
9038
- renameWithRetry(correctedPath, input.audioPath);
9122
+ renameWithRetry(correctedPath, input.audioPath, { copyFallback: true });
9039
9123
  return { success: true, loweredDb: Number((-attenuationDb).toFixed(2)) };
9040
9124
  }
9041
9125
  if (pass === MAX_TRUE_PEAK_CORRECTION_PASSES) break;
@@ -9076,7 +9160,7 @@ async function enforceAacTruePeak(input) {
9076
9160
  )}`
9077
9161
  };
9078
9162
  } finally {
9079
- if (scratchDir) rmSync7(scratchDir, { recursive: true, force: true });
9163
+ if (scratchDir) removeScratch(scratchDir);
9080
9164
  }
9081
9165
  }
9082
9166
  function failResult(outputPath, target, source, error) {
@@ -9221,7 +9305,15 @@ function assertAudioNotInterrupted(failures) {
9221
9305
  ])
9222
9306
  });
9223
9307
  }
9224
- async function runAudioStage(input) {
9308
+ function runAudioStage(input) {
9309
+ return collectScratchLeftovers(
9310
+ () => runAudioStageScoped(input),
9311
+ (left) => {
9312
+ if (left.length > 0) input.log?.warn("[audio] scratch left behind", { count: left.length });
9313
+ }
9314
+ );
9315
+ }
9316
+ async function runAudioStageScoped(input) {
9225
9317
  const stageStart = Date.now();
9226
9318
  const pcmSourcePath = join18(input.workDir, "audio-source.wav");
9227
9319
  const duration = input.totalFrames * input.fps.den / input.fps.num;
@@ -9243,7 +9335,7 @@ async function runAudioStage(input) {
9243
9335
  }
9244
9336
  return { ...result, audioLoweredDb, audioProcessMs: Date.now() - stageStart };
9245
9337
  } finally {
9246
- rmSync8(pcmSourcePath, { force: true });
9338
+ removeScratch(pcmSourcePath);
9247
9339
  }
9248
9340
  }
9249
9341
  async function mixAudioForDelivery(input, duration, pcmSourcePath) {
@@ -10360,6 +10452,7 @@ async function runCaptureHdrStage(input) {
10360
10452
  preset,
10361
10453
  effectiveQuality,
10362
10454
  effectiveBitrate,
10455
+ deliveryEncoder,
10363
10456
  fileServer,
10364
10457
  buildCaptureOptions,
10365
10458
  createRenderVideoFrameInjector,
@@ -10449,6 +10542,7 @@ async function runCaptureHdrStage(input) {
10449
10542
  preset: preset.preset,
10450
10543
  quality: effectiveQuality,
10451
10544
  bitrate: effectiveBitrate,
10545
+ ...deliveryEncoder,
10452
10546
  pixelFormat: preset.pixelFormat,
10453
10547
  hdr: preset.hdr,
10454
10548
  rawInputFormat: "rgb48le"
@@ -10652,7 +10746,7 @@ import {
10652
10746
  mkdirSync as mkdirSync7,
10653
10747
  readdirSync as readdirSync4,
10654
10748
  readFileSync as readFileSync6,
10655
- rmSync as rmSync9,
10749
+ rmSync as rmSync7,
10656
10750
  statSync as statSync5,
10657
10751
  writeFileSync as writeFileSync4
10658
10752
  } from "fs";
@@ -10776,7 +10870,7 @@ async function encodeGifFromDir(framesDir, framePattern, outputPath, input) {
10776
10870
  fileSize
10777
10871
  };
10778
10872
  } finally {
10779
- rmSync9(input.palettePath, { force: true });
10873
+ rmSync7(input.palettePath, { force: true });
10780
10874
  }
10781
10875
  }
10782
10876
  function startEncodeProgress(job, stage, onProgress) {
@@ -10800,6 +10894,8 @@ function videoEncoderOptions(input, engineCfg) {
10800
10894
  preset: preset.preset,
10801
10895
  quality: input.effectiveQuality,
10802
10896
  bitrate: input.effectiveBitrate,
10897
+ maxBitrate: input.maxBitrate,
10898
+ bufferSize: input.bufferSize,
10803
10899
  pixelFormat: preset.pixelFormat,
10804
10900
  vp9CpuUsed: engineCfg.vp9CpuUsed,
10805
10901
  useGpu: job.config.useGpu,
@@ -12073,6 +12169,7 @@ function resolveRenderDebugDir() {
12073
12169
  }
12074
12170
  async function executeRenderJob(job, projectDir, outputPath, progressSink, abortSignal, assertRenderActive) {
12075
12171
  validateHlsRenderConfig(job.config);
12172
+ validateDeliveryEncoderConfig(job.config);
12076
12173
  const debugDir = resolveRenderDebugDir();
12077
12174
  const outputDir = dirname9(outputPath);
12078
12175
  if (!existsSync15(outputDir)) mkdirSync8(outputDir, { recursive: true });
@@ -12093,7 +12190,7 @@ async function executeRenderJob(job, projectDir, outputPath, progressSink, abort
12093
12190
  log.info("KEEP_TEMP=1, leaving workDir on disk for inspection", { workDir });
12094
12191
  return;
12095
12192
  }
12096
- rmSync10(workDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
12193
+ rmSync8(workDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
12097
12194
  });
12098
12195
  try {
12099
12196
  await executeRenderPipeline({
@@ -12151,11 +12248,14 @@ async function executeRenderPipeline(input) {
12151
12248
  const isGif = outputFormat === "gif";
12152
12249
  const isHls = outputFormat === "hls";
12153
12250
  const hlsSegmentSeconds = isHls ? resolveHlsSegmentSeconds(job.config) : void 0;
12154
- const hlsEncoderGopLock = resolveHlsEncoderGopLock(
12155
- outputFormat,
12156
- job.config.fps,
12157
- job.config.hlsSegmentSeconds
12158
- );
12251
+ const deliveryEncoder = resolveDeliveryEncoderOptions({
12252
+ format: outputFormat,
12253
+ fps: job.config.fps,
12254
+ hlsSegmentSeconds: job.config.hlsSegmentSeconds,
12255
+ keyframeIntervalSeconds: job.config.keyframeIntervalSeconds,
12256
+ maxBitrate: job.config.maxBitrate,
12257
+ bufferSize: job.config.bufferSize
12258
+ });
12159
12259
  const artifactTransaction = new ArtifactTransaction(
12160
12260
  outputPath,
12161
12261
  isPngSequence || isHls ? "directory" : "file",
@@ -13238,6 +13338,7 @@ async function executeRenderPipeline(input) {
13238
13338
  preset,
13239
13339
  effectiveQuality,
13240
13340
  effectiveBitrate,
13341
+ deliveryEncoder,
13241
13342
  fileServer: activeFileServer,
13242
13343
  buildCaptureOptions,
13243
13344
  createRenderVideoFrameInjector,
@@ -13262,9 +13363,7 @@ async function executeRenderPipeline(input) {
13262
13363
  } else {
13263
13364
  let streamingHandled = false;
13264
13365
  if (capturePlan.kind === "sdr_segmented") {
13265
- const segmentedPlan = capturePlan;
13266
13366
  const captureFrameStart = Date.now();
13267
- resetCaptureAttemptProgress(job);
13268
13367
  const segmentFrames = resolveSegmentFrames(process.env);
13269
13368
  const segmentImageFormat = captureOptions.format || "jpeg";
13270
13369
  const segmentPlanHash = computeSegmentPlanHash({
@@ -13279,6 +13378,9 @@ async function executeRenderPipeline(input) {
13279
13378
  preset: preset.preset,
13280
13379
  quality: effectiveQuality,
13281
13380
  bitrate: effectiveBitrate,
13381
+ maxBitrate: deliveryEncoder.maxBitrate,
13382
+ bufferSize: deliveryEncoder.bufferSize,
13383
+ gopSize: deliveryEncoder.gopSize,
13282
13384
  pixelFormat: preset.pixelFormat,
13283
13385
  imageFormat: segmentImageFormat,
13284
13386
  useGpu: job.config.useGpu === true,
@@ -13304,71 +13406,129 @@ async function executeRenderPipeline(input) {
13304
13406
  });
13305
13407
  }
13306
13408
  if (completedSegments.size === 0) {
13307
- rmSync10(segmentDir, { recursive: true, force: true });
13409
+ rmSync8(segmentDir, { recursive: true, force: true });
13308
13410
  }
13309
13411
  } else {
13310
- rmSync10(segmentDir, { recursive: true, force: true });
13412
+ rmSync8(segmentDir, { recursive: true, force: true });
13311
13413
  }
13312
- const segmentManifest = readSegmentManifest(segmentDir) ?? {
13414
+ const emptySegmentManifest = () => ({
13313
13415
  version: 1,
13314
13416
  planHash: segmentPlanHash,
13315
13417
  totalFrames,
13316
13418
  segmentFrames,
13317
13419
  completed: []
13420
+ });
13421
+ let segmentManifest = readSegmentManifest(segmentDir) ?? emptySegmentManifest();
13422
+ const invokeSegmented = () => {
13423
+ if (capturePlan.kind !== "sdr_segmented") {
13424
+ throw new Error(`Cannot invoke segmented stage with ${capturePlan.kind} plan`);
13425
+ }
13426
+ const segmentedPlan = capturePlan;
13427
+ resetCaptureAttemptProgress(job);
13428
+ return observeRenderStage(
13429
+ observability,
13430
+ "capture_segmented",
13431
+ captureStageObservationData(),
13432
+ () => runCaptureSegmentedStage({
13433
+ fileServer: activeFileServer,
13434
+ workDir,
13435
+ framesDir,
13436
+ videoOnlyPath,
13437
+ job,
13438
+ totalFrames,
13439
+ cfg,
13440
+ plan: segmentedPlan,
13441
+ log,
13442
+ probeSession,
13443
+ outputFormat,
13444
+ streamingEncoderOptions: {
13445
+ fps: job.config.fps,
13446
+ width: captureCompositionWidth ?? width,
13447
+ height: captureCompositionHeight ?? height,
13448
+ codec: preset.codec,
13449
+ preset: preset.preset,
13450
+ quality: effectiveQuality,
13451
+ bitrate: effectiveBitrate,
13452
+ pixelFormat: preset.pixelFormat,
13453
+ vp9CpuUsed: cfg.vp9CpuUsed,
13454
+ useGpu: job.config.useGpu,
13455
+ imageFormat: segmentImageFormat,
13456
+ hdr: preset.hdr,
13457
+ // Each segment sets its own GOP (at most the interval); hls never reaches this route.
13458
+ ...deliveryEncoder
13459
+ },
13460
+ buildCaptureOptions,
13461
+ createRenderVideoFrameInjector,
13462
+ abortSignal: executionSignal,
13463
+ assertNotAborted,
13464
+ onProgress,
13465
+ dedupPerfs,
13466
+ segmentFrames,
13467
+ segmentDir,
13468
+ workerCount: segmentedPlan.workerCount,
13469
+ browserRecycleEverySegments: resolveSegmentBrowserRecycle(process.env),
13470
+ completedSegments,
13471
+ onSegmentComplete: (entry) => {
13472
+ segmentManifest.completed = [
13473
+ ...segmentManifest.completed.filter((e) => e.index !== entry.index),
13474
+ { ...entry, completedAt: (/* @__PURE__ */ new Date()).toISOString() }
13475
+ ];
13476
+ writeSegmentManifest(segmentDir, segmentManifest);
13477
+ },
13478
+ updateCaptureObservability
13479
+ })
13480
+ );
13318
13481
  };
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
- );
13482
+ let segmentedRes;
13483
+ try {
13484
+ segmentedRes = await invokeSegmented();
13485
+ } catch (err) {
13486
+ const isVerifyError = isDrawElementVerificationError(err);
13487
+ const isDeStall = isDeRendererStallError(err);
13488
+ if (!isVerifyError && !isDrawElementCaptureError(err) && !isDeStall || err instanceof RenderCancelledError || executionSignal?.aborted === true) {
13489
+ throw err;
13490
+ }
13491
+ deSelfVerifyFallback = isVerifyError;
13492
+ const t = deVerifyFallbackTelemetry(err);
13493
+ deFallbackReason = isVerifyError ? t.reason : isDeStall ? "de_renderer_stall" : "capture_error";
13494
+ deFallbackFailedDb = t.failedDb;
13495
+ deFallbackFrameIndex = t.frameIndex;
13496
+ deFallbackThresholdDb = t.thresholdDb;
13497
+ log.warn(
13498
+ "[Render] drawElement capture failed on the segmented path; re-rendering via screenshot",
13499
+ {
13500
+ error: err instanceof Error ? err.message : String(err)
13501
+ }
13502
+ );
13503
+ observability.checkpoint(
13504
+ "capture_segmented",
13505
+ "drawElement capture failed; retrying with a fresh screenshot session"
13506
+ );
13507
+ if (probeSession) {
13508
+ lastBrowserConsole = probeSession.browserConsoleBuffer;
13509
+ const orphaned = probeSession;
13510
+ probeSession = null;
13511
+ await closeOrphanedProbeForRetry(orphaned, closeCaptureSession, log, "segmented");
13512
+ }
13513
+ rmSync8(segmentDir, { recursive: true, force: true });
13514
+ completedSegments = /* @__PURE__ */ new Set();
13515
+ segmentManifest = emptySegmentManifest();
13516
+ dedupPerfs.length = 0;
13517
+ capturePlan = replanAfterFailure(capturePlan, {
13518
+ kind: isVerifyError ? "draw_element_verification" : "draw_element_capture"
13519
+ });
13520
+ syncCapturePlan();
13521
+ updateCaptureObservability({
13522
+ forceScreenshot: capturePlan.forceScreenshot,
13523
+ deSelfVerifyFallback,
13524
+ deFallbackReason,
13525
+ deFallbackFailedDb,
13526
+ deFallbackFrameIndex,
13527
+ deFallbackThresholdDb
13528
+ });
13529
+ segmentedRes = await invokeSegmented();
13530
+ observability.clearFailure("capture_segmented");
13531
+ }
13372
13532
  if (segmentedRes.success) {
13373
13533
  streamingHandled = true;
13374
13534
  workerCount = segmentedRes.workerCount;
@@ -13388,7 +13548,7 @@ async function executeRenderPipeline(input) {
13388
13548
  );
13389
13549
  updateCaptureObservability({ segmentRetries: segmentedRes.segmentRetries });
13390
13550
  if (job.config.keepSegments !== true) {
13391
- rmSync10(segmentDir, { recursive: true, force: true });
13551
+ rmSync8(segmentDir, { recursive: true, force: true });
13392
13552
  }
13393
13553
  } else {
13394
13554
  capturePlan = replanAfterFailure(capturePlan, { kind: "streaming_unavailable" });
@@ -13441,7 +13601,7 @@ async function executeRenderPipeline(input) {
13441
13601
  // assemble stage's `-c copy` segmentation cuts exactly on
13442
13602
  // the segment boundary. Every other format leaves the
13443
13603
  // encoder's open-GOP output untouched.
13444
- ...hlsEncoderGopLock
13604
+ ...deliveryEncoder
13445
13605
  },
13446
13606
  buildCaptureOptions,
13447
13607
  createRenderVideoFrameInjector,
@@ -13604,7 +13764,7 @@ async function executeRenderPipeline(input) {
13604
13764
  engineConfig: cfg,
13605
13765
  // Same value the streaming encoder above spreads — the disk and
13606
13766
  // chunked-concat encoders need an identical GOP lock for HLS.
13607
- ...hlsEncoderGopLock,
13767
+ ...deliveryEncoder,
13608
13768
  abortSignal: executionSignal,
13609
13769
  assertNotAborted,
13610
13770
  onProgress
@@ -13660,7 +13820,7 @@ async function executeRenderPipeline(input) {
13660
13820
  "capture_disk",
13661
13821
  "drawElement capture failed; retrying with a fresh screenshot session"
13662
13822
  );
13663
- rmSync10(framesDir, { recursive: true, force: true });
13823
+ rmSync8(framesDir, { recursive: true, force: true });
13664
13824
  mkdirSync8(framesDir, { recursive: true });
13665
13825
  resetCaptureAttemptProgress(job);
13666
13826
  dedupPerfs.length = 0;
@@ -13957,7 +14117,7 @@ import {
13957
14117
  existsSync as existsSync20,
13958
14118
  linkSync,
13959
14119
  mkdirSync as mkdirSync12,
13960
- rmSync as rmSync12,
14120
+ rmSync as rmSync10,
13961
14121
  writeFileSync as writeFileSync8
13962
14122
  } from "fs";
13963
14123
  import { extname as extname6, isAbsolute as isAbsolute2, join as join33, relative as relative5, sep as sep2 } from "path";
@@ -14962,7 +15122,7 @@ import { writeFileSync as writeFileSync7, writeSync } from "fs";
14962
15122
  import { join as join31 } from "path";
14963
15123
 
14964
15124
  // ../producer/src/services/distributed/mp4Stitch.ts
14965
- import { createReadStream as createReadStream4, createWriteStream, mkdirSync as mkdirSync10, mkdtempSync as mkdtempSync4, rmSync as rmSync11 } from "fs";
15125
+ import { createReadStream as createReadStream4, createWriteStream, mkdirSync as mkdirSync10, mkdtempSync as mkdtempSync4, rmSync as rmSync9 } from "fs";
14966
15126
  import { open } from "fs/promises";
14967
15127
  import { dirname as dirname11, join as join30 } from "path";
14968
15128
  import { finished, pipeline } from "stream/promises";
@@ -15339,7 +15499,7 @@ async function writeStitchedMp4(chunkPaths, outputPath, audioPath) {
15339
15499
  renameWithRetry(join30(workDir, "out.mp4"), outputPath);
15340
15500
  } finally {
15341
15501
  out.destroy();
15342
- rmSync11(workDir, { recursive: true, force: true });
15502
+ rmSync9(workDir, { recursive: true, force: true });
15343
15503
  }
15344
15504
  }
15345
15505
 
@@ -15847,7 +16007,7 @@ var FREEZE_OWNED_PLAN_FILES = [
15847
16007
  ];
15848
16008
  function removeFreezeOwnedPlanFiles(planDir) {
15849
16009
  for (const relativePath of FREEZE_OWNED_PLAN_FILES) {
15850
- rmSync12(join33(planDir, relativePath), { force: true });
16010
+ rmSync10(join33(planDir, relativePath), { force: true });
15851
16011
  }
15852
16012
  }
15853
16013
  function buildChunkSlices(totalFrames, chunkCount, effectiveChunkSize) {
@@ -15907,6 +16067,9 @@ function buildLockedRenderConfig(input) {
15907
16067
  preset,
15908
16068
  crf: config.crf,
15909
16069
  bitrate: config.bitrate,
16070
+ maxBitrate: config.maxBitrate,
16071
+ bufferSize: config.bufferSize,
16072
+ keyframeIntervalFrames: config.keyframeIntervalSeconds === void 0 ? void 0 : keyframeIntervalToGopSize({ num: config.fps, den: 1 }, config.keyframeIntervalSeconds),
15910
16073
  ...locksVp9CpuUsed,
15911
16074
  // GOP === chunkSize so every chunk's first frame is an IDR keyframe and
15912
16075
  // ffmpeg concat-copy round-trips losslessly.
@@ -16058,7 +16221,7 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
16058
16221
  throw new Error(`[plan] entry file not found: ${htmlPath}`);
16059
16222
  }
16060
16223
  const workDir = join33(planDir, ".plan-work");
16061
- rmSync12(workDir, { recursive: true, force: true });
16224
+ rmSync10(workDir, { recursive: true, force: true });
16062
16225
  mkdirSync12(workDir, { recursive: true });
16063
16226
  const compiledDir = join33(workDir, "compiled");
16064
16227
  mkdirSync12(compiledDir, { recursive: true });
@@ -16156,7 +16319,7 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
16156
16319
  if (probeResult.fileServer) closeFileServerSafely(probeResult.fileServer, "plan", log);
16157
16320
  if (probeResult.probeSession) {
16158
16321
  try {
16159
- const { closeCaptureSession: closeCaptureSession2 } = await import("./src-4YJKYMNF.js");
16322
+ const { closeCaptureSession: closeCaptureSession2 } = await import("./src-ZOXUSGAP.js");
16160
16323
  await closeCaptureSession2(probeResult.probeSession);
16161
16324
  } catch (err) {
16162
16325
  log.warn("[plan] probe session close failed", {
@@ -16265,15 +16428,15 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
16265
16428
  logPlanStage(log, "extract", stageStarted);
16266
16429
  const stagedVideoFrames = join33(compiledDir, "__hyperframes_video_frames");
16267
16430
  const videoFramesDst = join33(planDir, "video-frames");
16268
- if (existsSync20(videoFramesDst)) rmSync12(videoFramesDst, { recursive: true, force: true });
16431
+ if (existsSync20(videoFramesDst)) rmSync10(videoFramesDst, { recursive: true, force: true });
16269
16432
  const videoSourcesDir = join33(planDir, "video-sources");
16270
- rmSync12(videoSourcesDir, { recursive: true, force: true });
16433
+ rmSync10(videoSourcesDir, { recursive: true, force: true });
16271
16434
  if (existsSync20(stagedVideoFrames)) {
16272
16435
  renameWithRetry(stagedVideoFrames, videoFramesDst);
16273
16436
  } else {
16274
16437
  mkdirSync12(videoFramesDst, { recursive: true });
16275
16438
  }
16276
- if (existsSync20(finalCompiledDir)) rmSync12(finalCompiledDir, { recursive: true, force: true });
16439
+ if (existsSync20(finalCompiledDir)) rmSync10(finalCompiledDir, { recursive: true, force: true });
16277
16440
  renameWithRetry(compiledDir, finalCompiledDir);
16278
16441
  const shipVideoSource = createVideoSourceShipper({
16279
16442
  planDir,
@@ -16441,7 +16604,7 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
16441
16604
  format: config.format
16442
16605
  };
16443
16606
  try {
16444
- rmSync12(workDir, { recursive: true, force: true });
16607
+ rmSync10(workDir, { recursive: true, force: true });
16445
16608
  } catch (err) {
16446
16609
  log.warn("[plan] failed to remove temp work dir", {
16447
16610
  workDir,
@@ -16592,6 +16755,20 @@ function validateDistributedRenderConfig(config) {
16592
16755
  `must look like "10M" or "5000k"; got ${JSON.stringify(config.bitrate)}`
16593
16756
  );
16594
16757
  }
16758
+ try {
16759
+ validateDeliveryEncoderConfig({
16760
+ format: config.format,
16761
+ fps: { num: config.fps, den: 1 },
16762
+ keyframeIntervalSeconds: config.keyframeIntervalSeconds,
16763
+ maxBitrate: config.maxBitrate,
16764
+ bufferSize: config.bufferSize
16765
+ });
16766
+ } catch (error) {
16767
+ throw new InvalidConfigError(
16768
+ "config.maxBitrate",
16769
+ error instanceof Error ? error.message : String(error)
16770
+ );
16771
+ }
16595
16772
  if (config.chunkSize !== void 0) {
16596
16773
  if (!Number.isInteger(config.chunkSize) || config.chunkSize < 1) {
16597
16774
  throw new InvalidConfigError(
@@ -16771,6 +16948,12 @@ function assertOptionalInteger(options, field, min = 0) {
16771
16948
  throw new Error(`Render request ${field} must be an integer >= ${min}`);
16772
16949
  }
16773
16950
  }
16951
+ function assertOptionalPositiveNumber(options, field) {
16952
+ const value = options[field];
16953
+ if (value !== void 0 && !(typeof value === "number" && value > 0)) {
16954
+ throw new Error(`Render request ${field} must be a positive number`);
16955
+ }
16956
+ }
16774
16957
  function assertOptionalString(options, field) {
16775
16958
  if (options[field] !== void 0 && typeof options[field] !== "string") {
16776
16959
  throw new Error(`Render request ${field} must be a string`);
@@ -16818,10 +17001,11 @@ function assertRequestOptionScalars(options) {
16818
17001
  assertOptionalInteger(options, "workers", 1);
16819
17002
  assertOptionalInteger(options, "maxRenderMs");
16820
17003
  assertOptionalInteger(options, "crf");
17004
+ assertOptionalPositiveNumber(options, "keyframeIntervalSeconds");
16821
17005
  for (const field of ["useGpu", "debug", "outputResolutionAspectAgnostic"]) {
16822
17006
  assertOptionalBoolean(options, field);
16823
17007
  }
16824
- for (const field of ["entryFile", "videoBitrate"]) {
17008
+ for (const field of ["entryFile", "videoBitrate", "maxBitrate", "bufferSize"]) {
16825
17009
  assertOptionalString(options, field);
16826
17010
  }
16827
17011
  assertOptionalEnum(options, "strictness", ["strict", "best-effort"]);
@@ -16924,6 +17108,9 @@ function distributedConfigFromRequest(request, runtime = {}) {
16924
17108
  crf: options.crf,
16925
17109
  pageMotionBlur: options.pageMotionBlur,
16926
17110
  bitrate: options.videoBitrate,
17111
+ keyframeIntervalSeconds: options.keyframeIntervalSeconds,
17112
+ maxBitrate: options.maxBitrate,
17113
+ bufferSize: options.bufferSize,
16927
17114
  videoFrameFormat: options.videoFrameFormat,
16928
17115
  outputResolution: options.outputResolution,
16929
17116
  outputResolutionAspectAgnostic: options.outputResolutionAspectAgnostic,
@@ -16971,6 +17158,9 @@ function renderRequestFromDistributedConfig(input) {
16971
17158
  ...optionalProperty("crf", config.crf),
16972
17159
  ...optionalProperty("pageMotionBlur", config.pageMotionBlur),
16973
17160
  ...optionalProperty("videoBitrate", config.bitrate),
17161
+ ...optionalProperty("keyframeIntervalSeconds", config.keyframeIntervalSeconds),
17162
+ ...optionalProperty("maxBitrate", config.maxBitrate),
17163
+ ...optionalProperty("bufferSize", config.bufferSize),
16974
17164
  ...optionalProperty("videoFrameFormat", config.videoFrameFormat),
16975
17165
  ...optionalProperty("outputResolution", config.outputResolution),
16976
17166
  ...optionalProperty("outputResolutionAspectAgnostic", config.outputResolutionAspectAgnostic),
@@ -16994,7 +17184,7 @@ import {
16994
17184
  statSync as statSync8,
16995
17185
  mkdtempSync as mkdtempSync5,
16996
17186
  writeFileSync as writeFileSync9,
16997
- rmSync as rmSync13,
17187
+ rmSync as rmSync11,
16998
17188
  createReadStream as createReadStream5
16999
17189
  } from "fs";
17000
17190
  import { resolve as resolve9, dirname as dirname13, join as join36 } from "path";
@@ -17292,7 +17482,7 @@ function parseRenderOptions(body) {
17292
17482
  const format = parseServerFormat(body.format);
17293
17483
  const outputDynamicRange = parseServerOutputDynamicRange(body.outputDynamicRange) ?? fromRenderHdrMode(parseLegacyServerHdrMode(body.hdrMode));
17294
17484
  const encoder = parseEncoderOptions(body, format ?? "mp4");
17295
- const { crf, videoBitrate, videoFrameFormat } = encoder.ok ? encoder.options : {};
17485
+ const { crf, videoBitrate, videoFrameFormat, keyframeIntervalSeconds, maxBitrate, bufferSize } = encoder.ok ? encoder.options : {};
17296
17486
  const { variables, outputResolution, outputResolutionAspectAgnostic } = parseRenderOverrides(body);
17297
17487
  return {
17298
17488
  outputPath,
@@ -17302,6 +17492,9 @@ function parseRenderOptions(body) {
17302
17492
  maxRenderMs,
17303
17493
  crf,
17304
17494
  videoBitrate,
17495
+ keyframeIntervalSeconds,
17496
+ maxBitrate,
17497
+ bufferSize,
17305
17498
  useGpu,
17306
17499
  debug,
17307
17500
  strictness,
@@ -17336,6 +17529,9 @@ function buildRenderJobConfig(input, outputPath, log) {
17336
17529
  maxRenderMs: input.maxRenderMs,
17337
17530
  crf: input.crf,
17338
17531
  videoBitrate: input.videoBitrate,
17532
+ keyframeIntervalSeconds: input.keyframeIntervalSeconds,
17533
+ maxBitrate: input.maxBitrate,
17534
+ bufferSize: input.bufferSize,
17339
17535
  useGpu: input.useGpu,
17340
17536
  debug: input.debug,
17341
17537
  strictness: input.strictness,
@@ -17482,7 +17678,7 @@ function createArtifactStore(ttlMs) {
17482
17678
  function cleanupTempDir(dir, log) {
17483
17679
  if (!dir) return;
17484
17680
  try {
17485
- rmSync13(dir, { recursive: true, force: true });
17681
+ rmSync11(dir, { recursive: true, force: true });
17486
17682
  } catch (error) {
17487
17683
  log.warn("Failed to cleanup temp project dir", {
17488
17684
  cleanupProjectDir: dir,
@@ -17840,7 +18036,7 @@ function startServer(options = {}) {
17840
18036
  });
17841
18037
  async function shutdown(signal) {
17842
18038
  log.info(`Received ${signal}, shutting down`);
17843
- const { drainBrowserPool } = await import("./src-4YJKYMNF.js");
18039
+ const { drainBrowserPool } = await import("./src-ZOXUSGAP.js");
17844
18040
  await drainBrowserPool().catch(() => {
17845
18041
  });
17846
18042
  const handle = await Promise.race([
@@ -17884,7 +18080,7 @@ import {
17884
18080
  mkdtempSync as mkdtempSync7,
17885
18081
  readFileSync as readFileSync12,
17886
18082
  readdirSync as readdirSync9,
17887
- rmSync as rmSync15,
18083
+ rmSync as rmSync13,
17888
18084
  statSync as statSync10,
17889
18085
  writeFileSync as writeFileSync11
17890
18086
  } from "fs";
@@ -17898,7 +18094,7 @@ import {
17898
18094
  linkSync as linkSync2,
17899
18095
  mkdirSync as mkdirSync14,
17900
18096
  mkdtempSync as mkdtempSync6,
17901
- rmSync as rmSync14,
18097
+ rmSync as rmSync12,
17902
18098
  statSync as statSync9,
17903
18099
  writeFileSync as writeFileSync10
17904
18100
  } from "fs";
@@ -17992,7 +18188,7 @@ var LocalPlanV2ArtifactPublisher = class {
17992
18188
  }
17993
18189
  renameWithRetry(temporaryPath, destinationPath);
17994
18190
  } finally {
17995
- rmSync14(stagingDir, { recursive: true, force: true });
18191
+ rmSync12(stagingDir, { recursive: true, force: true });
17996
18192
  }
17997
18193
  }
17998
18194
  async commitManifest(manifestBytes) {
@@ -18009,7 +18205,7 @@ var LocalPlanV2ArtifactPublisher = class {
18009
18205
  }
18010
18206
  async abort() {
18011
18207
  if (!this.#committed) {
18012
- rmSync14(this.temporaryDir, { recursive: true, force: true });
18208
+ rmSync12(this.temporaryDir, { recursive: true, force: true });
18013
18209
  }
18014
18210
  }
18015
18211
  };
@@ -18278,7 +18474,7 @@ function writeBlob(sourcePath, destinationPath) {
18278
18474
  copyFileSync6(sourcePath, temporaryPath);
18279
18475
  renameWithRetry(temporaryPath, destinationPath);
18280
18476
  } finally {
18281
- rmSync15(temporaryDir, { recursive: true, force: true });
18477
+ rmSync13(temporaryDir, { recursive: true, force: true });
18282
18478
  }
18283
18479
  }
18284
18480
  function publishBlobFor(absolutePath, digests) {
@@ -18411,7 +18607,7 @@ function createPlanV2FromExecutionPlan(executionPlanDir, planV2Dir) {
18411
18607
  renameWithRetry(tempDir, planV2Dir);
18412
18608
  return resultFromManifest(planV2Dir, publication.manifest);
18413
18609
  } catch (error) {
18414
- rmSync15(tempDir, { recursive: true, force: true });
18610
+ rmSync13(tempDir, { recursive: true, force: true });
18415
18611
  throw error;
18416
18612
  }
18417
18613
  }
@@ -18478,7 +18674,7 @@ async function planV2WithPublisher(projectDir, config, publisher, options = {})
18478
18674
  }
18479
18675
  throw error;
18480
18676
  } finally {
18481
- rmSync15(stagingRoot, { recursive: true, force: true });
18677
+ rmSync13(stagingRoot, { recursive: true, force: true });
18482
18678
  }
18483
18679
  }
18484
18680
  async function planV2(projectDir, config, planV2Dir) {
@@ -18695,7 +18891,7 @@ function materializePlanV2Target(planV2Dir, target, destinationDir, options = {}
18695
18891
  );
18696
18892
  renameWithRetry(tempDir, destinationDir);
18697
18893
  } catch (error) {
18698
- rmSync15(tempDir, { recursive: true, force: true });
18894
+ rmSync13(tempDir, { recursive: true, force: true });
18699
18895
  throw error;
18700
18896
  }
18701
18897
  return {
@@ -18759,7 +18955,7 @@ function readValidatedPlanV2Materialization(planDir, expectedTarget) {
18759
18955
  }
18760
18956
 
18761
18957
  // ../producer/src/services/distributed/planV2Execution.ts
18762
- import { mkdtempSync as mkdtempSync9, rmSync as rmSync18 } from "fs";
18958
+ import { mkdtempSync as mkdtempSync9, rmSync as rmSync16 } from "fs";
18763
18959
  import { tmpdir as tmpdir5 } from "os";
18764
18960
  import { join as join42 } from "path";
18765
18961
 
@@ -18771,7 +18967,7 @@ import {
18771
18967
  mkdtempSync as mkdtempSync8,
18772
18968
  readFileSync as readFileSync13,
18773
18969
  readdirSync as readdirSync10,
18774
- rmSync as rmSync16,
18970
+ rmSync as rmSync14,
18775
18971
  statSync as statSync11,
18776
18972
  writeFileSync as writeFileSync12
18777
18973
  } from "fs";
@@ -18838,7 +19034,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
18838
19034
  });
18839
19035
  } finally {
18840
19036
  try {
18841
- rmSync16(workDir, { recursive: true, force: true });
19037
+ rmSync14(workDir, { recursive: true, force: true });
18842
19038
  } catch (err) {
18843
19039
  log.warn("[assemble] failed to remove work dir", {
18844
19040
  workDir,
@@ -18900,6 +19096,9 @@ function cfrEncodeArgs(inputArgs, encoder, fpsArg) {
18900
19096
  "-r",
18901
19097
  fpsArg
18902
19098
  ];
19099
+ if (encoder.keyframeIntervalFrames !== void 0)
19100
+ args.push("-g", String(encoder.keyframeIntervalFrames));
19101
+ appendRateCapArgs(args, encoder);
18903
19102
  appendSoftwareEncoderThreadsArg(args, "libx264");
18904
19103
  return args;
18905
19104
  }
@@ -19036,7 +19235,7 @@ function readCfrEncoder(planDir, format) {
19036
19235
  return encoderJson;
19037
19236
  }
19038
19237
  function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, startTimeMs) {
19039
- if (existsSync26(outputPath)) rmSync16(outputPath, { recursive: true, force: true });
19238
+ if (existsSync26(outputPath)) rmSync14(outputPath, { recursive: true, force: true });
19040
19239
  mkdirSync16(outputPath, { recursive: true });
19041
19240
  let globalIdx = 0;
19042
19241
  for (const chunkDir of chunkPaths) {
@@ -19081,7 +19280,7 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
19081
19280
 
19082
19281
  // ../producer/src/services/distributed/renderChunk.ts
19083
19282
  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";
19283
+ import { existsSync as existsSync27, mkdirSync as mkdirSync17, readFileSync as readFileSync14, readdirSync as readdirSync11, rmSync as rmSync15, writeFileSync as writeFileSync13 } from "fs";
19085
19284
  import { cpus as cpus3 } from "os";
19086
19285
  import { join as join41 } from "path";
19087
19286
  var LEGACY_DISTRIBUTED_VP9_CPU_USED = 2;
@@ -19519,7 +19718,9 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
19519
19718
  // first frame is an IDR keyframe and concat-copy at assemble time
19520
19719
  // round-trips losslessly.
19521
19720
  lockGopForChunkConcat: !isPngSequence,
19522
- gopSize: framesInChunk
19721
+ gopSize: chunkGopFrames(framesInChunk, encoder.keyframeIntervalFrames),
19722
+ maxBitrate: encoder.maxBitrate,
19723
+ bufferSize: encoder.bufferSize
19523
19724
  };
19524
19725
  const captureStarted = Date.now();
19525
19726
  captureMode = await runCaptureWithScreenshotFallback({
@@ -19591,7 +19792,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
19591
19792
  return observedChunkCaptureMode(capturePerfs);
19592
19793
  },
19593
19794
  resetForScreenshotRetry: () => {
19594
- rmSync17(workDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
19795
+ rmSync15(workDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
19595
19796
  mkdirSync17(framesDir, { recursive: true });
19596
19797
  capturePerfs.length = 0;
19597
19798
  captureAttempts.length = 0;
@@ -19634,8 +19835,8 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
19634
19835
  fps: { num: plan2.dimensions.fpsNum, den: plan2.dimensions.fpsDen },
19635
19836
  timeoutMs: cfg.ffmpegProcessTimeout
19636
19837
  });
19637
- rmSync17(videoOnlyPath, { force: true });
19638
- rmSync17(audioScratchPath, { force: true });
19838
+ rmSync15(videoOnlyPath, { force: true });
19839
+ rmSync15(audioScratchPath, { force: true });
19639
19840
  }
19640
19841
  encodeStageMs = Date.now() - encodeStarted;
19641
19842
  } finally {
@@ -19685,8 +19886,8 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
19685
19886
  writeFileSync13(perfPath, `${JSON.stringify(perfPayload, null, 2)}
19686
19887
  `, "utf-8");
19687
19888
  try {
19688
- rmSync17(workDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
19689
- rmSync17(videoFramesDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
19889
+ rmSync15(workDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
19890
+ rmSync15(videoFramesDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
19690
19891
  } catch (err) {
19691
19892
  log.warn("[renderChunk] failed to remove work dir", {
19692
19893
  workDir,
@@ -19721,7 +19922,7 @@ async function renderChunkV2(planV2Dir, chunkIndex, outputChunkPath, options) {
19721
19922
  materializePlanV2Target(planV2Dir, { role: "chunk", chunkIndex }, materializedPlanDir);
19722
19923
  return await renderChunk(materializedPlanDir, chunkIndex, outputChunkPath, options);
19723
19924
  } finally {
19724
- rmSync18(workRoot, { recursive: true, force: true });
19925
+ rmSync16(workRoot, { recursive: true, force: true });
19725
19926
  }
19726
19927
  }
19727
19928
  async function assembleV2(planV2Dir, chunkPaths, outputPath, options) {
@@ -19741,7 +19942,7 @@ async function assembleV2(planV2Dir, chunkPaths, outputPath, options) {
19741
19942
  options
19742
19943
  );
19743
19944
  } finally {
19744
- rmSync18(workRoot, { recursive: true, force: true });
19945
+ rmSync16(workRoot, { recursive: true, force: true });
19745
19946
  }
19746
19947
  }
19747
19948