-
Notifications
You must be signed in to change notification settings - Fork 3k
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
player: add --subs-match-os-language option #12100
Conversation
While uncommon I think you could use Alternatively, what about not doing anything? If users don't set |
I'm hesitant to ask, but may this finally fix behavior with forced subtitle selection, i.e. #8396 ? Issue case:
File contains 1. I'm sorry if this is perceived as hijacking this PR, but I'm pretty sure mpv's current behavior is seen as outright sadistic by a fair number of users. :( |
Is there a real usecase for someone wanting the audio language to match their OS language? I don't think this is something we would ever assume and someone wanting particular languages for audio would just configure it anyway. The only real point of
Yes, it can be. The current behavior can result in a track being selected even if the media file doesn't tag it as default or forced.
With this PR it might not select the eng subtitle track (depends on how it is tagged). It still wouldn't select the german subs because forced tracks are only ever autoselected if they match the language of the audio. |
Thanks, I think that's at least an improvement (basically restores some previous behavior?). If you are interested in this, I'd be highly grateful if you could expand or change behavior of |
Adding an |
Not really related to this. No opinion personally. I barely even have any files with forced subtitles though. |
Well, I missed the PR #12015 . IMO, UI/UX should also be a part of 'behavior' and I should post my comments at that time. BTW, even though the button hides, it will affect sub's behavior. Try to click on that area and sub will hide or show. |
And mpv did not select such tracks before? |
Correct. Consider this example. If you play it with --no-config an english system (or with LANG=en_US.UTF-8 for instance), it will select the subtitle track. It shouldn't but this happens because Considering that #11913 also happens. I'm considering just re-doing the default track selection again since it just seems wrong. |
383696c
to
3f4b7f0
Compare
I've done this so this PR is now 4 parts.
Testing welcome to make sure I didn't break something somewhere. For a sample file, here's this if it's handy (has a lot of subtitle tracks in it). I fictitiously changed the the arabic track to Japanese (sue me) since my machine has english and japanese locales readily available (i.e. testing with |
Thanks a lot! Though I don't think I have any sample that contains multiple forced subtitle tracks. I suppose with such a file, mpv would select a forced subtitle track according to the |
Well no, it picks based on |
Feel free to go ahead with the changes then. |
@aufkrawall: Could you clarify a bit and/or possibly provide a sample? The behavior you're describing honestly sounds like a bug with this PR. It shouldn't be selecting german forced subs if the audio is english unless you are also passing |
Sure, I'll take another look at it in a few hours. |
It selects |
Oh okay it happens with LANG=de_DE.UTF-8 but not my normal locale (english) so I assume your locale must be German. That subtitle track is tagged as both Edit: Yeah it's a bug. |
3f4b7f0
to
b38b6a7
Compare
Okay should be fixed now. All I needed to do was make |
Nice. Could it be that in your provided sample, the Edit: As it also selects it with
In other files when there are no forced tracks available, the subtitles are guarded behind the |
In that example, the english track is tagged as default (not forced) but so is the fake Japanese track. The general rule of thumb with subtitle selection priority and no configuration is: forced subtitle track if it matches the audio language -> default subtitle track -> nothing. In master, this doesn't work for a variety of situations currently. And of course if you set various subtitle options, the selection changes (e.g. slang will always try to select a track matching the language regardless of how the track is tagged). |
This proved to be too problematic. Depending on the value of --subs-with-matching-audio, you could either end up with cases where --slang wasn't respected and users didn't get subtitles or alternatively cases where subtitles were given and the user didn't ask for them. Fundamentally, the OS language functionality doesn't really map well to slang (and for alang/vlang it makes zero sense; not that anyone actually used it). Instead of trying to shove it in an option where it doesn't belong, we should split this off into something else. So for now, just remove the special handling of "auto" and flip slang back to NULL.
b38b6a7
to
3d59e59
Compare
What was previously there is extremely complicated and really confusing. Poorly named variables like "prefer_forced" that don't neccesarily have anything to do with prefering forced tracks didn't help either. Try to rewrite a few things to be saner. The idea is that after you loop through the tracks, the special sub-specific options (like subs-fallback and so on) should be handled and the track should be deselected if appropriate. Another change is to remove the "prefered_forced" argument in compare_track. This actually was both not neccessary and caused bad behavior by always depriortizing forced tracks even when it didn't apply (e.g. forced video tracks were never selected even though the flag should simply be ignored for anything that's not a subtitle track).
This is the replacement for the previous auto option for slang. It behaves similar however it never overrides slang if that is set and will instead try to pick the subtitle that matches the user's language if appropriately flagged by the file.
In general, forced tracks should only be shown if they match the language of the audio. However some people do want them no matter what, so add an always option to this so such tracks are always selected.
3d59e59
to
e839425
Compare
@aufkrawall:
The change I'm planning would make the eng subtitle be selected because it's first in your list of slang languages (language priority wins over forced and default tags always). Is that alright with you? If your config is just:
Then the german track is still selected by default since it's tagged as the default. |
Hm, in my clip, it selects just
and latest mpv git-master. And it also selects |
No that option is, like it says, for falling back. When you don't have a sub that's selected in some other manner (like slang), then fallback on one of those. I'm going to add yet another option for this soon. Probably something like |
Unfortunately, the
auto
slang behavior still proved to be problematic in some instances. Essentially, it would be as if you setslang
to the value of your OS language (if unset) which is not necessarily desirable and results in subs getting selected when they shouldn't. For example, with--no-config
onen_US.UTF-8
would basically behave like--slang=en
and cause english subtitles to be selected even if it is not the default track. Flipping--subs-with-matching-audio
to no again would simply cause the opposite problem where people that do setslang
have subtitles not actually picked.So instead, just divorce this concept from
--slang
all together because it doesn't really fit there (additionally, it removes it from--alang
and--vlang
as well butauto
has no real use there). Instead, use a--subs-match-os-language
option that handles this, turn it on by default, but always prefer--slang
over it if it is set. In the case where--slang
is not set and we are using the OS langs, then we can proceed to ignore the--subs-with-matching-audio
complexity all together and skip picking the subtitles if the audio language matches.The idea is to have the best of both worlds. I think the only remaining change in behavior was with the sub language == os language case, but not 100% sure. Testing welcome.