@@ -104,6 +104,48 @@ describe("mediaAudio integration tests", () => {
104104 expect ( hasAudio ) . toBe ( false ) ;
105105 } ) ;
106106
107+ test . each ( [
108+ [ 90 , true ] ,
109+ [ - 90 , true ] ,
110+ [ 180 , true ] ,
111+ [ 90 , false ] ,
112+ ] as const ) (
113+ "detects audio with display rotation %i and audio=%s" ,
114+ async ( rotation , hasAudio ) => {
115+ const dirPath = await mkdtemp ( join ( tmpdir ( ) , "cap-audio-rotation-" ) ) ;
116+ const outputPath = join ( dirPath , "rotated.mp4" ) ;
117+ try {
118+ const proc = Bun . spawn ( {
119+ cmd : [
120+ "ffmpeg" ,
121+ "-v" ,
122+ "error" ,
123+ "-display_rotation" ,
124+ String ( rotation ) ,
125+ "-i" ,
126+ hasAudio ? TEST_VIDEO_WITH_AUDIO : TEST_VIDEO_NO_AUDIO ,
127+ "-c" ,
128+ "copy" ,
129+ outputPath ,
130+ ] ,
131+ stdout : "ignore" ,
132+ stderr : "pipe" ,
133+ } ) ;
134+ const [ stderr , exitCode ] = await Promise . all ( [
135+ new Response ( proc . stderr ) . text ( ) ,
136+ proc . exited ,
137+ ] ) ;
138+ expect ( stderr ) . toBe ( "" ) ;
139+ expect ( exitCode ) . toBe ( 0 ) ;
140+ expect ( await checkHasAudioTrack ( `file://${ outputPath } ` ) ) . toBe (
141+ hasAudio ,
142+ ) ;
143+ } finally {
144+ await rm ( dirPath , { recursive : true , force : true } ) ;
145+ }
146+ } ,
147+ ) ;
148+
107149 test ( "inherits signed queries for relative HLS segments" , async ( ) => {
108150 const dirPath = await createHlsFixture ( ) ;
109151 const requests : string [ ] = [ ] ;
@@ -134,6 +176,21 @@ describe("mediaAudio integration tests", () => {
134176 }
135177 } ) ;
136178
179+ test ( "still rejects audio-only inputs without leaking an operation" , async ( ) => {
180+ const beforeCount = getActiveProcessCount ( ) ;
181+ const dirPath = await mkdtemp ( join ( tmpdir ( ) , "cap-audio-only-" ) ) ;
182+ const outputPath = join ( dirPath , "audio.mp3" ) ;
183+ try {
184+ await Bun . write ( outputPath , await extractAudio ( TEST_VIDEO_WITH_AUDIO ) ) ;
185+ await expect (
186+ checkHasAudioTrack ( `file://${ outputPath } ` ) ,
187+ ) . rejects . toThrow ( "No video stream found" ) ;
188+ await waitForAudioOperations ( beforeCount ) ;
189+ } finally {
190+ await rm ( dirPath , { recursive : true , force : true } ) ;
191+ }
192+ } ) ;
193+
137194 test ( "contains upstream failures without leaking the active operation" , async ( ) => {
138195 const beforeCount = getActiveProcessCount ( ) ;
139196 const server = Bun . serve ( {
0 commit comments