[FFmpeg-devel] [PATCH 2/2 RESEND] avformat/seek: fail seeking immediately

Zhao Zhili quinkblack at foxmail.com
Wed May 28 15:19:40 EEST 2025



> On May 28, 2025, at 20:08, Kaarle Ritvanen via ffmpeg-devel <ffmpeg-devel at ffmpeg.org> wrote:
> 
> when AVFMTCTX_UNSEEKABLE is set. Depending on the codec, the execution
> of this function may take several seconds. This is an optimization for

Why this depending on the codec? Could you provide a case that takes several seconds?

> 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
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".



More information about the ffmpeg-devel mailing list