From 165f9e061f79e95a6297cf79e8cf5f2d42b71b4c Mon Sep 17 00:00:00 2001 From: Dudemanguy Date: Fri, 25 Aug 2023 23:38:57 -0500 Subject: [PATCH] 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. --- DOCS/interface-changes.rst | 1 + DOCS/man/options.rst | 4 +++- options/options.c | 5 +++-- options/options.h | 2 +- player/loadfile.c | 6 ++++-- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/DOCS/interface-changes.rst b/DOCS/interface-changes.rst index 0384796699..aa2149ba4d 100644 --- a/DOCS/interface-changes.rst +++ b/DOCS/interface-changes.rst @@ -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. diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst index b4e9a2b8d3..cf0dcdc5ee 100644 --- a/DOCS/man/options.rst +++ b/DOCS/man/options.rst @@ -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=`` +``--subs-fallback-forced=`` 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 diff --git a/options/options.c b/options/options.c index 14fb4039c0..ae51a010ac 100644 --- a/options/options.c +++ b/options/options.c @@ -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., diff --git a/options/options.h b/options/options.h index 52547183a2..a2fca90432 100644 --- a/options/options.h +++ b/options/options.h @@ -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; diff --git a/player/loadfile.c b/player/loadfile.c index 2a83f57241..cd528624f0 100644 --- a/player/loadfile.c +++ b/player/loadfile.c @@ -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; }