summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-08-14 23:59:35 +0200
committerwm4 <wm4@nowhere>2014-08-14 23:59:35 +0200
commitd5940fabcd6b477c72430c84e460975060807646 (patch)
treeb8392948588c4e3e5d42c10537351697424659e4
parent498644afafbcff1bf4f4bcdc1bbc8ef41aae9546 (diff)
downloadmpv-d5940fabcd6b477c72430c84e460975060807646.tar.bz2
mpv-d5940fabcd6b477c72430c84e460975060807646.tar.xz
sub: add option to workaround broken mkv files
See additions to options.rst.
-rw-r--r--DOCS/man/options.rst7
-rw-r--r--options/options.c1
-rw-r--r--options/options.h1
-rw-r--r--player/sub.c4
-rw-r--r--sub/sd_ass.c2
5 files changed, 13 insertions, 2 deletions
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index 2bc7353299..356bd903b3 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -1322,6 +1322,13 @@ Subtitles
Can be used to disable display of subtitles, but still select and decode
them.
+``--sub-clear-on-seek``
+ (Obscure, rarely useful.) Can be used to play broken mkv files with
+ duplicate ReadOrder fields. ReadOrder is the first field in a
+ Matroska-style ASS subtitle packets. It should be unique, and libass
+ uses it for fast elimination of duplicates. This option disables caching
+ of subtitles across seeks, so after a seek libass can't eliminate subtitle
+ packets with the same ReadOrder as earlier packets.
Window
------
diff --git a/options/options.c b/options/options.c
index f8a18f891a..caf0171a7a 100644
--- a/options/options.c
+++ b/options/options.c
@@ -337,6 +337,7 @@ const m_option_t mp_opts[] = {
OPT_FLOATRANGE("osd-bar-h", osd_bar_h, 0, 0.1, 50),
OPT_SUBSTRUCT("osd", osd_style, osd_style_conf, 0),
OPT_SUBSTRUCT("sub-text", sub_text_style, osd_style_conf, 0),
+ OPT_FLAG("sub-clear-on-seek", sub_clear_on_seek, 0),
//---------------------- libao/libvo options ------------------------
OPT_SETTINGSLIST("vo", vo.video_driver_list, 0, &vo_obj_list),
diff --git a/options/options.h b/options/options.h
index 92e3ca0637..5f59fa42c6 100644
--- a/options/options.h
+++ b/options/options.h
@@ -230,6 +230,7 @@ typedef struct MPOpts {
int ass_hinting;
int ass_shaper;
int sub_scale_with_window;
+ int sub_clear_on_seek;
int hwdec_api;
char *hwdec_codecs;
diff --git a/player/sub.c b/player/sub.c
index efd2f68464..7f01a17961 100644
--- a/player/sub.c
+++ b/player/sub.c
@@ -172,6 +172,8 @@ void update_subtitles(struct MPContext *mpctx)
static void reinit_subdec(struct MPContext *mpctx, struct track *track,
struct dec_sub *dec_sub)
{
+ struct MPOpts *opts = mpctx->opts;
+
if (sub_is_initialized(dec_sub))
return;
@@ -189,7 +191,7 @@ static void reinit_subdec(struct MPContext *mpctx, struct track *track,
// Don't do this if the file has video/audio streams. Don't do it even
// if it has only sub streams, because reading packets will change the
// demuxer position.
- if (!track->preloaded && track->is_external) {
+ if (!track->preloaded && track->is_external && !opts->sub_clear_on_seek) {
demux_seek(track->demuxer, 0, SEEK_ABSOLUTE);
track->preloaded = sub_read_all_packets(dec_sub, track->stream);
}
diff --git a/sub/sd_ass.c b/sub/sd_ass.c
index 51b9472198..733f0ffa1d 100644
--- a/sub/sd_ass.c
+++ b/sub/sd_ass.c
@@ -270,7 +270,7 @@ static void fix_events(struct sd *sd)
static void reset(struct sd *sd)
{
struct sd_ass_priv *ctx = sd->priv;
- if (ctx->flush_on_seek)
+ if (ctx->flush_on_seek || sd->opts->sub_clear_on_seek)
ass_flush_events(ctx->ass_track);
ctx->flush_on_seek = false;
}