[PATCH] Fix wrong elapsed time due to MPEG-TS PTS rollover
Posted: Thu Apr 23, 2015 12:51 pm
[after I realized that the last patch posted there was from 2012, so this fotum seems to be the better place]
MPEG-TS files (e.g. DVB recordings) have a 2^33 wide PTS (playback timestamp) value regularly embedded, which is used by MPlayer to output the current time. As this timestamp is not (necessarily) 0 at the start of the file, in SMPlayer mset.starting_time is subtracted from mset.current_sec to get the elapsed time since the file start.
This only works if mset.current_sec > mset.starting_time is valid. But if between the file start and the current position there is a PTS rollover, this leads to a negative value displayed by SMPlayer.
The attached patch fixes this issue by compensating this PTS rollover. You can find a test MPEG-TS file at which is 20s long and has a PTS rollover at 10s.
MPEG-TS files (e.g. DVB recordings) have a 2^33 wide PTS (playback timestamp) value regularly embedded, which is used by MPlayer to output the current time. As this timestamp is not (necessarily) 0 at the start of the file, in SMPlayer mset.starting_time is subtracted from mset.current_sec to get the elapsed time since the file start.
This only works if mset.current_sec > mset.starting_time is valid. But if between the file start and the current position there is a PTS rollover, this leads to a negative value displayed by SMPlayer.
The attached patch fixes this issue by compensating this PTS rollover. You can find a test MPEG-TS file at which is 20s long and has a PTS rollover at 10s.