player: add always to --subs-fallback-forced

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.
This commit is contained in:
Dudemanguy 2023-08-25 23:38:57 -05:00
parent 58ec0630f5
commit 165f9e061f
5 changed files with 12 additions and 6 deletions

View File

@ -46,6 +46,7 @@ Interface changes
- change `slang` default back to NULL
- remove special handling of the `auto` value from `--alang/slang/vlang` options
- add `--subs-match-os-language` as a replacement for `--slang=auto`
- add `always` option to `--subs-fallback-forced`
--- mpv 0.36.0 ---
- add `--target-contrast`
- Target luminance value is now also applied when ICC profile is used.

View File

@ -150,9 +150,11 @@ Track Selection
select a full track even if it doesn't match your preferred subtitle language (default: default).
Setting this to `default` means that only streams flagged as `default` will be selected.
``--subs-fallback-forced=<yes|no>``
``--subs-fallback-forced=<yes|no|always>``
When autoselecting a subtitle track, if no tracks match your preferred languages,
select a forced track that matches the language of the selected audio track (default: yes).
`always` will always select a forced track if possible, regardles if the language matches the
selected audio track or not.
Playback Control

View File

@ -524,7 +524,8 @@ static const m_option_t mp_opts[] = {
{"subs-with-matching-audio", OPT_BOOL(subs_with_matching_audio)},
{"subs-match-os-language", OPT_BOOL(subs_match_os_language)},
{"subs-fallback", OPT_CHOICE(subs_fallback, {"no", 0}, {"default", 1}, {"yes", 2})},
{"subs-fallback-forced", OPT_BOOL(subs_fallback_forced)},
{"subs-fallback-forced", OPT_CHOICE(subs_fallback_forced, {"no", 0},
{"yes", 1}, {"always", 2})},
{"lavfi-complex", OPT_STRING(lavfi_complex), .flags = UPDATE_LAVFI_COMPLEX},
@ -1047,7 +1048,7 @@ static const struct MPOpts mp_default_opts = {
.subs_with_matching_audio = true,
.subs_match_os_language = true,
.subs_fallback = 1,
.subs_fallback_forced = true,
.subs_fallback_forced = 1,
.audio_display = 1,
.audio_output_format = 0, // AF_FORMAT_UNKNOWN
.playback_speed = 1.,

View File

@ -270,7 +270,7 @@ typedef struct MPOpts {
bool subs_with_matching_audio;
bool subs_match_os_language;
int subs_fallback;
bool subs_fallback_forced;
int subs_fallback_forced;
int audio_display;
char **display_tags;

View File

@ -646,8 +646,10 @@ struct track *select_default_track(struct MPContext *mpctx, int order,
if (!pick || compare_track(track, pick, langs, os_langs, mpctx->opts, preferred_program))
pick = track;
// We only try to autoselect forced tracks if they match the audio language and are subs
if (fallback_forced && track->forced_track && mp_match_lang_single(audio_lang, track->lang) &&
// We only try to autoselect forced tracks if they match the audio language and are subs or
// if the user always wants forced sub tracks
if (fallback_forced && track->forced_track &&
(mp_match_lang_single(audio_lang, track->lang) || opts->subs_fallback_forced == 2) &&
(!forced_pick || compare_track(track, forced_pick, langs, os_langs, mpctx->opts, preferred_program)))
forced_pick = track;
}