Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 100 additions & 0 deletions DOCS/man/options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3080,6 +3080,9 @@ Subtitles
options) are ignored when ASS-subtitles are rendered, unless
``--sub-ass=no`` is specified.

``--secondary-sub-font=<name>``
See ``--sub-font``. Font used for the secondary subtitles.

``--sub-font-size=<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
Expand All @@ -3088,26 +3091,50 @@ Subtitles

Default: 38

``--secondary-sub-font-size=<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=<yes|no>``
Format text on bold.

``--secondary-sub-bold=<yes|no>``
See ``--sub-bold``. Format secondary sub text on bold.

``--sub-italic=<yes|no>``
Format text on italic.

``--secondary-sub-italic=<yes|no>``
See ``--sub-italic``. Format secondary sub text on italic.

``--sub-outline-color=<color>``
See ``--sub-color``. Color used for the sub font outline.

``--sub-border-color`` is an alias for ``--sub-outline-color``.

``--secondary-sub-outline-color=<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=<color>``
See ``--sub-color``. Color used for sub text background.

``--sub-shadow-color`` is an alias for ``--sub-back-color``.

``--secondary-sub-back-color=<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>``
Size of the sub font outline in scaled pixels (see ``--sub-font-size``
for details). A value of 0 disables outlines.
Expand All @@ -3116,6 +3143,14 @@ Subtitles

Default: 1.65

``--secondary-sub-outline-size=<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=<outline-and-shadow|opaque-box|background-box>``
The style of the border.

Expand Down Expand Up @@ -3150,6 +3185,11 @@ Subtitles
including stats and console
- ``--profile=box`` applies the ``background-box`` style to both subtitles and OSD

``--secondary-sub-border-style=<outline-and-shadow|opaque-box|background-box>``
See ``--sub-border-style``. The style of the secondary sub border.

Default: ``outline-and-shadow``.

``--sub-color=<color>``
Specify the color used for unstyled text subtitles.

Expand Down Expand Up @@ -3178,6 +3218,13 @@ Subtitles
- ``--sub-color='#FF0000'`` set sub to opaque red
- ``--sub-color='#C0808080'`` set sub to 50% gray with 75% alpha

``--secondary-sub-color=<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=<size>``
Left and right screen margin for the subs in scaled pixels (see
``--sub-font-size`` for details).
Expand All @@ -3187,6 +3234,12 @@ Subtitles

Default: 19

``--secondary-sub-margin-x=<size>``
See ``--sub-margin-x``. Left and right screen margin for the secondary
subs.

Default: 19

``--sub-margin-y=<size>``
Top and bottom screen margin for the subs in scaled pixels (see
``--sub-font-size`` for details).
Expand All @@ -3196,6 +3249,13 @@ Subtitles

Default: 34

``--secondary-sub-margin-y=<size>``
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=<size>``
Additional vertical offset added to the subtitle margin, in scaled pixels.
This is added on top of ``--sub-margin-y``.
Expand All @@ -3206,22 +3266,41 @@ Subtitles

Default: 0

``--secondary-sub-margin-y-offset=<size>``
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=<left|center|right>``
Control to which corner of the screen text subtitles should be
aligned to (default: ``center``).

Never applied to ASS subtitles, except in ``--sub-ass=no`` mode. Likewise,
this does not apply to image subtitles.

``--secondary-sub-align-x=<left|center|right>``
See ``--sub-align-x``. Horizontal position of the secondary subtitles
(default: ``center``).

``--sub-align-y=<top|center|bottom>``
Vertical position (default: ``bottom``).
Details see ``--sub-align-x``.

``--secondary-sub-align-y=<top|center|bottom>``
See ``--sub-align-y``. Vertical position of the secondary subtitles
(default: ``bottom``).

``--sub-justify=<auto|left|center|right>``
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=<auto|left|center|right>``
See ``--sub-justify``. Justification of multi line secondary subs
(default: ``auto`` which justifies as defined by
``--secondary-sub-align-x``).

``--sub-ass-justify=<yes|no>``
Applies justification as defined by ``--sub-justify`` on ASS subtitles
if ``--sub-ass-override`` is not set to ``no``.
Expand All @@ -3233,13 +3312,25 @@ Subtitles

Default: 0.

``--secondary-sub-shadow-offset=<size>``
See ``--sub-shadow-offset``. Displacement of the secondary sub text
shadow. A value of 0 disables shadows.

Default: 0.

``--sub-spacing=<size>``
Horizontal sub font spacing in scaled pixels (see ``--sub-font-size``
for details). This value is added to the normal letter spacing. Negative
values are allowed.

Default: 0.

``--secondary-sub-spacing=<size>``
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=<yes|no>``
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.
Expand Down Expand Up @@ -3348,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=<auto|none|fontconfig>``
See ``--sub-font-provider``. Font provider backend used for the secondary
subtitles (default: auto).

``--sub-fonts-dir=<path>``
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
Expand All @@ -3357,6 +3452,11 @@ Subtitles

If this option is not specified, ``~~/fonts`` will be used by default.

``--secondary-sub-fonts-dir=<path>``
See ``--sub-fonts-dir``. Font directory used for the secondary subtitles.

If this option is not specified, ``~~/fonts`` will be used by default.

Window
------

Expand Down
1 change: 1 addition & 0 deletions options/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)},
{"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)},
Expand Down
1 change: 1 addition & 0 deletions options/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
20 changes: 20 additions & 0 deletions sub/osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {127, 127, 127, 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[] = {
Expand Down
1 change: 1 addition & 0 deletions sub/osd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
20 changes: 15 additions & 5 deletions sub/sd_ass.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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])
Expand Down Expand Up @@ -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);
}
}
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down