1
mirror of https://github.com/mpv-player/mpv synced 2024-08-24 07:21:49 +02:00

options: add -sub-speed option

Should we actually get into trouble for unproper handling of
frame-based subtitle formats, this might be the simplest way to
work this around. Also is a bit more intuitive than -subfps, which
might use an unknown, misdetected, or non-sense video FPS.
Still pretty silly, though.
This commit is contained in:
wm4 2013-06-25 00:03:37 +02:00
parent 125c20bd08
commit 00de44eec9
4 changed files with 24 additions and 2 deletions

View File

@ -2062,6 +2062,8 @@
*NOTE*: <rate> > 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=<n>
Specify the software scaler algorithm to be used with ``--vf=scale``. This
also affects video output drivers which lack hardware acceleration,

View File

@ -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

View File

@ -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;

View File

@ -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);