summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-02-04 23:02:27 +0100
committerwm4 <wm4@nowhere>2015-02-04 23:04:21 +0100
commit868d0f1e831eaf303ff8f198577583b2fadc67d4 (patch)
tree67cd115aa9fa3c3fca540841bb0e705721dcf11d
parent59dc351772e95742600979886591401923aceb25 (diff)
downloadmpv-868d0f1e831eaf303ff8f198577583b2fadc67d4.tar.bz2
mpv-868d0f1e831eaf303ff8f198577583b2fadc67d4.tar.xz
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.
-rw-r--r--player/timeline/tl_matroska.c49
1 files changed, 49 insertions, 0 deletions
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);
}