[FFmpeg-devel] [PATCH] lavf: call the new seek API from the old.

Reimar Döffinger Reimar.Doeffinger at gmx.de
Tue Apr 30 20:45:37 CEST 2013


On Tue, Apr 30, 2013 at 12:16:16AM +0200, Nicolas George wrote:
> If the demuxer implements read_seek2() and not read_seek(),
> call avformat_seek_file() from av_seek_frame().
> Allow to properly seek in formats that only implement the
> new API from applications that use the old one.
> Tested with mplayer and a concat script.
> 
> Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
> ---
>  libavformat/utils.c |   13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index c1f1362..92cb2ea 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -2135,7 +2135,18 @@ static int seek_frame_internal(AVFormatContext *s, int stream_index,
>  
>  int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
>  {
> -    int ret = seek_frame_internal(s, stream_index, timestamp, flags);
> +    int ret;
> +
> +    if (s->iformat->read_seek2 && !s->iformat->read_seek) {
> +        int64_t min_ts = INT64_MIN, max_ts = INT64_MAX;
> +        if ((flags & AVSEEK_FLAG_BACKWARD))
> +            max_ts = timestamp;
> +        else
> +            min_ts = timestamp;
> +        return avformat_seek_file(s, stream_index, min_ts, timestamp, max_ts, flags);

Since the discussion came up recently: I think AVSEEK_FLAG_BACKWARD
makes no sense/is not defined for the new API (main reason being
is that if we wanted to support it, its absence would have to be
interpreted as a request to seek preferably forward. That would
however leave no way to specify to seek to the closest no matter
the direction).
If that is the case, it probably would make sense to filter it out
here.


More information about the ffmpeg-devel mailing list