[FFmpeg-devel] [RFC] Seeking API

Baptiste Coudurier baptiste.coudurier
Thu Jan 22 23:42:04 CET 2009

Michael Niedermayer wrote:
> On Thu, Jan 22, 2009 at 12:46:42PM -0800, Baptiste Coudurier wrote:
>> Hi Michael,
>> Michael Niedermayer wrote:
>>> Hi
>>> Do we need a new API for seeking?
>>> I think we do
>>> * currently seeking happens based on >=X or <=X this is not truely ideal
>>>   for a normal player, for example at position 100sec and seeking 10sec
>>>   forward we would prefer 109 over 200sec likely but not 99sec over 200sec
>>> * seeking in relation to a single specific stream makes little sense, rather
>>>   seeking should happen relative to the set of streams that is presented
>>>   to the user (= the ones not disabled by AVStream.discard)
>>> Are there other issues? requirements?
>> Yes, I'd like a new AVSEEK_FLAG_FRAMENUM for containers supporting it
>> (mov/mp4/r3d)
> This also needs a stream_index  and could be done by the user app with
> ts= st.index_entries[frame_num].timestamp;

True, but aren't we defining an API to simplify _usage_ ?
Also we could handle FRAMENUM | NEXT_KEYFRAME or PREV_KEYFRAME with the
help of min_distance value, which becomes complicated for the user.

Needing a stream_index is ok if documented IMHO.

>> Not sure if this is much related to seeking:
>> I'd like containers to export the AVIndex feature usage and add pts to
>> AVIndexEntry, also a way to generate the full AVIndexEntry and have the
>> possibility to export it as file to be loaded later.
>> Also user needs to specify if he wants to seek by dts or pts and
>> therefore what timestamp value refers to.
> Is there any use case in which the user wants to seek by dts?

Not sure, currently, mpeg ps demuxer add dts to index entries, same for mov.
So either you add pts to index entries but with reordering, binary
search is difficult.
Or you add dts and export first_dts value, so it is possible to seek to
first dts.

In all case "timestamp" value needs clarification.

Also "pos" needs clarification, I propose to use pos as position which
enable byte seeking to and then call av_read_frame, for containers
supporting byte seeking (mpeg ps, mpeg ts), with rules like next
containing access unit.

Containers should export the information when supporting byte seeking
(mov/mp4 does not).

Baptiste COUDURIER                              GnuPG Key Id: 0x5C1ABAAA
Key fingerprint                 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
checking for life_signs in -lkenny... no
FFmpeg maintainer                                  http://www.ffmpeg.org

More information about the ffmpeg-devel mailing list