After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 743259 - tsdemux: bogus timestamp when PTS < PCR
tsdemux: bogus timestamp when PTS < PCR
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
git master
Other Linux
: Normal normal
: 1.6.4
Assigned To: GStreamer Maintainers
GStreamer Maintainers
1.6.4
Depends on:
Blocks:
 
 
Reported: 2015-01-20 17:41 UTC by Aurélien Zanelli
Modified: 2016-04-14 17:43 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
mpegtspacketizer: convert pcr time to gst time before comparing it to pts (1.02 KB, patch)
2015-01-20 17:43 UTC, Aurélien Zanelli
committed Details | Review
mpegtspacketizer: handle early PTS conversion when a group has been found (1.54 KB, patch)
2015-01-20 17:44 UTC, Aurélien Zanelli
committed Details | Review
collectpads: Assume PTS is equal DTS if PTS is missing (1.28 KB, patch)
2016-03-03 02:17 UTC, Nicolas Dufresne (ndufresne)
rejected Details | Review

Description Aurélien Zanelli 2015-01-20 17:41:23 UTC
Playing http://darkosphere.fr/tmp/payload.ts with the following pipeline doesn't work successfully:
gst-launch-1.0 filesrc location=payload.ts ! tsdemux ! h264parse ! avdec_h264 ! autovideosink

After further investigation, it is due to tsdemux outputting the first buffers with bogus timestamps which confuse videodecoder base class:
/GstPipeline:pipeline0/GstFakeSink:fakesink0: last-message = chain   ******* (fakesink0:sink) (18233 bytes, dts: none, pts: 5124095:34:33.663077135, duration: none, offset: -1, offset_end: -1, flags: 00000040 discont ) 0xa0e5ae0
New clock: GstSystemClock
/GstPipeline:pipeline0/GstFakeSink:fakesink0: last-message = chain   ******* (fakesink0:sink) (2031 bytes, dts: none, pts: 5124095:34:33.696410468, duration: none, offset: -1, offset_end: -1, flags: 00000000 ) 0xa0e5c20

This bogus timestamp are computed in mpegts_packetizer_pts_to_ts (mpegtspacketizer.c) and are wrong because PTS < PCRTIME_TO_GSTTIME(refpcr).
I found that this issue is likely the same as the one fixed by commit  a822517ca94c132104faf484d11aaeaaecf9769a (https://bugzilla.gnome.org/show_bug.cgi?id=731088) so I wrote likely the same patch for this part of the code.
Comment 1 Aurélien Zanelli 2015-01-20 17:43:42 UTC
Created attachment 295028 [details] [review]
mpegtspacketizer: convert pcr time to gst time before comparing it to pts

This little patch is to fix pts comparison with refpcr, i first found it when investigating this issue.
Comment 2 Aurélien Zanelli 2015-01-20 17:44:33 UTC
Created attachment 295029 [details] [review]
mpegtspacketizer: handle early PTS conversion when a group has been found

Proposal to fix the issue :)
Comment 3 Jan Schmidt 2016-03-02 13:27:09 UTC
I just encountered this exact issue and generated the same combined 2 patches.
Comment 4 Jan Schmidt 2016-03-02 14:26:01 UTC
Thanks, pushed as one squashed commit:

commit d87177b69b15e049d8e7da13c590b0db2e51529b
Author: Aurélien Zanelli <aurelien.zanelli@parrot.com>
Date:   Tue Jan 20 16:20:10 2015 +0100

    mpegtspacketizer: handle early PTS conversion when a group has been found
    
    In some cases, the PTS might be smaller than the first observed PCR
    value which causes element to apply wraparound leading to bogus
    timestamp. To solve this, we only apply it if the PTS-PCR difference is
    greater that 1 second to be sure that it's a real wraparound.
    
    Moreover, using unsigned 32 bits values to handle wrapover could end up
    with bogus value, so it use pts value to handle it.
    
    Also, convert pcr time to gst time before comparing it to pts.
    Since refpcr is expressed in PCR time base while pts is expressed in GStreamer
    time.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=743259
Comment 5 Nicolas Dufresne (ndufresne) 2016-03-03 01:35:40 UTC
Comment on attachment 295029 [details] [review]
mpegtspacketizer: handle early PTS conversion when a group has been found

Combined.
Comment 6 Nicolas Dufresne (ndufresne) 2016-03-03 01:35:54 UTC
Comment on attachment 295028 [details] [review]
mpegtspacketizer: convert pcr time to gst time before comparing it to pts

Combined.
Comment 7 Nicolas Dufresne (ndufresne) 2016-03-03 02:17:57 UTC
Created attachment 322936 [details] [review]
collectpads: Assume PTS is equal DTS if PTS is missing

This is the best guess we can make if such a buffer reached the collect
pad. This is uncommon, we do expect parsers to have tried and fixed that
if possible (or needed).
Comment 8 Nicolas Dufresne (ndufresne) 2016-03-03 02:19:13 UTC
Comment on attachment 322936 [details] [review]
collectpads: Assume PTS is equal DTS if PTS is missing

Sorry, wrong bug number.