diff --git a/libavformat/avidec.c b/libavformat/avidec.c index 73d1d166ea..2f637225e9 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -1681,9 +1681,13 @@ static int guess_ni_flag(AVFormatContext *s) if (n >= 2) { int64_t pos = st->index_entries[0].pos; - avio_seek(s->pb, pos + 4, SEEK_SET); + unsigned tag[2]; + avio_seek(s->pb, pos, SEEK_SET); + tag[0] = avio_r8(s->pb); + tag[1] = avio_r8(s->pb); + avio_rl16(s->pb); size = avio_rl32(s->pb); - if (pos + size > st->index_entries[1].pos) + if (get_stream_idx(tag) == i && pos + size > st->index_entries[1].pos) last_start = INT64_MAX; }