From c4f982637ff7d85130e53a85ab1b268cf3fe02ed Mon Sep 17 00:00:00 2001 From: Ripose Date: Mon, 12 Jul 2021 11:42:03 -0700 Subject: command: adds support for secondary subs to sub-seek and sub-step Modifies the sub-seek and sub-step commands with a second argument to specify whether to seek/step on the primary or secondary subtitles. The flag is used to index into the current_track array in cmd_sub_step_seek. --- DOCS/man/input.rst | 18 ++++++++++++++++-- player/command.c | 33 ++++++++++++++++++++++++++------- 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst index acb1f0bf75..ca7d2d2f57 100644 --- a/DOCS/man/input.rst +++ b/DOCS/man/input.rst @@ -683,16 +683,30 @@ Remember to quote string arguments in input.conf (see `Flat command syntax`_). This works by unloading and re-adding the subtitle track. -``sub-step `` +``sub-step `` Change subtitle timing such, that the subtitle event after the next ```` subtitle events is displayed. ```` can be negative to step backwards. -``sub-seek `` + Secondary argument: + + primary (default) + Steps through the primary subtitles. + secondary + Steps through the secondary subtitles. + +``sub-seek `` Seek to the next (skip set to 1) or the previous (skip set to -1) subtitle. This is similar to ``sub-step``, except that it seeks video and audio instead of adjusting the subtitle delay. + Secondary argument: + + primary (default) + Seeks through the primary subtitles. + secondary + Seeks through the secondary subtitles. + For embedded subtitles (like with Matroska), this works only with subtitle events that have already been displayed, or are within a short prefetch range. diff --git a/player/command.c b/player/command.c index f4dd93c5d0..46668f5471 100644 --- a/player/command.c +++ b/player/command.c @@ -3677,11 +3677,11 @@ static const struct m_property mp_properties_base[] = { .priv = (void *)&(const int){SD_TEXT_TYPE_ASS}}, {"sub-start", mp_property_sub_start, .priv = (void *)&(const int){0}}, - {"secondary-sub-start", mp_property_sub_start, + {"secondary-sub-start", mp_property_sub_start, .priv = (void *)&(const int){1}}, {"sub-end", mp_property_sub_end, .priv = (void *)&(const int){0}}, - {"secondary-sub-end", mp_property_sub_end, + {"secondary-sub-end", mp_property_sub_end, .priv = (void *)&(const int){1}}, {"vf", mp_property_vf}, @@ -5035,13 +5035,14 @@ static void cmd_sub_step_seek(void *p) struct mp_cmd_ctx *cmd = p; struct MPContext *mpctx = cmd->mpctx; bool step = *(bool *)cmd->priv; + int track_ind = cmd->args[1].v.i; if (!mpctx->playback_initialized) { cmd->success = false; return; } - struct track *track = mpctx->current_track[0][STREAM_SUB]; + struct track *track = mpctx->current_track[track_ind][STREAM_SUB]; struct dec_sub *sub = track ? track->d_sub : NULL; double refpts = get_current_time(mpctx); if (sub && refpts != MP_NOPTS_VALUE) { @@ -6073,10 +6074,28 @@ const struct mp_cmd_def mp_cmds[] = { }, { "playlist-shuffle", cmd_playlist_shuffle, }, { "playlist-unshuffle", cmd_playlist_unshuffle, }, - { "sub-step", cmd_sub_step_seek, { {"skip", OPT_INT(v.i)} }, - .allow_auto_repeat = true, .priv = &(const bool){true} }, - { "sub-seek", cmd_sub_step_seek, { {"skip", OPT_INT(v.i)} }, - .allow_auto_repeat = true, .priv = &(const bool){false} }, + { "sub-step", cmd_sub_step_seek, + { + {"skip", OPT_INT(v.i)}, + {"flags", OPT_CHOICE(v.i, + {"primary", 0}, + {"secondary", 1}), + OPTDEF_INT(0)}, + }, + .allow_auto_repeat = true, + .priv = &(const bool){true} + }, + { "sub-seek", cmd_sub_step_seek, + { + {"skip", OPT_INT(v.i)}, + {"flags", OPT_CHOICE(v.i, + {"primary", 0}, + {"secondary", 1}), + OPTDEF_INT(0)}, + }, + .allow_auto_repeat = true, + .priv = &(const bool){false} + }, { "print-text", cmd_print_text, { {"text", OPT_STRING(v.s)} }, .is_noisy = true, .allow_auto_repeat = true }, { "show-text", cmd_show_text, -- cgit v1.2.3