[PATCH] Fix wrong elapsed time due to MPEG-TS PTS rollover

Forum to talk about the development of SMPlayer (code, patches...).

[PATCH] Fix wrong elapsed time due to MPEG-TS PTS rollover

Postby Basic.Master » Thu Apr 23, 2015 12:51 pm

[after posting the patch at SF 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 http://www.basicmaster.de/test/PTS_rollover.ts which is 20s long and has a PTS rollover at 10s.
Attachments
smplayer_mpegts_pts_rollover.diff
(466 Bytes) Downloaded 63 times
Basic.Master
 
Posts: 5
Joined: Thu Apr 23, 2015 12:41 pm

Re: [PATCH] Fix wrong elapsed time due to MPEG-TS PTS rollov

Postby rvm » Fri Apr 24, 2015 3:46 am

I've just applied your patch (svn r6885).
rvm
Site Admin
 
Posts: 2769
Joined: Wed Dec 23, 2009 1:25 am
Location: España

Re: [PATCH] Fix wrong elapsed time due to MPEG-TS PTS rollov

Postby Basic.Master » Sat Mar 25, 2017 9:04 pm

After longer time, I updated from SVN and recompled SMPlayer. I then noticed that with MPEG-TS files unfortunately no longer the time since the beginning of the file is displayed as current position (e.g. 00:02:35, as I would expect for every file). Instead, the raw PTS time is displayed (e.g. 21:23:12), as output by mplayer. This makes it really difficult to tell at what position in a file the player currently is.

Enabling "#define MSET_USE_STARTING_TIME" in src/mediasettings.h restores the old behaviour; according to changelog the change was introduced on 2016-08-14:
Code: Select all
* (Experimental) Don't use starting_time (affects seeking in ts files).


What seeking problems did occur here that led to disabling the old behaviour? Is it related to this thread (I have the mentioned option disabled BTW)?
I think it is quite helpful when using a MPEG-TS file to see the current position relative to the file beginning.
Basic.Master
 
Posts: 5
Joined: Thu Apr 23, 2015 12:41 pm

Re: [PATCH] Fix wrong elapsed time due to MPEG-TS PTS rollov

Postby rvm » Sun Mar 26, 2017 2:04 am

The change was several months ago, I think I don't remember the reason. Maybe mpv didn't need it doesn't work well with it.
rvm
Site Admin
 
Posts: 2769
Joined: Wed Dec 23, 2009 1:25 am
Location: España

Re: [PATCH] Fix wrong elapsed time due to MPEG-TS PTS rollov

Postby Basic.Master » Fri Mar 31, 2017 11:03 pm

Hmm, in that case it would be great if the #define could be re-enabled so that everybody with mplayer benefits from having a correct position within a MPEG-TS.
Basic.Master
 
Posts: 5
Joined: Thu Apr 23, 2015 12:41 pm

Re: [PATCH] Fix wrong elapsed time due to MPEG-TS PTS rollov

Postby rvm » Sat Apr 01, 2017 10:22 am

Could you provide a sample video where this patch is needed? The link you provided on your first post doesn't work anymore. I'd like to test it with mpv.
rvm
Site Admin
 
Posts: 2769
Joined: Wed Dec 23, 2009 1:25 am
Location: España

Re: [PATCH] Fix wrong elapsed time due to MPEG-TS PTS rollov

Postby Basic.Master » Sat Apr 01, 2017 11:57 am

I just reuploaded the file; the link works again now. Without the #define and with mplayer, the video starts at about position 26:30:04.
Basic.Master
 
Posts: 5
Joined: Thu Apr 23, 2015 12:41 pm

Re: [PATCH] Fix wrong elapsed time due to MPEG-TS PTS rollov

Postby Basic.Master » Sat May 13, 2017 10:30 pm

Have you possibly been able to test it with mpv?
Basic.Master
 
Posts: 5
Joined: Thu Apr 23, 2015 12:41 pm

Re: [PATCH] Fix wrong elapsed time due to MPEG-TS PTS rollov

Postby rvm » Sat May 13, 2017 11:09 pm

Your sample video plays fine (correct time from 0 to 20 seconds) in mpv without the patch. So I think that maybe the problem should actually be fixed in mplayer, since mpv seems to already include a fix, instead of adding a workaround in smplayer.
rvm
Site Admin
 
Posts: 2769
Joined: Wed Dec 23, 2009 1:25 am
Location: España


Return to Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron