MPEG2/TS timestamp overflow handling #1770

wants to merge 1 commit into

4 participants


When using the PVR/VDR plug-in I had trouble playing back some recordings (especially jumping immediately stopped playback).

I think I tracked this down to problems when the ffmpeg library does a binary search based on the timestamps in the TS stream. The binary search naturally does not work if there is an overflow in the recording and the timestamps are not ordered anymore.

As these MPEG2/TS timestamps seem to have only 33 bits they regularly overflow in DVB streams.
This patch tries to recognize these overflows (by comparing with the position in the file and the bit rate) and adds 2^33 to all timestamps after the overflow. This restores the order of the timestamps and the binary search works.

(I don't know much about video streaming, so I don't know if this patch has any negative effects or even if the bit rate is always available or if more changes would be needed. But at least I can say this fixed the playback problems for all VDR recordings I tested.)

@imhof imhof Add some logic to handle MPEG2 timestamp overflow.
The timestamps have only 33 bits and regularly overflow in DVB streams. This results in problems when seeking in VDR recordings for example.

The patch tries to find these overflows and adds 2^33 to the timestamps after the overflow. ffmpeg internally uses 64 bits, so there is enough room.
Team Kodi member

see also #1655


Ah, thanks for the heads up. When looking for this issue the first time round (which was actually a while ago), I did not find anything substantial and I did not think about re-checking.

Team Kodi member

closing this one in favour of #1655

@opdenkamp opdenkamp closed this Nov 23, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment