package service import "testing" // Index is an ffmpeg "0:s:N" selector. A bitmap track is unusable but still // occupies a slot, so skipping it must not shift the following tracks. func TestSelectSubtitleStreamsCountsSkippedTracks(t *testing.T) { streams := []ffprobeStream{ {CodecType: "video", CodecName: "h264"}, {CodecType: "audio", CodecName: "aac"}, {CodecType: "subtitle", CodecName: "hdmv_pgs_subtitle"}, {CodecType: "subtitle", CodecName: "subrip"}, {CodecType: "subtitle", CodecName: "ass"}, } streams[3].Tags.Language = "eng" got := selectSubtitleStreams(streams) if len(got) != 2 { t.Fatalf("got %d streams, want 2: %+v", len(got), got) } if got[0].Index != 1 || got[0].Lang != "eng" || got[0].Label != "ENG" { t.Errorf("subrip track = %+v, want index 1 lang eng label ENG", got[0]) } // No language tag, so the name falls back to the selector index. if got[1].Index != 2 || got[1].Lang != "track2" { t.Errorf("ass track = %+v, want index 2 lang track2", got[1]) } }