[FFmpeg-devel] MPEG index entries

Taylan O. Toygarlar tozgorto
Wed Nov 14 17:51:58 CET 2007


Vinod G wrote:
> Hi,
> 
> I have been working on a similar problem, so let me share my findings.
> 
> You are right that the indexes generated inside mpegps_read_pes_header
> are not keyframe indexes. But I still use those indexes for the seek.
> After the seek, when I read a frame, I check the 'picture coding type'
> to check for I-frame. If it is not I-frame, I skip frames until I find
> one. This works reasonably, but not perfect.

Thanks for your feedback Vinod..

The problem with this approach is that we don't know the frame number of 
the I frame you sync on upon jumping to a non-key Frame location. For 
the sake of frame accuracy it is very important to know the frame 
numbers. I also do the same frame skipping until next I frame, but I'd 
prefer to know the frame number I end up at.

The current implementation I came up with creates its own index with 
each I frame position.(Actually I take the packet position of the last p 
frame before previous I frame, and when you sync to the stream you end 
up with the correct I Frame 80-90% of the time)

 From the application point of view, missing 10-20% frame accuracy is 
not acceptible. Therefore I have a backup plan - which is comparing the 
MD5 hashes that I create for every frame when going sequentially through 
the file. If the jumped location does not provide me with the MD5 hash I 
am looking for, I deduce that keyframe jump location is broken, and I 
delete it from the index..and jump and decode starting from the previous 
I frame. Hence absolute frame accuracy for my application.

But since the parser/demuxer code is there, I find this approach too 
cumbersome for the sake of performance - but still it's a working 
temporary solution.

In a week or so, I'll be back in debugging and getting the required 
information for fixing the mpeg indexes(hopefully). I'll keep the thread 
updated with what I come up with.

All the best,
t.

-- 
Taylan Ozgur Toygarlar
Scientific Programmer, B.Sc.
Intelligent Systems Lab Amsterdam
__________________________________________

Faculty of Science - Informatics Institute
University of Amsterdam
Kruislaan 403 1098 SJ
Amsterdam, The Netherlands

Telephone: +31 20 525 7555
Mobile   : +31 64 096 2866
Fax      : +31 20 525 7490
__________________________________________




More information about the ffmpeg-devel mailing list