[FFmpeg-devel] MPEG index entries

Nico Sabbi Nicola.Sabbi
Tue Nov 6 15:36:52 CET 2007


Il Tuesday 06 November 2007 15:22:25 Taylan O. Toygarlar ha scritto:
> Hi Everyone,
>
> I am trying to get MPEG frame accuracy through the internal index
> created within libavformat. I've seen that the index is updated
> during parsing, inside mpegps_read_pes_header. Is there any reason
> why it is not creating the indexes correctly? After my first
> decode, I have 13 index entries, all initiated from inside
> mpegps_read_pes_header, through av_add_index_entry.
>
> Second note, I would expect the keyframes to be collected, but
> there is no check for a keyframe, as it's commented when calling
> the function /* FIXME keyframe? */. Is there any magical way that
> makes this check inherent, but which I cannot see? I have my
> doubts, as with a movie of 9 frame GOP structure, I have 50 index
> entries @ frame 400.
>
> Has anyone before dealt with the MPEG indexes? Is this behaviour
> intentional, or should it be considered a bug? If not, how are the
> index entries used for MPEG seeking? If indexed entries are not
> keyframes, jumping to that location will have artifacts, isn't it
> true?
>
> Thank you very much for your comments and input.
>
> All the best,


mpeg files don't have indexes (almost: a kind of index structure
is specified but no one ever used it), consequently seeking
in mpeg files is random without an index.
I've never looked at av_add_index(), but what it's being fed
is the position of the starting position of the PES packet, that 
in no way indicates the position of a frame.
Additionally, in order to know if a frame is a keyframe or not
you have to rely on the AVParser, that is called on the already
demuxed payload (that is, after the mpeg demuxer).

If you want more accurate seeking to individual frame remux
to a format with an index, such as AVI or use avidemux
with its built-in indexer




More information about the ffmpeg-devel mailing list