summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-06-25 00:03:37 +0200
committerwm4 <wm4@nowhere>2013-06-25 00:34:58 +0200
commit00de44eec90e45f4801e45d636b6759e1fdb9d2f (patch)
tree944b084ba34c465e861c0bd6f48bdccabcf82556
parent125c20bd081a7d99681f3ac25174c1360b885436 (diff)
downloadmpv-00de44eec90e45f4801e45d636b6759e1fdb9d2f.tar.bz2
mpv-00de44eec90e45f4801e45d636b6759e1fdb9d2f.tar.xz
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.
-rw-r--r--DOCS/man/en/options.rst12
-rw-r--r--core/options.c2
-rw-r--r--core/options.h1
-rw-r--r--sub/dec_sub.c11
4 files changed, 24 insertions, 2 deletions
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*: <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,
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);