From a987aa840eb201ef985e306d2059363f990aae46 Mon Sep 17 00:00:00 2001 From: Mustafa Elnaquib Date: Wed, 16 Sep 2026 01:54:49 +0200 Subject: [PATCH 1/3] Add subtitle style command line options to secondary-sub as well, like secondary-sub-color etc. just accept params, options has no effect yet --- options/options.c | 1 + options/options.h | 1 + sub/osd.c | 20 ++++++++++++++++++++ sub/osd.h | 1 + 4 files changed, 23 insertions(+) diff --git a/options/options.c b/options/options.c index e8b590af8c04f..d19f9bca7023c 100644 --- a/options/options.c +++ b/options/options.c @@ -346,6 +346,7 @@ const struct m_sub_options mp_subtitle_sub_opts = { {"sub-scale-with-window", OPT_BOOL(sub_scale_with_window)}, {"sub-ass-scale-with-window", OPT_BOOL(ass_scale_with_window)}, {"sub", OPT_SUBSTRUCT(sub_style, sub_style_conf)}, + {"sub", OPT_SUBSTRUCT(secondary_sub_style, secondary_sub_style_conf)}, {"sub-clear-on-seek", OPT_BOOL(sub_clear_on_seek)}, {"teletext-page", OPT_INT(teletext_page), M_RANGE(-1, 999), .flags = UPDATE_SUB_FILT}, {"sub-past-video-end", OPT_BOOL(sub_past_video_end)}, diff --git a/options/options.h b/options/options.h index 26a791343ffff..d1d97d2478523 100644 --- a/options/options.h +++ b/options/options.h @@ -110,6 +110,7 @@ struct mp_subtitle_opts { bool sub_scale_with_window; bool ass_scale_with_window; struct osd_style_opts *sub_style; + struct osd_style_opts *secondary_sub_style; bool sub_scale_signs; float sub_gauss; bool sub_gray; diff --git a/sub/osd.c b/sub/osd.c index 0a073bd7113ef..92b062846c7dd 100644 --- a/sub/osd.c +++ b/sub/osd.c @@ -117,6 +117,26 @@ const struct m_sub_options sub_style_conf = { .change_flags = UPDATE_OSD, }; +const struct m_sub_options secondary_sub_style_conf = { + .opts = style_opts, + .size = sizeof(struct osd_style_opts), + .defaults = &(const struct osd_style_opts){ + .font = "sans-serif", + .font_size = 38, + .color = {255, 255, 255, 255}, + .outline_color = {0, 0, 0, 255}, + .back_color = {0, 0, 0, 175}, + .border_style = 1, + .outline_size = 1.65, + .shadow_offset = 0, + .margin_x = 19, + .margin_y = 34, + .align_x = 0, + .align_y = 1, + }, + .change_flags = UPDATE_OSD, +}; + #undef OPT_BASE_STRUCT #define OPT_BASE_STRUCT struct osd_bar_style_opts static const m_option_t bar_style_opts[] = { diff --git a/sub/osd.h b/sub/osd.h index b62836e517da1..8bd1dbdc8f6ee 100644 --- a/sub/osd.h +++ b/sub/osd.h @@ -190,6 +190,7 @@ struct osd_bar_style_opts { extern const struct m_sub_options osd_style_conf; extern const struct m_sub_options sub_style_conf; +extern const struct m_sub_options secondary_sub_style_conf; extern const struct m_sub_options osd_bar_style_conf; struct osd_state; From 36b7be1291b9251f782ced6459beba77e51b8b9e Mon Sep 17 00:00:00 2001 From: Mustafa Elnaquib Date: Thu, 17 Sep 2026 00:23:21 +0200 Subject: [PATCH 2/3] Use secondary subtitle style options for rendering of secondary subtitle, instead of always referencing primary subtitle style. Effectively adding options for, among others; secondary-sub-color secondary-sub-outline-color secondary-sub-back-color Make default secondary subtitle color gray --- DOCS/man/options.rst | 17 +++++++++++++++++ options/options.c | 2 +- sub/osd.c | 2 +- sub/sd_ass.c | 20 +++++++++++++++----- 4 files changed, 34 insertions(+), 7 deletions(-) diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst index 1aa5ccb80dcde..aec8d46645890 100644 --- a/DOCS/man/options.rst +++ b/DOCS/man/options.rst @@ -3103,11 +3103,21 @@ Subtitles ``--sub-border-color`` is an alias for ``--sub-outline-color``. +``--secondary-sub-outline-color=`` + See ``--secondary-sub-color``. Color used for the secondary sub font outline. + + ``--secondary-sub-border-color`` is an alias for ``--secondary-sub-outline-color``. + ``--sub-back-color=`` See ``--sub-color``. Color used for sub text background. ``--sub-shadow-color`` is an alias for ``--sub-back-color``. +``--secondary-sub-back-color=`` + See ``--secondary-sub-color``. Color used for secondary sub text background. + + ``--secondary-sub-shadow-color`` is an alias for ``--secondary-sub-back-color``. + ``--sub-outline-size=`` Size of the sub font outline in scaled pixels (see ``--sub-font-size`` for details). A value of 0 disables outlines. @@ -3178,6 +3188,13 @@ Subtitles - ``--sub-color='#FF0000'`` set sub to opaque red - ``--sub-color='#C0808080'`` set sub to 50% gray with 75% alpha +``--secondary-sub-color=`` + Specify the color used for unstyled text subtitles. + Control whether user secondary substyle overrides should be applied. This + works exactly like ``--sub-color``. + + Default: '#7F7F7FFF'. + ``--sub-margin-x=`` Left and right screen margin for the subs in scaled pixels (see ``--sub-font-size`` for details). diff --git a/options/options.c b/options/options.c index d19f9bca7023c..8a854034f74cf 100644 --- a/options/options.c +++ b/options/options.c @@ -346,7 +346,7 @@ const struct m_sub_options mp_subtitle_sub_opts = { {"sub-scale-with-window", OPT_BOOL(sub_scale_with_window)}, {"sub-ass-scale-with-window", OPT_BOOL(ass_scale_with_window)}, {"sub", OPT_SUBSTRUCT(sub_style, sub_style_conf)}, - {"sub", OPT_SUBSTRUCT(secondary_sub_style, secondary_sub_style_conf)}, + {"secondary-sub", OPT_SUBSTRUCT(secondary_sub_style, secondary_sub_style_conf)}, {"sub-clear-on-seek", OPT_BOOL(sub_clear_on_seek)}, {"teletext-page", OPT_INT(teletext_page), M_RANGE(-1, 999), .flags = UPDATE_SUB_FILT}, {"sub-past-video-end", OPT_BOOL(sub_past_video_end)}, diff --git a/sub/osd.c b/sub/osd.c index 92b062846c7dd..2e3a3b1c484fc 100644 --- a/sub/osd.c +++ b/sub/osd.c @@ -123,7 +123,7 @@ const struct m_sub_options secondary_sub_style_conf = { .defaults = &(const struct osd_style_opts){ .font = "sans-serif", .font_size = 38, - .color = {255, 255, 255, 255}, + .color = {127, 127, 127, 255}, .outline_color = {0, 0, 0, 255}, .back_color = {0, 0, 0, 175}, .border_style = 1, diff --git a/sub/sd_ass.c b/sub/sd_ass.c index db4d67daca1c9..913c14e21ae7b 100644 --- a/sub/sd_ass.c +++ b/sub/sd_ass.c @@ -112,6 +112,15 @@ static const struct sd_filter_functions *const filters[] = { NULL, }; +// Return style options for subtitle; primary or secondary. +static struct osd_style_opts *get_sub_style(struct sd *sd) +{ + if(sd->order == 1) { + return sd->opts->secondary_sub_style; + } + return sd->opts->sub_style; +} + // Add default styles, if the track does not have any styles yet. // Apply style overrides if the user provides any. static void mp_ass_add_default_styles(struct sd *sd, ASS_Track *track, struct mp_subtitle_opts *opts, @@ -133,7 +142,7 @@ static void mp_ass_add_default_styles(struct sd *sd, ASS_Track *track, struct mp track->default_style = sid; ASS_Style *style = track->styles + sid; style->Name = strdup("Default"); - mp_ass_set_style(style, track->PlayResY, opts->sub_style); + mp_ass_set_style(style, track->PlayResY, get_sub_style(sd)); } if (shared_opts->ass_style_override[sd->order]) @@ -240,7 +249,7 @@ static void enable_output(struct sd *sd, bool enable) } else { ctx->ass_renderer = ass_renderer_init(ctx->ass_library); - mp_ass_configure_fonts(ctx->ass_renderer, sd->opts->sub_style, + mp_ass_configure_fonts(ctx->ass_renderer, get_sub_style(sd), sd->global, sd->log); } } @@ -251,7 +260,7 @@ static void assobjects_init(struct sd *sd) struct mp_subtitle_opts *opts = sd->opts; struct mp_subtitle_shared_opts *shared_opts = sd->shared_opts; - ctx->ass_library = mp_ass_init(sd->global, sd->opts->sub_style, sd->log); + ctx->ass_library = mp_ass_init(sd->global, get_sub_style(sd), sd->log); ass_set_extract_fonts(ctx->ass_library, opts->use_embedded_fonts); add_subtitle_fonts(sd); @@ -591,13 +600,14 @@ static void configure_ass(struct sd *sd, struct mp_osd_res *dim, set_force_flags |= ASS_OVERRIDE_BIT_JUSTIFY; #endif ass_set_selective_style_override_enabled(priv, set_force_flags); + struct osd_style_opts *sub_style = get_sub_style(sd); ASS_Style style = {0}; - mp_ass_set_style(&style, MP_ASS_FONT_PLAYRESY, opts->sub_style); + mp_ass_set_style(&style, MP_ASS_FONT_PLAYRESY, sub_style); ass_set_selective_style_override(priv, &style); free(style.FontName); if (converted && track->default_style < track->n_styles) { mp_ass_set_style(track->styles + track->default_style, - track->PlayResY, opts->sub_style); + track->PlayResY, sub_style); } ass_set_font_scale(priv, set_font_scale); ass_set_hinting(priv, set_hinting); From a898438480bdc16cd7486ada8b5cb16b62e8a1c0 Mon Sep 17 00:00:00 2001 From: Mustafa Elnaquib Date: Thu, 17 Sep 2026 00:38:33 +0200 Subject: [PATCH 3/3] DOCS/options: document secondary-sub-* style options Commit 36b7be1291 added a full set of secondary-sub-* style options (secondary-sub-font, secondary-sub-outline-size, secondary-sub-align-x, etc.) mirroring the existing sub-* style options, but only documented secondary-sub-color, secondary-sub-outline-color, and secondary-sub-back-color. This adds options.rst entries for the remaining secondary-sub-* options, each pointing back to its sub-* counterpart for the full description, per the existing --secondary-sub-* documentation convention in this file. AI assistance disclosure: an AI assistant (Claude) was used to compile the list of documented vs. undocumented secondary-sub-* options and to draft the options.rst text and this commit message. I reviewed and adjusted the wording before committing, and take full responsibility for the change and its correctness. --- DOCS/man/options.rst | 83 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst index aec8d46645890..ba418781b403d 100644 --- a/DOCS/man/options.rst +++ b/DOCS/man/options.rst @@ -3080,6 +3080,9 @@ Subtitles options) are ignored when ASS-subtitles are rendered, unless ``--sub-ass=no`` is specified. +``--secondary-sub-font=`` + See ``--sub-font``. Font used for the secondary subtitles. + ``--sub-font-size=`` Specify the sub font size. The unit is the size in scaled pixels at a window height of 720. The actual pixel size is scaled with the window @@ -3088,16 +3091,30 @@ Subtitles Default: 38 +``--secondary-sub-font-size=`` + See ``--sub-font-size``. Font size used for the secondary subtitles. + + Default: 38 + ``--sub-blur=<0..20.0>`` Gaussian blur factor applied to the sub font border. 0 means no blur applied (default). +``--secondary-sub-blur=<0..20.0>`` + See ``--sub-blur``. Blur factor applied to the secondary sub font border. + ``--sub-bold=`` Format text on bold. +``--secondary-sub-bold=`` + See ``--sub-bold``. Format secondary sub text on bold. + ``--sub-italic=`` Format text on italic. +``--secondary-sub-italic=`` + See ``--sub-italic``. Format secondary sub text on italic. + ``--sub-outline-color=`` See ``--sub-color``. Color used for the sub font outline. @@ -3126,6 +3143,14 @@ Subtitles Default: 1.65 +``--secondary-sub-outline-size=`` + See ``--sub-outline-size``. Size of the secondary sub font outline. + + ``--secondary-sub-border-size`` is an alias for + ``--secondary-sub-outline-size``. + + Default: 1.65 + ``--sub-border-style=`` The style of the border. @@ -3160,6 +3185,11 @@ Subtitles including stats and console - ``--profile=box`` applies the ``background-box`` style to both subtitles and OSD +``--secondary-sub-border-style=`` + See ``--sub-border-style``. The style of the secondary sub border. + + Default: ``outline-and-shadow``. + ``--sub-color=`` Specify the color used for unstyled text subtitles. @@ -3204,6 +3234,12 @@ Subtitles Default: 19 +``--secondary-sub-margin-x=`` + See ``--sub-margin-x``. Left and right screen margin for the secondary + subs. + + Default: 19 + ``--sub-margin-y=`` Top and bottom screen margin for the subs in scaled pixels (see ``--sub-font-size`` for details). @@ -3213,6 +3249,13 @@ Subtitles Default: 34 +``--secondary-sub-margin-y=`` + See ``--sub-margin-y``. Top and bottom screen margin for the secondary + subs. If you just want to raise the vertical secondary subtitle position, + use ``--secondary-sub-pos``. + + Default: 34 + ``--sub-margin-y-offset=`` Additional vertical offset added to the subtitle margin, in scaled pixels. This is added on top of ``--sub-margin-y``. @@ -3223,6 +3266,12 @@ Subtitles Default: 0 +``--secondary-sub-margin-y-offset=`` + See ``--sub-margin-y-offset``. Additional vertical offset added to the + secondary subtitle margin, on top of ``--secondary-sub-margin-y``. + + Default: 0 + ``--sub-align-x=`` Control to which corner of the screen text subtitles should be aligned to (default: ``center``). @@ -3230,15 +3279,28 @@ Subtitles Never applied to ASS subtitles, except in ``--sub-ass=no`` mode. Likewise, this does not apply to image subtitles. +``--secondary-sub-align-x=`` + See ``--sub-align-x``. Horizontal position of the secondary subtitles + (default: ``center``). + ``--sub-align-y=`` Vertical position (default: ``bottom``). Details see ``--sub-align-x``. +``--secondary-sub-align-y=`` + See ``--sub-align-y``. Vertical position of the secondary subtitles + (default: ``bottom``). + ``--sub-justify=`` Control how multi line subs are justified irrespective of where they are aligned (default: ``auto`` which justifies as defined by ``--sub-align-x``). +``--secondary-sub-justify=`` + See ``--sub-justify``. Justification of multi line secondary subs + (default: ``auto`` which justifies as defined by + ``--secondary-sub-align-x``). + ``--sub-ass-justify=`` Applies justification as defined by ``--sub-justify`` on ASS subtitles if ``--sub-ass-override`` is not set to ``no``. @@ -3250,6 +3312,12 @@ Subtitles Default: 0. +``--secondary-sub-shadow-offset=`` + See ``--sub-shadow-offset``. Displacement of the secondary sub text + shadow. A value of 0 disables shadows. + + Default: 0. + ``--sub-spacing=`` Horizontal sub font spacing in scaled pixels (see ``--sub-font-size`` for details). This value is added to the normal letter spacing. Negative @@ -3257,6 +3325,12 @@ Subtitles Default: 0. +``--secondary-sub-spacing=`` + See ``--sub-spacing``. Horizontal secondary sub font spacing. This value + is added to the normal letter spacing. Negative values are allowed. + + Default: 0. + ``--sub-filter-sdh=`` Applies filter removing subtitle additions for the deaf or hard-of-hearing (SDH). This is intended for English, but may in part work for other languages too. @@ -3365,6 +3439,10 @@ Subtitles name does not match, it may prefer not to render any text that uses the missing font.) +``--secondary-sub-font-provider=`` + See ``--sub-font-provider``. Font provider backend used for the secondary + subtitles (default: auto). + ``--sub-fonts-dir=`` Font files in this directory are used by mpv/libass for subtitles. Useful if you do not want to install fonts to your system. Note that files in this @@ -3374,6 +3452,11 @@ Subtitles If this option is not specified, ``~~/fonts`` will be used by default. +``--secondary-sub-fonts-dir=`` + See ``--sub-fonts-dir``. Font directory used for the secondary subtitles. + + If this option is not specified, ``~~/fonts`` will be used by default. + Window ------