mirror of
https://github.com/mpv-player/mpv
synced 2024-12-23 15:22:09 +00:00
demux_lavf: update growing file size info for AVSEEK_SIZE
demux_lavf was returning a static size value when libavformat queried file size with AVSEEK_SIZE. Add code to query the stream for possibly changed value first. This at least improves seeking with growing MPEG files; before seeks would never go beyond the part of the file that existed when the stream was first opened.
This commit is contained in:
parent
d0bae74702
commit
9f9bbb3c8b
@ -109,9 +109,12 @@ static int64_t mp_seek(void *opaque, int64_t pos, int whence)
|
|||||||
pos += stream->end_pos;
|
pos += stream->end_pos;
|
||||||
else if (whence == SEEK_SET)
|
else if (whence == SEEK_SET)
|
||||||
pos += stream->start_pos;
|
pos += stream->start_pos;
|
||||||
else if (whence == AVSEEK_SIZE && stream->end_pos > 0)
|
else if (whence == AVSEEK_SIZE && stream->end_pos > 0) {
|
||||||
|
off_t size;
|
||||||
|
if (stream_control(stream, STREAM_CTRL_GET_SIZE, &size) == STREAM_OK)
|
||||||
|
return size;
|
||||||
return stream->end_pos - stream->start_pos;
|
return stream->end_pos - stream->start_pos;
|
||||||
else
|
} else
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (pos < 0)
|
if (pos < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user