@@ -259,6 +259,65 @@ describe("runEncodeStage config plumbing", () => {
259259 } ) ;
260260 } ) ;
261261
262+ it ( "gives the reported long high-quality encode a 24x source-duration budget" , async ( ) => {
263+ const { runEncodeStage } = await import ( "./encodeStage.js" ) ;
264+ const input = makeInput ( ) ;
265+
266+ await runEncodeStage (
267+ makeInput ( {
268+ job : {
269+ ...input . job ,
270+ config : { ...input . job . config , quality : "high" } ,
271+ duration : 331.273 ,
272+ } ,
273+ engineConfig : { ffmpegEncodeTimeout : 600_000 } ,
274+ } ) ,
275+ ) ;
276+
277+ expect ( encodeFramesFromDirMock . mock . calls [ 0 ] ?. [ 5 ] ) . toEqual ( {
278+ ffmpegEncodeTimeout : 7_950_552 ,
279+ } ) ;
280+ } ) ;
281+
282+ it ( "keeps the 4x budget for a standard encode" , async ( ) => {
283+ const { runEncodeStage } = await import ( "./encodeStage.js" ) ;
284+ const input = makeInput ( ) ;
285+
286+ await runEncodeStage (
287+ makeInput ( {
288+ job : {
289+ ...input . job ,
290+ config : { ...input . job . config , quality : "standard" } ,
291+ duration : 331.273 ,
292+ } ,
293+ engineConfig : { ffmpegEncodeTimeout : 600_000 } ,
294+ } ) ,
295+ ) ;
296+
297+ expect ( encodeFramesFromDirMock . mock . calls [ 0 ] ?. [ 5 ] ) . toEqual ( {
298+ ffmpegEncodeTimeout : 1_325_092 ,
299+ } ) ;
300+ } ) ;
301+
302+ it ( "preserves a larger operator timeout for high-quality encoding" , async ( ) => {
303+ const { runEncodeStage } = await import ( "./encodeStage.js" ) ;
304+ const input = makeInput ( ) ;
305+ const operatorConfig = { ffmpegEncodeTimeout : 9_000_000 } ;
306+
307+ await runEncodeStage (
308+ makeInput ( {
309+ job : {
310+ ...input . job ,
311+ config : { ...input . job . config , quality : "high" } ,
312+ duration : 331.273 ,
313+ } ,
314+ engineConfig : operatorConfig ,
315+ } ) ,
316+ ) ;
317+
318+ expect ( encodeFramesFromDirMock . mock . calls [ 0 ] ?. [ 5 ] ) . toBe ( operatorConfig ) ;
319+ } ) ;
320+
262321 it ( "prefers engine config supplied by the orchestrator" , async ( ) => {
263322 const { runEncodeStage } = await import ( "./encodeStage.js" ) ;
264323 const orchestratorEngineConfig = { ffmpegEncodeTimeout : 54_321 } ;
0 commit comments