diff --git a/DOCS/man/en/options.rst b/DOCS/man/en/options.rst index 956758ef7d..57af5ff209 100644 --- a/DOCS/man/en/options.rst +++ b/DOCS/man/en/options.rst @@ -2062,6 +2062,8 @@ *NOTE*: > movie fps speeds the subtitles up for frame-based subtitle files and slows them down for time-based ones. + Also see ``--sub-speed`` option. + --sub-gauss=<0.0-3.0> Apply gaussian blur to image subtitles (default: 0). This can help making pixelated DVD/Vobsubs look nicer. A value other than 0 also switches to @@ -2088,6 +2090,16 @@ *NOTE*: this affects ASS subtitles as well, and may lead to incorrect subtitle rendering. Use with care, or use ``--sub-text-font-size`` instead. +--sub-speed=<0.1-10.0> + Multiply the subtitle event timestamps with the given value. Can be used + to fix the playback speed for frame-based subtitle formats. Works for + external text subtitles only. + + *EXAMPLE*: + + - ``--sub-speed=25/23.976`` play frame based subtitles, which have been + loaded assuming a framerate of 23.976, at 25 FPS. + --sws= Specify the software scaler algorithm to be used with ``--vf=scale``. This also affects video output drivers which lack hardware acceleration, diff --git a/core/options.c b/core/options.c index 3ce4315572..40c8527394 100644 --- a/core/options.c +++ b/core/options.c @@ -492,6 +492,7 @@ const m_option_t mp_opts[] = { OPT_STRING("subcp", sub_cp, 0), OPT_FLOAT("sub-delay", sub_delay, 0), OPT_FLOAT("subfps", sub_fps, 0), + OPT_FLOAT("sub-speed", sub_speed, 0), OPT_FLAG("autosub", sub_auto, 0), OPT_FLAG("sub-visibility", sub_visibility, 0), OPT_FLAG("sub-forced-only", forced_subs_only, 0), @@ -786,6 +787,7 @@ const struct MPOpts mp_default_opts = { .audio_display = 1, .sub_visibility = 1, .sub_pos = 100, + .sub_speed = 1.0, .extension_parsing = 1, .audio_output_channels = MP_CHMAP_INIT_STEREO, .audio_output_format = -1, // AF_FORMAT_UNKNOWN diff --git a/core/options.h b/core/options.h index 6ec051ddca..0c6f6c7271 100644 --- a/core/options.h +++ b/core/options.h @@ -141,6 +141,7 @@ typedef struct MPOpts { int sub_pos; float sub_delay; float sub_fps; + float sub_speed; int forced_subs_only; char *quvi_format; diff --git a/sub/dec_sub.c b/sub/dec_sub.c index 968ca3e39f..a1392017a2 100644 --- a/sub/dec_sub.c +++ b/sub/dec_sub.c @@ -401,12 +401,19 @@ bool sub_read_all_packets(struct dec_sub *sub, struct sh_sub *sh) if (sub->charset) mp_msg(MSGT_OSD, MSGL_INFO, "Using subtitle charset: %s\n", sub->charset); + double sub_speed = 1.0; + // 23.976 FPS is used as default timebase for frame based formats if (sub->video_fps && sh->frame_based) - multiply_timings(subs, sub->video_fps / 23.976); + sub_speed *= sub->video_fps / 23.976; if (opts->sub_fps && sub->video_fps) - multiply_timings(subs, opts->sub_fps / sub->video_fps); + sub_speed *= opts->sub_fps / sub->video_fps; + + sub_speed *= opts->sub_speed; + + if (sub_speed != 1.0) + multiply_timings(subs, sub_speed); if (!opts->suboverlap_enabled) fix_overlaps_and_gaps(subs);