[FFmpeg-devel] [PATCH] avformat/utils: use AVIOContext.read_seek for seeks if available

Aman Gupta ffmpeg at tmm1.net
Wed Apr 3 13:55:29 EEST 2019


From: Aman Gupta <aman at tmm1.net>

Currently only flv and asf decoders attempt to use pb->read_seek,
by calling avio_read_seek() expliclity.

This change allows avformat users to specify a custom AVIOContext
with a read_seek callback, and have it be used with any format
whenever av_seek_frame() is invoked.

Signed-off-by: Aman Gupta <aman at tmm1.net>
---
 libavformat/utils.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 9b3f0d28e6..b38727b3ed 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2487,6 +2487,9 @@ static int seek_frame_internal(AVFormatContext *s, int stream_index,
     if (s->iformat->read_seek) {
         ff_read_frame_flush(s);
         ret = s->iformat->read_seek(s, stream_index, timestamp, flags);
+    } else if (s->pb->read_seek) {
+        ff_read_frame_flush(s);
+        ret = s->pb->read_seek(s->pb->opaque, stream_index, timestamp, flags);
     } else
         ret = -1;
     if (ret >= 0)
-- 
2.20.1



More information about the ffmpeg-devel mailing list