Use relative index matching for subtitle selection #4201
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When I rewrote the subtitle behavior I did test with media that had both embedded and external subtitles, and in those tests the server would always put all embedded tracks (including audio/video) before external tracks, keeping their indexes the same as you would find them sorted in when inspecting with ffprobe, mkvtoolnix and other tools.
However, this piece of shit API does not always do that. In fact, it can put the external tracks before internal tracks just for funs. This leaves a client literally unable to reliably map a media stream to tracks in their video engine. The hack I've implemented will take all the embedded/hls subtitle streams, filtering out everything else, and then calculate the index. Then does the same when selecting the ExoPlayer track. This should fix all the issues we've encountered (it does so for the media I tested with) but it's still unreliable because this will still fail if the server decided to fuck up the order of these tracks too.
Changes
Issues
Fixes #4183
Maybe fixes #4182