[FFmpeg-devel] obseve PTS overflow when seeking

Michael Niedermayer michaelni at gmx.at
Sun Aug 19 17:09:31 CEST 2012


On Sat, Aug 18, 2012 at 11:12:19AM +0200, Rainer Hochecker wrote:
> Hi,
> 
> I have tracked down a problem where seeking did not work because PTS
> overflow in mpegts file. The following would fix it but I am not
> sure whether it's entirely correct. Could you have a look at this?

yes, it wont work like this :(

the first problem is the index (see av_index* and ff_seek_frame_binary)
it is required to be ordered and it wont be for such files. Your code
likely works because your testcase seeks before the index is filled or
maybe you are just lucky
also the timestamps passed may lay before start_time for the reason
of seeking to the first keyframe, some code is doing that IIRC

i think the sane solution for timestamp wraps and discontinuities is
to simply remove them. I think trying to handle a single wrap through
special cases all over the code would be messy but iam happy to apply
a patch if a clean & working one is posted by someone ...

For the discontinuity removial case, it would have to be optional
because it has some disadvanatges.
The simplest way to implement it is probably to add a array of
pos,ts_offset pairs to AVFormatContext
Now each time a packet is demuxed in streams that allow discontinuities
(AVFMT_TS_DISCONT), its timestamp is corrected based on this array and
the array is updated when new discontinuities are discovered.

This way the index can be kept with monotonic timestamps and the
user application would not have to deal with discontinuities. The
price for this is that in such a discontinuity removial mode timestamps
of packets would not be imutable but could change when more
discontinuities are discovered. Thats why it has to be optional

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Into a blind darkness they enter who follow after the Ignorance,
they as if into a greater darkness enter who devote themselves
to the Knowledge alone. -- Isha Upanishad
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120819/c2bd468e/attachment.asc>


More information about the ffmpeg-devel mailing list