[FFmpeg-devel] New seeking API
Ivan Schreter
schreter
Thu Mar 12 08:33:10 CET 2009
Vladimir Pantelic wrote:
> Ivan Schreter wrote:
>
>
>> BTW, I take it this new API will implicitly assume
>> "AVSEEK_FLAG_BACKWARD", since I cannot really imagine a reason why
>> someone would like to get a key frame _after_ the given timestamp/position.
>>
>
> Actually, I would. Given the timestamp "t_c" of the currently displayed
> video frame, going to the next key frame (seeking the minimum possible
> amount forward) would be done by
>
> ...seek( ..., t_c, AVSEEK_FLAG_FORWARD );
>
> Otherwise, I would have to use:
>
> ...seek( ..., t_c + t_d, AVSEEK_FLAG_BACKWARD );
>
> but how would I know how to chose t_d so that I do neither skip over one
> key frame nor seek back before t_c.
>
Seeking is relatively expensive.
Instead, you could set loop filter to skip non-reference frames and
decode only reference frames (i.e., usually key frames and P frames in
MPEG).
Additionally, in some codecs (namely H.264), key frames are not
necessarily frames without references, i.e., decoding a random key frame
doesn't necessarily produce usable output image and/or following frames
don't necessarily decode to a usable output image. Instead, one has to
pay attention to convergence duration, which will tell you, how much
further you need to decode to get a usable picture. This is still under
development (API how to tell the user, convergence_duration, is
currently somewhat broken).
What is the (end user) use case you'd want to address by seeking to the
next key frame?
Regards,
Ivan
More information about the ffmpeg-devel
mailing list