[FFmpeg-devel] [PATCH 2/2] avformat/seek: fail seeking immediately
Kaarle Ritvanen
kaarle.ritvanen at datakunkku.fi
Fri May 2 11:01:45 EEST 2025
when AVFMTCTX_UNSEEKABLE is set. Depending on the codec, the execution
of this function may take several seconds. This is an optimization for
the case where the stream is already known unseekable.
Signed-off-by: Kaarle Ritvanen <kaarle.ritvanen at datakunkku.fi>
---
libavformat/seek.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/libavformat/seek.c b/libavformat/seek.c
index c0d94371e6..1a7d3d6741 100644
--- a/libavformat/seek.c
+++ b/libavformat/seek.c
@@ -643,6 +643,9 @@ int av_seek_frame(AVFormatContext *s, int stream_index,
{
int ret;
+ if (s->ctx_flags & AVFMTCTX_UNSEEKABLE)
+ return AVERROR(ENOSYS);
+
if (ffifmt(s->iformat)->read_seek2 && !ffifmt(s->iformat)->read_seek) {
int64_t min_ts = INT64_MIN, max_ts = INT64_MAX;
if ((flags & AVSEEK_FLAG_BACKWARD))
--
2.49.0
More information about the ffmpeg-devel
mailing list