@@ -418,7 +418,7 @@ describe("muxVideoWithAudio audio codec handling", () => {
418418 } ) ;
419419 } ) ;
420420
421- it ( "preserves M4A priming edit lists instead of shifting copied video " , async ( ) => {
421+ it ( "keeps negative-timestamp repair for an M4A without a known priming edit list " , async ( ) => {
422422 const { spawn, calls } = createSpawnSpy ( ) ;
423423 vi . resetModules ( ) ;
424424 vi . doMock ( "child_process" , ( ) => ( { spawn } ) ) ;
@@ -433,6 +433,30 @@ describe("muxVideoWithAudio audio codec handling", () => {
433433 { num : 30 , den : 1 } ,
434434 ) ;
435435
436+ await flushMuxCodecResolution ( ) ;
437+ expect ( calls ) . toHaveLength ( 1 ) ;
438+ expect ( calls [ 0 ] ! . args ) . toContain ( "copy" ) ;
439+ expect ( calls [ 0 ] ! . args ) . toContain ( "-avoid_negative_ts" ) ;
440+
441+ emitClose ( calls [ 0 ] ! . proc , 0 ) ;
442+ await expect ( muxPromise ) . resolves . toMatchObject ( { success : true } ) ;
443+ } ) ;
444+
445+ it ( "preserves a known M4A priming edit list instead of shifting copied video" , async ( ) => {
446+ const { spawn, calls } = createSpawnSpy ( ) ;
447+ vi . resetModules ( ) ;
448+ vi . doMock ( "child_process" , ( ) => ( { spawn } ) ) ;
449+
450+ const { muxVideoWithAudio } = await import ( "./chunkEncoder.js" ) ;
451+ const muxPromise = muxVideoWithAudio (
452+ "/tmp/video-only.mp4" ,
453+ "/tmp/audio.duration-normalized.m4a" ,
454+ "/tmp/output.mp4" ,
455+ undefined ,
456+ { audioCodec : "aac" , preserveAudioPrimingEditList : true } ,
457+ { num : 30 , den : 1 } ,
458+ ) ;
459+
436460 await flushMuxCodecResolution ( ) ;
437461 expect ( calls ) . toHaveLength ( 1 ) ;
438462 expect ( calls [ 0 ] ! . args ) . toContain ( "copy" ) ;
0 commit comments