demux: fail probing when the stream cannot be rewound to the start

Each probe attempt assumes it reads from position 0. If the rewind
fails, the demuxer would silently misparse the stream from a wrong
position.

On non-seekable streams this may fail when the probe size > buffer size,
which would cause us to drop the buffered data and not allow to rewind
the stream. This can be improved in the future.
This commit is contained in:
Kacper Michajłow committed 2026-07-26 12:59:51 +02:00
1 parent 762c5999c2
commit b27573a239
1 file changed
+6 -2
+6 -2
View File
@@ -3436,8 +3436,12 @@ static struct demuxer *open_given_type(struct mpv_global *global,
mp_dbg(log, "Trying demuxer: %s (force-level: %s)\n",
desc->name, d_level(check));
if (stream)
stream_seek(stream, 0);
if (stream && !stream_seek(stream, 0)) {
mp_err(log, "Failed to rewind stream to the start.\n");
demuxer->stream = NULL;
demux_free(demuxer);
return NULL;
}
in->d_thread->params = params; // temporary during open()
int ret = demuxer->desc->open(in->d_thread, check);