diff options
Diffstat (limited to 'demux/demux_lavf.c')
-rw-r--r-- | demux/demux_lavf.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c index b5a6ef998c..2b43f4f27f 100644 --- a/demux/demux_lavf.c +++ b/demux/demux_lavf.c @@ -135,17 +135,18 @@ static int64_t mp_seek(void *opaque, int64_t pos, int whence) return -1; MP_DBG(demuxer, "mp_seek(%p, %"PRId64", %d)\n", stream, pos, whence); - if (whence == SEEK_CUR) + if (whence == SEEK_END || whence == AVSEEK_SIZE) { + int64_t end; + if (stream_control(stream, STREAM_CTRL_GET_SIZE, &end) != STREAM_OK) + return -1; + if (whence == AVSEEK_SIZE) + return end; + pos += end; + } else if (whence == SEEK_CUR) { pos += stream_tell(stream); - else if (whence == SEEK_END && stream->end_pos > 0) - pos += stream->end_pos; - else if (whence == SEEK_SET) - /* ok */; - else if (whence == AVSEEK_SIZE && stream->end_pos > 0) { - stream_update_size(stream); - return stream->end_pos; - } else + } else if (whence != SEEK_SET) { return -1; + } if (pos < 0) return -1; @@ -824,11 +825,13 @@ static void demux_seek_lavf(demuxer_t *demuxer, float rel_seek_secs, int flags) if (flags & SEEK_FACTOR) { struct stream *s = demuxer->stream; - if (s->end_pos > 0 && demuxer->ts_resets_possible && + int64_t end = 0; + stream_control(s, STREAM_CTRL_GET_SIZE, &end); + if (end > 0 && demuxer->ts_resets_possible && !(priv->avif->flags & AVFMT_NO_BYTE_SEEK)) { avsflags |= AVSEEK_FLAG_BYTE; - priv->last_pts = s->end_pos * rel_seek_secs; + priv->last_pts = end * rel_seek_secs; } else if (priv->avfc->duration != 0 && priv->avfc->duration != AV_NOPTS_VALUE) { |