[MPlayer-dev-eng] [PATCH] demux_lavf: add an option to use the new seek API.

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


On Mon, Apr 29, 2013 at 11:38:08PM +0200, Nicolas George wrote:
> Le decadi 10 floréal, an CCXXI, Reimar Döffinger a écrit :
> > Of which you set neither min or max, that was my point...
> 
> The flag indicating the preferred direction is set. Look at the existing
> code:
> 
>     if (av_seek_frame(priv->avfc, -1, priv->last_pts, avsflags) < 0) {
>         avsflags ^= AVSEEK_FLAG_BACKWARD;
>         av_seek_frame(priv->avfc, -1, priv->last_pts, avsflags);
>     }
> 
> Translation: try to seek in the selected direction, if it fails, try to seek
> in the opposite direction. There is neither an upper nor a lower bound to
> the target timestamp, just a preferred direction.
> 
> Unless I completely misunderstood the API, that is exactly what
> avformat_seek_file() does with min = INT64_MIN, max = INT64_MAX and flags
> set to the preferred direction.

I haven't checked all implementations, but no, that's not how the API
should work. It would destroy some of the advantages of the API.
AVSEEK_FLAG_BACKWARD is only relevant for av_seek_frame (so you probably
should make sure to not set it for the new API).
To my understanding the new API should always seek to the position
_closest_ to the given target time-stamp.
If you only want to seek in one direction, you have to set either the
min or the max to the target.
However that probably isn't _really_ what we want, it is just the best
the old API could do.
What we really want is to seek as close to the target as possible, _but_
for relative seeks we don't want to end up on the wrong end of the
current position at the least. Due to buffering etc. it might make sense
to even include a bit of a margin, e.g. when seeking forward we must
jump forward at least 1/4 of the desired distance.

> Setting min (or max) would serve to force the direction forward (or
> backward), but there is no point in doing that and then trying the opposite
> direction immediately.

Since AVSEEK_FLAG_BACKWARD to my knowledge has no effect, I think it
would have some sense. Though it probably isn't the best one can do
with the new API.


More information about the MPlayer-dev-eng mailing list