demux_mkv: better behavior/warnings on partial files/unseekable streams

demux_mkv may seek to the end of the file to read certain headers (which
should probably be called "footers", but in theory they are just headers
that have been placed at the end of the file unfortunately).

This commit changes behavior not to seek if the stream is not marked as
seekable. Before this, it only checked whether the stream size was
unknown (end negative). In practice it doesn't make much of a
difference, since seekable usually equals known stream size.

Also improve the wording, and distinguish between actual incomplete
files, and unseekable ones.
This commit is contained in:
wm4 2019-10-01 20:48:45 +02:00
parent 1f76e69145
commit 07d9ca5ee3
1 changed files with 8 additions and 5 deletions

View File

@ -2104,13 +2104,16 @@ static int demux_mkv_open(demuxer_t *demuxer, enum demux_check check)
if (elem->parsed)
continue;
// Warn against incomplete files and skip headers outside of range.
if (elem->pos >= end) {
if (elem->pos >= end || !s->seekable) {
elem->parsed = true; // don't bother if file is incomplete
if (!mkv_d->eof_warning && !(mkv_d->probably_webm_dash_init &&
elem->pos == end))
if (end < 0 || !s->seekable) {
MP_WARN(demuxer, "Stream is not seekable or unknown size, "
"not reading mkv metadata at end of file.\n");
} else if (!mkv_d->eof_warning &&
!(mkv_d->probably_webm_dash_init && elem->pos == end))
{
MP_WARN(demuxer, "SeekHead position beyond "
"end of file - incomplete file?\n");
MP_WARN(demuxer, "mkv metadata beyond end of file - incomplete "
"file?\n");
mkv_d->eof_warning = true;
}
continue;