[FFmpeg-devel] [RFC] Many formats return wrong position => seeking problems

Ivan Schreter schreter
Sat Mar 7 17:28:41 CET 2009


Reimar D?ffinger wrote:
> On Sat, Mar 07, 2009 at 03:43:12PM +0100, Ivan Schreter wrote:
>   
>> I'm writing some low-level support for new seeking API. In principle, it 
>> works OK now, but many format demuxers in lavf are broken in the sense 
>> that they don't return correct packet positions. This is mandatory for 
>> new seeking API and for corrections to current seeking API as well.
>>     
>
> Can you please define what "correct position" means? That would make it
> easier to know which are broken and how to fix them (or alternatively
> flame you if the requirements are too restrictive ;-) ).
>   
Well, quite easy:

av_read_frame() returns an AVPacket, containing file position in member 
pos. If I reposition the file pointer to this position in the file, I 
expect next av_read_frame() to return exactly the same packet (also with 
same DTS/PTS, single exception being undefined DTS/PTS after repositioning).

Basically, AVInputFormat::read_packet() needs to be checked, whether it 
really returns correct positon in AVPacket::pos.

As a side note, the seeking code I'm working on does parser 
reinitialization before repositioning and next av_read_frame(), since 
some parsers may store some state. Also, if the parser assembles actual 
frames from smaller packets, the position of first packet which contains 
portion of the frame is taken as frame position (e.g., MPEG start codes 
in the middle of the packet). So this doesn't have to be handled by the 
format, it's handled in generic code.

I hope this explain the things.

Currently, I'm seeing issues in rm, avi, flv, asf, au, ffm, gxf, mkv, 
ogg, wav and dv (which even segfaults). Possibly others have also some 
issues. Various mpeg formats seem to work in general OK.

Regards,

Ivan




More information about the ffmpeg-devel mailing list