@@ -206,6 +206,28 @@ func TestBuildFFmpegArgsUsesVAAPIEncodeFallbackPipeline(t *testing.T) {
206206 }
207207}
208208
209+ func TestBuildFFmpegArgsDoesNotForceVAAPIH264Profile (t * testing.T ) {
210+ session := & Session {
211+ ID : "item123" ,
212+ Dir : t .TempDir (),
213+ }
214+ request := Request {InputURL : "http://upstream/stream" }
215+
216+ for _ , pipeline := range []string {"vaapi-full" , "vaapi-encode" } {
217+ t .Run (pipeline , func (t * testing.T ) {
218+ args := buildFFmpegArgs (session , request , FFmpegOptions {
219+ HardwareDecode : "vaapi" ,
220+ HardwareDevice : "/dev/dri/renderD128" ,
221+ HardwarePipeline : pipeline ,
222+ })
223+
224+ if slices .Contains (args , "-profile:v" ) {
225+ t .Fatalf ("VAAPI pipeline should not force H.264 profile: %v" , args )
226+ }
227+ })
228+ }
229+ }
230+
209231func TestBuildFFmpegArgsCapsVideoOutputTo1080p (t * testing.T ) {
210232 session := & Session {
211233 ID : "item123" ,
@@ -227,7 +249,7 @@ func TestBuildFFmpegArgsCapsVideoOutputTo1080p(t *testing.T) {
227249 }
228250}
229251
230- func TestBuildFFmpegArgsMapsFirstAudioStreamReturnedByEmby (t * testing.T ) {
252+ func TestBuildFFmpegArgsMapsFirstAudioStreamWhenNoAudioStreamIndexRequested (t * testing.T ) {
231253 session := & Session {
232254 ID : "item123" ,
233255 Dir : t .TempDir (),
@@ -238,6 +260,30 @@ func TestBuildFFmpegArgsMapsFirstAudioStreamReturnedByEmby(t *testing.T) {
238260 },
239261 },
240262 }
263+ request := Request {InputURL : "http://upstream/stream" }
264+
265+ args := buildFFmpegArgs (session , request )
266+
267+ mapIndexes := allIndexes (args , "-map" )
268+ if len (mapIndexes ) < 2 {
269+ t .Fatalf ("missing map args: %v" , args )
270+ }
271+ if got := args [mapIndexes [1 ]+ 1 ]; got != "0:a:0?" {
272+ t .Fatalf ("audio map = %q, args=%v" , got , args )
273+ }
274+ }
275+
276+ func TestBuildFFmpegArgsMapsRequestedAudioStreamIndex (t * testing.T ) {
277+ session := & Session {
278+ ID : "item123" ,
279+ Dir : t .TempDir (),
280+ Media : MediaInfo {
281+ AudioStreams : []AudioStreamInfo {
282+ {Index : 1 , Ordinal : 0 , Codec : "aac" },
283+ {Index : 2 , Ordinal : 1 , Codec : "eac3" },
284+ },
285+ },
286+ }
241287 request := Request {
242288 InputURL : "http://upstream/stream?AudioStreamIndex=2" ,
243289 AudioStreamIndex : 2 ,
@@ -249,7 +295,7 @@ func TestBuildFFmpegArgsMapsFirstAudioStreamReturnedByEmby(t *testing.T) {
249295 if len (mapIndexes ) < 2 {
250296 t .Fatalf ("missing map args: %v" , args )
251297 }
252- if got := args [mapIndexes [1 ]+ 1 ]; got != "0:a:0 ?" {
298+ if got := args [mapIndexes [1 ]+ 1 ]; got != "0:a:1 ?" {
253299 t .Fatalf ("audio map = %q, args=%v" , got , args )
254300 }
255301}
0 commit comments