hyperframes 0.8.198 → 0.8.199
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{add-KEYBYC4P.js → add-7LA5CGDM.js} +12 -12
- package/dist/{animatedGifPrep-Z5BJNWKN.js → animatedGifPrep-NB2MZTMQ.js} +6 -6
- package/dist/api.js +14 -14
- package/dist/{asset-I4SWXLQ6.js → asset-4BIOI6GN.js} +2 -2
- package/dist/{assetCataloger-FBZ36VTV.js → assetCataloger-TX5KL5VV.js} +6 -6
- package/dist/{audio-I4Z5PT7P.js → audio-ZGMIIDNU.js} +13 -13
- package/dist/{auth-CKN546QV.js → auth-OQ5PWEUG.js} +1 -1
- package/dist/{autoUpdate-AKOIVDJZ.js → autoUpdate-QREPD6I4.js} +3 -3
- package/dist/{backgroundChecks-5BJIAXAC.js → backgroundChecks-5CJPJX2O.js} +4 -4
- package/dist/backgroundChecksWorker.js +4 -4
- package/dist/{batchRender-QY2RN3J2.js → batchRender-BW2ZK4MA.js} +3 -3
- package/dist/{beats-UEGEBTZ6.js → beats-I5XARMDB.js} +9 -9
- package/dist/{benchmark-BNGEOBEM.js → benchmark-S2WWY4U7.js} +9 -9
- package/dist/{browser-DL2STX2A.js → browser-PAXVQYQZ.js} +4 -4
- package/dist/{bundleWithLocalizedFonts-ULZJ7GHE.js → bundleWithLocalizedFonts-3ED26VCR.js} +2 -2
- package/dist/{capture-UNI6ZOPZ.js → capture-23574YLP.js} +9 -9
- package/dist/{capture-DHYANXXU.js → capture-OVITDMKK.js} +2 -2
- package/dist/{captureCompositionFrame-PS5KDJXF.js → captureCompositionFrame-KAUUHCOL.js} +11 -11
- package/dist/{catalog-UF3CDKXY.js → catalog-CM3VXSQE.js} +12 -12
- package/dist/{catch-up-DIESQDJZ.js → catch-up-HMFREOC2.js} +5 -5
- package/dist/{check-WZ6L42CH.js → check-CYJZ6CGT.js} +34 -34
- package/dist/{checkBrowser-7J6VC7D6.js → checkBrowser-GZJ3W2OP.js} +29 -29
- package/dist/{chunk-MMJ3L4XQ.js → chunk-2KZSKIYY.js} +1 -1
- package/dist/chunk-2ONVJ7NT.js +3901 -0
- package/dist/{chunk-JTTWK6IM.js → chunk-3CFTCM7X.js} +1 -1
- package/dist/{chunk-WA6HZFDD.js → chunk-4QG64APO.js} +2 -2
- package/dist/{chunk-4WDOTQDY.js → chunk-65HUC64P.js} +1 -1
- package/dist/{chunk-JBTNMFFR.js → chunk-6RRO4GE3.js} +1 -1
- package/dist/{chunk-F2ZAINSR.js → chunk-7QB46WTF.js} +1 -1
- package/dist/{chunk-7W7F3KBH.js → chunk-7SKOZHIY.js} +2 -2
- package/dist/{chunk-6NSH5EAO.js → chunk-7YZME6DE.js} +1 -1
- package/dist/{chunk-TXJKDBUB.js → chunk-AHZLNYZY.js} +1 -1
- package/dist/{chunk-ISZK5IJM.js → chunk-BFYDVTD3.js} +1 -1
- package/dist/{chunk-O3KFO66O.js → chunk-BYLC52GJ.js} +1 -1
- package/dist/{chunk-56ZYGITX.js → chunk-CMHVLASW.js} +1 -1
- package/dist/{chunk-2CGWIIPE.js → chunk-D5CZCYYT.js} +2 -2
- package/dist/{chunk-6WZ6HNK2.js → chunk-DMRDGGNM.js} +6 -6
- package/dist/{chunk-GJA6QSSQ.js → chunk-DWUOGV3M.js} +3 -3
- package/dist/{chunk-N4NKPFKQ.js → chunk-FHDKRWQN.js} +54 -16
- package/dist/{chunk-P3ZZD4SK.js → chunk-FV5GKRAO.js} +3 -3
- package/dist/{chunk-OU6YITCR.js → chunk-FZ2VPLXL.js} +2 -2
- package/dist/{chunk-FXDYR644.js → chunk-GQACWAOC.js} +1 -1
- package/dist/{chunk-4UAUXH77.js → chunk-HK45GJMI.js} +648 -422
- package/dist/{chunk-EUZB3ZV3.js → chunk-HOAXHVRR.js} +9 -9
- package/dist/{chunk-MFDZK3X5.js → chunk-HRZ6ZBKO.js} +2 -2
- package/dist/{chunk-YUODO5H2.js → chunk-IC6BO4GU.js} +25 -2
- package/dist/{chunk-FCY375PD.js → chunk-IELYOY6S.js} +3 -3
- package/dist/{chunk-HBPFY3KU.js → chunk-ILFDFMYJ.js} +3 -3
- package/dist/{chunk-5I74DQPC.js → chunk-IMVTN367.js} +2 -2
- package/dist/{chunk-7OFK6XMH.js → chunk-JFIEV2J4.js} +7 -7
- package/dist/{chunk-HVF7K2T3.js → chunk-JN63IPHT.js} +1 -1
- package/dist/{chunk-ESJYD4AE.js → chunk-K5O6JTJQ.js} +5 -5
- package/dist/{chunk-DZWTK3HJ.js → chunk-K65XUUJX.js} +1 -1
- package/dist/{chunk-BPU22WKT.js → chunk-KFZPWUPN.js} +7 -7
- package/dist/{chunk-F2K72QNO.js → chunk-KG3BVLA4.js} +1 -1
- package/dist/{chunk-ZSO7UVC5.js → chunk-L6FG62QM.js} +40 -24
- package/dist/{chunk-JSLQZKXA.js → chunk-LPDNR3R4.js} +2 -2
- package/dist/{chunk-AFQ777YP.js → chunk-M2GO2AAS.js} +1 -1
- package/dist/{chunk-O2CO6QNK.js → chunk-M6IMQBK6.js} +1 -1
- package/dist/{chunk-7FT7E7OU.js → chunk-NUZMP7SV.js} +17 -17
- package/dist/{chunk-2FT5WJPY.js → chunk-NY2OH5XD.js} +1 -1
- package/dist/{chunk-O2SA7HOG.js → chunk-OZVRCLEN.js} +2 -2
- package/dist/{chunk-UBOBOWWB.js → chunk-PO5PAROC.js} +3 -3
- package/dist/{chunk-6NLPPKBO.js → chunk-PSX5SF2N.js} +36 -0
- package/dist/{chunk-6BTMNV3R.js → chunk-QH4425AL.js} +1 -1
- package/dist/{chunk-4V2OO56A.js → chunk-QYOUK3UO.js} +1 -1
- package/dist/{chunk-PKQ3GBDU.js → chunk-RYCANWOM.js} +4 -4
- package/dist/{chunk-DFL4XSQZ.js → chunk-S5WSJVHP.js} +3 -3
- package/dist/{chunk-NDBOBZRL.js → chunk-SQQZUUK6.js} +9 -9
- package/dist/{chunk-UUG3DETI.js → chunk-T4IJMVCB.js} +1 -1
- package/dist/{chunk-C6WBKEOI.js → chunk-TF7LCULS.js} +2 -2
- package/dist/{chunk-ORNE2BC4.js → chunk-TTWFTEUG.js} +5 -5
- package/dist/{chunk-GHO33VCP.js → chunk-TVR744AS.js} +2 -2
- package/dist/{chunk-XIYNIHGQ.js → chunk-UBSAHYWA.js} +2 -2
- package/dist/{chunk-YP5XWK7M.js → chunk-UMBCYIFE.js} +1 -1
- package/dist/{chunk-YEVU5W5G.js → chunk-UVQLSMAR.js} +27 -4
- package/dist/{chunk-256C5DYC.js → chunk-VWPU6URV.js} +5 -5
- package/dist/{chunk-U66P7HPN.js → chunk-XP55QWOB.js} +13 -13
- package/dist/{chunk-UMCU32QC.js → chunk-XVZZQVT4.js} +1 -1
- package/dist/{chunk-WY67Q2QY.js → chunk-YAMRODVV.js} +3 -2
- package/dist/{chunk-Y2I7KT2R.js → chunk-Z6Q4ASCD.js} +107 -44
- package/dist/{clean-2W5OGTMI.js → clean-QX6LKOWJ.js} +15 -15
- package/dist/cli.js +54 -54
- package/dist/{cloud-AJK5OLJM.js → cloud-ASA7Y3HA.js} +4 -4
- package/dist/{cloudrun-HAAYNZWP.js → cloudrun-LK4GJWUZ.js} +4 -4
- package/dist/{compare-KRY3JTXM.js → compare-426Z2ND6.js} +26 -26
- package/dist/{compiler-47QXFQF4.js → compiler-WER7FC5O.js} +3 -3
- package/dist/{component-XQR75LCM.js → component-HTDWZMEG.js} +3 -3
- package/dist/{compositions-QJZQZJFB.js → compositions-EKRLQ5TU.js} +11 -11
- package/dist/{delete-PPOMPFZG.js → delete-KHXM6R7A.js} +3 -3
- package/dist/{deploy-IKVAHO42.js → deploy-WJ5JQJBD.js} +1 -1
- package/dist/{dist-JBRYL3MH.js → dist-EYJATCTF.js} +2 -2
- package/dist/{dist-XPD7X6JB.js → dist-ONHJ6ZDA.js} +1 -1
- package/dist/{doctor-TM2B4PLJ.js → doctor-NB3G2GDG.js} +11 -11
- package/dist/{events-UFQAFJ7A.js → events-6EL5NIJV.js} +3 -3
- package/dist/{events-QERYXJVB.js → events-LH6W5ZCV.js} +4 -4
- package/dist/{feedback-X6GA5Z2Y.js → feedback-2GNY725M.js} +7 -7
- package/dist/{ffmpeg-G6RMIP5K.js → ffmpeg-XX3O53B3.js} +6 -6
- package/dist/{figma-WAM4RJUC.js → figma-X7KKOOXB.js} +3 -3
- package/dist/fontLocalizeCli.js +8 -8
- package/dist/{get-7TO44JK3.js → get-M57U7QCX.js} +3 -3
- package/dist/{gpuPolicy-IMLRNUEJ.js → gpuPolicy-GIBBYBI5.js} +6 -6
- package/dist/{grade-compare-TCUAQKW4.js → grade-compare-XNY37UYQ.js} +27 -27
- package/dist/{help-GSPNIWE2.js → help-ZXSPZBUG.js} +1 -1
- package/dist/{history-SFC4KDFT.js → history-G5B4IPBH.js} +7 -7
- package/dist/hyperframe.manifest.json +1 -1
- package/dist/hyperframe.runtime.iife.js +59 -59
- package/dist/hyperframes-player.global.js +1 -1
- package/dist/{info-YBSWR4VE.js → info-ZWZDG54W.js} +8 -8
- package/dist/{init-RJCZWSTH.js → init-F4XMU6SV.js} +27 -27
- package/dist/{inspect-R6C5Q7WI.js → inspect-6VXFMQRR.js} +27 -27
- package/dist/{installer-BJQSDYHE.js → installer-4M3Y5T5F.js} +4 -4
- package/dist/{keyframes-UJOV3QTF.js → keyframes-3U466AWX.js} +7 -7
- package/dist/{lambda-645URVF4.js → lambda-OPSTAEF6.js} +6 -6
- package/dist/{layout-MPGHNIY6.js → layout-B3MXD3F3.js} +27 -27
- package/dist/{lint-BWYP7H5P.js → lint-TVOEGW63.js} +8 -8
- package/dist/{lintProject-Q4ZVEF3G.js → lintProject-FKPKSU6M.js} +1 -1
- package/dist/{list-YBOALPIY.js → list-M5GQSFVT.js} +3 -3
- package/dist/{login-Z3JYXJKB.js → login-HBHGZIDN.js} +4 -4
- package/dist/{manager-CCRWUMQO.js → manager-VLIJARMF.js} +7 -7
- package/dist/{media-treatment-4P54XYM7.js → media-treatment-RQZ437VS.js} +13 -13
- package/dist/{models-3LIZKQPH.js → models-2CCKVBTR.js} +10 -10
- package/dist/{motionShot-22NRFNLM.js → motionShot-3IFRSICA.js} +14 -14
- package/dist/{normalize-audio-C6JTJBZE.js → normalize-audio-23H2MBDP.js} +5 -5
- package/dist/{open-5KOE2UWD.js → open-J33KT3G7.js} +12 -12
- package/dist/{parakeetRunner-67JLWWPE.js → parakeetRunner-QTXNEMVY.js} +11 -11
- package/dist/{pipeline-QZQRLXSV.js → pipeline-2ECWWEBD.js} +7 -7
- package/dist/{play-ID4KS6LH.js → play-G5777L7A.js} +18 -18
- package/dist/{preflight-DVW7XWEO.js → preflight-NVFB4HXQ.js} +7 -7
- package/dist/{present-CDJCTLFJ.js → present-4EI2BE4Z.js} +14 -14
- package/dist/{preview-KDMHWG3L.js → preview-HYCIDZ52.js} +18 -18
- package/dist/{producer-QPUWC6S3.js → producer-6JAATJVD.js} +1 -1
- package/dist/{projectConfig-VMVZXMC6.js → projectConfig-XPGN76VV.js} +6 -6
- package/dist/{publication-VBXDWVC7.js → publication-YRZ7EBUV.js} +2 -2
- package/dist/{publish-XDNOVFIZ.js → publish-UIDHN7KD.js} +8 -8
- package/dist/{remove-background-OQUEVC4I.js → remove-background-LPQP4WBN.js} +8 -8
- package/dist/{render-MMEZAOL7.js → render-DT3OCUCV.js} +117 -37
- package/dist/{render-2MVVITHT.js → render-LFJQNVCK.js} +5 -5
- package/dist/{render-L5DUPSDJ.js → render-NZSNQFYW.js} +14 -14
- package/dist/{render-batch-EZRFUUHG.js → render-batch-QI2A45WH.js} +5 -5
- package/dist/renderSetupWorker.js +1 -1
- package/dist/{resolver-E6OFNCLG.js → resolver-4YDXG4PP.js} +4 -4
- package/dist/{sherpa-MQUVKCRX.js → sherpa-XLKWFYFO.js} +10 -10
- package/dist/skills/media-use/references/mixing.md +1 -0
- package/dist/{skills-Y7AATMSQ.js → skills-OVVLZHF5.js} +6 -6
- package/dist/{skillsUpdateCheck-K7DSQJGU.js → skillsUpdateCheck-Y2UQA7I5.js} +4 -4
- package/dist/{snapshot-DZWLAQAW.js → snapshot-7NVB5WSO.js} +31 -31
- package/dist/{src-RRTSNZLM.js → src-ACAFJXAJ.js} +7 -7
- package/dist/{src-7FSQZKIY.js → src-QQPHMIJ7.js} +5 -5
- package/dist/{staticProjectServer-J2IXFINI.js → staticProjectServer-JUN6BRTW.js} +14 -14
- package/dist/studio/assets/{hyperframes-player-DDoxfTBd.js → hyperframes-player-BDtBfwof.js} +1 -1
- package/dist/studio/assets/{index-D9WoRF2S.js → index--W_0fuR8.js} +1 -1
- package/dist/studio/assets/{index-BAKWbo0z.js → index-BFfBBQMu.js} +4 -4
- package/dist/studio/index.html +1 -1
- package/dist/{studio-api-7BNDWZG5.js → studio-api-D76Q4Q2N.js} +7 -7
- package/dist/{studioServer-FBRUE3XK.js → studioServer-HG3RFAOY.js} +45 -45
- package/dist/{telemetry-4K6CPMNT.js → telemetry-IHU4HL3R.js} +1 -1
- package/dist/{telemetry-OOQVUJGL.js → telemetry-Q2EHWVO4.js} +4 -4
- package/dist/{timeline-U6MIU6JP.js → timeline-WDQCCETQ.js} +16 -16
- package/dist/{tokens-3ZPX6WKB.js → tokens-2GJWP2HY.js} +2 -2
- package/dist/{transcribe-VPGQV5TG.js → transcribe-SRLAY6RG.js} +9 -9
- package/dist/{transcribe-QDBXRADM.js → transcribe-Z63Y53GQ.js} +16 -16
- package/dist/{updateCheck-MN3QTSGM.js → updateCheck-MJ6NDE3T.js} +3 -3
- package/dist/{upgrade-4FVRTMU5.js → upgrade-D5XEX3XE.js} +3 -3
- package/dist/{urlDownloader-UTVBU5IQ.js → urlDownloader-R7BZ47TY.js} +5 -5
- package/dist/{validate-NN43T4XX.js → validate-F5BIDZLN.js} +21 -21
- package/dist/{video-VQ67QXES.js → video-QUG5OG5Q.js} +6 -6
- package/dist/warmCheck.js +34 -34
- package/package.json +1 -1
- package/dist/chunk-UYBXHV7R.js +0 -3901
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
EncoderInterruptedError,
|
|
9
9
|
encoderFailureError,
|
|
10
10
|
prepareAnimatedGifInputs
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-7SKOZHIY.js";
|
|
12
12
|
import {
|
|
13
13
|
GENERIC_FAMILIES,
|
|
14
14
|
collectFontFamilyCustomProperties,
|
|
@@ -161,7 +161,7 @@ import {
|
|
|
161
161
|
verifyDiskDrawElementSamples,
|
|
162
162
|
videoAudioId,
|
|
163
163
|
writeCapturedFrame
|
|
164
|
-
} from "./chunk-
|
|
164
|
+
} from "./chunk-L6FG62QM.js";
|
|
165
165
|
import {
|
|
166
166
|
DISTRIBUTED_FPS,
|
|
167
167
|
HF_VFX_ATTR,
|
|
@@ -177,7 +177,7 @@ import {
|
|
|
177
177
|
parseVfxChain,
|
|
178
178
|
resolveAuthoredTimingWindow,
|
|
179
179
|
toFps
|
|
180
|
-
} from "./chunk-
|
|
180
|
+
} from "./chunk-UVQLSMAR.js";
|
|
181
181
|
import {
|
|
182
182
|
assignBundledRuntimeCompositionIds,
|
|
183
183
|
buildVariablesByCompScript,
|
|
@@ -189,7 +189,7 @@ import {
|
|
|
189
189
|
inlineSubCompositions,
|
|
190
190
|
parsesAsScript,
|
|
191
191
|
prepareFlattenedInnerRoot
|
|
192
|
-
} from "./chunk-
|
|
192
|
+
} from "./chunk-HRZ6ZBKO.js";
|
|
193
193
|
import {
|
|
194
194
|
COMPOSITION_SOURCE_URL,
|
|
195
195
|
HF_COLOR_GRADING_ATTR,
|
|
@@ -220,7 +220,7 @@ import {
|
|
|
220
220
|
sourceTimeAt,
|
|
221
221
|
styleElementsFor,
|
|
222
222
|
timeAtSourceTime
|
|
223
|
-
} from "./chunk-
|
|
223
|
+
} from "./chunk-2ONVJ7NT.js";
|
|
224
224
|
import {
|
|
225
225
|
MAX_AUDIO_GAIN
|
|
226
226
|
} from "./chunk-X7HBSTCZ.js";
|
|
@@ -250,7 +250,7 @@ import {
|
|
|
250
250
|
import {
|
|
251
251
|
lintHyperframeHtml,
|
|
252
252
|
resolveReferencedStart
|
|
253
|
-
} from "./chunk-
|
|
253
|
+
} from "./chunk-IC6BO4GU.js";
|
|
254
254
|
import {
|
|
255
255
|
isUnresolvedAssetPlaceholder,
|
|
256
256
|
readProjectFile,
|
|
@@ -290,14 +290,14 @@ import {
|
|
|
290
290
|
mkdirSync as mkdirSync8,
|
|
291
291
|
readFileSync as readFileSync7,
|
|
292
292
|
readdirSync as readdirSync5,
|
|
293
|
-
rmSync as
|
|
294
|
-
statSync as
|
|
293
|
+
rmSync as rmSync10,
|
|
294
|
+
statSync as statSync6,
|
|
295
295
|
writeFileSync as writeFileSync5,
|
|
296
296
|
copyFileSync as copyFileSync3,
|
|
297
297
|
appendFileSync
|
|
298
298
|
} from "fs";
|
|
299
299
|
import { tmpdir as tmpdir2 } from "os";
|
|
300
|
-
import { join as
|
|
300
|
+
import { join as join25, dirname as dirname9, resolve as resolve6 } from "path";
|
|
301
301
|
import { totalmem as totalmem2 } from "os";
|
|
302
302
|
import { randomUUID } from "crypto";
|
|
303
303
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
@@ -2094,8 +2094,8 @@ function replanAfterFailure(plan2, failure) {
|
|
|
2094
2094
|
}
|
|
2095
2095
|
|
|
2096
2096
|
// ../producer/src/services/render/stages/captureSegmentedStage.ts
|
|
2097
|
-
import { existsSync as existsSync6, mkdirSync as mkdirSync3, rmSync as
|
|
2098
|
-
import { join as
|
|
2097
|
+
import { existsSync as existsSync6, mkdirSync as mkdirSync3, rmSync as rmSync6, statSync as statSync3 } from "fs";
|
|
2098
|
+
import { join as join10 } from "path";
|
|
2099
2099
|
|
|
2100
2100
|
// ../producer/src/services/render/perfSummary.ts
|
|
2101
2101
|
import { arch, cpus, platform, totalmem } from "os";
|
|
@@ -2453,7 +2453,7 @@ function getCaptureStageBrowserConsole(error) {
|
|
|
2453
2453
|
}
|
|
2454
2454
|
|
|
2455
2455
|
// ../producer/src/services/hdrCompositor.ts
|
|
2456
|
-
import { readSync as readSync2
|
|
2456
|
+
import { readSync as readSync2 } from "fs";
|
|
2457
2457
|
import { join as join6 } from "path";
|
|
2458
2458
|
function countNonZeroAlpha(rgba) {
|
|
2459
2459
|
let n = 0;
|
|
@@ -2493,10 +2493,10 @@ function cropRgb48le(src, srcW, srcH, cropX, cropY, cropW, cropH) {
|
|
|
2493
2493
|
}
|
|
2494
2494
|
function closeHdrVideoFrameSource(source, log) {
|
|
2495
2495
|
try {
|
|
2496
|
-
|
|
2496
|
+
source.windows.close();
|
|
2497
2497
|
} catch (err) {
|
|
2498
|
-
log?.warn("Failed to close HDR raw frame
|
|
2499
|
-
|
|
2498
|
+
log?.warn("Failed to close HDR raw frame windows", {
|
|
2499
|
+
dir: source.dir,
|
|
2500
2500
|
error: err instanceof Error ? err.message : String(err)
|
|
2501
2501
|
});
|
|
2502
2502
|
}
|
|
@@ -2506,7 +2506,7 @@ function resolveHdrVideoFrameIndex(time, startTime, fps, frameCount, loop = fals
|
|
|
2506
2506
|
if (frameIndex < 0 || frameCount < 1) return null;
|
|
2507
2507
|
return loop ? frameIndex % frameCount : Math.min(frameIndex, frameCount - 1);
|
|
2508
2508
|
}
|
|
2509
|
-
function blitHdrVideoLayer(canvas, el, time, fps, hdrVideoFrameSources, hdrStartTimes, width, height, log, sourceTransfer, targetTransfer, hdrPerf) {
|
|
2509
|
+
async function blitHdrVideoLayer(canvas, el, time, fps, hdrVideoFrameSources, hdrStartTimes, width, height, log, sourceTransfer, targetTransfer, hdrPerf) {
|
|
2510
2510
|
const frameSource = hdrVideoFrameSources.get(el.id);
|
|
2511
2511
|
const startTime = hdrStartTimes.get(el.id);
|
|
2512
2512
|
if (!frameSource || startTime === void 0 || el.opacity <= 0) {
|
|
@@ -2522,13 +2522,32 @@ function blitHdrVideoLayer(canvas, el, time, fps, hdrVideoFrameSources, hdrStart
|
|
|
2522
2522
|
if (effectiveIndex === null) return;
|
|
2523
2523
|
const mediaTime = (frameSource.mediaStart ?? 0) + effectiveIndex / fps;
|
|
2524
2524
|
if (isVideoHiddenBeforeStreamStart(frameSource.videoStreamLeadSeconds, mediaTime)) return;
|
|
2525
|
-
|
|
2525
|
+
if (hdrPerf) hdrPerf.hdrVideoLayerBlits += 1;
|
|
2526
|
+
const lease = await frameSource.windows.lease(effectiveIndex);
|
|
2527
|
+
if (!lease) return;
|
|
2528
|
+
try {
|
|
2529
|
+
blitScratchFrameWithoutYielding(
|
|
2530
|
+
canvas,
|
|
2531
|
+
el,
|
|
2532
|
+
frameSource,
|
|
2533
|
+
lease,
|
|
2534
|
+
width,
|
|
2535
|
+
height,
|
|
2536
|
+
log,
|
|
2537
|
+
sourceTransfer,
|
|
2538
|
+
targetTransfer,
|
|
2539
|
+
hdrPerf
|
|
2540
|
+
);
|
|
2541
|
+
} finally {
|
|
2542
|
+
lease.release();
|
|
2543
|
+
}
|
|
2544
|
+
}
|
|
2545
|
+
function blitScratchFrameWithoutYielding(canvas, el, frameSource, lease, width, height, log, sourceTransfer, targetTransfer, hdrPerf) {
|
|
2526
2546
|
try {
|
|
2527
|
-
if (hdrPerf) hdrPerf.hdrVideoLayerBlits += 1;
|
|
2528
2547
|
const bytesRead = timeHdrPhase(
|
|
2529
2548
|
hdrPerf,
|
|
2530
2549
|
"hdrVideoReadDecodeMs",
|
|
2531
|
-
() => readSync2(
|
|
2550
|
+
() => readSync2(lease.fd, frameSource.scratch, 0, frameSource.frameSize, lease.offset)
|
|
2532
2551
|
);
|
|
2533
2552
|
if (bytesRead !== frameSource.frameSize) return;
|
|
2534
2553
|
const hdrRgb = frameSource.scratch;
|
|
@@ -2757,7 +2776,7 @@ async function compositeHdrFrame(ctx, canvas, time, fullStacking, elementFilter,
|
|
|
2757
2776
|
hdrPerf
|
|
2758
2777
|
);
|
|
2759
2778
|
} else {
|
|
2760
|
-
blitHdrVideoLayer(
|
|
2779
|
+
await blitHdrVideoLayer(
|
|
2761
2780
|
canvas,
|
|
2762
2781
|
layer.element,
|
|
2763
2782
|
time,
|
|
@@ -2801,7 +2820,7 @@ async function compositeHdrFrame(ctx, canvas, time, fullStacking, elementFilter,
|
|
|
2801
2820
|
startTime,
|
|
2802
2821
|
localTime: localTime.toFixed(3),
|
|
2803
2822
|
hdrFrameNum: frameNum,
|
|
2804
|
-
|
|
2823
|
+
dir: frameSource?.dir ?? null,
|
|
2805
2824
|
frameCount: frameSource?.frameCount ?? null
|
|
2806
2825
|
});
|
|
2807
2826
|
}
|
|
@@ -2897,19 +2916,92 @@ async function compositeHdrFrame(ctx, canvas, time, fullStacking, elementFilter,
|
|
|
2897
2916
|
}
|
|
2898
2917
|
|
|
2899
2918
|
// ../producer/src/services/render/stages/captureHdrResources.ts
|
|
2900
|
-
import {
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
mkdtempSync as mkdtempSync2,
|
|
2906
|
-
openSync as openSync3,
|
|
2907
|
-
readFileSync as readFileSync3,
|
|
2908
|
-
rmSync as rmSync4,
|
|
2909
|
-
statfsSync
|
|
2910
|
-
} from "fs";
|
|
2919
|
+
import { mkdirSync as mkdirSync2, mkdtempSync as mkdtempSync2, readFileSync as readFileSync3, rmSync as rmSync5, statSync as statSync2, statfsSync } from "fs";
|
|
2920
|
+
import { join as join8 } from "path";
|
|
2921
|
+
|
|
2922
|
+
// ../producer/src/services/hdrFrameWindows.ts
|
|
2923
|
+
import { closeSync as closeSync3, constants as constants2, openSync as openSync3, rmSync as rmSync4 } from "fs";
|
|
2911
2924
|
import { join as join7 } from "path";
|
|
2912
|
-
|
|
2925
|
+
function createHdrFrameWindows(opts) {
|
|
2926
|
+
const { dir, frameSize, windowFrames, maxResident, extract } = opts;
|
|
2927
|
+
let totalFrames = opts.totalFrames;
|
|
2928
|
+
const windows = /* @__PURE__ */ new Map();
|
|
2929
|
+
const drop = (index, w) => {
|
|
2930
|
+
windows.delete(index);
|
|
2931
|
+
if (w.fd >= 0) closeSync3(w.fd);
|
|
2932
|
+
rmSync4(w.path, { force: true });
|
|
2933
|
+
};
|
|
2934
|
+
const open2 = (index) => {
|
|
2935
|
+
const known = windows.get(index);
|
|
2936
|
+
if (known) {
|
|
2937
|
+
windows.delete(index);
|
|
2938
|
+
windows.set(index, known);
|
|
2939
|
+
return known;
|
|
2940
|
+
}
|
|
2941
|
+
for (const [i, w2] of windows) {
|
|
2942
|
+
if (windows.size < maxResident) break;
|
|
2943
|
+
if (w2.pins === 0) drop(i, w2);
|
|
2944
|
+
}
|
|
2945
|
+
const firstFrame = index * windowFrames;
|
|
2946
|
+
const w = {
|
|
2947
|
+
firstFrame,
|
|
2948
|
+
path: join7(dir, `window-${index}.rgb48le`),
|
|
2949
|
+
frames: 0,
|
|
2950
|
+
fd: -1,
|
|
2951
|
+
pins: 0,
|
|
2952
|
+
ready: Promise.resolve()
|
|
2953
|
+
};
|
|
2954
|
+
w.ready = extract({
|
|
2955
|
+
firstFrame,
|
|
2956
|
+
frames: Math.min(windowFrames, totalFrames - firstFrame),
|
|
2957
|
+
path: w.path
|
|
2958
|
+
}).then((produced) => {
|
|
2959
|
+
if (produced < 1) return;
|
|
2960
|
+
w.fd = openSync3(w.path, constants2.O_RDONLY | (constants2.O_NOFOLLOW ?? 0));
|
|
2961
|
+
w.frames = produced;
|
|
2962
|
+
});
|
|
2963
|
+
windows.set(index, w);
|
|
2964
|
+
return w;
|
|
2965
|
+
};
|
|
2966
|
+
return {
|
|
2967
|
+
get totalFrames() {
|
|
2968
|
+
return totalFrames;
|
|
2969
|
+
},
|
|
2970
|
+
async lease(frameIndex) {
|
|
2971
|
+
for (; ; ) {
|
|
2972
|
+
if (totalFrames < 1) return null;
|
|
2973
|
+
const index = Math.min(Math.max(0, frameIndex), totalFrames - 1);
|
|
2974
|
+
const key = Math.floor(index / windowFrames);
|
|
2975
|
+
const w = open2(key);
|
|
2976
|
+
w.pins += 1;
|
|
2977
|
+
try {
|
|
2978
|
+
await w.ready;
|
|
2979
|
+
} catch (error) {
|
|
2980
|
+
w.pins -= 1;
|
|
2981
|
+
windows.delete(key);
|
|
2982
|
+
throw error;
|
|
2983
|
+
}
|
|
2984
|
+
const local = index - w.firstFrame;
|
|
2985
|
+
if (local < w.frames) {
|
|
2986
|
+
return {
|
|
2987
|
+
fd: w.fd,
|
|
2988
|
+
offset: local * frameSize,
|
|
2989
|
+
release: () => {
|
|
2990
|
+
w.pins -= 1;
|
|
2991
|
+
}
|
|
2992
|
+
};
|
|
2993
|
+
}
|
|
2994
|
+
w.pins -= 1;
|
|
2995
|
+
totalFrames = Math.min(totalFrames, w.firstFrame + w.frames);
|
|
2996
|
+
}
|
|
2997
|
+
},
|
|
2998
|
+
close() {
|
|
2999
|
+
for (const [i, w] of [...windows]) drop(i, w);
|
|
3000
|
+
}
|
|
3001
|
+
};
|
|
3002
|
+
}
|
|
3003
|
+
|
|
3004
|
+
// ../producer/src/services/render/stages/captureHdrResources.ts
|
|
2913
3005
|
function tempDirSafePrefix(id) {
|
|
2914
3006
|
const safe = id.replace(/[^A-Za-z0-9_.-]/g, "_").slice(0, 80);
|
|
2915
3007
|
return safe || "video";
|
|
@@ -2954,10 +3046,16 @@ async function probeHdrExtractionDims(args) {
|
|
|
2954
3046
|
const stacking = await queryElementStacking(domSession.page, nativeHdrIds);
|
|
2955
3047
|
for (const el of stacking) {
|
|
2956
3048
|
if (el.isHdr && el.layoutWidth > 0 && el.layoutHeight > 0 && !prep.hdrExtractionDims.has(el.id)) {
|
|
2957
|
-
prep.hdrExtractionDims.set(el.id, {
|
|
3049
|
+
prep.hdrExtractionDims.set(el.id, {
|
|
3050
|
+
width: el.layoutWidth,
|
|
3051
|
+
height: el.layoutHeight
|
|
3052
|
+
});
|
|
2958
3053
|
}
|
|
2959
3054
|
if (el.isHdr && nativeHdrImageIds.has(el.id) && !prep.hdrImageFitInfo.has(el.id)) {
|
|
2960
|
-
prep.hdrImageFitInfo.set(el.id, {
|
|
3055
|
+
prep.hdrImageFitInfo.set(el.id, {
|
|
3056
|
+
fit: el.objectFit,
|
|
3057
|
+
position: el.objectPosition
|
|
3058
|
+
});
|
|
2961
3059
|
}
|
|
2962
3060
|
}
|
|
2963
3061
|
}
|
|
@@ -2976,23 +3074,21 @@ async function probeHdrExtractionDims(args) {
|
|
|
2976
3074
|
const retryStacking = await queryElementStacking(domSession.page, nativeHdrIds);
|
|
2977
3075
|
for (const el of retryStacking) {
|
|
2978
3076
|
if (el.id === imageId && el.isHdr && el.layoutWidth > 0 && el.layoutHeight > 0) {
|
|
2979
|
-
prep.hdrExtractionDims.set(el.id, {
|
|
3077
|
+
prep.hdrExtractionDims.set(el.id, {
|
|
3078
|
+
width: el.layoutWidth,
|
|
3079
|
+
height: el.layoutHeight
|
|
3080
|
+
});
|
|
2980
3081
|
if (!prep.hdrImageFitInfo.has(el.id)) {
|
|
2981
|
-
prep.hdrImageFitInfo.set(el.id, {
|
|
3082
|
+
prep.hdrImageFitInfo.set(el.id, {
|
|
3083
|
+
fit: el.objectFit,
|
|
3084
|
+
position: el.objectPosition
|
|
3085
|
+
});
|
|
2982
3086
|
}
|
|
2983
3087
|
break;
|
|
2984
3088
|
}
|
|
2985
3089
|
}
|
|
2986
3090
|
}
|
|
2987
3091
|
}
|
|
2988
|
-
function estimateHdrExtractionBytes(videos, fps) {
|
|
2989
|
-
let total = 0;
|
|
2990
|
-
for (const v of videos) {
|
|
2991
|
-
const frames = Math.ceil(Math.max(0, v.durationSeconds) * fps);
|
|
2992
|
-
total += frames * v.width * v.height * 6;
|
|
2993
|
-
}
|
|
2994
|
-
return total;
|
|
2995
|
-
}
|
|
2996
3092
|
var HDR_EXTRACTION_HEADROOM_FRACTION = 0.9;
|
|
2997
3093
|
var HDR_EXTRACTION_CGROUP_BUDGET_FRACTION = 0.5;
|
|
2998
3094
|
var HDR_EXTRACTION_WARN_BYTES = 1e10;
|
|
@@ -3056,24 +3152,22 @@ function resolveHdrExtractionWindow(video, compositionDuration, metadata) {
|
|
|
3056
3152
|
}
|
|
3057
3153
|
return window2;
|
|
3058
3154
|
}
|
|
3059
|
-
function cleanupHdrFrameDirectory(frameDir,
|
|
3155
|
+
function cleanupHdrFrameDirectory(frameDir, log) {
|
|
3060
3156
|
if (process.env.KEEP_TEMP === "1") return;
|
|
3061
3157
|
try {
|
|
3062
|
-
|
|
3158
|
+
rmSync5(frameDir, { recursive: true, force: true });
|
|
3063
3159
|
} catch (err) {
|
|
3064
3160
|
log?.warn("Failed to clean up HDR raw frame directory", {
|
|
3065
3161
|
frameDir,
|
|
3066
|
-
rawPath,
|
|
3067
3162
|
error: err instanceof Error ? err.message : String(err)
|
|
3068
3163
|
});
|
|
3069
3164
|
}
|
|
3070
3165
|
}
|
|
3071
3166
|
function cleanupHdrVideoFrameSource(source, log) {
|
|
3072
3167
|
closeHdrVideoFrameSource(source, log);
|
|
3073
|
-
cleanupHdrFrameDirectory(source.dir,
|
|
3168
|
+
cleanupHdrFrameDirectory(source.dir, log);
|
|
3074
3169
|
}
|
|
3075
|
-
function assertHdrExtractionDiskHeadroom(framesDir,
|
|
3076
|
-
const estimatedBytes = estimateHdrExtractionBytes(plannedVideos, fps);
|
|
3170
|
+
function assertHdrExtractionDiskHeadroom(framesDir, estimatedBytes, log) {
|
|
3077
3171
|
const configuredBudget = resolveHdrExtractionBudgetBytes(
|
|
3078
3172
|
process.env[HDR_EXTRACTION_MAX_BYTES_ENV]
|
|
3079
3173
|
);
|
|
@@ -3107,14 +3201,29 @@ function assertHdrExtractionDiskHeadroom(framesDir, plannedVideos, fps, log) {
|
|
|
3107
3201
|
budgetBytes: resolveHdrExtractionActiveBudgetBytes(configuredBudget, freeBytes)
|
|
3108
3202
|
};
|
|
3109
3203
|
}
|
|
3204
|
+
var DEFAULT_HDR_WINDOW_BYTES = 512 * BYTES_PER_MIB;
|
|
3205
|
+
function hdrWindowFrames(frameSize, windowBytes) {
|
|
3206
|
+
return Math.max(8, Math.floor(windowBytes / frameSize));
|
|
3207
|
+
}
|
|
3208
|
+
async function probeFirstTick(srcPath, mediaStart, fps, runFfmpegImpl, abortSignal) {
|
|
3209
|
+
const args = ["-ss", String(mediaStart), "-i", srcPath, "-frames:v", "1"];
|
|
3210
|
+
const result = await runFfmpegImpl([...args, ...["-vf", "showinfo", "-f", "null", "-"]], {
|
|
3211
|
+
signal: abortSignal
|
|
3212
|
+
});
|
|
3213
|
+
const match = /pts_time:(-?[\d.]+)/.exec(result.stderr);
|
|
3214
|
+
return match ? Math.max(0, Math.floor(Number(match[1]) * fps + 0.5)) : 0;
|
|
3215
|
+
}
|
|
3110
3216
|
async function extractHdrVideoFrames(args) {
|
|
3111
3217
|
const { job, log, framesDir, composition, prep, width, height, abortSignal, hdrDiagnostics } = args;
|
|
3218
|
+
const maxResident = Math.max(2, args.maxResidentWindows ?? 2);
|
|
3219
|
+
const windowBytes = args.windowBytes ?? DEFAULT_HDR_WINDOW_BYTES;
|
|
3112
3220
|
const runFfmpegImpl = args.runFfmpegImpl ?? runFfmpeg;
|
|
3113
3221
|
const extractMediaMetadataImpl = args.extractMediaMetadataImpl ?? extractMediaMetadata;
|
|
3114
3222
|
const resolveFinalFrameExtractionWindowImpl = args.resolveFinalFrameExtractionWindowImpl ?? resolveFinalFrameExtractionWindow;
|
|
3223
|
+
const fps = fpsToNumber(job.config.fps);
|
|
3115
3224
|
const out = /* @__PURE__ */ new Map();
|
|
3116
3225
|
mkdirSync2(framesDir, { recursive: true });
|
|
3117
|
-
|
|
3226
|
+
let scratchBytes = 0;
|
|
3118
3227
|
const extractionWindows = /* @__PURE__ */ new Map();
|
|
3119
3228
|
for (const [videoId, srcPath] of prep.hdrVideoSrcPaths) {
|
|
3120
3229
|
const video = composition.videos.find((v) => v.id === videoId);
|
|
@@ -3135,16 +3244,13 @@ async function extractHdrVideoFrames(args) {
|
|
|
3135
3244
|
videoStreamLeadSeconds: metadata.videoStreamLeadSeconds
|
|
3136
3245
|
});
|
|
3137
3246
|
prep.hdrVideoStartTimes.set(videoId, window2.compositionStart);
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
height: dims.height
|
|
3142
|
-
});
|
|
3247
|
+
const frameSize = dims.width * dims.height * 6;
|
|
3248
|
+
const frames = window2.finalFrameOnly ? 1 : Math.ceil(window2.durationSeconds * fps);
|
|
3249
|
+
scratchBytes += Math.min(frames, maxResident * hdrWindowFrames(frameSize, windowBytes)) * frameSize;
|
|
3143
3250
|
}
|
|
3144
3251
|
const { estimatedBytes, budgetBytes } = assertHdrExtractionDiskHeadroom(
|
|
3145
3252
|
framesDir,
|
|
3146
|
-
|
|
3147
|
-
fpsToNumber(job.config.fps),
|
|
3253
|
+
scratchBytes,
|
|
3148
3254
|
log
|
|
3149
3255
|
);
|
|
3150
3256
|
const releaseReservation = reserveHdrExtractionBytes(estimatedBytes, budgetBytes);
|
|
@@ -3156,79 +3262,79 @@ async function extractHdrVideoFrames(args) {
|
|
|
3156
3262
|
if (!video || !planned) continue;
|
|
3157
3263
|
const { window: window2 } = planned;
|
|
3158
3264
|
mkdirSync2(framesDir, { recursive: true });
|
|
3159
|
-
const frameDir = mkdtempSync2(
|
|
3265
|
+
const frameDir = mkdtempSync2(join8(framesDir, `hdr_${tempDirSafePrefix(videoId)}-`));
|
|
3160
3266
|
createdFrameDirs.add(frameDir);
|
|
3161
3267
|
const dims = prep.hdrExtractionDims.get(videoId) ?? { width, height };
|
|
3162
|
-
const rawPath = join7(frameDir, "frames.rgb48le");
|
|
3163
|
-
const extractionMediaStart = window2.extractionMediaStart ?? window2.mediaStart;
|
|
3164
|
-
const extractionStart = String(extractionMediaStart);
|
|
3165
|
-
const ffmpegArgs = [];
|
|
3166
|
-
if (window2.finalFrameOnly) {
|
|
3167
|
-
ffmpegArgs.push("-i", srcPath, "-ss", extractionStart, "-frames:v", "1");
|
|
3168
|
-
} else {
|
|
3169
|
-
ffmpegArgs.push(
|
|
3170
|
-
"-ss",
|
|
3171
|
-
extractionStart,
|
|
3172
|
-
"-i",
|
|
3173
|
-
srcPath,
|
|
3174
|
-
"-t",
|
|
3175
|
-
String(window2.durationSeconds)
|
|
3176
|
-
);
|
|
3177
|
-
}
|
|
3178
|
-
if (!window2.finalFrameOnly) {
|
|
3179
|
-
ffmpegArgs.push("-r", fpsToFfmpegArg(job.config.fps));
|
|
3180
|
-
}
|
|
3181
|
-
ffmpegArgs.push(
|
|
3182
|
-
"-vf",
|
|
3183
|
-
`scale=${dims.width}:${dims.height}:force_original_aspect_ratio=increase,crop=${dims.width}:${dims.height}`,
|
|
3184
|
-
"-pix_fmt",
|
|
3185
|
-
"rgb48le",
|
|
3186
|
-
"-f",
|
|
3187
|
-
"rawvideo",
|
|
3188
|
-
"-y",
|
|
3189
|
-
rawPath
|
|
3190
|
-
);
|
|
3191
|
-
const result = await runFfmpegImpl(ffmpegArgs, { signal: abortSignal });
|
|
3192
|
-
if (!result.success) {
|
|
3193
|
-
hdrDiagnostics.videoExtractionFailures += 1;
|
|
3194
|
-
log.error("HDR frame pre-extraction failed; aborting render", {
|
|
3195
|
-
videoId,
|
|
3196
|
-
srcPath,
|
|
3197
|
-
stderr: result.stderr.slice(-400)
|
|
3198
|
-
});
|
|
3199
|
-
throw encoderFailureError(`HDR frame extraction failed for video "${videoId}"`, {
|
|
3200
|
-
error: `Aborting render to avoid shipping black HDR layers: ${result.stderr.slice(-400)}`,
|
|
3201
|
-
failureReason: result.failureReason
|
|
3202
|
-
});
|
|
3203
|
-
}
|
|
3204
3268
|
const frameSize = dims.width * dims.height * 6;
|
|
3205
|
-
const
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3269
|
+
const extractionMediaStart = window2.extractionMediaStart ?? window2.mediaStart;
|
|
3270
|
+
const scale = `scale=${dims.width}:${dims.height}:force_original_aspect_ratio=increase,crop=${dims.width}:${dims.height}`;
|
|
3271
|
+
const firstTick = window2.finalFrameOnly ? 0 : await probeFirstTick(srcPath, extractionMediaStart, fps, runFfmpegImpl, abortSignal);
|
|
3272
|
+
const totalFrames = window2.finalFrameOnly ? 1 : Math.max(1, Math.ceil(window2.durationSeconds * fps - firstTick - 1e-9)) + Number(video.loop);
|
|
3273
|
+
const windowFrames = Math.min(totalFrames, hdrWindowFrames(frameSize, windowBytes));
|
|
3274
|
+
const windows = createHdrFrameWindows({
|
|
3275
|
+
dir: frameDir,
|
|
3276
|
+
frameSize,
|
|
3277
|
+
totalFrames,
|
|
3278
|
+
windowFrames,
|
|
3279
|
+
maxResident,
|
|
3280
|
+
extract: async (spec) => {
|
|
3281
|
+
const ffmpegArgs = window2.finalFrameOnly ? (
|
|
3282
|
+
// Decode before seeking for the one-frame path. Input-side seeking can
|
|
3283
|
+
// return zero frames for valid unindexed/negative-base transports.
|
|
3284
|
+
["-i", srcPath, "-ss", String(extractionMediaStart), "-frames:v", "1", "-vf", scale]
|
|
3285
|
+
) : hdrWindowFfmpegArgs({
|
|
3286
|
+
srcPath,
|
|
3287
|
+
mediaStart: extractionMediaStart,
|
|
3288
|
+
fps,
|
|
3289
|
+
fpsArg: fpsToFfmpegArg(job.config.fps),
|
|
3290
|
+
firstTick,
|
|
3291
|
+
firstFrame: spec.firstFrame,
|
|
3292
|
+
frames: spec.frames,
|
|
3293
|
+
scale
|
|
3294
|
+
});
|
|
3295
|
+
const result = await runFfmpegImpl(
|
|
3296
|
+
[...ffmpegArgs, "-pix_fmt", "rgb48le", "-f", "rawvideo", "-y", spec.path],
|
|
3297
|
+
{ signal: abortSignal }
|
|
3213
3298
|
);
|
|
3299
|
+
if (!result.success) {
|
|
3300
|
+
hdrDiagnostics.videoExtractionFailures += 1;
|
|
3301
|
+
log.error("HDR frame extraction failed; aborting render", {
|
|
3302
|
+
videoId,
|
|
3303
|
+
srcPath,
|
|
3304
|
+
firstFrame: spec.firstFrame,
|
|
3305
|
+
stderr: result.stderr.slice(-400)
|
|
3306
|
+
});
|
|
3307
|
+
throw encoderFailureError(`HDR frame extraction failed for video "${videoId}"`, {
|
|
3308
|
+
error: `Aborting render to avoid shipping black HDR layers: ${result.stderr.slice(-400)}`,
|
|
3309
|
+
failureReason: result.failureReason
|
|
3310
|
+
});
|
|
3311
|
+
}
|
|
3312
|
+
return Math.min(Math.floor(statSync2(spec.path).size / frameSize), spec.frames);
|
|
3214
3313
|
}
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
frameCount,
|
|
3223
|
-
scratch: Buffer.allocUnsafe(frameSize),
|
|
3224
|
-
loop: video.loop,
|
|
3225
|
-
mediaStart: extractionMediaStart,
|
|
3226
|
-
videoStreamLeadSeconds: planned.videoStreamLeadSeconds
|
|
3227
|
-
});
|
|
3228
|
-
handedOff = true;
|
|
3229
|
-
} finally {
|
|
3230
|
-
if (!handedOff) closeSync4(fd);
|
|
3314
|
+
});
|
|
3315
|
+
const first = await windows.lease(0);
|
|
3316
|
+
if (!first) {
|
|
3317
|
+
hdrDiagnostics.videoExtractionFailures += 1;
|
|
3318
|
+
throw new Error(
|
|
3319
|
+
`HDR frame extraction produced no frames for video "${videoId}". Aborting render to avoid shipping black HDR layers.`
|
|
3320
|
+
);
|
|
3231
3321
|
}
|
|
3322
|
+
first.release();
|
|
3323
|
+
if (video.loop) (await windows.lease(totalFrames - 1))?.release();
|
|
3324
|
+
out.set(videoId, {
|
|
3325
|
+
dir: frameDir,
|
|
3326
|
+
windows,
|
|
3327
|
+
width: dims.width,
|
|
3328
|
+
height: dims.height,
|
|
3329
|
+
frameSize,
|
|
3330
|
+
get frameCount() {
|
|
3331
|
+
return windows.totalFrames;
|
|
3332
|
+
},
|
|
3333
|
+
scratch: Buffer.allocUnsafe(frameSize),
|
|
3334
|
+
loop: video.loop,
|
|
3335
|
+
mediaStart: extractionMediaStart,
|
|
3336
|
+
videoStreamLeadSeconds: planned.videoStreamLeadSeconds
|
|
3337
|
+
});
|
|
3232
3338
|
}
|
|
3233
3339
|
return { sources: out, estimatedBytes, releaseReservation };
|
|
3234
3340
|
} catch (error) {
|
|
@@ -3237,12 +3343,23 @@ async function extractHdrVideoFrames(args) {
|
|
|
3237
3343
|
createdFrameDirs.delete(source.dir);
|
|
3238
3344
|
}
|
|
3239
3345
|
for (const frameDir of createdFrameDirs) {
|
|
3240
|
-
cleanupHdrFrameDirectory(frameDir,
|
|
3346
|
+
cleanupHdrFrameDirectory(frameDir, log);
|
|
3241
3347
|
}
|
|
3242
3348
|
releaseReservation();
|
|
3243
3349
|
throw error;
|
|
3244
3350
|
}
|
|
3245
3351
|
}
|
|
3352
|
+
function hdrWindowFfmpegArgs(a) {
|
|
3353
|
+
const unit = Math.ceil(a.fps);
|
|
3354
|
+
const seekFrame = a.firstFrame < unit ? 0 : (Math.floor(a.firstFrame / unit) - 1) * unit;
|
|
3355
|
+
const trim = a.firstFrame - seekFrame;
|
|
3356
|
+
const filters = [`fps=${a.fpsArg}:start_time=${(a.firstTick / a.fps).toFixed(6)}`, a.scale];
|
|
3357
|
+
if (trim > 0) filters.push(`trim=start_frame=${trim}`);
|
|
3358
|
+
return [
|
|
3359
|
+
...["-ss", (a.mediaStart + seekFrame / a.fps).toFixed(6), "-i", a.srcPath],
|
|
3360
|
+
...["-vf", filters.join(","), "-frames:v", String(a.frames)]
|
|
3361
|
+
];
|
|
3362
|
+
}
|
|
3246
3363
|
function decodeHdrImageBuffers(args) {
|
|
3247
3364
|
const { log, hdrImageSrcPaths, prep, hdrDiagnostics } = args;
|
|
3248
3365
|
const out = /* @__PURE__ */ new Map();
|
|
@@ -3262,7 +3379,11 @@ function decodeHdrImageBuffers(args) {
|
|
|
3262
3379
|
fit,
|
|
3263
3380
|
fitInfo?.position
|
|
3264
3381
|
);
|
|
3265
|
-
out.set(imageId, {
|
|
3382
|
+
out.set(imageId, {
|
|
3383
|
+
data: resampled,
|
|
3384
|
+
width: layout.width,
|
|
3385
|
+
height: layout.height
|
|
3386
|
+
});
|
|
3266
3387
|
} else {
|
|
3267
3388
|
out.set(imageId, {
|
|
3268
3389
|
data: Buffer.from(decoded.data),
|
|
@@ -3374,7 +3495,7 @@ async function captureSceneIntoBuffer(a) {
|
|
|
3374
3495
|
hdrPerf
|
|
3375
3496
|
);
|
|
3376
3497
|
} else {
|
|
3377
|
-
blitHdrVideoLayer(
|
|
3498
|
+
await blitHdrVideoLayer(
|
|
3378
3499
|
sceneBuf,
|
|
3379
3500
|
el,
|
|
3380
3501
|
time,
|
|
@@ -3576,7 +3697,7 @@ function isTargetLossError(error) {
|
|
|
3576
3697
|
// ../producer/src/services/render/stages/captureStreamingStage.ts
|
|
3577
3698
|
import { mkdtemp, writeFile } from "fs/promises";
|
|
3578
3699
|
import { tmpdir } from "os";
|
|
3579
|
-
import { join as
|
|
3700
|
+
import { join as join9 } from "path";
|
|
3580
3701
|
var DEFAULT_CAPTURE_STALL_MS = 6e4;
|
|
3581
3702
|
var DE_STALL_POLL_MS = 5e3;
|
|
3582
3703
|
var STALL_ADVICE = "Chrome stopped answering. If another app is keeping the GPU or CPU busy (a 3D render, a game, another export), let it finish or render one job at a time, then retry.";
|
|
@@ -3718,11 +3839,11 @@ function createDrainFrameGuard(args) {
|
|
|
3718
3839
|
return buf;
|
|
3719
3840
|
}
|
|
3720
3841
|
if (db < verifyMinDb) {
|
|
3721
|
-
const dumpDir = await mkdtemp(
|
|
3842
|
+
const dumpDir = await mkdtemp(join9(tmpdir(), "hf-de-verify-fail-")).catch(() => null);
|
|
3722
3843
|
if (dumpDir) {
|
|
3723
3844
|
await Promise.all([
|
|
3724
|
-
writeFile(
|
|
3725
|
-
writeFile(
|
|
3845
|
+
writeFile(join9(dumpDir, `frame-${idx}-de.jpg`), buf),
|
|
3846
|
+
writeFile(join9(dumpDir, `frame-${idx}-truth.jpg`), truth)
|
|
3726
3847
|
]).catch(() => {
|
|
3727
3848
|
});
|
|
3728
3849
|
}
|
|
@@ -4171,7 +4292,7 @@ async function runCaptureStreamingStage(input) {
|
|
|
4171
4292
|
|
|
4172
4293
|
// ../producer/src/services/render/stages/captureSegmentedStage.ts
|
|
4173
4294
|
function segmentOutputPath(segmentDir, index) {
|
|
4174
|
-
return
|
|
4295
|
+
return join10(segmentDir, `segment_${String(index).padStart(5, "0")}.mp4`);
|
|
4175
4296
|
}
|
|
4176
4297
|
function segmentEncoderOptions(base, segment) {
|
|
4177
4298
|
return {
|
|
@@ -4247,7 +4368,7 @@ async function captureSegment(ctx, segment) {
|
|
|
4247
4368
|
path: segmentPath,
|
|
4248
4369
|
// Recorded so resume can prove the file on disk is the one that
|
|
4249
4370
|
// finished; absent only in unit tests, whose fake encoder writes none.
|
|
4250
|
-
bytes: existsSync6(segmentPath) ?
|
|
4371
|
+
bytes: existsSync6(segmentPath) ? statSync3(segmentPath).size : 0
|
|
4251
4372
|
});
|
|
4252
4373
|
return encodeResult.durationMs;
|
|
4253
4374
|
} finally {
|
|
@@ -4265,7 +4386,7 @@ var DEFAULT_DEPS = {
|
|
|
4265
4386
|
// is invisible to a test that swaps the engine module after this file has
|
|
4266
4387
|
// been evaluated (bun updates live bindings, not copies).
|
|
4267
4388
|
closeSession: (session) => closeCaptureSession(session),
|
|
4268
|
-
removeFile: (path) =>
|
|
4389
|
+
removeFile: (path) => rmSync6(path, { force: true })
|
|
4269
4390
|
};
|
|
4270
4391
|
function defaultSessionFactory(input) {
|
|
4271
4392
|
let probeSession = input.probeSession;
|
|
@@ -4432,7 +4553,7 @@ async function runCaptureSegmentedStage(input) {
|
|
|
4432
4553
|
const { log, dedupPerfs, assertNotAborted } = input;
|
|
4433
4554
|
const deps = { ...DEFAULT_DEPS, ...input.deps };
|
|
4434
4555
|
const segments = planSegments(input.totalFrames, input.segmentFrames);
|
|
4435
|
-
const segmentDir = input.segmentDir ??
|
|
4556
|
+
const segmentDir = input.segmentDir ?? join10(input.workDir, "segments");
|
|
4436
4557
|
mkdirSync3(segmentDir, { recursive: true });
|
|
4437
4558
|
const skip = input.completedSegments ?? /* @__PURE__ */ new Set();
|
|
4438
4559
|
const pending = segments.filter((s) => !skip.has(s.index));
|
|
@@ -4503,10 +4624,83 @@ async function runCaptureSegmentedStage(input) {
|
|
|
4503
4624
|
};
|
|
4504
4625
|
}
|
|
4505
4626
|
|
|
4627
|
+
// ../producer/src/services/render/renderEtaGuard.ts
|
|
4628
|
+
var RENDER_TOO_SLOW = "RENDER_TOO_SLOW";
|
|
4629
|
+
var ETA_MARGIN = 1.2;
|
|
4630
|
+
var MIN_SAMPLE_MS = 6e4;
|
|
4631
|
+
var MIN_SAMPLE_FRAMES = 3;
|
|
4632
|
+
var POLL_MS = 5e3;
|
|
4633
|
+
var RenderTooSlowError = class extends Error {
|
|
4634
|
+
code = RENDER_TOO_SLOW;
|
|
4635
|
+
// The producer server reads these off the error for the wire envelope.
|
|
4636
|
+
// fallow-ignore-next-line unused-class-member
|
|
4637
|
+
owner = "user";
|
|
4638
|
+
// fallow-ignore-next-line unused-class-member
|
|
4639
|
+
retryable = false;
|
|
4640
|
+
publicMetadata;
|
|
4641
|
+
constructor(stage, input) {
|
|
4642
|
+
const { framesCompleted, totalFrames, msPerFrame, etaMs, maxRenderMs } = input;
|
|
4643
|
+
super(
|
|
4644
|
+
`render too slow: stage ${stage}, ${framesCompleted}/${totalFrames} frames, ${Math.round(msPerFrame)} ms/frame, ETA ${etaMs} ms exceeds maxRenderMs ${maxRenderMs}`
|
|
4645
|
+
);
|
|
4646
|
+
this.name = "RenderTooSlowError";
|
|
4647
|
+
this.publicMetadata = { stage, framesCompleted, totalFrames, msPerFrame, etaMs, maxRenderMs };
|
|
4648
|
+
}
|
|
4649
|
+
};
|
|
4650
|
+
function checkRenderEta(stage, input) {
|
|
4651
|
+
const { maxRenderMs, elapsedMs, framesCompleted, totalFrames, msPerFrame } = input;
|
|
4652
|
+
if (!maxRenderMs || maxRenderMs <= 0 || !(msPerFrame > 0)) return void 0;
|
|
4653
|
+
const etaMs = Math.round(elapsedMs + (totalFrames - framesCompleted) * msPerFrame);
|
|
4654
|
+
if (etaMs <= maxRenderMs * ETA_MARGIN) return void 0;
|
|
4655
|
+
return new RenderTooSlowError(stage, { ...input, maxRenderMs, etaMs });
|
|
4656
|
+
}
|
|
4657
|
+
function createRateSampler() {
|
|
4658
|
+
let base;
|
|
4659
|
+
let lastFrames = 0;
|
|
4660
|
+
return {
|
|
4661
|
+
observe(done, at) {
|
|
4662
|
+
if (done === 0 || done < lastFrames) base = void 0;
|
|
4663
|
+
lastFrames = done;
|
|
4664
|
+
if (done === 0) return void 0;
|
|
4665
|
+
base ??= { at, frames: done };
|
|
4666
|
+
const sampleMs = at - base.at;
|
|
4667
|
+
const sampleFrames = done - base.frames;
|
|
4668
|
+
if (sampleMs < MIN_SAMPLE_MS || sampleFrames < MIN_SAMPLE_FRAMES) return void 0;
|
|
4669
|
+
return sampleMs / sampleFrames;
|
|
4670
|
+
}
|
|
4671
|
+
};
|
|
4672
|
+
}
|
|
4673
|
+
function startRenderEtaGuard(options) {
|
|
4674
|
+
const { maxRenderMs, job, totalFrames, pipelineStartMs, onTooSlow, now = Date.now } = options;
|
|
4675
|
+
if (!maxRenderMs || maxRenderMs <= 0) return () => {
|
|
4676
|
+
};
|
|
4677
|
+
const sampler = createRateSampler();
|
|
4678
|
+
const stop = () => clearInterval(timer);
|
|
4679
|
+
const timer = setInterval(() => {
|
|
4680
|
+
const done = job.framesRendered ?? 0;
|
|
4681
|
+
if (done >= totalFrames) return stop();
|
|
4682
|
+
const at = now();
|
|
4683
|
+
const msPerFrame = sampler.observe(done, at);
|
|
4684
|
+
if (msPerFrame === void 0) return;
|
|
4685
|
+
const error = checkRenderEta("capture", {
|
|
4686
|
+
maxRenderMs,
|
|
4687
|
+
elapsedMs: at - pipelineStartMs,
|
|
4688
|
+
framesCompleted: done,
|
|
4689
|
+
totalFrames,
|
|
4690
|
+
msPerFrame
|
|
4691
|
+
});
|
|
4692
|
+
if (!error) return;
|
|
4693
|
+
stop();
|
|
4694
|
+
onTooSlow(error);
|
|
4695
|
+
}, options.pollMs ?? POLL_MS);
|
|
4696
|
+
timer.unref?.();
|
|
4697
|
+
return stop;
|
|
4698
|
+
}
|
|
4699
|
+
|
|
4506
4700
|
// ../producer/src/services/render/segmentManifest.ts
|
|
4507
4701
|
import { createHash as createHash2 } from "crypto";
|
|
4508
|
-
import { existsSync as existsSync7, mkdirSync as mkdirSync4, readFileSync as readFileSync4, statSync as
|
|
4509
|
-
import { join as
|
|
4702
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync4, readFileSync as readFileSync4, statSync as statSync4, writeFileSync as writeFileSync3 } from "fs";
|
|
4703
|
+
import { join as join11 } from "path";
|
|
4510
4704
|
var MANIFEST_FILENAME = "segments.json";
|
|
4511
4705
|
function computeSegmentPlanHash(input) {
|
|
4512
4706
|
const ordered = [
|
|
@@ -4531,7 +4725,7 @@ function computeSegmentPlanHash(input) {
|
|
|
4531
4725
|
return createHash2("sha256").update(ordered).digest("hex").slice(0, 16);
|
|
4532
4726
|
}
|
|
4533
4727
|
function segmentDirFor(projectRendersDir, planHash) {
|
|
4534
|
-
return
|
|
4728
|
+
return join11(projectRendersDir, ".hf-segments", planHash);
|
|
4535
4729
|
}
|
|
4536
4730
|
function hasNumber(value, key) {
|
|
4537
4731
|
return key in value && typeof Reflect.get(value, key) === "number";
|
|
@@ -4549,7 +4743,7 @@ function isManifest(value) {
|
|
|
4549
4743
|
return Reflect.get(value, "version") === 1 && hasString(value, "planHash") && hasNumber(value, "totalFrames") && hasNumber(value, "segmentFrames") && Array.isArray(completed) && completed.every(isEntry);
|
|
4550
4744
|
}
|
|
4551
4745
|
function readSegmentManifest(segmentDir) {
|
|
4552
|
-
const path =
|
|
4746
|
+
const path = join11(segmentDir, MANIFEST_FILENAME);
|
|
4553
4747
|
if (!existsSync7(path)) return null;
|
|
4554
4748
|
try {
|
|
4555
4749
|
const parsed = JSON.parse(readFileSync4(path, "utf-8"));
|
|
@@ -4560,9 +4754,9 @@ function readSegmentManifest(segmentDir) {
|
|
|
4560
4754
|
}
|
|
4561
4755
|
function writeSegmentManifest(segmentDir, manifest) {
|
|
4562
4756
|
mkdirSync4(segmentDir, { recursive: true });
|
|
4563
|
-
const tmp =
|
|
4757
|
+
const tmp = join11(segmentDir, `${MANIFEST_FILENAME}.${process.pid}.tmp`);
|
|
4564
4758
|
writeFileSync3(tmp, JSON.stringify(manifest, null, 2), "utf-8");
|
|
4565
|
-
renameWithRetry(tmp,
|
|
4759
|
+
renameWithRetry(tmp, join11(segmentDir, MANIFEST_FILENAME));
|
|
4566
4760
|
}
|
|
4567
4761
|
async function probeSegmentFrameCount(path, probe) {
|
|
4568
4762
|
try {
|
|
@@ -4580,7 +4774,7 @@ async function validateCompletedSegments(manifest, expectedHash, probeFrames) {
|
|
|
4580
4774
|
if (manifest.planHash !== expectedHash) return ok;
|
|
4581
4775
|
for (const entry of manifest.completed) {
|
|
4582
4776
|
if (!existsSync7(entry.path)) continue;
|
|
4583
|
-
const size =
|
|
4777
|
+
const size = statSync4(entry.path).size;
|
|
4584
4778
|
if (size <= 0 || size !== entry.bytes) continue;
|
|
4585
4779
|
const frames = await probeFrames(entry.path);
|
|
4586
4780
|
if (frames !== entry.endFrame - entry.startFrame) continue;
|
|
@@ -4667,7 +4861,7 @@ function resolveVideoCaptureBeyondViewport(videoCount) {
|
|
|
4667
4861
|
}
|
|
4668
4862
|
|
|
4669
4863
|
// ../producer/src/services/render/captureCost.ts
|
|
4670
|
-
import { join as
|
|
4864
|
+
import { join as join12 } from "path";
|
|
4671
4865
|
var CAPTURE_CALIBRATION_TARGET_MS = 600;
|
|
4672
4866
|
var MAX_MEASURED_CAPTURE_COST_MULTIPLIER = 8;
|
|
4673
4867
|
var CAPTURE_CALIBRATION_PROTOCOL_TIMEOUT_MS = 3e4;
|
|
@@ -4903,7 +5097,7 @@ async function runCaptureCalibration(input) {
|
|
|
4903
5097
|
});
|
|
4904
5098
|
let calibration;
|
|
4905
5099
|
try {
|
|
4906
|
-
calibration = await runOneCalibration(
|
|
5100
|
+
calibration = await runOneCalibration(join12(workDir, "capture-calibration"), calibrationCfg);
|
|
4907
5101
|
} catch (error) {
|
|
4908
5102
|
const shouldFallback = !forceScreenshot && shouldFallbackToScreenshotAfterCalibrationError(error);
|
|
4909
5103
|
if (!shouldFallback) {
|
|
@@ -4936,7 +5130,7 @@ async function runCaptureCalibration(input) {
|
|
|
4936
5130
|
const screenshotCfg = createCaptureCalibrationConfig({ ...cfg, forceScreenshot: true });
|
|
4937
5131
|
try {
|
|
4938
5132
|
calibration = await runOneCalibration(
|
|
4939
|
-
|
|
5133
|
+
join12(workDir, "capture-calibration-screenshot"),
|
|
4940
5134
|
screenshotCfg
|
|
4941
5135
|
);
|
|
4942
5136
|
} catch (fallbackError) {
|
|
@@ -5356,12 +5550,12 @@ function countAuthoredTimedClips(html) {
|
|
|
5356
5550
|
}
|
|
5357
5551
|
|
|
5358
5552
|
// ../producer/src/services/render/stages/compileStage.ts
|
|
5359
|
-
import { join as
|
|
5553
|
+
import { join as join14 } from "path";
|
|
5360
5554
|
|
|
5361
5555
|
// ../producer/src/services/htmlCompiler.ts
|
|
5362
5556
|
import { createHash as createHash4 } from "crypto";
|
|
5363
5557
|
import { createReadStream as createReadStream2, existsSync as existsSync9, mkdirSync as mkdirSync5, readFileSync as readFileSync5 } from "fs";
|
|
5364
|
-
import { join as
|
|
5558
|
+
import { join as join13, dirname as dirname5, resolve as resolve5, basename as basename4, relative as relative2 } from "path";
|
|
5365
5559
|
|
|
5366
5560
|
// ../producer/src/services/renderMediaCollector.ts
|
|
5367
5561
|
function resolveHostEnd(host, hostStart) {
|
|
@@ -5866,7 +6060,7 @@ async function resolveMediaDuration(src, mediaStart, playbackRate, baseDir, down
|
|
|
5866
6060
|
}
|
|
5867
6061
|
} else {
|
|
5868
6062
|
filePath = decodedUrlPath(src);
|
|
5869
|
-
if (!filePath.startsWith("/")) filePath =
|
|
6063
|
+
if (!filePath.startsWith("/")) filePath = join13(baseDir, filePath);
|
|
5870
6064
|
filePath = urlByAbsentLocalPath?.get(filePath) ?? filePath;
|
|
5871
6065
|
}
|
|
5872
6066
|
if (!isHttpUrl(filePath) && !existsSync9(filePath)) {
|
|
@@ -6486,7 +6680,7 @@ async function localizeRemoteMediaSources(html, downloadDir) {
|
|
|
6486
6680
|
return downloadAndRewriteUrls(
|
|
6487
6681
|
urlSet,
|
|
6488
6682
|
html,
|
|
6489
|
-
|
|
6683
|
+
join13(downloadDir, REMOTE_MEDIA_SUBDIR),
|
|
6490
6684
|
"Remote media download failed",
|
|
6491
6685
|
"Localized remote media source(s)"
|
|
6492
6686
|
);
|
|
@@ -6501,7 +6695,7 @@ async function localizeRemoteImageSources(html, downloadDir) {
|
|
|
6501
6695
|
return downloadAndRewriteUrls(
|
|
6502
6696
|
urlSet,
|
|
6503
6697
|
html,
|
|
6504
|
-
|
|
6698
|
+
join13(downloadDir, REMOTE_MEDIA_SUBDIR),
|
|
6505
6699
|
"Remote image download failed",
|
|
6506
6700
|
"Localized remote image source(s)"
|
|
6507
6701
|
);
|
|
@@ -6517,7 +6711,7 @@ async function localizeRemoteBackgroundImages(html, downloadDir) {
|
|
|
6517
6711
|
return downloadAndRewriteUrls(
|
|
6518
6712
|
urlSet,
|
|
6519
6713
|
html,
|
|
6520
|
-
|
|
6714
|
+
join13(downloadDir, REMOTE_MEDIA_SUBDIR),
|
|
6521
6715
|
"Remote background-image download failed",
|
|
6522
6716
|
"Localized remote background-image(s)",
|
|
6523
6717
|
// Quoted url('..')/url("..") are rewritten by downloadAndRewriteUrls' default
|
|
@@ -6652,7 +6846,7 @@ async function localizeRemoteFontFaces(html, downloadDir) {
|
|
|
6652
6846
|
return downloadAndRewriteUrls(
|
|
6653
6847
|
urlSet,
|
|
6654
6848
|
processed,
|
|
6655
|
-
|
|
6849
|
+
join13(downloadDir, REMOTE_MEDIA_SUBDIR),
|
|
6656
6850
|
"Remote font download failed",
|
|
6657
6851
|
"Localized remote font face(s)",
|
|
6658
6852
|
(h, url, relPath) => h.replaceAll(`url(${url})`, `url("${relPath}")`)
|
|
@@ -7319,7 +7513,7 @@ async function runCompileStage(input) {
|
|
|
7319
7513
|
abortSignal
|
|
7320
7514
|
} = input;
|
|
7321
7515
|
const compileStart = Date.now();
|
|
7322
|
-
const compiled = await compileForRender(projectDir, htmlPath,
|
|
7516
|
+
const compiled = await compileForRender(projectDir, htmlPath, join14(workDir, "downloads"), {
|
|
7323
7517
|
log,
|
|
7324
7518
|
failClosedFontFetch: failClosedFontFetch === true,
|
|
7325
7519
|
allowSystemFontCapture,
|
|
@@ -7327,7 +7521,7 @@ async function runCompileStage(input) {
|
|
|
7327
7521
|
variables: input.variables,
|
|
7328
7522
|
urlByAbsentLocalPath: input.urlByAbsentLocalPath,
|
|
7329
7523
|
pageMotionBlur: input.pageMotionBlur,
|
|
7330
|
-
animatedGifCacheDir: cfg.extractCacheDir ?
|
|
7524
|
+
animatedGifCacheDir: cfg.extractCacheDir ? join14(cfg.extractCacheDir, "animated-gif") : void 0,
|
|
7331
7525
|
ffmpegProcessTimeout: cfg.ffmpegProcessTimeout
|
|
7332
7526
|
});
|
|
7333
7527
|
assertNotAborted();
|
|
@@ -7390,7 +7584,7 @@ async function runCompileStage(input) {
|
|
|
7390
7584
|
};
|
|
7391
7585
|
await preflightCompositionAssetMediaTypes({
|
|
7392
7586
|
projectDir,
|
|
7393
|
-
compiledDir:
|
|
7587
|
+
compiledDir: join14(workDir, "compiled"),
|
|
7394
7588
|
composition,
|
|
7395
7589
|
signal: abortSignal
|
|
7396
7590
|
});
|
|
@@ -7435,7 +7629,7 @@ async function runCompileStage(input) {
|
|
|
7435
7629
|
}
|
|
7436
7630
|
|
|
7437
7631
|
// ../producer/src/services/render/stages/probeStage.ts
|
|
7438
|
-
import { join as
|
|
7632
|
+
import { join as join15 } from "path";
|
|
7439
7633
|
|
|
7440
7634
|
// ../producer/src/services/render/stages/probeFailures.ts
|
|
7441
7635
|
var NETWORK_FAILURE_PATTERN = /404|ERR_NAME_NOT_RESOLVED|ERR_CONNECTION_REFUSED|net::ERR_/i;
|
|
@@ -7605,7 +7799,7 @@ async function runProbeStage(input) {
|
|
|
7605
7799
|
});
|
|
7606
7800
|
fileServer = await createFileServer({
|
|
7607
7801
|
projectDir,
|
|
7608
|
-
compiledDir:
|
|
7802
|
+
compiledDir: join15(workDir, "compiled"),
|
|
7609
7803
|
port: 0,
|
|
7610
7804
|
preHeadScripts: [VIRTUAL_TIME_SHIM],
|
|
7611
7805
|
fps: job.config.fps
|
|
@@ -7633,7 +7827,7 @@ async function runProbeStage(input) {
|
|
|
7633
7827
|
log.info("Creating capture session...", { attempt, maxAttempts: PROBE_MAX_ATTEMPTS });
|
|
7634
7828
|
probeSession = await createCaptureSession(
|
|
7635
7829
|
fileServer.url,
|
|
7636
|
-
|
|
7830
|
+
join15(workDir, "probe"),
|
|
7637
7831
|
captureOpts,
|
|
7638
7832
|
null,
|
|
7639
7833
|
probeCfg
|
|
@@ -7718,7 +7912,7 @@ async function runProbeStage(input) {
|
|
|
7718
7912
|
});
|
|
7719
7913
|
probeSession = await createCaptureSession(
|
|
7720
7914
|
fileServer.url,
|
|
7721
|
-
|
|
7915
|
+
join15(workDir, "probe-screenshot"),
|
|
7722
7916
|
captureOpts,
|
|
7723
7917
|
null,
|
|
7724
7918
|
{ ...probeCfg, forceScreenshot: true }
|
|
@@ -7754,7 +7948,7 @@ async function runProbeStage(input) {
|
|
|
7754
7948
|
compiled,
|
|
7755
7949
|
resolutions,
|
|
7756
7950
|
projectDir,
|
|
7757
|
-
|
|
7951
|
+
join15(workDir, "downloads")
|
|
7758
7952
|
);
|
|
7759
7953
|
assertNotAborted();
|
|
7760
7954
|
composition.videos = compiled.videos;
|
|
@@ -7945,7 +8139,7 @@ async function runProbeStage(input) {
|
|
|
7945
8139
|
}
|
|
7946
8140
|
await preflightCompositionAssetMediaTypes({
|
|
7947
8141
|
projectDir,
|
|
7948
|
-
compiledDir:
|
|
8142
|
+
compiledDir: join15(workDir, "compiled"),
|
|
7949
8143
|
composition,
|
|
7950
8144
|
signal: abortSignal
|
|
7951
8145
|
});
|
|
@@ -8101,7 +8295,7 @@ function validateDistributedDuration(input) {
|
|
|
8101
8295
|
|
|
8102
8296
|
// ../producer/src/services/render/stages/extractVideosStage.ts
|
|
8103
8297
|
import { existsSync as existsSync10 } from "fs";
|
|
8104
|
-
import { join as
|
|
8298
|
+
import { join as join16 } from "path";
|
|
8105
8299
|
|
|
8106
8300
|
// ../producer/src/services/render/extractionFailureMetadata.ts
|
|
8107
8301
|
function stringOrEmpty(value) {
|
|
@@ -8404,14 +8598,14 @@ async function runExtractVideosStage(input) {
|
|
|
8404
8598
|
// because short boundary counts can differ by one frame.
|
|
8405
8599
|
{
|
|
8406
8600
|
fps: job.config.fps,
|
|
8407
|
-
outputDir:
|
|
8601
|
+
outputDir: join16(compiledDir, "__hyperframes_video_frames"),
|
|
8408
8602
|
format: job.config.videoFrameFormat ?? "auto",
|
|
8409
8603
|
toneMapHdrToSdr: job.config.hdrMode === "force-sdr",
|
|
8410
8604
|
timelineEnd: composition.duration,
|
|
8411
8605
|
maxTransientRetries: extractionPolicy.maxTransientRetries,
|
|
8412
8606
|
collectProbeFailures: extractionPolicy.failureMode === "enforce",
|
|
8413
8607
|
deferRangeExtraction,
|
|
8414
|
-
contentKeyedDirs: [
|
|
8608
|
+
contentKeyedDirs: [join16(compiledDir, REMOTE_MEDIA_SUBDIR)],
|
|
8415
8609
|
urlByAbsentLocalPath
|
|
8416
8610
|
},
|
|
8417
8611
|
abortSignal,
|
|
@@ -8478,13 +8672,13 @@ function appendAutoDetectedVideoAudio(composition, extracted) {
|
|
|
8478
8672
|
}
|
|
8479
8673
|
|
|
8480
8674
|
// ../producer/src/services/render/stages/audioStage.ts
|
|
8481
|
-
import { join as
|
|
8482
|
-
import { rmSync as
|
|
8675
|
+
import { join as join18 } from "path";
|
|
8676
|
+
import { rmSync as rmSync8 } from "fs";
|
|
8483
8677
|
|
|
8484
8678
|
// ../producer/src/services/render/audioPadTrim.ts
|
|
8485
8679
|
import { spawn } from "child_process";
|
|
8486
|
-
import { mkdtempSync as mkdtempSync3, rmSync as
|
|
8487
|
-
import { dirname as dirname6, join as
|
|
8680
|
+
import { mkdtempSync as mkdtempSync3, rmSync as rmSync7 } from "fs";
|
|
8681
|
+
import { dirname as dirname6, join as join17 } from "path";
|
|
8488
8682
|
|
|
8489
8683
|
// ../producer/src/services/render/audioTruePeak.ts
|
|
8490
8684
|
var toDbfs = (token) => token.toLowerCase() === "-inf" ? Number.NEGATIVE_INFINITY : Number(token);
|
|
@@ -8669,7 +8863,7 @@ async function padOrTrimAudioToVideoFrameCount(input) {
|
|
|
8669
8863
|
error: `audioPadTrim: failed to materialize ${plan2.operation}: ${err instanceof Error ? err.message : String(err)}`
|
|
8670
8864
|
};
|
|
8671
8865
|
} finally {
|
|
8672
|
-
for (const path of plan2.cleanupPaths)
|
|
8866
|
+
for (const path of plan2.cleanupPaths) rmSync7(path, { force: true });
|
|
8673
8867
|
}
|
|
8674
8868
|
let loweredDb = 0;
|
|
8675
8869
|
if (probeTruePeak) {
|
|
@@ -8715,8 +8909,8 @@ async function constrainAacTruePeak(input) {
|
|
|
8715
8909
|
async function enforceAacTruePeak(input) {
|
|
8716
8910
|
let scratchDir;
|
|
8717
8911
|
try {
|
|
8718
|
-
scratchDir = mkdtempSync3(
|
|
8719
|
-
const correctedPath =
|
|
8912
|
+
scratchDir = mkdtempSync3(join17(dirname6(input.audioPath), ".true-peak-"));
|
|
8913
|
+
const correctedPath = join17(scratchDir, "audio.m4a");
|
|
8720
8914
|
const measurements = [];
|
|
8721
8915
|
let attenuationDb = 0;
|
|
8722
8916
|
let measuredPath = input.audioPath;
|
|
@@ -8767,7 +8961,7 @@ async function enforceAacTruePeak(input) {
|
|
|
8767
8961
|
)}`
|
|
8768
8962
|
};
|
|
8769
8963
|
} finally {
|
|
8770
|
-
if (scratchDir)
|
|
8964
|
+
if (scratchDir) rmSync7(scratchDir, { recursive: true, force: true });
|
|
8771
8965
|
}
|
|
8772
8966
|
}
|
|
8773
8967
|
function failResult(outputPath, target, source, error) {
|
|
@@ -8914,7 +9108,7 @@ function assertAudioNotInterrupted(failures) {
|
|
|
8914
9108
|
}
|
|
8915
9109
|
async function runAudioStage(input) {
|
|
8916
9110
|
const stageStart = Date.now();
|
|
8917
|
-
const pcmSourcePath =
|
|
9111
|
+
const pcmSourcePath = join18(input.workDir, "audio-source.wav");
|
|
8918
9112
|
const duration = input.totalFrames * input.fps.den / input.fps.num;
|
|
8919
9113
|
try {
|
|
8920
9114
|
const result = await mixAudioForDelivery(input, duration, pcmSourcePath);
|
|
@@ -8934,7 +9128,7 @@ async function runAudioStage(input) {
|
|
|
8934
9128
|
}
|
|
8935
9129
|
return { ...result, audioLoweredDb, audioProcessMs: Date.now() - stageStart };
|
|
8936
9130
|
} finally {
|
|
8937
|
-
|
|
9131
|
+
rmSync8(pcmSourcePath, { force: true });
|
|
8938
9132
|
}
|
|
8939
9133
|
}
|
|
8940
9134
|
async function mixAudioForDelivery(input, duration, pcmSourcePath) {
|
|
@@ -8952,7 +9146,7 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath) {
|
|
|
8952
9146
|
assertNotAborted,
|
|
8953
9147
|
log
|
|
8954
9148
|
} = input;
|
|
8955
|
-
const audioOutputPath =
|
|
9149
|
+
const audioOutputPath = join18(workDir, MIXED_AUDIO_FILENAME);
|
|
8956
9150
|
let hasAudio = false;
|
|
8957
9151
|
let audioError;
|
|
8958
9152
|
let audioFailures;
|
|
@@ -8963,7 +9157,7 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath) {
|
|
|
8963
9157
|
audioResult = await processCompositionAudio(
|
|
8964
9158
|
audios,
|
|
8965
9159
|
projectDir,
|
|
8966
|
-
|
|
9160
|
+
join18(workDir, "audio-work"),
|
|
8967
9161
|
audioOutputPath,
|
|
8968
9162
|
duration,
|
|
8969
9163
|
abortSignal,
|
|
@@ -9032,7 +9226,7 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath) {
|
|
|
9032
9226
|
|
|
9033
9227
|
// ../producer/src/services/render/stages/captureStage.ts
|
|
9034
9228
|
import { existsSync as existsSync11, readdirSync as readdirSync3, statfsSync as statfsSync2 } from "fs";
|
|
9035
|
-
import { join as
|
|
9229
|
+
import { join as join19 } from "path";
|
|
9036
9230
|
function shouldAllowAdaptiveCaptureRetry(workerCount, _explicitlyConfigured) {
|
|
9037
9231
|
return workerCount > 1;
|
|
9038
9232
|
}
|
|
@@ -9091,13 +9285,13 @@ function measureCaptureFrameBytes(workDir, framesDir) {
|
|
|
9091
9285
|
if (!existsSync11(workDir)) return total;
|
|
9092
9286
|
for (const attempt of readdirSync3(workDir)) {
|
|
9093
9287
|
if (/^retry-\d+-batch-\d+-worker-\d+$/.test(attempt)) {
|
|
9094
|
-
total += sampleDirectoryBytes(
|
|
9288
|
+
total += sampleDirectoryBytes(join19(workDir, attempt));
|
|
9095
9289
|
continue;
|
|
9096
9290
|
}
|
|
9097
9291
|
if (!/^capture-attempt-\d+$/.test(attempt)) continue;
|
|
9098
|
-
const attemptDir =
|
|
9292
|
+
const attemptDir = join19(workDir, attempt);
|
|
9099
9293
|
for (const name of readdirSync3(attemptDir)) {
|
|
9100
|
-
if (/^worker-\d+$/.test(name)) total += sampleDirectoryBytes(
|
|
9294
|
+
if (/^worker-\d+$/.test(name)) total += sampleDirectoryBytes(join19(attemptDir, name));
|
|
9101
9295
|
}
|
|
9102
9296
|
}
|
|
9103
9297
|
return total;
|
|
@@ -9384,7 +9578,7 @@ async function captureSessionFrames(session, { input, rangeStart, rangeEnd, resu
|
|
|
9384
9578
|
|
|
9385
9579
|
// ../producer/src/services/render/stages/captureHdrStage.ts
|
|
9386
9580
|
import { existsSync as existsSync13, mkdirSync as mkdirSync6 } from "fs";
|
|
9387
|
-
import { join as
|
|
9581
|
+
import { join as join23 } from "path";
|
|
9388
9582
|
|
|
9389
9583
|
// ../producer/src/services/hdrImageTransferCache.ts
|
|
9390
9584
|
var DEFAULT_MAX_BYTES = 200 * 1024 * 1024;
|
|
@@ -9446,7 +9640,7 @@ function createHdrImageTransferCache(options = {}) {
|
|
|
9446
9640
|
}
|
|
9447
9641
|
|
|
9448
9642
|
// ../producer/src/services/render/stages/captureHdrSequentialLoop.ts
|
|
9449
|
-
import { join as
|
|
9643
|
+
import { join as join20 } from "path";
|
|
9450
9644
|
async function runSequentialLayeredFrameLoop(input) {
|
|
9451
9645
|
const {
|
|
9452
9646
|
job,
|
|
@@ -9567,7 +9761,7 @@ async function runSequentialLayeredFrameLoop(input) {
|
|
|
9567
9761
|
);
|
|
9568
9762
|
if (debugDumpEnabled && debugDumpDir && i % 30 === 0) {
|
|
9569
9763
|
writeFileExclusiveSync(
|
|
9570
|
-
|
|
9764
|
+
join20(debugDumpDir, `frame_${String(i).padStart(4, "0")}_final_rgb48le.bin`),
|
|
9571
9765
|
normalCanvas
|
|
9572
9766
|
);
|
|
9573
9767
|
}
|
|
@@ -9599,12 +9793,12 @@ async function runSequentialLayeredFrameLoop(input) {
|
|
|
9599
9793
|
}
|
|
9600
9794
|
|
|
9601
9795
|
// ../producer/src/services/render/stages/captureHdrHybridLoop.ts
|
|
9602
|
-
import { join as
|
|
9796
|
+
import { join as join22 } from "path";
|
|
9603
9797
|
|
|
9604
9798
|
// ../producer/src/services/shaderTransitionWorkerPool.ts
|
|
9605
9799
|
import { Worker } from "worker_threads";
|
|
9606
9800
|
import { fileURLToPath as fileURLToPath3, pathToFileURL } from "url";
|
|
9607
|
-
import { dirname as dirname7, join as
|
|
9801
|
+
import { dirname as dirname7, join as join21 } from "path";
|
|
9608
9802
|
import { createRequire } from "module";
|
|
9609
9803
|
import { existsSync as existsSync12 } from "fs";
|
|
9610
9804
|
import { cpus as cpus2 } from "os";
|
|
@@ -9618,9 +9812,9 @@ function resolveWorkerEntry(explicit) {
|
|
|
9618
9812
|
return { path: override, isTs };
|
|
9619
9813
|
}
|
|
9620
9814
|
const moduleDir = dirname7(fileURLToPath3(import.meta.url));
|
|
9621
|
-
const jsPath =
|
|
9815
|
+
const jsPath = join21(moduleDir, "shaderTransitionWorker.js");
|
|
9622
9816
|
if (existsSync12(jsPath)) return { path: jsPath, isTs: false };
|
|
9623
|
-
const tsPath =
|
|
9817
|
+
const tsPath = join21(moduleDir, "shaderTransitionWorker.ts");
|
|
9624
9818
|
return { path: tsPath, isTs: true };
|
|
9625
9819
|
}
|
|
9626
9820
|
function buildExecArgv(entryIsTs) {
|
|
@@ -9988,7 +10182,7 @@ async function runHybridLayeredFrameLoop(input) {
|
|
|
9988
10182
|
);
|
|
9989
10183
|
if (debugDumpEnabled && debugDumpDir && i % 30 === 0) {
|
|
9990
10184
|
writeFileExclusiveSync(
|
|
9991
|
-
|
|
10185
|
+
join22(debugDumpDir, `frame_${String(i).padStart(4, "0")}_final_rgb48le.bin`),
|
|
9992
10186
|
canvas
|
|
9993
10187
|
);
|
|
9994
10188
|
}
|
|
@@ -10157,7 +10351,8 @@ async function runCaptureHdrStage(input) {
|
|
|
10157
10351
|
width,
|
|
10158
10352
|
height,
|
|
10159
10353
|
abortSignal,
|
|
10160
|
-
hdrDiagnostics
|
|
10354
|
+
hdrDiagnostics,
|
|
10355
|
+
maxResidentWindows: Math.max(1, workerCount) + 1
|
|
10161
10356
|
});
|
|
10162
10357
|
releaseHdrExtractionReservation = extracted.releaseReservation;
|
|
10163
10358
|
for (const [id, source] of extracted.sources) hdrVideoFrameSources.set(id, source);
|
|
@@ -10175,7 +10370,7 @@ async function runCaptureHdrStage(input) {
|
|
|
10175
10370
|
if (hdrVideoFrameSources.has(v.id)) hdrVideoEndTimes.set(v.id, v.end);
|
|
10176
10371
|
}
|
|
10177
10372
|
const debugDumpEnabled = process.env.KEEP_TEMP === "1";
|
|
10178
|
-
const debugDumpDir = debugDumpEnabled ?
|
|
10373
|
+
const debugDumpDir = debugDumpEnabled ? join23(framesDir, "debug-composite") : null;
|
|
10179
10374
|
if (debugDumpDir && !existsSync13(debugDumpDir)) {
|
|
10180
10375
|
mkdirSync6(debugDumpDir, { recursive: true });
|
|
10181
10376
|
}
|
|
@@ -10335,12 +10530,12 @@ import {
|
|
|
10335
10530
|
mkdirSync as mkdirSync7,
|
|
10336
10531
|
readdirSync as readdirSync4,
|
|
10337
10532
|
readFileSync as readFileSync6,
|
|
10338
|
-
rmSync as
|
|
10339
|
-
statSync as
|
|
10533
|
+
rmSync as rmSync9,
|
|
10534
|
+
statSync as statSync5,
|
|
10340
10535
|
writeFileSync as writeFileSync4
|
|
10341
10536
|
} from "fs";
|
|
10342
10537
|
import { readFile as readFile2 } from "fs/promises";
|
|
10343
|
-
import { dirname as dirname8, join as
|
|
10538
|
+
import { dirname as dirname8, join as join24 } from "path";
|
|
10344
10539
|
|
|
10345
10540
|
// ../producer/src/services/render/stages/gifEncodeArgs.ts
|
|
10346
10541
|
function fpsToFfmpegArg2(fps) {
|
|
@@ -10450,7 +10645,7 @@ async function encodeGifFromDir(framesDir, framePattern, outputPath, input) {
|
|
|
10450
10645
|
const failure = await reencodeWithClearedWholeFrames(argsInput, run, startTime);
|
|
10451
10646
|
if (failure) return failure;
|
|
10452
10647
|
}
|
|
10453
|
-
const fileSize = existsSync14(outputPath) ?
|
|
10648
|
+
const fileSize = existsSync14(outputPath) ? statSync5(outputPath).size : 0;
|
|
10454
10649
|
return {
|
|
10455
10650
|
success: true,
|
|
10456
10651
|
outputPath,
|
|
@@ -10459,7 +10654,7 @@ async function encodeGifFromDir(framesDir, framePattern, outputPath, input) {
|
|
|
10459
10654
|
fileSize
|
|
10460
10655
|
};
|
|
10461
10656
|
} finally {
|
|
10462
|
-
|
|
10657
|
+
rmSync9(input.palettePath, { force: true });
|
|
10463
10658
|
}
|
|
10464
10659
|
}
|
|
10465
10660
|
function startEncodeProgress(job, stage, onProgress) {
|
|
@@ -10534,7 +10729,7 @@ function encodeWhileCapturing(input, totalFrames) {
|
|
|
10534
10729
|
await new Promise((resolve11) => wake = resolve11);
|
|
10535
10730
|
}
|
|
10536
10731
|
if (signal.aborted) return;
|
|
10537
|
-
const mergedPath =
|
|
10732
|
+
const mergedPath = join24(input.framesDir, formatCaptureFrameName(next, "jpg"));
|
|
10538
10733
|
const frame = await readLandedFrame(landed.get(next), mergedPath);
|
|
10539
10734
|
landed.delete(next);
|
|
10540
10735
|
if (!await stream.writeFrame(frame)) {
|
|
@@ -10617,11 +10812,11 @@ async function runEncodeStage(input) {
|
|
|
10617
10812
|
);
|
|
10618
10813
|
}
|
|
10619
10814
|
captured.forEach((name, i) => {
|
|
10620
|
-
const dst =
|
|
10621
|
-
copyFileSync2(
|
|
10815
|
+
const dst = join24(outputPath, formatExportFrameName(i, "png"));
|
|
10816
|
+
copyFileSync2(join24(framesDir, name), dst);
|
|
10622
10817
|
});
|
|
10623
10818
|
if (hasAudio && audioOutputPath && existsSync14(audioOutputPath)) {
|
|
10624
|
-
copyFileSync2(audioOutputPath,
|
|
10819
|
+
copyFileSync2(audioOutputPath, join24(outputPath, MIXED_AUDIO_FILENAME));
|
|
10625
10820
|
log.info(
|
|
10626
10821
|
`[Render] png-sequence: ${MIXED_AUDIO_FILENAME} sidecar written to ${outputPath}/${MIXED_AUDIO_FILENAME}`
|
|
10627
10822
|
);
|
|
@@ -10641,7 +10836,7 @@ async function runEncodeStage(input) {
|
|
|
10641
10836
|
const encodeResult2 = await encodeGifFromDir(framesDir, framePattern2, outputPath, {
|
|
10642
10837
|
fps: job.config.fps,
|
|
10643
10838
|
loop,
|
|
10644
|
-
palettePath:
|
|
10839
|
+
palettePath: join24(dirname8(videoOnlyPath), "gif-palette.png"),
|
|
10645
10840
|
preserveAlpha: needsAlpha,
|
|
10646
10841
|
signal: abortSignal,
|
|
10647
10842
|
timeout: engineCfg.ffmpegEncodeTimeout
|
|
@@ -10853,9 +11048,9 @@ function sampleDirectoryBytes(dir) {
|
|
|
10853
11048
|
continue;
|
|
10854
11049
|
}
|
|
10855
11050
|
for (const name of entries) {
|
|
10856
|
-
const full =
|
|
11051
|
+
const full = join25(current, name);
|
|
10857
11052
|
try {
|
|
10858
|
-
const st =
|
|
11053
|
+
const st = statSync6(full);
|
|
10859
11054
|
if (st.isDirectory()) {
|
|
10860
11055
|
stack.push(full);
|
|
10861
11056
|
} else if (st.isFile()) {
|
|
@@ -11002,8 +11197,8 @@ function findMissingFrameRanges(totalFrames, framesDir, frameExt) {
|
|
|
11002
11197
|
const ranges = [];
|
|
11003
11198
|
let rangeStart = null;
|
|
11004
11199
|
for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
|
|
11005
|
-
const framePath =
|
|
11006
|
-
const missing = !existsSync15(framePath) ||
|
|
11200
|
+
const framePath = join25(framesDir, formatCaptureFrameName(frameIndex, frameExt));
|
|
11201
|
+
const missing = !existsSync15(framePath) || statSync6(framePath).size <= 8;
|
|
11007
11202
|
if (missing && rangeStart === null) {
|
|
11008
11203
|
rangeStart = frameIndex;
|
|
11009
11204
|
} else if (!missing && rangeStart !== null) {
|
|
@@ -11025,7 +11220,7 @@ function buildMissingFrameRetryBatches(ranges, maxWorkers, workDir, attempt, ran
|
|
|
11025
11220
|
workerId,
|
|
11026
11221
|
startFrame: rangeStart + range.startFrame,
|
|
11027
11222
|
endFrame: rangeStart + range.endFrame,
|
|
11028
|
-
outputDir:
|
|
11223
|
+
outputDir: join25(workDir, `retry-${attempt}-batch-${batchIndex}-worker-${workerId}`),
|
|
11029
11224
|
outputFrameOffset: rangeStart
|
|
11030
11225
|
}));
|
|
11031
11226
|
batches.push(batch);
|
|
@@ -11053,8 +11248,8 @@ function getNextRetryWorkerCount(currentWorkers) {
|
|
|
11053
11248
|
return Math.max(1, Math.floor(currentWorkers / 2));
|
|
11054
11249
|
}
|
|
11055
11250
|
function resolveRenderWorkDirPrefix(outputPath, jobId, platform2 = process.platform, systemTempDir = tmpdir2()) {
|
|
11056
|
-
if (platform2 === "win32" || platform2 === "darwin") return
|
|
11057
|
-
return
|
|
11251
|
+
if (platform2 === "win32" || platform2 === "darwin") return join25(systemTempDir, "hf-render-");
|
|
11252
|
+
return join25(dirname9(outputPath), `work-${jobId}-`);
|
|
11058
11253
|
}
|
|
11059
11254
|
var MAX_TRANSIENT_CAPTURE_RETRIES = 1;
|
|
11060
11255
|
function isTransientCaptureRetryEligible(failureKind, missing, retriesUsed) {
|
|
@@ -11086,7 +11281,7 @@ The composition is too large for the available memory. To reduce memory pressure
|
|
|
11086
11281
|
function countCapturedFrames(totalFrames, framesDir, frameExt) {
|
|
11087
11282
|
let captured = 0;
|
|
11088
11283
|
for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
|
|
11089
|
-
const framePath =
|
|
11284
|
+
const framePath = join25(framesDir, formatCaptureFrameName(frameIndex, frameExt));
|
|
11090
11285
|
if (existsSync15(framePath)) captured++;
|
|
11091
11286
|
}
|
|
11092
11287
|
return captured;
|
|
@@ -11112,7 +11307,7 @@ async function executeDiskCaptureWithAdaptiveRetry(options) {
|
|
|
11112
11307
|
reason: attempt === 0 ? "initial" : pendingTransientRetry ? "transient-retry" : "retry"
|
|
11113
11308
|
});
|
|
11114
11309
|
pendingTransientRetry = false;
|
|
11115
|
-
const attemptWorkDir =
|
|
11310
|
+
const attemptWorkDir = join25(options.workDir, `capture-attempt-${attempt}`);
|
|
11116
11311
|
const batches = missingRanges ? buildMissingFrameRetryBatches(
|
|
11117
11312
|
missingRanges,
|
|
11118
11313
|
currentWorkers,
|
|
@@ -11569,7 +11764,7 @@ function resolveDeShortBand(args) {
|
|
|
11569
11764
|
return args.bandOpen ? "applied" : "skipped_elements";
|
|
11570
11765
|
}
|
|
11571
11766
|
function shouldPreferSingleWorkerDrawElement(args) {
|
|
11572
|
-
return args.workerCount > 1 &&
|
|
11767
|
+
return args.workerCount > 1 && args.useDrawElement && !args.deCompileGate && !args.forceScreenshot && outputUsesH264Pipeline(args.outputFormat) && args.minFrames > 0 && args.totalFrames >= args.minFrames && args.singleWorkerStreamingOk && !args.layeredOrEffectRoute && !args.supersampling && !args.probeDeGated && !args.experimentalParallelDeOptIn;
|
|
11573
11768
|
}
|
|
11574
11769
|
function isProbeDeGated(session) {
|
|
11575
11770
|
return session !== null && session.captureMode !== "drawelement" && !session.deInitDeferred;
|
|
@@ -11705,17 +11900,17 @@ function deVerifyFallbackTelemetry(err) {
|
|
|
11705
11900
|
}
|
|
11706
11901
|
function resolveRenderDebugDir() {
|
|
11707
11902
|
const producerRoot = process.env.PRODUCER_RENDERS_DIR ? resolve6(process.env.PRODUCER_RENDERS_DIR, "..") : resolve6(dirname9(fileURLToPath4(import.meta.url)), "../..");
|
|
11708
|
-
return
|
|
11903
|
+
return join25(producerRoot, ".debug");
|
|
11709
11904
|
}
|
|
11710
11905
|
async function executeRenderJob(job, projectDir, outputPath, progressSink, abortSignal, assertRenderActive) {
|
|
11711
11906
|
validateHlsRenderConfig(job.config);
|
|
11712
11907
|
const debugDir = resolveRenderDebugDir();
|
|
11713
11908
|
const outputDir = dirname9(outputPath);
|
|
11714
11909
|
if (!existsSync15(outputDir)) mkdirSync8(outputDir, { recursive: true });
|
|
11715
|
-
const workDir = job.config.debug ?
|
|
11910
|
+
const workDir = job.config.debug ? join25(debugDir, job.id) : createRenderWorkDir(resolveRenderWorkDirPrefix(outputPath, job.id), outputDir);
|
|
11716
11911
|
const pipelineStart = Date.now();
|
|
11717
11912
|
const baseLog = job.config.logger ?? defaultLogger;
|
|
11718
|
-
const logPath = job.config.debug ?
|
|
11913
|
+
const logPath = job.config.debug ? join25(workDir, "render.log") : null;
|
|
11719
11914
|
const execution = new RenderExecutionContext({
|
|
11720
11915
|
request: { renderJobId: job.id, projectDir, outputPath },
|
|
11721
11916
|
logger: logPath ? createRenderFileLogger(logPath, baseLog) : baseLog,
|
|
@@ -11729,7 +11924,7 @@ async function executeRenderJob(job, projectDir, outputPath, progressSink, abort
|
|
|
11729
11924
|
log.info("KEEP_TEMP=1, leaving workDir on disk for inspection", { workDir });
|
|
11730
11925
|
return;
|
|
11731
11926
|
}
|
|
11732
|
-
|
|
11927
|
+
rmSync10(workDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
|
|
11733
11928
|
});
|
|
11734
11929
|
try {
|
|
11735
11930
|
await executeRenderPipeline({
|
|
@@ -11760,7 +11955,9 @@ async function executeRenderPipeline(input) {
|
|
|
11760
11955
|
const log = execution.logger;
|
|
11761
11956
|
const eventPublisher = execution.events;
|
|
11762
11957
|
const onProgress = execution.onProgress;
|
|
11763
|
-
const
|
|
11958
|
+
const tooSlow = new AbortController();
|
|
11959
|
+
let tooSlowError;
|
|
11960
|
+
const executionSignal = job.config.maxRenderMs ? AbortSignal.any([tooSlow.signal, ...execution.signal ? [execution.signal] : []]) : execution.signal;
|
|
11764
11961
|
let fileServer = null;
|
|
11765
11962
|
let probeSession = null;
|
|
11766
11963
|
let lastBrowserConsole = [];
|
|
@@ -11773,7 +11970,7 @@ async function executeRenderPipeline(input) {
|
|
|
11773
11970
|
imageDecodeFailures: 0
|
|
11774
11971
|
};
|
|
11775
11972
|
let hdrPerf;
|
|
11776
|
-
const perfOutputPath =
|
|
11973
|
+
const perfOutputPath = join25(workDir, "perf-summary.json");
|
|
11777
11974
|
const cfg = { ...job.config.producerConfig ?? resolveConfig() };
|
|
11778
11975
|
const observability = new RenderObservabilityRecorder({
|
|
11779
11976
|
pipelineStartMs: pipelineStart,
|
|
@@ -11875,15 +12072,15 @@ async function executeRenderPipeline(input) {
|
|
|
11875
12072
|
requestedWorkers: job.config.workers ?? "auto"
|
|
11876
12073
|
});
|
|
11877
12074
|
const entryFile = job.config.entryFile || "index.html";
|
|
11878
|
-
let htmlPath =
|
|
12075
|
+
let htmlPath = join25(projectDir, entryFile);
|
|
11879
12076
|
if (!existsSync15(htmlPath)) {
|
|
11880
12077
|
throw new Error(`Entry file not found: ${htmlPath}`);
|
|
11881
12078
|
}
|
|
11882
12079
|
assertNotAborted();
|
|
11883
12080
|
const rawEntry = readFileSync7(htmlPath, "utf-8");
|
|
11884
12081
|
if (entryFile !== "index.html" && isTemplateEntry(rawEntry)) {
|
|
11885
|
-
const wrapperPath =
|
|
11886
|
-
const projectIndexPath =
|
|
12082
|
+
const wrapperPath = join25(workDir, "standalone-entry.html");
|
|
12083
|
+
const projectIndexPath = join25(projectDir, "index.html");
|
|
11887
12084
|
if (!existsSync15(projectIndexPath)) {
|
|
11888
12085
|
throw new Error(
|
|
11889
12086
|
`Template entry file "${entryFile}" requires a project index.html to extract its render shell.`
|
|
@@ -12046,7 +12243,7 @@ async function executeRenderPipeline(input) {
|
|
|
12046
12243
|
updateJobStatus(job, "preprocessing", "Extracting video frames", 10, onProgress, {
|
|
12047
12244
|
code: "extract_video"
|
|
12048
12245
|
});
|
|
12049
|
-
const compiledDir =
|
|
12246
|
+
const compiledDir = join25(workDir, "compiled");
|
|
12050
12247
|
const extractResult = await observeRenderStage(
|
|
12051
12248
|
observability,
|
|
12052
12249
|
"video_extract",
|
|
@@ -12180,7 +12377,7 @@ async function executeRenderPipeline(input) {
|
|
|
12180
12377
|
try {
|
|
12181
12378
|
fileServer = await createFileServer({
|
|
12182
12379
|
projectDir,
|
|
12183
|
-
compiledDir:
|
|
12380
|
+
compiledDir: join25(workDir, "compiled"),
|
|
12184
12381
|
port: 0,
|
|
12185
12382
|
preHeadScripts: [VIRTUAL_TIME_SHIM],
|
|
12186
12383
|
fps: job.config.fps
|
|
@@ -12198,7 +12395,7 @@ async function executeRenderPipeline(input) {
|
|
|
12198
12395
|
if (!activeFileServer) {
|
|
12199
12396
|
throw new Error("File server failed to initialize before frame capture");
|
|
12200
12397
|
}
|
|
12201
|
-
const framesDir =
|
|
12398
|
+
const framesDir = join25(workDir, "captured-frames");
|
|
12202
12399
|
if (!existsSync15(framesDir)) mkdirSync8(framesDir, { recursive: true });
|
|
12203
12400
|
updateJobStatus(job, "rendering", "Checking browser GPU", 25, onProgress, {
|
|
12204
12401
|
code: "start_browsers"
|
|
@@ -12302,7 +12499,6 @@ async function executeRenderPipeline(input) {
|
|
|
12302
12499
|
const WOULD_RESOLVE_MULTI_WORKER = 2;
|
|
12303
12500
|
const deInversionArgs = {
|
|
12304
12501
|
workerCount: WOULD_RESOLVE_MULTI_WORKER,
|
|
12305
|
-
requestedWorkers: job.config.workers,
|
|
12306
12502
|
useDrawElement: cfg.useDrawElement,
|
|
12307
12503
|
deCompileGate,
|
|
12308
12504
|
forceScreenshot: captureForceScreenshot,
|
|
@@ -12508,7 +12704,7 @@ async function executeRenderPipeline(input) {
|
|
|
12508
12704
|
} else if (deInversionEligible && workerCount > 1) {
|
|
12509
12705
|
deWorkerInversion = "inverted";
|
|
12510
12706
|
log.info(
|
|
12511
|
-
`[Render] Fast capture: single-worker drawElement streaming preferred over ${workerCount}-worker screenshot capture (${totalFrames} frames >= ${deInversionEffectiveMinFrames}; verified path, measured faster at every worker count). Set HF_DE_SINGLE_MIN_FRAMES=0
|
|
12707
|
+
`[Render] Fast capture: single-worker drawElement streaming preferred over ${workerCount}-worker screenshot capture (${totalFrames} frames >= ${deInversionEffectiveMinFrames}; verified path, measured faster at every worker count). Set HF_DE_SINGLE_MIN_FRAMES=0 to override.`
|
|
12512
12708
|
);
|
|
12513
12709
|
workerCount = 1;
|
|
12514
12710
|
}
|
|
@@ -12552,6 +12748,27 @@ async function executeRenderPipeline(input) {
|
|
|
12552
12748
|
deWorkerInversion: deWorkerInversion ?? "none",
|
|
12553
12749
|
deParallelRouter: deParallelRouter ?? "none"
|
|
12554
12750
|
});
|
|
12751
|
+
const calibratedTooSlow = checkRenderEta("capture_calibration", {
|
|
12752
|
+
maxRenderMs: job.config.maxRenderMs,
|
|
12753
|
+
elapsedMs: Date.now() - pipelineStart,
|
|
12754
|
+
framesCompleted: 0,
|
|
12755
|
+
totalFrames,
|
|
12756
|
+
msPerFrame: (captureCalibration?.estimate.p95Ms ?? 0) / workerCount
|
|
12757
|
+
});
|
|
12758
|
+
if (calibratedTooSlow) throw calibratedTooSlow;
|
|
12759
|
+
execution.defer(
|
|
12760
|
+
"stop render ETA guard",
|
|
12761
|
+
startRenderEtaGuard({
|
|
12762
|
+
maxRenderMs: job.config.maxRenderMs,
|
|
12763
|
+
job,
|
|
12764
|
+
totalFrames,
|
|
12765
|
+
pipelineStartMs: pipelineStart,
|
|
12766
|
+
onTooSlow: (error) => {
|
|
12767
|
+
tooSlowError = error;
|
|
12768
|
+
tooSlow.abort(error);
|
|
12769
|
+
}
|
|
12770
|
+
})
|
|
12771
|
+
);
|
|
12555
12772
|
let useStreamingEncode = shouldUseStreamingEncode(
|
|
12556
12773
|
cfg,
|
|
12557
12774
|
outputFormat,
|
|
@@ -12645,7 +12862,7 @@ async function executeRenderPipeline(input) {
|
|
|
12645
12862
|
hls: ".mp4"
|
|
12646
12863
|
};
|
|
12647
12864
|
const videoExt = FORMAT_EXT[outputFormat] ?? ".mp4";
|
|
12648
|
-
const videoOnlyPath =
|
|
12865
|
+
const videoOnlyPath = join25(workDir, `video-only${videoExt}`);
|
|
12649
12866
|
const usePageSideCompositingForTransitions = (cfg.enablePageSideCompositing || isGif) && compiled.hasShaderTransitions && !hasHdrContent && outputSupportsPageSideShaderCompositing(outputFormat);
|
|
12650
12867
|
if (usePageSideCompositingForTransitions) {
|
|
12651
12868
|
activeFileServer.addPreHeadScript(HF_PAGE_SIDE_COMPOSITING_STUB);
|
|
@@ -12891,7 +13108,7 @@ async function executeRenderPipeline(input) {
|
|
|
12891
13108
|
pageMotionBlur: job.config.pageMotionBlur,
|
|
12892
13109
|
captureQuality: captureOptions.quality
|
|
12893
13110
|
});
|
|
12894
|
-
const segmentDir = segmentDirFor(
|
|
13111
|
+
const segmentDir = segmentDirFor(join25(projectDir, "renders"), segmentPlanHash);
|
|
12895
13112
|
let completedSegments = /* @__PURE__ */ new Set();
|
|
12896
13113
|
if (job.config.resumeSegments === true) {
|
|
12897
13114
|
const existing = readSegmentManifest(segmentDir);
|
|
@@ -12906,10 +13123,10 @@ async function executeRenderPipeline(input) {
|
|
|
12906
13123
|
});
|
|
12907
13124
|
}
|
|
12908
13125
|
if (completedSegments.size === 0) {
|
|
12909
|
-
|
|
13126
|
+
rmSync10(segmentDir, { recursive: true, force: true });
|
|
12910
13127
|
}
|
|
12911
13128
|
} else {
|
|
12912
|
-
|
|
13129
|
+
rmSync10(segmentDir, { recursive: true, force: true });
|
|
12913
13130
|
}
|
|
12914
13131
|
const segmentManifest = readSegmentManifest(segmentDir) ?? {
|
|
12915
13132
|
version: 1,
|
|
@@ -12990,7 +13207,7 @@ async function executeRenderPipeline(input) {
|
|
|
12990
13207
|
);
|
|
12991
13208
|
updateCaptureObservability({ segmentRetries: segmentedRes.segmentRetries });
|
|
12992
13209
|
if (job.config.keepSegments !== true) {
|
|
12993
|
-
|
|
13210
|
+
rmSync10(segmentDir, { recursive: true, force: true });
|
|
12994
13211
|
}
|
|
12995
13212
|
} else {
|
|
12996
13213
|
capturePlan = replanAfterFailure(capturePlan, { kind: "streaming_unavailable" });
|
|
@@ -13259,7 +13476,7 @@ async function executeRenderPipeline(input) {
|
|
|
13259
13476
|
"capture_disk",
|
|
13260
13477
|
"drawElement capture failed; retrying with a fresh screenshot session"
|
|
13261
13478
|
);
|
|
13262
|
-
|
|
13479
|
+
rmSync10(framesDir, { recursive: true, force: true });
|
|
13263
13480
|
mkdirSync8(framesDir, { recursive: true });
|
|
13264
13481
|
resetCaptureAttemptProgress(job);
|
|
13265
13482
|
dedupPerfs.length = 0;
|
|
@@ -13446,7 +13663,7 @@ async function executeRenderPipeline(input) {
|
|
|
13446
13663
|
}
|
|
13447
13664
|
if (job.config.debug) {
|
|
13448
13665
|
if (!isPngSequence && !isHls && existsSync15(stagedOutputPath)) {
|
|
13449
|
-
const debugOutput =
|
|
13666
|
+
const debugOutput = join25(workDir, `output${videoExt}`);
|
|
13450
13667
|
copyFileSync3(stagedOutputPath, debugOutput);
|
|
13451
13668
|
}
|
|
13452
13669
|
}
|
|
@@ -13457,8 +13674,9 @@ async function executeRenderPipeline(input) {
|
|
|
13457
13674
|
job.outputPath = outputPath;
|
|
13458
13675
|
updateJobStatus(job, "complete", "Render complete", 100, onProgress);
|
|
13459
13676
|
await eventPublisher.flush();
|
|
13460
|
-
} catch (
|
|
13461
|
-
|
|
13677
|
+
} catch (caught) {
|
|
13678
|
+
const error = tooSlowError ?? caught;
|
|
13679
|
+
if (!tooSlowError && (error instanceof RenderCancelledError || executionSignal?.aborted)) {
|
|
13462
13680
|
job.error = error instanceof Error ? error.message : "render_cancelled";
|
|
13463
13681
|
updateJobStatus(job, "cancelled", "Render cancelled", job.progress, onProgress);
|
|
13464
13682
|
await eventPublisher.flush();
|
|
@@ -13555,21 +13773,21 @@ import {
|
|
|
13555
13773
|
existsSync as existsSync20,
|
|
13556
13774
|
linkSync,
|
|
13557
13775
|
mkdirSync as mkdirSync12,
|
|
13558
|
-
rmSync as
|
|
13776
|
+
rmSync as rmSync12,
|
|
13559
13777
|
writeFileSync as writeFileSync8
|
|
13560
13778
|
} from "fs";
|
|
13561
|
-
import { extname as extname6, isAbsolute as isAbsolute2, join as
|
|
13779
|
+
import { extname as extname6, isAbsolute as isAbsolute2, join as join33, relative as relative5, sep as sep2 } from "path";
|
|
13562
13780
|
|
|
13563
13781
|
// ../producer/src/services/distributed/planFrameCost.ts
|
|
13564
|
-
import { join as
|
|
13782
|
+
import { join as join28 } from "path";
|
|
13565
13783
|
|
|
13566
13784
|
// ../producer/src/services/distributed/chunkFrames.ts
|
|
13567
13785
|
import { existsSync as existsSync17, readdirSync as readdirSync6 } from "fs";
|
|
13568
|
-
import { extname as extname4, join as
|
|
13786
|
+
import { extname as extname4, join as join27 } from "path";
|
|
13569
13787
|
|
|
13570
13788
|
// ../producer/src/services/distributed/shared.ts
|
|
13571
13789
|
import { execFile as execFileCallback } from "child_process";
|
|
13572
|
-
import { dirname as dirname10, join as
|
|
13790
|
+
import { dirname as dirname10, join as join26 } from "path";
|
|
13573
13791
|
import { existsSync as existsSync16, readFileSync as readFileSync8 } from "fs";
|
|
13574
13792
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
13575
13793
|
import { promisify as promisify2 } from "util";
|
|
@@ -13581,7 +13799,7 @@ function isPlanAudioArtifactPath(path) {
|
|
|
13581
13799
|
}
|
|
13582
13800
|
function resolvePlanAudioPath(planDir) {
|
|
13583
13801
|
for (const name of [PLAN_AUDIO_RELATIVE_PATH, PLAN_AUDIO_LEGACY_RELATIVE_PATH]) {
|
|
13584
|
-
const candidate =
|
|
13802
|
+
const candidate = join26(planDir, name);
|
|
13585
13803
|
if (existsSync16(candidate)) return candidate;
|
|
13586
13804
|
}
|
|
13587
13805
|
return null;
|
|
@@ -13841,7 +14059,7 @@ function readProducerVersion() {
|
|
|
13841
14059
|
const startDir = dirname10(fileURLToPath5(import.meta.url));
|
|
13842
14060
|
let current = startDir;
|
|
13843
14061
|
for (let i = 0; i < 10; i++) {
|
|
13844
|
-
const candidate =
|
|
14062
|
+
const candidate = join26(current, "package.json");
|
|
13845
14063
|
if (existsSync16(candidate)) {
|
|
13846
14064
|
try {
|
|
13847
14065
|
const pkg = JSON.parse(readFileSync8(candidate, "utf-8"));
|
|
@@ -13895,7 +14113,7 @@ function frameNumberFromFileName(name) {
|
|
|
13895
14113
|
function rebuildExtractedFramesFromPlanDir(planDir, videos, indexMode = "dense-v1") {
|
|
13896
14114
|
const result = [];
|
|
13897
14115
|
for (const v of videos) {
|
|
13898
|
-
const outputDir =
|
|
14116
|
+
const outputDir = join27(planDir, "video-frames", v.videoId);
|
|
13899
14117
|
if (!existsSync17(outputDir)) {
|
|
13900
14118
|
throw new Error(
|
|
13901
14119
|
`[renderChunk] planDir missing extracted video frames for ${JSON.stringify(v.videoId)}: ${outputDir} not present. plan() should have written frames here; the planDir is malformed.`
|
|
@@ -13914,7 +14132,7 @@ function rebuildExtractedFramesFromPlanDir(planDir, videos, indexMode = "dense-v
|
|
|
13914
14132
|
if (!frameName) continue;
|
|
13915
14133
|
const frameNumber = indexMode === "sparse-v2" ? frameNumberFromFileName(frameName) : null;
|
|
13916
14134
|
const frameIndex = frameNumber === null ? i : frameNumber - 1;
|
|
13917
|
-
framePaths.set(frameIndex,
|
|
14135
|
+
framePaths.set(frameIndex, join27(outputDir, frameName));
|
|
13918
14136
|
}
|
|
13919
14137
|
result.push({
|
|
13920
14138
|
videoId: v.videoId,
|
|
@@ -14004,14 +14222,14 @@ async function extractDeferredVideoFramesForChunk(input) {
|
|
|
14004
14222
|
const shown = shownDeferredFrameIndexes(input.planVideos, input.frames, input.fps);
|
|
14005
14223
|
return Promise.all(
|
|
14006
14224
|
deferred.map(async (video) => {
|
|
14007
|
-
const outputDir =
|
|
14225
|
+
const outputDir = join27(input.outputRoot, video.videoId);
|
|
14008
14226
|
const indexes = [...shown.get(video.videoId) ?? []].sort((a, b) => a - b);
|
|
14009
14227
|
if (indexes.length === 0) {
|
|
14010
14228
|
return { ...video, outputDir, framePaths: /* @__PURE__ */ new Map(), ownedByLookup: false };
|
|
14011
14229
|
}
|
|
14012
14230
|
const range = video.deferredRange;
|
|
14013
14231
|
const remoteUrl = remoteSources[range.sourcePath];
|
|
14014
|
-
const sourcePath = remoteUrl ??
|
|
14232
|
+
const sourcePath = remoteUrl ?? join27(input.planDir, ...range.sourcePath.split("/"));
|
|
14015
14233
|
if (remoteUrl === void 0 && !existsSync17(sourcePath)) {
|
|
14016
14234
|
throw new RenderChunkValidationError(
|
|
14017
14235
|
MISSING_PLAN_ARTIFACT,
|
|
@@ -14060,12 +14278,12 @@ async function measurePlanSecondsPerFrame(input) {
|
|
|
14060
14278
|
planVideos,
|
|
14061
14279
|
frames: sampled,
|
|
14062
14280
|
fps: fpsRatio,
|
|
14063
|
-
outputRoot:
|
|
14281
|
+
outputRoot: join28(workDir, "frame-cost-video-frames"),
|
|
14064
14282
|
cfg: input.cfg
|
|
14065
14283
|
})
|
|
14066
14284
|
];
|
|
14067
14285
|
const lookup = extracted.length > 0 ? createFrameLookupTable(planVideos.videos, extracted, resolveRenderFpsConfig(fpsRatio).value) : null;
|
|
14068
|
-
const compiledDir =
|
|
14286
|
+
const compiledDir = join28(planDir, "compiled");
|
|
14069
14287
|
const fileServer = await createFileServer({
|
|
14070
14288
|
projectDir: compiledDir,
|
|
14071
14289
|
compiledDir,
|
|
@@ -14077,7 +14295,7 @@ async function measurePlanSecondsPerFrame(input) {
|
|
|
14077
14295
|
try {
|
|
14078
14296
|
session = await createCaptureSession(
|
|
14079
14297
|
fileServer.url,
|
|
14080
|
-
|
|
14298
|
+
join28(workDir, "frame-cost"),
|
|
14081
14299
|
buildChunkCaptureOptions({
|
|
14082
14300
|
dimensions: { ...input, fpsNum: fps, fpsDen: 1 },
|
|
14083
14301
|
encoder: input,
|
|
@@ -14162,7 +14380,7 @@ function buildWeightedChunkSlices(weights, chunkCount, minFrames, maxFrames) {
|
|
|
14162
14380
|
|
|
14163
14381
|
// ../producer/src/services/render/stages/freezePlan.ts
|
|
14164
14382
|
import { existsSync as existsSync18, mkdirSync as mkdirSync9, readFileSync as readFileSync9, readdirSync as readdirSync7, writeFileSync as writeFileSync6 } from "fs";
|
|
14165
|
-
import { join as
|
|
14383
|
+
import { join as join29, relative as relative3, resolve as resolve7 } from "path";
|
|
14166
14384
|
|
|
14167
14385
|
// ../producer/src/services/distributed/planProtocol.ts
|
|
14168
14386
|
var PLAN_SCHEMA_VERSION = 1;
|
|
@@ -14261,7 +14479,7 @@ function readPlanProtocolV1(planJson, capabilities = DISTRIBUTED_RENDER_CAPABILI
|
|
|
14261
14479
|
|
|
14262
14480
|
// ../producer/src/services/render/stages/planHash.ts
|
|
14263
14481
|
import { createHash as createHash5 } from "crypto";
|
|
14264
|
-
import { closeSync as
|
|
14482
|
+
import { closeSync as closeSync4, createReadStream as createReadStream3, openSync as openSync4, readSync as readSync3 } from "fs";
|
|
14265
14483
|
var PLAN_HASH_SCHEMA_PREFIX = "hyperframes-plan-hash-v1\0";
|
|
14266
14484
|
var FIELD_DELIMITER = Buffer.from([0]);
|
|
14267
14485
|
function computePlanHash(input) {
|
|
@@ -14327,7 +14545,7 @@ function sha256File(path) {
|
|
|
14327
14545
|
if (bytesRead > 0) hash.update(buffer.subarray(0, bytesRead));
|
|
14328
14546
|
} while (bytesRead > 0);
|
|
14329
14547
|
} finally {
|
|
14330
|
-
|
|
14548
|
+
closeSync4(fd);
|
|
14331
14549
|
}
|
|
14332
14550
|
return hash.digest("hex");
|
|
14333
14551
|
}
|
|
@@ -14380,7 +14598,7 @@ function listPlanFiles(planDir) {
|
|
|
14380
14598
|
function walk(dir) {
|
|
14381
14599
|
const entries = readdirSync7(dir, { withFileTypes: true });
|
|
14382
14600
|
for (const entry of entries) {
|
|
14383
|
-
const full =
|
|
14601
|
+
const full = join29(dir, entry.name);
|
|
14384
14602
|
if (entry.isDirectory()) {
|
|
14385
14603
|
walk(full);
|
|
14386
14604
|
} else if (entry.isFile()) {
|
|
@@ -14421,15 +14639,15 @@ var PLAN_REMOTE_FILES_RELATIVE_PATH = "meta/remote-files.json";
|
|
|
14421
14639
|
function writePlanRemoteFiles(planDir, files) {
|
|
14422
14640
|
if (files.length === 0) return;
|
|
14423
14641
|
const sorted = [...files].sort((a, b) => a.path < b.path ? -1 : 1);
|
|
14424
|
-
writeFileSync6(
|
|
14642
|
+
writeFileSync6(join29(planDir, PLAN_REMOTE_FILES_RELATIVE_PATH), JSON.stringify(sorted), "utf-8");
|
|
14425
14643
|
}
|
|
14426
14644
|
function readPlanRemoteFiles(planDir) {
|
|
14427
|
-
const path =
|
|
14645
|
+
const path = join29(planDir, PLAN_REMOTE_FILES_RELATIVE_PATH);
|
|
14428
14646
|
return existsSync18(path) ? JSON.parse(readFileSync9(path, "utf-8")) : [];
|
|
14429
14647
|
}
|
|
14430
14648
|
function recomputePlanHashFromPlanDir(planDir, digests) {
|
|
14431
|
-
const planJsonPath =
|
|
14432
|
-
const encoderJsonPath =
|
|
14649
|
+
const planJsonPath = join29(planDir, "plan.json");
|
|
14650
|
+
const encoderJsonPath = join29(planDir, "meta", "encoder.json");
|
|
14433
14651
|
if (!existsSync18(planJsonPath)) {
|
|
14434
14652
|
throw new Error(`[freezePlan] plan.json missing: ${planJsonPath}`);
|
|
14435
14653
|
}
|
|
@@ -14466,18 +14684,18 @@ async function freezePlan(input) {
|
|
|
14466
14684
|
if (!existsSync18(planDir)) {
|
|
14467
14685
|
throw new Error(`[freezePlan] planDir does not exist: ${planDir}`);
|
|
14468
14686
|
}
|
|
14469
|
-
const metaDir =
|
|
14687
|
+
const metaDir = join29(planDir, "meta");
|
|
14470
14688
|
if (!existsSync18(metaDir)) mkdirSync9(metaDir, { recursive: true });
|
|
14471
14689
|
writeFileSync6(
|
|
14472
|
-
|
|
14690
|
+
join29(metaDir, "composition.json"),
|
|
14473
14691
|
`${JSON.stringify(composition, null, 2)}
|
|
14474
14692
|
`,
|
|
14475
14693
|
"utf-8"
|
|
14476
14694
|
);
|
|
14477
14695
|
const encoderForCanonical = stripUndefined(encoder);
|
|
14478
14696
|
const encoderConfigCanonicalJson = canonicalJsonStringify(encoderForCanonical);
|
|
14479
|
-
writeFileSync6(
|
|
14480
|
-
writeFileSync6(
|
|
14697
|
+
writeFileSync6(join29(metaDir, "encoder.json"), encoderConfigCanonicalJson, "utf-8");
|
|
14698
|
+
writeFileSync6(join29(metaDir, "chunks.json"), `${JSON.stringify(chunks, null, 2)}
|
|
14481
14699
|
`, "utf-8");
|
|
14482
14700
|
const { compositionHtml, assets } = collectPlanAssetShas(planDir, digests);
|
|
14483
14701
|
const planHash = computePlanHash({
|
|
@@ -14501,7 +14719,7 @@ async function freezePlan(input) {
|
|
|
14501
14719
|
duration: durationSeconds,
|
|
14502
14720
|
hasAudio
|
|
14503
14721
|
};
|
|
14504
|
-
const planJsonPath =
|
|
14722
|
+
const planJsonPath = join29(planDir, "plan.json");
|
|
14505
14723
|
writeFileSync6(planJsonPath, `${JSON.stringify(planJson, null, 2)}
|
|
14506
14724
|
`, "utf-8");
|
|
14507
14725
|
return { planJsonPath, planHash };
|
|
@@ -14543,14 +14761,14 @@ function applyRuntimeEnvSnapshot(snapshot, env = process.env) {
|
|
|
14543
14761
|
}
|
|
14544
14762
|
|
|
14545
14763
|
// ../producer/src/services/distributed/chunkAudio.ts
|
|
14546
|
-
import { closeSync as
|
|
14764
|
+
import { closeSync as closeSync5, existsSync as existsSync19, ftruncateSync, mkdirSync as mkdirSync11, openSync as openSync5, readFileSync as readFileSync10 } from "fs";
|
|
14547
14765
|
import { writeFileSync as writeFileSync7, writeSync } from "fs";
|
|
14548
|
-
import { join as
|
|
14766
|
+
import { join as join31 } from "path";
|
|
14549
14767
|
|
|
14550
14768
|
// ../producer/src/services/distributed/mp4Stitch.ts
|
|
14551
|
-
import { createReadStream as createReadStream4, createWriteStream, mkdirSync as mkdirSync10, mkdtempSync as mkdtempSync4, rmSync as
|
|
14769
|
+
import { createReadStream as createReadStream4, createWriteStream, mkdirSync as mkdirSync10, mkdtempSync as mkdtempSync4, rmSync as rmSync11 } from "fs";
|
|
14552
14770
|
import { open } from "fs/promises";
|
|
14553
|
-
import { dirname as dirname11, join as
|
|
14771
|
+
import { dirname as dirname11, join as join30 } from "path";
|
|
14554
14772
|
import { finished, pipeline } from "stream/promises";
|
|
14555
14773
|
function boxAt(src, off, at, limit) {
|
|
14556
14774
|
let size = src.readUInt32BE(off);
|
|
@@ -14916,16 +15134,16 @@ async function writeStitchedMp4(chunkPaths, outputPath, audioPath) {
|
|
|
14916
15134
|
const header = audioPath ? buildStitchedHeader(layouts.slice(1), layouts[0]) : buildStitchedHeader(layouts);
|
|
14917
15135
|
mkdirSync10(dirname11(outputPath), { recursive: true });
|
|
14918
15136
|
const workDir = mkdtempSync4(`${outputPath}.stitch-`);
|
|
14919
|
-
const out = createWriteStream(
|
|
15137
|
+
const out = createWriteStream(join30(workDir, "out.mp4"));
|
|
14920
15138
|
try {
|
|
14921
15139
|
out.write(header);
|
|
14922
15140
|
for (const [i, path] of sourcePaths.entries()) await copyPayload(path, layouts[i], i, out);
|
|
14923
15141
|
out.end();
|
|
14924
15142
|
await finished(out);
|
|
14925
|
-
renameWithRetry(
|
|
15143
|
+
renameWithRetry(join30(workDir, "out.mp4"), outputPath);
|
|
14926
15144
|
} finally {
|
|
14927
15145
|
out.destroy();
|
|
14928
|
-
|
|
15146
|
+
rmSync11(workDir, { recursive: true, force: true });
|
|
14929
15147
|
}
|
|
14930
15148
|
}
|
|
14931
15149
|
|
|
@@ -15016,7 +15234,7 @@ async function writeChunkAudioSlices(input) {
|
|
|
15016
15234
|
});
|
|
15017
15235
|
const bytes = readFileSync10(input.audioPath);
|
|
15018
15236
|
const layout = { sizeBytes: bytes.length, payloadStart, payloadEnd, partStarts: {} };
|
|
15019
|
-
mkdirSync11(
|
|
15237
|
+
mkdirSync11(join31(input.planDir, SLICE_DIR), { recursive: true });
|
|
15020
15238
|
input.chunks.forEach((_, index) => {
|
|
15021
15239
|
const cut = audioCutForChunk(grid, input.chunks, index, input.fps);
|
|
15022
15240
|
if (!cut) return;
|
|
@@ -15024,17 +15242,17 @@ async function writeChunkAudioSlices(input) {
|
|
|
15024
15242
|
const start = offsets[cut.firstPacket];
|
|
15025
15243
|
layout.partStarts[index] = start;
|
|
15026
15244
|
const end = offsets[last] + track.sizes[last];
|
|
15027
|
-
writeFileSync7(
|
|
15245
|
+
writeFileSync7(join31(input.planDir, chunkAudioSlicePath(index)), bytes.subarray(start, end));
|
|
15028
15246
|
});
|
|
15029
15247
|
const frame = [bytes.subarray(0, payloadStart), bytes.subarray(payloadEnd)];
|
|
15030
|
-
writeFileSync7(
|
|
15031
|
-
writeFileSync7(
|
|
15248
|
+
writeFileSync7(join31(input.planDir, SLICE_FRAME), Buffer.concat(frame));
|
|
15249
|
+
writeFileSync7(join31(input.planDir, SLICE_LAYOUT), JSON.stringify(layout));
|
|
15032
15250
|
}
|
|
15033
15251
|
function chunkAudioSource(planDir, chunkIndex, scratchPath) {
|
|
15034
|
-
const layoutPath =
|
|
15252
|
+
const layoutPath = join31(planDir, SLICE_LAYOUT);
|
|
15035
15253
|
if (!existsSync19(layoutPath)) return resolvePlanAudioPath(planDir);
|
|
15036
15254
|
const layout = JSON.parse(readFileSync10(layoutPath, "utf-8"));
|
|
15037
|
-
const frame = readFileSync10(
|
|
15255
|
+
const frame = readFileSync10(join31(planDir, SLICE_FRAME));
|
|
15038
15256
|
const fd = openSync5(scratchPath, "w");
|
|
15039
15257
|
try {
|
|
15040
15258
|
writeSync(fd, frame, 0, layout.payloadStart, 0);
|
|
@@ -15047,12 +15265,12 @@ function chunkAudioSource(planDir, chunkIndex, scratchPath) {
|
|
|
15047
15265
|
);
|
|
15048
15266
|
const start = layout.partStarts[chunkIndex];
|
|
15049
15267
|
if (start !== void 0) {
|
|
15050
|
-
const part = readFileSync10(
|
|
15268
|
+
const part = readFileSync10(join31(planDir, chunkAudioSlicePath(chunkIndex)));
|
|
15051
15269
|
writeSync(fd, part, 0, part.length, start);
|
|
15052
15270
|
}
|
|
15053
15271
|
ftruncateSync(fd, layout.sizeBytes);
|
|
15054
15272
|
} finally {
|
|
15055
|
-
|
|
15273
|
+
closeSync5(fd);
|
|
15056
15274
|
}
|
|
15057
15275
|
return scratchPath;
|
|
15058
15276
|
}
|
|
@@ -15103,7 +15321,7 @@ async function muxChunkWithAudio(input) {
|
|
|
15103
15321
|
// ../producer/src/services/distributed/planSize.ts
|
|
15104
15322
|
import { createHash as createHash6 } from "crypto";
|
|
15105
15323
|
import { lstatSync as lstatSync2, readdirSync as readdirSync8 } from "fs";
|
|
15106
|
-
import { extname as extname5, join as
|
|
15324
|
+
import { extname as extname5, join as join32, relative as relative4 } from "path";
|
|
15107
15325
|
var MAX_TOP_COMPONENTS = 10;
|
|
15108
15326
|
var SOURCE_MEDIA_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
15109
15327
|
".aac",
|
|
@@ -15215,7 +15433,7 @@ function walkRegularFiles(dir, visit) {
|
|
|
15215
15433
|
return;
|
|
15216
15434
|
}
|
|
15217
15435
|
for (const entry of entries) {
|
|
15218
|
-
const full =
|
|
15436
|
+
const full = join32(dir, entry.name);
|
|
15219
15437
|
if (entry.isDirectory()) {
|
|
15220
15438
|
walkRegularFiles(full, visit);
|
|
15221
15439
|
} else if (entry.isFile()) {
|
|
@@ -15427,13 +15645,13 @@ function assertPositiveInteger2(name, value) {
|
|
|
15427
15645
|
}
|
|
15428
15646
|
var FREEZE_OWNED_PLAN_FILES = [
|
|
15429
15647
|
"plan.json",
|
|
15430
|
-
|
|
15431
|
-
|
|
15432
|
-
|
|
15648
|
+
join33("meta", "composition.json"),
|
|
15649
|
+
join33("meta", "encoder.json"),
|
|
15650
|
+
join33("meta", "chunks.json")
|
|
15433
15651
|
];
|
|
15434
15652
|
function removeFreezeOwnedPlanFiles(planDir) {
|
|
15435
15653
|
for (const relativePath of FREEZE_OWNED_PLAN_FILES) {
|
|
15436
|
-
|
|
15654
|
+
rmSync12(join33(planDir, relativePath), { force: true });
|
|
15437
15655
|
}
|
|
15438
15656
|
}
|
|
15439
15657
|
function buildChunkSlices(totalFrames, chunkCount, effectiveChunkSize) {
|
|
@@ -15575,19 +15793,19 @@ function createVideoSourceShipper(input) {
|
|
|
15575
15793
|
const known = shipped.get(srcPath);
|
|
15576
15794
|
if (known) return known;
|
|
15577
15795
|
const stagedRel = pathInside(input.workVideoFramesDir, srcPath);
|
|
15578
|
-
const current = stagedRel === null ? srcPath :
|
|
15796
|
+
const current = stagedRel === null ? srcPath : join33(input.planDir, "video-frames", stagedRel);
|
|
15579
15797
|
let result = null;
|
|
15580
15798
|
for (const root of stagedRel === null ? [input.workCompiledDir, input.projectDir] : []) {
|
|
15581
15799
|
const rel = pathInside(root, srcPath);
|
|
15582
|
-
if (rel !== null && (existsSync20(
|
|
15800
|
+
if (rel !== null && (existsSync20(join33(input.planDir, "compiled", rel)) || input.isRemote(srcPath))) {
|
|
15583
15801
|
result = ["compiled", ...rel.split(sep2)].join("/");
|
|
15584
15802
|
break;
|
|
15585
15803
|
}
|
|
15586
15804
|
}
|
|
15587
15805
|
if (result === null) {
|
|
15588
15806
|
result = `video-sources/${shipped.size}${extname6(current)}`;
|
|
15589
|
-
const destination =
|
|
15590
|
-
mkdirSync12(
|
|
15807
|
+
const destination = join33(input.planDir, ...result.split("/"));
|
|
15808
|
+
mkdirSync12(join33(input.planDir, "video-sources"), { recursive: true });
|
|
15591
15809
|
try {
|
|
15592
15810
|
linkSync(current, destination);
|
|
15593
15811
|
} catch {
|
|
@@ -15636,14 +15854,14 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
|
|
|
15636
15854
|
variables: config.variables
|
|
15637
15855
|
});
|
|
15638
15856
|
const entryFile = config.entryFile ?? "index.html";
|
|
15639
|
-
const htmlPath =
|
|
15857
|
+
const htmlPath = join33(projectDir, entryFile);
|
|
15640
15858
|
if (!existsSync20(htmlPath)) {
|
|
15641
15859
|
throw new Error(`[plan] entry file not found: ${htmlPath}`);
|
|
15642
15860
|
}
|
|
15643
|
-
const workDir =
|
|
15644
|
-
|
|
15861
|
+
const workDir = join33(planDir, ".plan-work");
|
|
15862
|
+
rmSync12(workDir, { recursive: true, force: true });
|
|
15645
15863
|
mkdirSync12(workDir, { recursive: true });
|
|
15646
|
-
const compiledDir =
|
|
15864
|
+
const compiledDir = join33(workDir, "compiled");
|
|
15647
15865
|
mkdirSync12(compiledDir, { recursive: true });
|
|
15648
15866
|
let stageStarted = Date.now();
|
|
15649
15867
|
cpSync2(projectDir, compiledDir, {
|
|
@@ -15657,10 +15875,10 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
|
|
|
15657
15875
|
}
|
|
15658
15876
|
});
|
|
15659
15877
|
logPlanStage(log, "copy", stageStarted);
|
|
15660
|
-
const finalCompiledDir =
|
|
15878
|
+
const finalCompiledDir = join33(planDir, "compiled");
|
|
15661
15879
|
const needsAlpha = outputNeedsAlpha(config.format);
|
|
15662
15880
|
const remoteFiles = Object.entries(options.remoteFiles ?? {});
|
|
15663
|
-
const remoteLocalPath = (rel) =>
|
|
15881
|
+
const remoteLocalPath = (rel) => join33(projectDir, ...rel.split("/"));
|
|
15664
15882
|
for (const [, file] of remoteFiles) {
|
|
15665
15883
|
declareContentAddressedUrl(file.url, file.sha256);
|
|
15666
15884
|
if (file.probeFactsUrl) declareProbeFactsUrl(file.url, file.probeFactsUrl);
|
|
@@ -15739,7 +15957,7 @@ async function compilePlanComposition(projectDir, config, planDir, options) {
|
|
|
15739
15957
|
if (probeResult.fileServer) closeFileServerSafely(probeResult.fileServer, "plan", log);
|
|
15740
15958
|
if (probeResult.probeSession) {
|
|
15741
15959
|
try {
|
|
15742
|
-
const { closeCaptureSession: closeCaptureSession2 } = await import("./src-
|
|
15960
|
+
const { closeCaptureSession: closeCaptureSession2 } = await import("./src-QQPHMIJ7.js");
|
|
15743
15961
|
await closeCaptureSession2(probeResult.probeSession);
|
|
15744
15962
|
} catch (err) {
|
|
15745
15963
|
log.warn("[plan] probe session close failed", {
|
|
@@ -15846,17 +16064,17 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
|
|
|
15846
16064
|
let stageStarted = Date.now();
|
|
15847
16065
|
const extractResult = await extractPlanVideos(c, options.deferVideoExtraction);
|
|
15848
16066
|
logPlanStage(log, "extract", stageStarted);
|
|
15849
|
-
const stagedVideoFrames =
|
|
15850
|
-
const videoFramesDst =
|
|
15851
|
-
if (existsSync20(videoFramesDst))
|
|
15852
|
-
const videoSourcesDir =
|
|
15853
|
-
|
|
16067
|
+
const stagedVideoFrames = join33(compiledDir, "__hyperframes_video_frames");
|
|
16068
|
+
const videoFramesDst = join33(planDir, "video-frames");
|
|
16069
|
+
if (existsSync20(videoFramesDst)) rmSync12(videoFramesDst, { recursive: true, force: true });
|
|
16070
|
+
const videoSourcesDir = join33(planDir, "video-sources");
|
|
16071
|
+
rmSync12(videoSourcesDir, { recursive: true, force: true });
|
|
15854
16072
|
if (existsSync20(stagedVideoFrames)) {
|
|
15855
16073
|
renameWithRetry(stagedVideoFrames, videoFramesDst);
|
|
15856
16074
|
} else {
|
|
15857
16075
|
mkdirSync12(videoFramesDst, { recursive: true });
|
|
15858
16076
|
}
|
|
15859
|
-
if (existsSync20(finalCompiledDir))
|
|
16077
|
+
if (existsSync20(finalCompiledDir)) rmSync12(finalCompiledDir, { recursive: true, force: true });
|
|
15860
16078
|
renameWithRetry(compiledDir, finalCompiledDir);
|
|
15861
16079
|
const shipVideoSource = createVideoSourceShipper({
|
|
15862
16080
|
planDir,
|
|
@@ -15886,7 +16104,7 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
|
|
|
15886
16104
|
};
|
|
15887
16105
|
})
|
|
15888
16106
|
});
|
|
15889
|
-
mkdirSync12(
|
|
16107
|
+
mkdirSync12(join33(planDir, "meta"), { recursive: true });
|
|
15890
16108
|
writePlanRemoteFiles(
|
|
15891
16109
|
planDir,
|
|
15892
16110
|
remoteFiles.map(([rel, { sha256, sizeBytes }]) => ({
|
|
@@ -15896,7 +16114,7 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
|
|
|
15896
16114
|
}))
|
|
15897
16115
|
);
|
|
15898
16116
|
writeFileSync8(
|
|
15899
|
-
|
|
16117
|
+
join33(planDir, PLAN_VIDEOS_META_RELATIVE_PATH),
|
|
15900
16118
|
JSON.stringify(planVideosJson, null, 2),
|
|
15901
16119
|
"utf-8"
|
|
15902
16120
|
);
|
|
@@ -15975,7 +16193,7 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
|
|
|
15975
16193
|
if (audioResult?.audioError) {
|
|
15976
16194
|
applyDistributedAudioWarningPolicy(job, audioResult.audioError, audioResult.audioFailures, log);
|
|
15977
16195
|
}
|
|
15978
|
-
const planAudioPath =
|
|
16196
|
+
const planAudioPath = join33(planDir, PLAN_AUDIO_RELATIVE_PATH);
|
|
15979
16197
|
if (audioResult?.hasAudio && existsSync20(audioResult.audioOutputPath)) {
|
|
15980
16198
|
renameWithRetry(audioResult.audioOutputPath, planAudioPath);
|
|
15981
16199
|
}
|
|
@@ -16024,7 +16242,7 @@ async function buildLocalExecutionPlan(projectDir, config, executionPlanDir, opt
|
|
|
16024
16242
|
format: config.format
|
|
16025
16243
|
};
|
|
16026
16244
|
try {
|
|
16027
|
-
|
|
16245
|
+
rmSync12(workDir, { recursive: true, force: true });
|
|
16028
16246
|
} catch (err) {
|
|
16029
16247
|
log.warn("[plan] failed to remove temp work dir", {
|
|
16030
16248
|
workDir,
|
|
@@ -16399,6 +16617,7 @@ function assertRequestOptionScalars(options) {
|
|
|
16399
16617
|
assertOptionalInteger(options, "gifLoop");
|
|
16400
16618
|
assertOptionalInteger(options, "hlsSegmentSeconds", 1);
|
|
16401
16619
|
assertOptionalInteger(options, "workers", 1);
|
|
16620
|
+
assertOptionalInteger(options, "maxRenderMs");
|
|
16402
16621
|
assertOptionalInteger(options, "crf");
|
|
16403
16622
|
for (const field of ["useGpu", "debug", "outputResolutionAspectAgnostic"]) {
|
|
16404
16623
|
assertOptionalBoolean(options, field);
|
|
@@ -16573,13 +16792,13 @@ function renderRequestFromDistributedConfig(input) {
|
|
|
16573
16792
|
import {
|
|
16574
16793
|
existsSync as existsSync23,
|
|
16575
16794
|
mkdirSync as mkdirSync13,
|
|
16576
|
-
statSync as
|
|
16795
|
+
statSync as statSync8,
|
|
16577
16796
|
mkdtempSync as mkdtempSync5,
|
|
16578
16797
|
writeFileSync as writeFileSync9,
|
|
16579
|
-
rmSync as
|
|
16798
|
+
rmSync as rmSync13,
|
|
16580
16799
|
createReadStream as createReadStream5
|
|
16581
16800
|
} from "fs";
|
|
16582
|
-
import { resolve as resolve9, dirname as dirname13, join as
|
|
16801
|
+
import { resolve as resolve9, dirname as dirname13, join as join36 } from "path";
|
|
16583
16802
|
import { tmpdir as tmpdir3 } from "os";
|
|
16584
16803
|
import { parseArgs } from "util";
|
|
16585
16804
|
import crypto from "crypto";
|
|
@@ -16591,13 +16810,13 @@ import { serve as serve2 } from "@hono/node-server";
|
|
|
16591
16810
|
import {
|
|
16592
16811
|
existsSync as existsSync21,
|
|
16593
16812
|
readFileSync as readFileSync11,
|
|
16594
|
-
statSync as
|
|
16813
|
+
statSync as statSync7,
|
|
16595
16814
|
openSync as openSync6,
|
|
16596
|
-
fstatSync as
|
|
16597
|
-
closeSync as
|
|
16815
|
+
fstatSync as fstatSync3,
|
|
16816
|
+
closeSync as closeSync6,
|
|
16598
16817
|
constants as constants3
|
|
16599
16818
|
} from "fs";
|
|
16600
|
-
import { resolve as resolve8, join as
|
|
16819
|
+
import { resolve as resolve8, join as join34, relative as relative6, isAbsolute as isAbsolute3, sep as sep3 } from "path";
|
|
16601
16820
|
function isStringRecord(value) {
|
|
16602
16821
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
16603
16822
|
return false;
|
|
@@ -16630,19 +16849,19 @@ function readEntryHtml(filePath) {
|
|
|
16630
16849
|
} catch (error) {
|
|
16631
16850
|
if (error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR"))
|
|
16632
16851
|
return null;
|
|
16633
|
-
if (!
|
|
16852
|
+
if (!statSync7(filePath, { throwIfNoEntry: false })?.isFile()) return null;
|
|
16634
16853
|
throw error;
|
|
16635
16854
|
}
|
|
16636
16855
|
try {
|
|
16637
|
-
if (!
|
|
16856
|
+
if (!fstatSync3(fd).isFile()) return null;
|
|
16638
16857
|
return readFileSync11(fd, "utf-8");
|
|
16639
16858
|
} finally {
|
|
16640
|
-
|
|
16859
|
+
closeSync6(fd);
|
|
16641
16860
|
}
|
|
16642
16861
|
}
|
|
16643
16862
|
function readProjectEntryFile(projectDir, preferredEntryFile) {
|
|
16644
16863
|
const absProjectDir = resolve8(projectDir);
|
|
16645
|
-
if (!existsSync21(absProjectDir) || !
|
|
16864
|
+
if (!existsSync21(absProjectDir) || !statSync7(absProjectDir).isDirectory()) {
|
|
16646
16865
|
return { error: `Project directory not found: ${absProjectDir}` };
|
|
16647
16866
|
}
|
|
16648
16867
|
const entryCandidates = [preferredEntryFile, "index.html", "src/index.html"].filter(
|
|
@@ -16664,7 +16883,7 @@ function readProjectEntryFile(projectDir, preferredEntryFile) {
|
|
|
16664
16883
|
}
|
|
16665
16884
|
}
|
|
16666
16885
|
return {
|
|
16667
|
-
error: `No HTML entry file found in project directory: ${
|
|
16886
|
+
error: `No HTML entry file found in project directory: ${join34(absProjectDir, preferredEntryFile || "index.html")}`
|
|
16668
16887
|
};
|
|
16669
16888
|
}
|
|
16670
16889
|
function prepareHyperframeLintBody(body) {
|
|
@@ -16710,7 +16929,7 @@ async function runHyperframeLint(prepared) {
|
|
|
16710
16929
|
// ../producer/src/services/healthWorker.ts
|
|
16711
16930
|
import { Worker as Worker2 } from "worker_threads";
|
|
16712
16931
|
import { fileURLToPath as fileURLToPath6 } from "url";
|
|
16713
|
-
import { dirname as dirname12, join as
|
|
16932
|
+
import { dirname as dirname12, join as join35 } from "path";
|
|
16714
16933
|
import { existsSync as existsSync22 } from "fs";
|
|
16715
16934
|
var DEFAULT_HEALTH_PORT = 9848;
|
|
16716
16935
|
async function startHealthWorker(options = {}) {
|
|
@@ -16786,7 +17005,7 @@ function defaultLogger2() {
|
|
|
16786
17005
|
}
|
|
16787
17006
|
function resolveWorkerEntry2() {
|
|
16788
17007
|
const here = dirname12(fileURLToPath6(import.meta.url));
|
|
16789
|
-
const candidates = [
|
|
17008
|
+
const candidates = [join35(here, "healthWorkerThread.js"), join35(here, "healthWorkerThread.ts")];
|
|
16790
17009
|
for (const candidate of candidates) {
|
|
16791
17010
|
if (existsSync22(candidate)) return candidate;
|
|
16792
17011
|
}
|
|
@@ -16801,7 +17020,8 @@ var SAFE_RENDER_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
|
16801
17020
|
"INVALID_VIDEO_METADATA",
|
|
16802
17021
|
"VIDEO_SOURCE_UNRENDERABLE",
|
|
16803
17022
|
"VIDEO_EXTRACTION_FAILED",
|
|
16804
|
-
"ENCODER_INTERRUPTED"
|
|
17023
|
+
"ENCODER_INTERRUPTED",
|
|
17024
|
+
"RENDER_TOO_SLOW"
|
|
16805
17025
|
]);
|
|
16806
17026
|
function extractSafeRenderErrorCode(error) {
|
|
16807
17027
|
if (typeof error !== "object" || error === null || !("code" in error)) return void 0;
|
|
@@ -16860,6 +17080,7 @@ function parseRenderOptions(body) {
|
|
|
16860
17080
|
const fps = parseServerFps(body.fps);
|
|
16861
17081
|
const quality = parseServerQuality(body.quality);
|
|
16862
17082
|
const workers = typeof body.workers === "number" ? body.workers : void 0;
|
|
17083
|
+
const maxRenderMs = typeof body.maxRenderMs === "number" ? body.maxRenderMs : void 0;
|
|
16863
17084
|
const useGpu = body.gpu === true;
|
|
16864
17085
|
const debug = body.debug === true;
|
|
16865
17086
|
const strictness = body.bestEffort === false ? "strict" : "best-effort";
|
|
@@ -16875,6 +17096,7 @@ function parseRenderOptions(body) {
|
|
|
16875
17096
|
fps,
|
|
16876
17097
|
quality,
|
|
16877
17098
|
workers,
|
|
17099
|
+
maxRenderMs,
|
|
16878
17100
|
crf,
|
|
16879
17101
|
videoBitrate,
|
|
16880
17102
|
useGpu,
|
|
@@ -16908,6 +17130,7 @@ function buildRenderJobConfig(input, outputPath, log) {
|
|
|
16908
17130
|
quality: input.quality,
|
|
16909
17131
|
format: input.format ?? "mp4",
|
|
16910
17132
|
workers: input.workers,
|
|
17133
|
+
maxRenderMs: input.maxRenderMs,
|
|
16911
17134
|
crf: input.crf,
|
|
16912
17135
|
videoBitrate: input.videoBitrate,
|
|
16913
17136
|
useGpu: input.useGpu,
|
|
@@ -16934,6 +17157,9 @@ function resolvePreparedRenderOutput(prepared, rendersDir, log) {
|
|
|
16934
17157
|
function validateRenderOverrides(body) {
|
|
16935
17158
|
const encoder = parseEncoderOptions(body, parseServerFormat(body.format) ?? "mp4");
|
|
16936
17159
|
if (!encoder.ok) return encoder.error;
|
|
17160
|
+
if (body.maxRenderMs !== void 0 && (typeof body.maxRenderMs !== "number" || !Number.isInteger(body.maxRenderMs) || body.maxRenderMs < 0)) {
|
|
17161
|
+
return "maxRenderMs must be a non-negative integer number of milliseconds";
|
|
17162
|
+
}
|
|
16937
17163
|
if (body.variables !== void 0 && !isPlainObject2(body.variables)) {
|
|
16938
17164
|
return 'variables must be a JSON object keyed by variable id (e.g. {"title":"Hello"})';
|
|
16939
17165
|
}
|
|
@@ -16966,7 +17192,7 @@ function prepareProjectDirectory(projectDir, options) {
|
|
|
16966
17192
|
const candidate = nonEmptyString(projectDir);
|
|
16967
17193
|
if (!candidate) return null;
|
|
16968
17194
|
const absProjectDir = resolve9(candidate);
|
|
16969
|
-
if (!existsSync23(absProjectDir) || !
|
|
17195
|
+
if (!existsSync23(absProjectDir) || !statSync8(absProjectDir).isDirectory()) {
|
|
16970
17196
|
return { error: `Project directory not found: ${absProjectDir}` };
|
|
16971
17197
|
}
|
|
16972
17198
|
const entry = options.entryFile || "index.html";
|
|
@@ -16991,8 +17217,8 @@ async function resolveInlineRenderHtml(body) {
|
|
|
16991
17217
|
}
|
|
16992
17218
|
function materializeInlineProject(html, options) {
|
|
16993
17219
|
const tempRoot = process.env.PRODUCER_TMP_PROJECT_DIR || tmpdir3();
|
|
16994
|
-
const tempProjectDir = mkdtempSync5(
|
|
16995
|
-
writeFileSync9(
|
|
17220
|
+
const tempProjectDir = mkdtempSync5(join36(tempRoot, "producer-project-"));
|
|
17221
|
+
writeFileSync9(join36(tempProjectDir, "index.html"), html, "utf-8");
|
|
16996
17222
|
return {
|
|
16997
17223
|
prepared: {
|
|
16998
17224
|
input: { projectDir: tempProjectDir, ...options },
|
|
@@ -17053,7 +17279,7 @@ function createArtifactStore(ttlMs) {
|
|
|
17053
17279
|
function cleanupTempDir(dir, log) {
|
|
17054
17280
|
if (!dir) return;
|
|
17055
17281
|
try {
|
|
17056
|
-
|
|
17282
|
+
rmSync13(dir, { recursive: true, force: true });
|
|
17057
17283
|
} catch (error) {
|
|
17058
17284
|
log.warn("Failed to cleanup temp project dir", {
|
|
17059
17285
|
cleanupProjectDir: dir,
|
|
@@ -17062,7 +17288,7 @@ function cleanupTempDir(dir, log) {
|
|
|
17062
17288
|
}
|
|
17063
17289
|
}
|
|
17064
17290
|
function outputFileSize(path) {
|
|
17065
|
-
return existsSync23(path) ?
|
|
17291
|
+
return existsSync23(path) ? statSync8(path).size : 0;
|
|
17066
17292
|
}
|
|
17067
17293
|
function createBlockingProgressReporter(log, requestId) {
|
|
17068
17294
|
let lastLoggedPct = -10;
|
|
@@ -17362,7 +17588,7 @@ function createRenderHandlers(options = {}) {
|
|
|
17362
17588
|
store.delete(token);
|
|
17363
17589
|
return c.json({ success: false, error: "Output artifact file missing" }, 404);
|
|
17364
17590
|
}
|
|
17365
|
-
const stats =
|
|
17591
|
+
const stats = statSync8(artifact.path);
|
|
17366
17592
|
return new Response(createReadStream5(artifact.path), {
|
|
17367
17593
|
headers: {
|
|
17368
17594
|
"content-type": "video/mp4",
|
|
@@ -17405,7 +17631,7 @@ function startServer(options = {}) {
|
|
|
17405
17631
|
});
|
|
17406
17632
|
async function shutdown(signal) {
|
|
17407
17633
|
log.info(`Received ${signal}, shutting down`);
|
|
17408
|
-
const { drainBrowserPool } = await import("./src-
|
|
17634
|
+
const { drainBrowserPool } = await import("./src-QQPHMIJ7.js");
|
|
17409
17635
|
await drainBrowserPool().catch(() => {
|
|
17410
17636
|
});
|
|
17411
17637
|
const handle = await Promise.race([
|
|
@@ -17449,12 +17675,12 @@ import {
|
|
|
17449
17675
|
mkdtempSync as mkdtempSync7,
|
|
17450
17676
|
readFileSync as readFileSync12,
|
|
17451
17677
|
readdirSync as readdirSync9,
|
|
17452
|
-
rmSync as
|
|
17453
|
-
statSync as
|
|
17678
|
+
rmSync as rmSync15,
|
|
17679
|
+
statSync as statSync10,
|
|
17454
17680
|
writeFileSync as writeFileSync11
|
|
17455
17681
|
} from "fs";
|
|
17456
17682
|
import { tmpdir as tmpdir4 } from "os";
|
|
17457
|
-
import { dirname as dirname15, isAbsolute as isAbsolute4, join as
|
|
17683
|
+
import { dirname as dirname15, isAbsolute as isAbsolute4, join as join39, relative as relative7, resolve as resolve10, sep as sep4 } from "path";
|
|
17458
17684
|
|
|
17459
17685
|
// ../producer/src/services/distributed/planV2Publisher.ts
|
|
17460
17686
|
import {
|
|
@@ -17463,11 +17689,11 @@ import {
|
|
|
17463
17689
|
linkSync as linkSync2,
|
|
17464
17690
|
mkdirSync as mkdirSync14,
|
|
17465
17691
|
mkdtempSync as mkdtempSync6,
|
|
17466
|
-
rmSync as
|
|
17467
|
-
statSync as
|
|
17692
|
+
rmSync as rmSync14,
|
|
17693
|
+
statSync as statSync9,
|
|
17468
17694
|
writeFileSync as writeFileSync10
|
|
17469
17695
|
} from "fs";
|
|
17470
|
-
import { dirname as dirname14, join as
|
|
17696
|
+
import { dirname as dirname14, join as join38 } from "path";
|
|
17471
17697
|
|
|
17472
17698
|
// ../producer/src/services/distributed/planV2Errors.ts
|
|
17473
17699
|
var PLAN_V2_INTEGRITY_UNRECOVERABLE = "PLAN_V2_INTEGRITY_UNRECOVERABLE";
|
|
@@ -17482,7 +17708,7 @@ var PlanV2IntegrityError = class extends Error {
|
|
|
17482
17708
|
};
|
|
17483
17709
|
|
|
17484
17710
|
// ../producer/src/services/distributed/planV2Layout.ts
|
|
17485
|
-
import { join as
|
|
17711
|
+
import { join as join37 } from "path";
|
|
17486
17712
|
var SHA256_PATTERN = /^[0-9a-f]{64}$/;
|
|
17487
17713
|
function assertPlanV2Sha256(value, field) {
|
|
17488
17714
|
if (typeof value !== "string" || !SHA256_PATTERN.test(value)) {
|
|
@@ -17492,7 +17718,7 @@ function assertPlanV2Sha256(value, field) {
|
|
|
17492
17718
|
}
|
|
17493
17719
|
function planV2BlobPath(root, sha256) {
|
|
17494
17720
|
const digest = assertPlanV2Sha256(sha256, "artifact sha256");
|
|
17495
|
-
return
|
|
17721
|
+
return join37(root, "artifacts", "sha256", digest.slice(0, 2), digest);
|
|
17496
17722
|
}
|
|
17497
17723
|
|
|
17498
17724
|
// ../producer/src/services/distributed/planV2Publisher.ts
|
|
@@ -17533,11 +17759,11 @@ var LocalPlanV2ArtifactPublisher = class {
|
|
|
17533
17759
|
this.destinationDir = destinationDir;
|
|
17534
17760
|
this.#linkFile = options.linkFile ?? linkSync2;
|
|
17535
17761
|
mkdirSync14(dirname14(destinationDir), { recursive: true });
|
|
17536
|
-
this.temporaryDir = mkdtempSync6(
|
|
17762
|
+
this.temporaryDir = mkdtempSync6(join38(dirname14(destinationDir), ".plan-v2-publish-"));
|
|
17537
17763
|
}
|
|
17538
17764
|
async putBlob(blob) {
|
|
17539
17765
|
const digest = assertPlanV2Sha256(blob.sha256, "published blob sha256");
|
|
17540
|
-
const sourceSize =
|
|
17766
|
+
const sourceSize = statSync9(blob.sourcePath).size;
|
|
17541
17767
|
if (sourceSize !== blob.sizeBytes) {
|
|
17542
17768
|
throw new PlanV2IntegrityError(
|
|
17543
17769
|
`published blob size changed for ${digest}: expected ${blob.sizeBytes}, got ${sourceSize}`
|
|
@@ -17546,8 +17772,8 @@ var LocalPlanV2ArtifactPublisher = class {
|
|
|
17546
17772
|
const destinationPath = planV2BlobPath(this.temporaryDir, digest);
|
|
17547
17773
|
if (existsSync24(destinationPath)) return;
|
|
17548
17774
|
mkdirSync14(dirname14(destinationPath), { recursive: true });
|
|
17549
|
-
const stagingDir = mkdtempSync6(
|
|
17550
|
-
const temporaryPath =
|
|
17775
|
+
const stagingDir = mkdtempSync6(join38(dirname14(destinationPath), ".plan-v2-blob-"));
|
|
17776
|
+
const temporaryPath = join38(stagingDir, "blob");
|
|
17551
17777
|
try {
|
|
17552
17778
|
try {
|
|
17553
17779
|
this.#linkFile(blob.sourcePath, temporaryPath);
|
|
@@ -17557,7 +17783,7 @@ var LocalPlanV2ArtifactPublisher = class {
|
|
|
17557
17783
|
}
|
|
17558
17784
|
renameWithRetry(temporaryPath, destinationPath);
|
|
17559
17785
|
} finally {
|
|
17560
|
-
|
|
17786
|
+
rmSync14(stagingDir, { recursive: true, force: true });
|
|
17561
17787
|
}
|
|
17562
17788
|
}
|
|
17563
17789
|
async commitManifest(manifestBytes) {
|
|
@@ -17568,13 +17794,13 @@ var LocalPlanV2ArtifactPublisher = class {
|
|
|
17568
17794
|
);
|
|
17569
17795
|
}
|
|
17570
17796
|
}
|
|
17571
|
-
writeFileSync10(
|
|
17797
|
+
writeFileSync10(join38(this.temporaryDir, "plan.json"), manifestBytes, "utf-8");
|
|
17572
17798
|
renameWithRetry(this.temporaryDir, this.destinationDir);
|
|
17573
17799
|
this.#committed = true;
|
|
17574
17800
|
}
|
|
17575
17801
|
async abort() {
|
|
17576
17802
|
if (!this.#committed) {
|
|
17577
|
-
|
|
17803
|
+
rmSync14(this.temporaryDir, { recursive: true, force: true });
|
|
17578
17804
|
}
|
|
17579
17805
|
}
|
|
17580
17806
|
};
|
|
@@ -17613,7 +17839,7 @@ function listFiles(root) {
|
|
|
17613
17839
|
const rootResolved = resolve10(root);
|
|
17614
17840
|
function walk(dir) {
|
|
17615
17841
|
for (const entry of readdirSync9(dir, { withFileTypes: true })) {
|
|
17616
|
-
const absolutePath =
|
|
17842
|
+
const absolutePath = join39(dir, entry.name);
|
|
17617
17843
|
if (entry.isDirectory()) {
|
|
17618
17844
|
walk(absolutePath);
|
|
17619
17845
|
} else if (entry.isFile()) {
|
|
@@ -17640,13 +17866,13 @@ function assertValidExtractionCacheCompleteSentinel(path) {
|
|
|
17640
17866
|
}
|
|
17641
17867
|
}
|
|
17642
17868
|
function validateExtractionCacheCompleteSentinels(executionPlanDir) {
|
|
17643
|
-
const videoRoot =
|
|
17869
|
+
const videoRoot = join39(executionPlanDir, "video-frames");
|
|
17644
17870
|
if (!existsSync25(videoRoot)) return;
|
|
17645
17871
|
for (const videoEntry of readdirSync9(videoRoot, { withFileTypes: true })) {
|
|
17646
17872
|
if (!videoEntry.isDirectory()) continue;
|
|
17647
|
-
const videoDir =
|
|
17873
|
+
const videoDir = join39(videoRoot, videoEntry.name);
|
|
17648
17874
|
if (readdirSync9(videoDir).includes(EXTRACTION_CACHE_COMPLETE_SENTINEL)) {
|
|
17649
|
-
const sentinelPath =
|
|
17875
|
+
const sentinelPath = join39(videoDir, EXTRACTION_CACHE_COMPLETE_SENTINEL);
|
|
17650
17876
|
assertValidExtractionCacheCompleteSentinel(sentinelPath);
|
|
17651
17877
|
}
|
|
17652
17878
|
}
|
|
@@ -17693,7 +17919,7 @@ function listVideoFramePaths(executionPlanDir, videos) {
|
|
|
17693
17919
|
if (video.deferredRange) {
|
|
17694
17920
|
const framePaths2 = /* @__PURE__ */ new Map();
|
|
17695
17921
|
for (let index = 0; index < video.totalFrames; index++) {
|
|
17696
|
-
framePaths2.set(index,
|
|
17922
|
+
framePaths2.set(index, join39(outputDir, String(index)));
|
|
17697
17923
|
}
|
|
17698
17924
|
return { ...video, outputDir, framePaths: framePaths2, ownedByLookup: false };
|
|
17699
17925
|
}
|
|
@@ -17701,7 +17927,7 @@ function listVideoFramePaths(executionPlanDir, videos) {
|
|
|
17701
17927
|
const framePaths = /* @__PURE__ */ new Map();
|
|
17702
17928
|
for (const frameName of frameNames) {
|
|
17703
17929
|
if (frameName === EXTRACTION_CACHE_COMPLETE_SENTINEL) {
|
|
17704
|
-
assertValidExtractionCacheCompleteSentinel(
|
|
17930
|
+
assertValidExtractionCacheCompleteSentinel(join39(outputDir, frameName));
|
|
17705
17931
|
continue;
|
|
17706
17932
|
}
|
|
17707
17933
|
const match = /(\d+)(?=\.[^.]+$)/.exec(frameName);
|
|
@@ -17720,7 +17946,7 @@ function listVideoFramePaths(executionPlanDir, videos) {
|
|
|
17720
17946
|
`duplicate extracted frame index ${frameIndex} in ${outputDir}`
|
|
17721
17947
|
);
|
|
17722
17948
|
}
|
|
17723
|
-
framePaths.set(frameIndex,
|
|
17949
|
+
framePaths.set(frameIndex, join39(outputDir, frameName));
|
|
17724
17950
|
}
|
|
17725
17951
|
return {
|
|
17726
17952
|
...video,
|
|
@@ -17741,7 +17967,7 @@ function parsePlanVideosJson2(value) {
|
|
|
17741
17967
|
}
|
|
17742
17968
|
}
|
|
17743
17969
|
function materializeExtractedVideoDirectories(planDir) {
|
|
17744
|
-
const videosPath =
|
|
17970
|
+
const videosPath = join39(planDir, PLAN_VIDEOS_META_RELATIVE_PATH);
|
|
17745
17971
|
if (!existsSync25(videosPath)) return;
|
|
17746
17972
|
const videos = parsePlanVideosJson2(readJsonFile(videosPath, PLAN_VIDEOS_META_RELATIVE_PATH));
|
|
17747
17973
|
for (const video of videos.extracted) {
|
|
@@ -17770,13 +17996,13 @@ function parseChunkSlices(value) {
|
|
|
17770
17996
|
});
|
|
17771
17997
|
}
|
|
17772
17998
|
function buildVideoChunkDependencies(executionPlanDir, dimensions) {
|
|
17773
|
-
const videoRoot =
|
|
17999
|
+
const videoRoot = join39(executionPlanDir, "video-frames");
|
|
17774
18000
|
const hasExtractedFrames = existsSync25(videoRoot) && listFiles(videoRoot).length > 0;
|
|
17775
|
-
const videosPath =
|
|
18001
|
+
const videosPath = join39(executionPlanDir, PLAN_VIDEOS_META_RELATIVE_PATH);
|
|
17776
18002
|
if (!existsSync25(videosPath)) {
|
|
17777
18003
|
return hasExtractedFrames ? { mode: "full-source-pack", dependencies: null } : { mode: "exact-rendered-frames", dependencies: /* @__PURE__ */ new Map() };
|
|
17778
18004
|
}
|
|
17779
|
-
const chunksPath =
|
|
18005
|
+
const chunksPath = join39(executionPlanDir, "meta", "chunks.json");
|
|
17780
18006
|
const videos = readJsonFile(videosPath, PLAN_VIDEOS_META_RELATIVE_PATH);
|
|
17781
18007
|
const chunks = readJsonFile(chunksPath, "meta/chunks.json");
|
|
17782
18008
|
const parsedVideos = parsePlanVideosJson2(videos);
|
|
@@ -17832,20 +18058,20 @@ function computeManifestHash(manifest) {
|
|
|
17832
18058
|
function writeBlob(sourcePath, destinationPath) {
|
|
17833
18059
|
if (existsSync25(destinationPath)) return;
|
|
17834
18060
|
mkdirSync15(dirname15(destinationPath), { recursive: true });
|
|
17835
|
-
const temporaryDir = mkdtempSync7(
|
|
17836
|
-
const temporaryPath =
|
|
18061
|
+
const temporaryDir = mkdtempSync7(join39(dirname15(destinationPath), ".plan-v2-blob-"));
|
|
18062
|
+
const temporaryPath = join39(temporaryDir, "blob");
|
|
17837
18063
|
try {
|
|
17838
18064
|
copyFileSync6(sourcePath, temporaryPath);
|
|
17839
18065
|
renameWithRetry(temporaryPath, destinationPath);
|
|
17840
18066
|
} finally {
|
|
17841
|
-
|
|
18067
|
+
rmSync15(temporaryDir, { recursive: true, force: true });
|
|
17842
18068
|
}
|
|
17843
18069
|
}
|
|
17844
18070
|
function publishBlobFor(absolutePath, digests) {
|
|
17845
18071
|
return {
|
|
17846
18072
|
sourcePath: absolutePath,
|
|
17847
18073
|
sha256: planFileSha256(absolutePath, digests),
|
|
17848
|
-
sizeBytes:
|
|
18074
|
+
sizeBytes: statSync10(absolutePath).size
|
|
17849
18075
|
};
|
|
17850
18076
|
}
|
|
17851
18077
|
async function putBlobs(publisher, blobs) {
|
|
@@ -17869,7 +18095,7 @@ async function putTasks(tasks) {
|
|
|
17869
18095
|
if (failure) throw failure.reason;
|
|
17870
18096
|
}
|
|
17871
18097
|
function buildPlanV2Publication(executionPlanDir, digests) {
|
|
17872
|
-
const executionPlanPath =
|
|
18098
|
+
const executionPlanPath = join39(executionPlanDir, "plan.json");
|
|
17873
18099
|
if (!existsSync25(executionPlanPath)) {
|
|
17874
18100
|
throw new PlanV2IntegrityError(`execution plan is missing plan.json: ${executionPlanPath}`);
|
|
17875
18101
|
}
|
|
@@ -17897,7 +18123,7 @@ function buildPlanV2Publication(executionPlanDir, digests) {
|
|
|
17897
18123
|
}
|
|
17898
18124
|
validateExtractionCacheCompleteSentinels(executionPlanDir);
|
|
17899
18125
|
const videoDependencyPlan = buildVideoChunkDependencies(executionPlanDir, dimensions);
|
|
17900
|
-
const encoder = readJsonFile(
|
|
18126
|
+
const encoder = readJsonFile(join39(executionPlanDir, "meta", "encoder.json"), "meta/encoder.json");
|
|
17901
18127
|
const files = listFiles(executionPlanDir);
|
|
17902
18128
|
const chunkAudio = !isRecord3(encoder) || encoder.chunksCarryAudio !== true ? "none" : files.some((file) => chunkAudioSliceTarget(file.path) !== null) ? "sliced" : "whole";
|
|
17903
18129
|
for (const file of files) {
|
|
@@ -17958,20 +18184,20 @@ function createPlanV2FromExecutionPlan(executionPlanDir, planV2Dir) {
|
|
|
17958
18184
|
throw new PlanV2IntegrityError("a local plan v2 directory cannot reference remote files");
|
|
17959
18185
|
}
|
|
17960
18186
|
mkdirSync15(dirname15(planV2Dir), { recursive: true });
|
|
17961
|
-
const tempDir = mkdtempSync7(
|
|
18187
|
+
const tempDir = mkdtempSync7(join39(dirname15(planV2Dir), ".plan-v2-build-"));
|
|
17962
18188
|
try {
|
|
17963
18189
|
for (const blob of publication.blobs) {
|
|
17964
18190
|
writeBlob(blob.sourcePath, planV2BlobPath(tempDir, blob.sha256));
|
|
17965
18191
|
}
|
|
17966
18192
|
writeFileSync11(
|
|
17967
|
-
|
|
18193
|
+
join39(tempDir, "plan.json"),
|
|
17968
18194
|
canonicalJsonStringify(publication.manifest),
|
|
17969
18195
|
"utf-8"
|
|
17970
18196
|
);
|
|
17971
18197
|
renameWithRetry(tempDir, planV2Dir);
|
|
17972
18198
|
return resultFromManifest(planV2Dir, publication.manifest);
|
|
17973
18199
|
} catch (error) {
|
|
17974
|
-
|
|
18200
|
+
rmSync15(tempDir, { recursive: true, force: true });
|
|
17975
18201
|
throw error;
|
|
17976
18202
|
}
|
|
17977
18203
|
}
|
|
@@ -18011,7 +18237,7 @@ async function publishPlanV2FromV1(executionPlanDir, publisher) {
|
|
|
18011
18237
|
return publishPlanV2FromExecutionPlan(executionPlanDir, publisher);
|
|
18012
18238
|
}
|
|
18013
18239
|
async function planV2WithPublisher(projectDir, config, publisher, options = {}) {
|
|
18014
|
-
const stagingRoot = mkdtempSync7(
|
|
18240
|
+
const stagingRoot = mkdtempSync7(join39(options.stagingParentDir ?? tmpdir4(), ".execution-plan-"));
|
|
18015
18241
|
const digests = /* @__PURE__ */ new Map();
|
|
18016
18242
|
try {
|
|
18017
18243
|
await buildLocalExecutionPlan(projectDir, config, stagingRoot, {
|
|
@@ -18022,7 +18248,7 @@ async function planV2WithPublisher(projectDir, config, publisher, options = {})
|
|
|
18022
18248
|
// artifactTargets ships every compiled/ file to all chunks, so each is in the manifest.
|
|
18023
18249
|
whileAudioMixes: () => putBlobs(
|
|
18024
18250
|
publisher,
|
|
18025
|
-
listFiles(
|
|
18251
|
+
listFiles(join39(stagingRoot, "compiled")).map(
|
|
18026
18252
|
(file) => publishBlobFor(file.absolutePath, digests)
|
|
18027
18253
|
)
|
|
18028
18254
|
),
|
|
@@ -18038,7 +18264,7 @@ async function planV2WithPublisher(projectDir, config, publisher, options = {})
|
|
|
18038
18264
|
}
|
|
18039
18265
|
throw error;
|
|
18040
18266
|
} finally {
|
|
18041
|
-
|
|
18267
|
+
rmSync15(stagingRoot, { recursive: true, force: true });
|
|
18042
18268
|
}
|
|
18043
18269
|
}
|
|
18044
18270
|
async function planV2(projectDir, config, planV2Dir) {
|
|
@@ -18054,7 +18280,7 @@ async function planV2(projectDir, config, planV2Dir) {
|
|
|
18054
18280
|
function resultFromManifest(planV2Dir, manifest) {
|
|
18055
18281
|
return {
|
|
18056
18282
|
planDir: planV2Dir,
|
|
18057
|
-
manifestPath:
|
|
18283
|
+
manifestPath: join39(planV2Dir, "plan.json"),
|
|
18058
18284
|
planProtocol: PLAN_PROTOCOL_V2,
|
|
18059
18285
|
planHash: manifest.planHash,
|
|
18060
18286
|
sourcePlanV1Hash: getPlanV2ExecutionPlanHash(manifest),
|
|
@@ -18190,7 +18416,7 @@ function parsePlanV2Manifest(value) {
|
|
|
18190
18416
|
return parsed;
|
|
18191
18417
|
}
|
|
18192
18418
|
function readPlanV2Manifest(planV2Dir) {
|
|
18193
|
-
const manifestPath =
|
|
18419
|
+
const manifestPath = join39(planV2Dir, "plan.json");
|
|
18194
18420
|
if (!existsSync25(manifestPath)) {
|
|
18195
18421
|
throw new PlanV2IntegrityError(`missing v2 manifest: ${manifestPath}`);
|
|
18196
18422
|
}
|
|
@@ -18213,7 +18439,7 @@ function verifyBlob(planV2Dir, artifact) {
|
|
|
18213
18439
|
if (!existsSync25(sourcePath)) {
|
|
18214
18440
|
throw new PlanV2IntegrityError(`missing content-addressed artifact ${artifact.sha256}`);
|
|
18215
18441
|
}
|
|
18216
|
-
const stats =
|
|
18442
|
+
const stats = statSync10(sourcePath);
|
|
18217
18443
|
if (!stats.isFile() || stats.size !== artifact.sizeBytes) {
|
|
18218
18444
|
throw new PlanV2IntegrityError(`artifact size mismatch for ${artifact.path}`);
|
|
18219
18445
|
}
|
|
@@ -18236,16 +18462,16 @@ function materializePlanV2Target(planV2Dir, target, destinationDir, options = {}
|
|
|
18236
18462
|
sourcePath: verifyBlob(planV2Dir, artifact)
|
|
18237
18463
|
}));
|
|
18238
18464
|
mkdirSync15(dirname15(destinationDir), { recursive: true });
|
|
18239
|
-
const tempDir = mkdtempSync7(
|
|
18465
|
+
const tempDir = mkdtempSync7(join39(dirname15(destinationDir), ".plan-v2-materialize-"));
|
|
18240
18466
|
try {
|
|
18241
18467
|
for (const { artifact, sourcePath } of verified) {
|
|
18242
|
-
const destinationPath =
|
|
18468
|
+
const destinationPath = join39(tempDir, ...artifact.path.split("/"));
|
|
18243
18469
|
mkdirSync15(dirname15(destinationPath), { recursive: true });
|
|
18244
18470
|
copyFileSync6(sourcePath, destinationPath);
|
|
18245
18471
|
}
|
|
18246
18472
|
if (target.role === "chunk") materializeExtractedVideoDirectories(tempDir);
|
|
18247
18473
|
writeFileSync11(
|
|
18248
|
-
|
|
18474
|
+
join39(tempDir, PLAN_V2_MATERIALIZATION_MARKER),
|
|
18249
18475
|
canonicalJsonStringify({
|
|
18250
18476
|
manifest,
|
|
18251
18477
|
target,
|
|
@@ -18255,7 +18481,7 @@ function materializePlanV2Target(planV2Dir, target, destinationDir, options = {}
|
|
|
18255
18481
|
);
|
|
18256
18482
|
renameWithRetry(tempDir, destinationDir);
|
|
18257
18483
|
} catch (error) {
|
|
18258
|
-
|
|
18484
|
+
rmSync15(tempDir, { recursive: true, force: true });
|
|
18259
18485
|
throw error;
|
|
18260
18486
|
}
|
|
18261
18487
|
return {
|
|
@@ -18268,7 +18494,7 @@ function materializePlanV2Target(planV2Dir, target, destinationDir, options = {}
|
|
|
18268
18494
|
// Join the artifact's OWN name, not the current constant: a plan written
|
|
18269
18495
|
// before the container change carries the legacy name, and materializing it
|
|
18270
18496
|
// under the new one would point at a file that was never written.
|
|
18271
|
-
audioPath: target.role === "assembler" ? audioArtifact ?
|
|
18497
|
+
audioPath: target.role === "assembler" ? audioArtifact ? join39(destinationDir, audioArtifact.path) : null : null
|
|
18272
18498
|
};
|
|
18273
18499
|
}
|
|
18274
18500
|
function assertRemoteSources(remoteSources, artifacts) {
|
|
@@ -18287,7 +18513,7 @@ function validatePlanV2MaterializedTarget(planDir, expectedTarget) {
|
|
|
18287
18513
|
return readValidatedPlanV2Materialization(planDir, expectedTarget)?.manifest ?? null;
|
|
18288
18514
|
}
|
|
18289
18515
|
function readValidatedPlanV2Materialization(planDir, expectedTarget) {
|
|
18290
|
-
const markerPath =
|
|
18516
|
+
const markerPath = join39(planDir, PLAN_V2_MATERIALIZATION_MARKER);
|
|
18291
18517
|
if (!existsSync25(markerPath)) return null;
|
|
18292
18518
|
const marker = readJsonFile(markerPath, "materialization marker");
|
|
18293
18519
|
if (!isRecord3(marker) || !isRecord3(marker.manifest) || !isRecord3(marker.target)) {
|
|
@@ -18305,8 +18531,8 @@ function readValidatedPlanV2Materialization(planDir, expectedTarget) {
|
|
|
18305
18531
|
assertRemoteSources(remoteSources, required);
|
|
18306
18532
|
for (const artifact of required) {
|
|
18307
18533
|
if (Object.hasOwn(remoteSources, artifact.path)) continue;
|
|
18308
|
-
const path =
|
|
18309
|
-
if (!existsSync25(path) ||
|
|
18534
|
+
const path = join39(planDir, ...artifact.path.split("/"));
|
|
18535
|
+
if (!existsSync25(path) || statSync10(path).size !== artifact.sizeBytes) {
|
|
18310
18536
|
throw new PlanV2IntegrityError(
|
|
18311
18537
|
`materialized artifact missing or truncated: ${artifact.path}`
|
|
18312
18538
|
);
|
|
@@ -18319,9 +18545,9 @@ function readValidatedPlanV2Materialization(planDir, expectedTarget) {
|
|
|
18319
18545
|
}
|
|
18320
18546
|
|
|
18321
18547
|
// ../producer/src/services/distributed/planV2Execution.ts
|
|
18322
|
-
import { mkdtempSync as mkdtempSync9, rmSync as
|
|
18548
|
+
import { mkdtempSync as mkdtempSync9, rmSync as rmSync18 } from "fs";
|
|
18323
18549
|
import { tmpdir as tmpdir5 } from "os";
|
|
18324
|
-
import { join as
|
|
18550
|
+
import { join as join42 } from "path";
|
|
18325
18551
|
|
|
18326
18552
|
// ../producer/src/services/distributed/assemble.ts
|
|
18327
18553
|
import {
|
|
@@ -18331,11 +18557,11 @@ import {
|
|
|
18331
18557
|
mkdtempSync as mkdtempSync8,
|
|
18332
18558
|
readFileSync as readFileSync13,
|
|
18333
18559
|
readdirSync as readdirSync10,
|
|
18334
|
-
rmSync as
|
|
18335
|
-
statSync as
|
|
18560
|
+
rmSync as rmSync16,
|
|
18561
|
+
statSync as statSync11,
|
|
18336
18562
|
writeFileSync as writeFileSync12
|
|
18337
18563
|
} from "fs";
|
|
18338
|
-
import { dirname as dirname16, join as
|
|
18564
|
+
import { dirname as dirname16, join as join40 } from "path";
|
|
18339
18565
|
function cfrRateControlArgs(locked) {
|
|
18340
18566
|
const preset = getEncoderPreset(locked.quality ?? "standard", "mp4");
|
|
18341
18567
|
if (locked.crf == null && locked.bitrate) {
|
|
@@ -18359,7 +18585,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
|
|
|
18359
18585
|
outputPath,
|
|
18360
18586
|
durationMs: Date.now() - start,
|
|
18361
18587
|
framesEncoded: plan2.totalFrames,
|
|
18362
|
-
fileSize:
|
|
18588
|
+
fileSize: statSync11(outputPath).size
|
|
18363
18589
|
};
|
|
18364
18590
|
}
|
|
18365
18591
|
const format = plan2.dimensions.format;
|
|
@@ -18387,7 +18613,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
|
|
|
18387
18613
|
};
|
|
18388
18614
|
try {
|
|
18389
18615
|
const videoSources = cfrEncoder ? [await reencodeCfr(ctx, chunkPaths, cfrEncoder)] : chunkPaths;
|
|
18390
|
-
const finalPath =
|
|
18616
|
+
const finalPath = join40(workDir, `output.${format}`);
|
|
18391
18617
|
const audio = audioPath !== null && existsSync26(audioPath) ? audioPath : null;
|
|
18392
18618
|
await writeJoined(ctx, videoSources, audio, finalPath);
|
|
18393
18619
|
renameWithRetry(finalPath, outputPath);
|
|
@@ -18398,7 +18624,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
|
|
|
18398
18624
|
});
|
|
18399
18625
|
} finally {
|
|
18400
18626
|
try {
|
|
18401
|
-
|
|
18627
|
+
rmSync16(workDir, { recursive: true, force: true });
|
|
18402
18628
|
} catch (err) {
|
|
18403
18629
|
log.warn("[assemble] failed to remove work dir", {
|
|
18404
18630
|
workDir,
|
|
@@ -18406,7 +18632,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
|
|
|
18406
18632
|
});
|
|
18407
18633
|
}
|
|
18408
18634
|
}
|
|
18409
|
-
const fileSize = existsSync26(outputPath) ?
|
|
18635
|
+
const fileSize = existsSync26(outputPath) ? statSync11(outputPath).size : 0;
|
|
18410
18636
|
return {
|
|
18411
18637
|
outputPath,
|
|
18412
18638
|
durationMs: Date.now() - start,
|
|
@@ -18415,8 +18641,8 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
|
|
|
18415
18641
|
};
|
|
18416
18642
|
}
|
|
18417
18643
|
function readAssemblePlan(planDir, chunkPaths) {
|
|
18418
|
-
const planJsonPath =
|
|
18419
|
-
const chunksJsonPath =
|
|
18644
|
+
const planJsonPath = join40(planDir, "plan.json");
|
|
18645
|
+
const chunksJsonPath = join40(planDir, "meta", "chunks.json");
|
|
18420
18646
|
if (!existsSync26(planJsonPath)) {
|
|
18421
18647
|
throw new Error(`[assemble] planDir missing plan.json: ${planJsonPath}`);
|
|
18422
18648
|
}
|
|
@@ -18464,7 +18690,7 @@ function cfrEncodeArgs(inputArgs, encoder, fpsArg) {
|
|
|
18464
18690
|
return args;
|
|
18465
18691
|
}
|
|
18466
18692
|
async function reencodeCfr(ctx, chunkPaths, encoder) {
|
|
18467
|
-
const cfrOutputPath =
|
|
18693
|
+
const cfrOutputPath = join40(ctx.workDir, `cfr.${ctx.format}`);
|
|
18468
18694
|
const cfrArgs = cfrEncodeArgs(videoInputArgs(ctx, chunkPaths), encoder, ctx.fpsArg);
|
|
18469
18695
|
appendRenderProvenanceArgs(cfrArgs, cfrOutputPath);
|
|
18470
18696
|
cfrArgs.push("-y", cfrOutputPath);
|
|
@@ -18491,7 +18717,7 @@ async function writeJoined(ctx, videoSources, audioPath, finalPath) {
|
|
|
18491
18717
|
);
|
|
18492
18718
|
return;
|
|
18493
18719
|
}
|
|
18494
|
-
const paddedAudioPath =
|
|
18720
|
+
const paddedAudioPath = join40(ctx.workDir, "audio-padded.m4a");
|
|
18495
18721
|
const padTrimResult = await ctx.timed(
|
|
18496
18722
|
"audioMs",
|
|
18497
18723
|
() => padOrTrimAudioToVideoFrameCount({
|
|
@@ -18531,7 +18757,7 @@ async function writeJoined(ctx, videoSources, audioPath, finalPath) {
|
|
|
18531
18757
|
}
|
|
18532
18758
|
}
|
|
18533
18759
|
function concatDemuxerInput(chunkPaths, workDir, fpsArg) {
|
|
18534
|
-
const listPath =
|
|
18760
|
+
const listPath = join40(workDir, "concat-list.txt");
|
|
18535
18761
|
const body = chunkPaths.map((path) => `file '${path.replace(/'/g, "'\\''")}'`).join("\n");
|
|
18536
18762
|
writeFileSync12(listPath, `${body}
|
|
18537
18763
|
`, "utf-8");
|
|
@@ -18569,11 +18795,11 @@ function stitchesSeparateAudio(planDir) {
|
|
|
18569
18795
|
return lockedAudio(planDir).separateAudio === true;
|
|
18570
18796
|
}
|
|
18571
18797
|
function planFormat(planDir) {
|
|
18572
|
-
const plan2 = JSON.parse(readFileSync13(
|
|
18798
|
+
const plan2 = JSON.parse(readFileSync13(join40(planDir, "plan.json"), "utf-8"));
|
|
18573
18799
|
return plan2.dimensions.format;
|
|
18574
18800
|
}
|
|
18575
18801
|
function lockedAudio(planDir) {
|
|
18576
|
-
const encoderJsonPath =
|
|
18802
|
+
const encoderJsonPath = join40(planDir, "meta", "encoder.json");
|
|
18577
18803
|
if (!existsSync26(encoderJsonPath)) return {};
|
|
18578
18804
|
return JSON.parse(readFileSync13(encoderJsonPath, "utf-8"));
|
|
18579
18805
|
}
|
|
@@ -18583,7 +18809,7 @@ function readCfrEncoder(planDir, format) {
|
|
|
18583
18809
|
`[assemble] cfr=true is only supported for format="mp4" (got "${format}"). Stream-copy paths for webm and mov already produce exact avg_frame_rate; cfr re-encode is not needed.`
|
|
18584
18810
|
);
|
|
18585
18811
|
}
|
|
18586
|
-
const encoderJsonPath =
|
|
18812
|
+
const encoderJsonPath = join40(planDir, "meta", "encoder.json");
|
|
18587
18813
|
if (!existsSync26(encoderJsonPath)) {
|
|
18588
18814
|
throw new Error(`[assemble] planDir missing meta/encoder.json: ${encoderJsonPath}`);
|
|
18589
18815
|
}
|
|
@@ -18596,11 +18822,11 @@ function readCfrEncoder(planDir, format) {
|
|
|
18596
18822
|
return encoderJson;
|
|
18597
18823
|
}
|
|
18598
18824
|
function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, startTimeMs) {
|
|
18599
|
-
if (existsSync26(outputPath))
|
|
18825
|
+
if (existsSync26(outputPath)) rmSync16(outputPath, { recursive: true, force: true });
|
|
18600
18826
|
mkdirSync16(outputPath, { recursive: true });
|
|
18601
18827
|
let globalIdx = 0;
|
|
18602
18828
|
for (const chunkDir of chunkPaths) {
|
|
18603
|
-
if (!
|
|
18829
|
+
if (!statSync11(chunkDir).isDirectory()) {
|
|
18604
18830
|
throw new Error(
|
|
18605
18831
|
`[assemble] png-sequence chunk must be a directory: ${chunkDir} (got a file)`
|
|
18606
18832
|
);
|
|
@@ -18610,8 +18836,8 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
|
|
|
18610
18836
|
throw new Error(`[assemble] png-sequence chunk has no frames: ${chunkDir}`);
|
|
18611
18837
|
}
|
|
18612
18838
|
for (const frame of frames) {
|
|
18613
|
-
const dst =
|
|
18614
|
-
cpSync3(
|
|
18839
|
+
const dst = join40(outputPath, formatExportFrameName(globalIdx, "png"));
|
|
18840
|
+
cpSync3(join40(chunkDir, frame), dst);
|
|
18615
18841
|
globalIdx += 1;
|
|
18616
18842
|
}
|
|
18617
18843
|
}
|
|
@@ -18621,13 +18847,13 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
|
|
|
18621
18847
|
);
|
|
18622
18848
|
}
|
|
18623
18849
|
if (audioPath !== null && existsSync26(audioPath)) {
|
|
18624
|
-
const sidecar =
|
|
18850
|
+
const sidecar = join40(outputPath, MIXED_AUDIO_FILENAME);
|
|
18625
18851
|
cpSync3(audioPath, sidecar);
|
|
18626
18852
|
}
|
|
18627
18853
|
let fileSize = 0;
|
|
18628
18854
|
for (const name of readdirSync10(outputPath)) {
|
|
18629
18855
|
try {
|
|
18630
|
-
fileSize +=
|
|
18856
|
+
fileSize += statSync11(join40(outputPath, name)).size;
|
|
18631
18857
|
} catch {
|
|
18632
18858
|
}
|
|
18633
18859
|
}
|
|
@@ -18641,9 +18867,9 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
|
|
|
18641
18867
|
|
|
18642
18868
|
// ../producer/src/services/distributed/renderChunk.ts
|
|
18643
18869
|
import { randomBytes } from "crypto";
|
|
18644
|
-
import { existsSync as existsSync27, mkdirSync as mkdirSync17, readFileSync as readFileSync14, readdirSync as readdirSync11, rmSync as
|
|
18870
|
+
import { existsSync as existsSync27, mkdirSync as mkdirSync17, readFileSync as readFileSync14, readdirSync as readdirSync11, rmSync as rmSync17, writeFileSync as writeFileSync13 } from "fs";
|
|
18645
18871
|
import { cpus as cpus3 } from "os";
|
|
18646
|
-
import { join as
|
|
18872
|
+
import { join as join41 } from "path";
|
|
18647
18873
|
var LEGACY_DISTRIBUTED_VP9_CPU_USED = 2;
|
|
18648
18874
|
function validatePlanVideosForChunk(value) {
|
|
18649
18875
|
try {
|
|
@@ -18745,7 +18971,7 @@ function hashChunkOutput(outputPath, kind) {
|
|
|
18745
18971
|
if (kind === "file") return sha256Hex(readFileSync14(outputPath));
|
|
18746
18972
|
const entries = readdirSync11(outputPath).filter((name) => /\.(png|jpg|jpeg)$/i.test(name)).sort();
|
|
18747
18973
|
const lines = entries.map(
|
|
18748
|
-
(name) => `${name}\0${sha256Hex(readFileSync14(
|
|
18974
|
+
(name) => `${name}\0${sha256Hex(readFileSync14(join41(outputPath, name)))}`
|
|
18749
18975
|
);
|
|
18750
18976
|
return sha256Hex(lines.join("\0"));
|
|
18751
18977
|
}
|
|
@@ -18762,9 +18988,9 @@ function resolveLockedVp9CpuUsed(lockedEncoder) {
|
|
|
18762
18988
|
async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
18763
18989
|
const start = Date.now();
|
|
18764
18990
|
const log = defaultLogger;
|
|
18765
|
-
const planJsonPath =
|
|
18766
|
-
const encoderJsonPath =
|
|
18767
|
-
const chunksJsonPath =
|
|
18991
|
+
const planJsonPath = join41(planDir, "plan.json");
|
|
18992
|
+
const encoderJsonPath = join41(planDir, "meta", "encoder.json");
|
|
18993
|
+
const chunksJsonPath = join41(planDir, "meta", "chunks.json");
|
|
18768
18994
|
if (!existsSync27(planJsonPath)) {
|
|
18769
18995
|
throw new RenderChunkValidationError(
|
|
18770
18996
|
MISSING_PLAN_ARTIFACT,
|
|
@@ -18790,7 +19016,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
|
18790
19016
|
}
|
|
18791
19017
|
const encoder = JSON.parse(readFileSync14(encoderJsonPath, "utf-8"));
|
|
18792
19018
|
const chunks = JSON.parse(readFileSync14(chunksJsonPath, "utf-8"));
|
|
18793
|
-
const videosJsonPath =
|
|
19019
|
+
const videosJsonPath = join41(planDir, PLAN_VIDEOS_META_RELATIVE_PATH);
|
|
18794
19020
|
let planVideos = null;
|
|
18795
19021
|
if (existsSync27(videosJsonPath)) {
|
|
18796
19022
|
try {
|
|
@@ -18822,7 +19048,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
|
18822
19048
|
}
|
|
18823
19049
|
const range = resolveChunkFrameRange(slice, chunkIndex, options?.frameRange);
|
|
18824
19050
|
const framesInChunk = range.endFrame - range.startFrame;
|
|
18825
|
-
const compiledDir =
|
|
19051
|
+
const compiledDir = join41(planDir, "compiled");
|
|
18826
19052
|
if (!existsSync27(compiledDir)) {
|
|
18827
19053
|
throw new RenderChunkValidationError(
|
|
18828
19054
|
MISSING_PLAN_ARTIFACT,
|
|
@@ -18880,7 +19106,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
|
18880
19106
|
};
|
|
18881
19107
|
const workDir = `${outputChunkPath}.work.${process.pid}.${randomBytes(4).toString("hex")}`;
|
|
18882
19108
|
mkdirSync17(workDir, { recursive: true });
|
|
18883
|
-
const framesDir =
|
|
19109
|
+
const framesDir = join41(workDir, "captured-frames");
|
|
18884
19110
|
mkdirSync17(framesDir, { recursive: true });
|
|
18885
19111
|
const videoFramesDir = `${workDir}.video-frames`;
|
|
18886
19112
|
const chunkFrameNumbers = Array.from({ length: framesInChunk }, (_, i) => range.startFrame + i);
|
|
@@ -18905,7 +19131,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
|
18905
19131
|
dimensions: plan2.dimensions,
|
|
18906
19132
|
encoder,
|
|
18907
19133
|
videoCount: planVideos?.videos.length ?? 0,
|
|
18908
|
-
html: readFileSync14(
|
|
19134
|
+
html: readFileSync14(join41(compiledDir, "index.html"), "utf-8"),
|
|
18909
19135
|
// The plan ships a deferred source only to chunks that show it; don't wait on the rest.
|
|
18910
19136
|
skipReadinessVideoIds: deferredVideos.filter(
|
|
18911
19137
|
(video) => !shownFrames.get(video.videoId)?.size || remoteVideoIds.has(video.videoId)
|
|
@@ -19030,7 +19256,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
|
19030
19256
|
if (isPngSequence) {
|
|
19031
19257
|
if (!existsSync27(outputChunkPath)) mkdirSync17(outputChunkPath, { recursive: true });
|
|
19032
19258
|
} else {
|
|
19033
|
-
const outDir =
|
|
19259
|
+
const outDir = join41(outputChunkPath, "..");
|
|
19034
19260
|
if (!existsSync27(outDir)) mkdirSync17(outDir, { recursive: true });
|
|
19035
19261
|
}
|
|
19036
19262
|
const encodeInput = {
|
|
@@ -19134,7 +19360,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
|
19134
19360
|
return observedChunkCaptureMode(capturePerfs);
|
|
19135
19361
|
},
|
|
19136
19362
|
resetForScreenshotRetry: () => {
|
|
19137
|
-
|
|
19363
|
+
rmSync17(workDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
|
|
19138
19364
|
mkdirSync17(framesDir, { recursive: true });
|
|
19139
19365
|
capturePerfs.length = 0;
|
|
19140
19366
|
captureAttempts.length = 0;
|
|
@@ -19177,8 +19403,8 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
|
19177
19403
|
fps: { num: plan2.dimensions.fpsNum, den: plan2.dimensions.fpsDen },
|
|
19178
19404
|
timeoutMs: cfg.ffmpegProcessTimeout
|
|
19179
19405
|
});
|
|
19180
|
-
|
|
19181
|
-
|
|
19406
|
+
rmSync17(videoOnlyPath, { force: true });
|
|
19407
|
+
rmSync17(audioScratchPath, { force: true });
|
|
19182
19408
|
}
|
|
19183
19409
|
encodeStageMs = Date.now() - encodeStarted;
|
|
19184
19410
|
} finally {
|
|
@@ -19226,8 +19452,8 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
|
19226
19452
|
writeFileSync13(perfPath, `${JSON.stringify(perfPayload, null, 2)}
|
|
19227
19453
|
`, "utf-8");
|
|
19228
19454
|
try {
|
|
19229
|
-
|
|
19230
|
-
|
|
19455
|
+
rmSync17(workDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
|
|
19456
|
+
rmSync17(videoFramesDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
|
|
19231
19457
|
} catch (err) {
|
|
19232
19458
|
log.warn("[renderChunk] failed to remove work dir", {
|
|
19233
19459
|
workDir,
|
|
@@ -19256,18 +19482,18 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
|
19256
19482
|
|
|
19257
19483
|
// ../producer/src/services/distributed/planV2Execution.ts
|
|
19258
19484
|
async function renderChunkV2(planV2Dir, chunkIndex, outputChunkPath, options) {
|
|
19259
|
-
const workRoot = mkdtempSync9(
|
|
19260
|
-
const materializedPlanDir =
|
|
19485
|
+
const workRoot = mkdtempSync9(join42(tmpdir5(), "hf-plan-v2-chunk-"));
|
|
19486
|
+
const materializedPlanDir = join42(workRoot, "plan");
|
|
19261
19487
|
try {
|
|
19262
19488
|
materializePlanV2Target(planV2Dir, { role: "chunk", chunkIndex }, materializedPlanDir);
|
|
19263
19489
|
return await renderChunk(materializedPlanDir, chunkIndex, outputChunkPath, options);
|
|
19264
19490
|
} finally {
|
|
19265
|
-
|
|
19491
|
+
rmSync18(workRoot, { recursive: true, force: true });
|
|
19266
19492
|
}
|
|
19267
19493
|
}
|
|
19268
19494
|
async function assembleV2(planV2Dir, chunkPaths, outputPath, options) {
|
|
19269
|
-
const workRoot = mkdtempSync9(
|
|
19270
|
-
const materializedPlanDir =
|
|
19495
|
+
const workRoot = mkdtempSync9(join42(tmpdir5(), "hf-plan-v2-assembler-"));
|
|
19496
|
+
const materializedPlanDir = join42(workRoot, "plan");
|
|
19271
19497
|
try {
|
|
19272
19498
|
const materialized = materializePlanV2Target(
|
|
19273
19499
|
planV2Dir,
|
|
@@ -19282,14 +19508,14 @@ async function assembleV2(planV2Dir, chunkPaths, outputPath, options) {
|
|
|
19282
19508
|
options
|
|
19283
19509
|
);
|
|
19284
19510
|
} finally {
|
|
19285
|
-
|
|
19511
|
+
rmSync18(workRoot, { recursive: true, force: true });
|
|
19286
19512
|
}
|
|
19287
19513
|
}
|
|
19288
19514
|
|
|
19289
19515
|
// ../producer/src/services/distributed/projectHash.ts
|
|
19290
|
-
import { closeSync as
|
|
19516
|
+
import { closeSync as closeSync7, openSync as openSync7, readdirSync as readdirSync12, readSync as readSync5, realpathSync as realpathSync2, statSync as statSync12 } from "fs";
|
|
19291
19517
|
import { createHash as createHash7 } from "crypto";
|
|
19292
|
-
import { join as
|
|
19518
|
+
import { join as join43 } from "path";
|
|
19293
19519
|
var READ_CHUNK_BYTES = 256 * 1024;
|
|
19294
19520
|
|
|
19295
19521
|
// ../producer/src/services/distributed/audioSidecar.ts
|