[FFmpeg-devel] [PATCH] First shot at AVCHD seeking via new seeking API

Ivan Schreter schreter
Sun Jul 5 23:23:38 CEST 2009


Hi,

I've finally found some time to experiment a bit further with seeking 
code. I've implemented a read_seek2 routine in mpegts.c and some generic 
code for finding proper position in lavf/utils.c. This is just a first 
shot, as I suppose, I can make the generic code a little simpler. 
Comments welcome.

Basically, the implementation in mpegts.c first calls generic seeking 
routine to find approximate position with given timestamp (via 
bisection) and then calls the routine to find exact position in 
lavf/utils.c based on given timestamp criteria.

The lavf patch introduces two functions, one public to be used by 
demuxers (av_gen_syncpoint_search) and one internal to iterate to proper 
position (av_search_keyframe_multi_partial). The implementation tries to 
find for each active stream key frames just before and just after the 
target timestamp. If there is no key frame fulfilling the timestamp 
criteria in given direction, then obviously only one direction can be 
used. Additionally, timestamp and position of minimum timestamp frame 
will be also stored, in order to handle one special case (see later).

After the positions and timestamps of key frames are known, we will 
search for closest timestamp to the requested one and then for an 
associated position in the file where to reposition the file pointer in 
order to guarantee that all active streams meet a key frame before this 
position.

There is one special case, however: seeking to a negative timestamp or 
timestamp lower than minimum timestamp in the file. This was handled 
until now by seeking to the beginning of video file. Strictly speaking, 
the new API should simply discard the request returning an error. 
However, this will break just about any player and video editor, so I 
implemented it as a special case.

Comments on that?

There is also seek regression of mpegts, since now it returns key frames 
instead of some frames. Patch also attached.

Byte seeking is not yet implemented.

BTW, if I understand it correctly, new seeking API should guarantee 
seeking by PTS. Maybe it would make sense to add a flag to format 
descriptor, whether it supports seeking by PTS or by DTS. Currently, you 
cannot say what timestamp are you actually seeking to. Any 
comments/suggestions?

Regards,

Ivan

-------------- next part --------------
A non-text attachment was scrubbed...
Name: seek_cooked_lavf.patch
Type: text/x-patch
Size: 16456 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090705/e29fb658/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: seek_cooked_mpegts.patch
Type: text/x-patch
Size: 3962 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090705/e29fb658/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: seek_cooked_seekregress.patch
Type: text/x-patch
Size: 4863 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090705/e29fb658/attachment-0002.bin>



More information about the ffmpeg-devel mailing list