Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: a more reasonable order in compare_track #6071

Open
zc62 opened this issue Aug 14, 2018 · 0 comments
Open

Proposal: a more reasonable order in compare_track #6071

zc62 opened this issue Aug 14, 2018 · 0 comments
Labels
core:file core:option-param-conf config, parameters, properties, options, shortcuts meta:feature-request

Comments

@zc62
Copy link
Contributor

zc62 commented Aug 14, 2018

There have been very few discussions about what is the best default for track auto-selection mechanism, and previous issues such as #3777, #5127 and #5433 usually result in no change. One big reason I think is, most people will not encounter external files or multiple tracks. The other reason I guess is, most of the core devs are already comfortable with the current behavior or didn't find any cases that current auto-selection mechanism might make trouble, so they decided nothing should be changed.

Here is the current order of comparison:

mpv/player/loadfile.c

Lines 315 to 332 in d5cad85

/* Get the track wanted by the user.
* tid is the track ID requested by the user (-2: deselect, -1: default)
* lang is a string list, NULL is same as empty list
* Sort tracks based on the following criteria, and pick the first:
* 0a) track matches ff-index (always wins)
* 0b) track matches tid (almost always wins)
* 0c) track is not from --external-file
* 1) track is external (no_default cancels this)
* 1b) track was passed explicitly (is not an auto-loaded subtitle)
* 2) earlier match in lang list
* 3a) track is marked forced
* 3b) track is marked default
* 4) attached picture, HLS bitrate
* 5) lower track number
* If select_fallback is not set, 5) is only used to determine whether a
* matching track is preferred over another track. Otherwise, always pick a
* track (if nothing else matches, return the track with lowest ID).
*/

compare_track was introduced in 0f15592. The external file auto-load and selection was a feature.

Couldn't trace back further to see why "external" precedes "lang" (this is the point that most conflicts arise), but I do see the intentions in the design:

  1. External subtitle files usually come with no language code. With language code competition it will not necessarily win.
  2. The video has an internal 'eng' sub track, and the user places an external 'eng' sub file in the same directory, it must be the case that the user wants the external subtitle but not the internal one.

But it will also lead to unexpected behavior when:

  • The video has an internal 'eng' sub track, while this video file is provided along with sub files in other languages. It is rare, but it happens. The user is not willing to move/delete those files because the file integrity of the entire folder must be kept.

So I think the track auto-selection should not always pick up external tracks blindly. It also happens that users may want the tracks loaded and change the track being played during the playback time. Commit 34cf655 supports the idea. (Otherwise what is --external-files for?)

I propose:

0a) track matches ff-index (always wins) 
0b) track matches tid (almost always wins) 
0c) track is not from --external-file
1) track was passed explicitly (is not an auto-loaded subtitle) 
2) track is external (no_default cancels this) **and (has match in lang list or (filename is exact match && lang is unknown))**
3) earlier match in lang list 
4) **track is external (no_default cancels this) and !(conditions in 2)**
5a) track is marked forced 
5b) track is marked default 
6) attached picture, HLS bitrate 
7) lower track number 

In this case, most of the users won't get affected. People who care about this issue, can name their subtitle/audio files to explicitly include language codes, so that they get external files auto-loaded and get the desired auto-selected track simultaneously.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core:file core:option-param-conf config, parameters, properties, options, shortcuts meta:feature-request
Projects
None yet
Development

No branches or pull requests

3 participants