From 868d0f1e831eaf303ff8f198577583b2fadc67d4 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 4 Feb 2015 23:02:27 +0100 Subject: matroska: warn against mismatching segments Matroska ordered chapters require all segment files to have the same layout. If a referenced file has more tracks than the main file or misses some tracks, the file is invalid. Also see issue #1553. --- player/timeline/tl_matroska.c | 49 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'player') diff --git a/player/timeline/tl_matroska.c b/player/timeline/tl_matroska.c index 8ced0ca7ac..a2cc43550a 100644 --- a/player/timeline/tl_matroska.c +++ b/player/timeline/tl_matroska.c @@ -471,6 +471,53 @@ static void build_timeline_loop(struct MPContext *mpctx, *missing_time += limit - local_starttime; } +static void check_track_compatibility(struct MPContext *mpctx) +{ + struct demuxer *mainsrc = mpctx->track_layout; + + for (int n = 0; n < mpctx->num_timeline_parts; n++) { + struct timeline_part *p = &mpctx->timeline[n]; + if (p->source == mainsrc) + continue; + + for (int i = 0; i < p->source->num_streams; i++) { + struct sh_stream *s = p->source->streams[i]; + if (s->attached_picture) + continue; + + if (!demuxer_stream_by_demuxer_id(mainsrc, s->type, s->demuxer_id)) { + MP_WARN(mpctx, "Source %s has %s stream with TID=%d, which " + "is not present in the ordered chapters main " + "file. This is a broken file. " + "The additional stream is ignored.\n", + p->source->filename, stream_type_name(s->type), + s->demuxer_id); + } + } + + for (int i = 0; i < mainsrc->num_streams; i++) { + struct sh_stream *m = mainsrc->streams[i]; + if (m->attached_picture) + continue; + + struct sh_stream *s = + demuxer_stream_by_demuxer_id(p->source, m->type, m->demuxer_id); + if (s) { + // There are actually many more things that in theory have to + // match (though mpv's implementation doesn't care). + if (s->codec && m->codec && strcmp(s->codec, m->codec) != 0) + MP_WARN(mpctx, "Timeline segments have mismatching codec.\n"); + } else { + MP_WARN(mpctx, "Source %s lacks %s stream with TID=%d, which " + "is present in the ordered chapters main " + "file. This is a broken file.\n", + p->source->filename, stream_type_name(m->type), + m->demuxer_id); + } + } + } +} + void build_ordered_chapter_timeline(struct MPContext *mpctx) { struct MPOpts *opts = mpctx->opts; @@ -579,4 +626,6 @@ void build_ordered_chapter_timeline(struct MPContext *mpctx) break; } } + + check_track_compatibility(mpctx); } -- cgit v1.2.3