sub: add option to workaround broken mkv files

See additions to options.rst.
This commit is contained in:
wm4 2014-08-14 23:59:35 +02:00
parent 498644afaf
commit d5940fabcd
5 changed files with 13 additions and 2 deletions

View File

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

View File

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

View File

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

View File

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

View File

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