Fix some track selection bugs (#649)

## Description
Fixes track selection issues with MPV. This was especially focused on
libraries that disable embedded subtitles, but also fixes issues where
the audio streams are listed before video streams.

Also includes test media source JSON and unit tests to verify many
scenarios.

### Related issues
Fixes #494
This commit is contained in:
Ray 2026-01-07 17:27:54 -05:00 committed by GitHub
parent 6906813bbc
commit d2e0d527dd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 1278 additions and 28 deletions

View file

@ -0,0 +1,178 @@
{
"Protocol": "File",
"Id": "",
"Path": "",
"Type": "Default",
"Container": "mkv",
"Size": 651217902,
"Name": "",
"IsRemote": false,
"ETag": "",
"RunTimeTicks": 14919360000,
"ReadAtNativeFramerate": false,
"IgnoreDts": false,
"IgnoreIndex": false,
"GenPtsInput": false,
"SupportsTranscoding": true,
"SupportsDirectStream": true,
"SupportsDirectPlay": true,
"IsInfiniteStream": false,
"UseMostCompatibleTranscodingProfile": false,
"RequiresOpening": false,
"RequiresClosing": false,
"RequiresLooping": false,
"SupportsProbing": true,
"VideoType": "VideoFile",
"MediaStreams": [
{
"Codec": "subrip",
"Language": "spa",
"TimeBase": "1/1000",
"VideoRange": "Unknown",
"VideoRangeType": "Unknown",
"AudioSpatialFormat": "None",
"LocalizedUndefined": "Undefined",
"LocalizedDefault": "Default",
"LocalizedForced": "Forced",
"LocalizedExternal": "External",
"LocalizedHearingImpaired": "Hearing Impaired",
"DisplayTitle": "Spanish - SUBRIP - External",
"IsInterlaced": false,
"IsAVC": false,
"IsDefault": false,
"IsForced": false,
"IsHearingImpaired": false,
"Height": 0,
"Width": 0,
"Type": "Subtitle",
"Index": 0,
"IsExternal": true,
"IsTextSubtitleStream": true,
"SupportsExternalStream": true,
"Path": "",
"Level": 0
},
{
"Codec": "hevc",
"Language": "jpn",
"TimeBase": "1/1000",
"Title": "",
"VideoRange": "SDR",
"VideoRangeType": "SDR",
"AudioSpatialFormat": "None",
"DisplayTitle": "1080p - HEVC - SDR",
"IsInterlaced": false,
"IsAVC": false,
"BitRate": 3491934,
"BitDepth": 10,
"RefFrames": 1,
"IsDefault": true,
"IsForced": false,
"IsHearingImpaired": false,
"Height": 1080,
"Width": 1448,
"AverageFrameRate": 23.809525,
"RealFrameRate": 23.809525,
"ReferenceFrameRate": 23.809525,
"Profile": "Main 10",
"Type": "Video",
"AspectRatio": "4:3",
"Index": 1,
"IsExternal": false,
"IsTextSubtitleStream": false,
"SupportsExternalStream": false,
"PixelFormat": "yuv420p10le",
"Level": 120,
"IsAnamorphic": false
},
{
"Codec": "opus",
"Language": "jpn",
"TimeBase": "1/1000",
"Title": "Stereo (Opus 112Kbps)",
"VideoRange": "Unknown",
"VideoRangeType": "Unknown",
"AudioSpatialFormat": "None",
"LocalizedDefault": "Default",
"LocalizedExternal": "External",
"DisplayTitle": "Stereo (Opus 112Kbps) - Japanese",
"IsInterlaced": false,
"IsAVC": false,
"ChannelLayout": "stereo",
"BitRate": 101618,
"Channels": 2,
"SampleRate": 48000,
"IsDefault": false,
"IsForced": false,
"IsHearingImpaired": false,
"Type": "Audio",
"Index": 2,
"IsExternal": false,
"IsTextSubtitleStream": false,
"SupportsExternalStream": false,
"Level": 0
},
{
"Codec": "aac",
"Language": "por",
"TimeBase": "1/1000",
"Title": "",
"VideoRange": "Unknown",
"VideoRangeType": "Unknown",
"AudioSpatialFormat": "None",
"LocalizedDefault": "Default",
"LocalizedExternal": "External",
"DisplayTitle": "Portuguese - AAC - Stereo",
"IsInterlaced": false,
"IsAVC": false,
"ChannelLayout": "stereo",
"BitRate": 249225,
"Channels": 2,
"SampleRate": 44100,
"IsDefault": false,
"IsForced": false,
"IsHearingImpaired": false,
"Profile": "LC",
"Type": "Audio",
"Index": 3,
"IsExternal": false,
"IsTextSubtitleStream": false,
"SupportsExternalStream": false,
"Level": 0
},
{
"Codec": "eac3",
"Language": "por",
"TimeBase": "1/1000",
"Title": "",
"VideoRange": "Unknown",
"VideoRangeType": "Unknown",
"AudioSpatialFormat": "None",
"LocalizedDefault": "Default",
"LocalizedExternal": "External",
"DisplayTitle": "Portuguese - Dolby Digital+ - 5.1",
"IsInterlaced": false,
"IsAVC": false,
"ChannelLayout": "5.1",
"BitRate": 640000,
"Channels": 6,
"SampleRate": 48000,
"IsDefault": false,
"IsForced": false,
"IsHearingImpaired": false,
"Type": "Audio",
"Index": 4,
"IsExternal": false,
"IsTextSubtitleStream": false,
"SupportsExternalStream": false,
"Level": 0
}
],
"MediaAttachments": [],
"Formats": [],
"Bitrate": 4482777,
"RequiredHttpHeaders": {},
"TranscodingSubProtocol": "http",
"DefaultAudioStreamIndex": 2,
"HasSegments": true
}