@@ -1012,7 +1012,7 @@ describe("handler dispatch", () => {
10121012 expect ( url . searchParams . get ( "X-Amz-Signature" ) ) . toMatch ( / ^ [ a - f 0 - 9 ] { 64 } $ / ) ;
10131013 } ) ;
10141014
1015- async function planStitched ( chunkCount : number , separateAudio = false ) {
1015+ async function planStitched ( chunkCount : number , separateAudio = false , workerConcurrency = 16 ) {
10161016 const tmpRoot = makeTmpRoot ( ) ;
10171017 const s3 = new FakeS3Client ( ) ;
10181018 s3 . objects . set ( "s3://bucket/project.tar.gz" , await makeMinimalProjectTar ( ) ) ;
@@ -1049,7 +1049,7 @@ describe("handler dispatch", () => {
10491049 Action : "plan" ,
10501050 ProjectS3Uri : "s3://bucket/project.tar.gz" ,
10511051 PlanOutputS3Prefix : "s3://bucket/renders/f/" ,
1052- Config : { fps : 30 , width : 640 , height : 360 , format : "mp4" } ,
1052+ Config : { fps : 30 , width : 640 , height : 360 , format : "mp4" , workerConcurrency } ,
10531053 } ,
10541054 deps ,
10551055 ) ;
@@ -1069,9 +1069,20 @@ describe("handler dispatch", () => {
10691069 } ,
10701070 deps ,
10711071 ) ;
1072- return { s3, assembleMock, assemble, planV2WithPublisherMock } ;
1072+ return { s3, assembleMock, assemble, planV2WithPublisherMock, planned } ;
10731073 }
10741074
1075+ it ( "keeps a worker free for the audio task, and keeps the audio in a plan with one worker" , async ( ) => {
1076+ const planOptions = ( run : Awaited < ReturnType < typeof planStitched > > ) =>
1077+ ( run . planV2WithPublisherMock . mock . calls [ 0 ] as unknown [ ] ) [ 3 ] ;
1078+ const four = await planStitched ( 8 , true , 4 ) ;
1079+ expect ( planOptions ( four ) ) . toMatchObject ( { deferAudio : true } ) ;
1080+ expect ( [ four . planned . SeparateAudio , four . planned . MaxChunkConcurrency ] ) . toEqual ( [ true , 3 ] ) ;
1081+ const one = await planStitched ( 8 , false , 1 ) ;
1082+ expect ( planOptions ( one ) ) . toMatchObject ( { deferAudio : false } ) ;
1083+ expect ( [ one . planned . SeparateAudio , one . planned . MaxChunkConcurrency ] ) . toEqual ( [ false , 1 ] ) ;
1084+ } ) ;
1085+
10751086 it . skipIf ( spawnSync ( "ffmpeg" , [ "-version" ] ) . status !== 0 ) (
10761087 "stitches mp4 chunks inside S3 instead of joining them locally" ,
10771088 async ( ) => {
0 commit comments