MPEG TS PCR and PTS

Adams, Bruce (KMLWG) Bruce.Adams at KantarMedia.com
Fri May 4 17:43:55 UTC 2018


>>Date: Fri, 4 May 2018 07:13:14 +0000

>>From: "Adams, Bruce (KMLWG)" <Bruce.Adams at KantarMedia.com<mailto:Bruce.Adams at KantarMedia.com>>

>>To: "gstreamer-devel at lists.freedesktop.org<mailto:gstreamer-devel at lists.freedesktop.org>"<gstreamer-devel at lists.freedesktop.org<mailto:gstreamer-devel at lists.freedesktop.org>>

>>Subject: MPEG TS PCR and PTS

>>

>>Hi,

>>    I am trying to work out how to get absolute time-stamps from an incoming MPEG transport stream.

>>The basics seem to be that we get a presentation time-stamp via buffer->get_pts(). This is relative to >>the program clock reference PCR which is dictated by one of the elementary streams - typically the >>video. How do I get that base time out of gstreamer?

>>I note that if I use a tsparse element it can decode TOT and TDT sections for DVB inputs. However, I >>also notice that one of my inputs is a TSIP input which does not include these sections.

>>How can I tell if an  absolute time reference is available and when it is what is the epoch? Is it the >>standard unix epoch 1970-01-01T00:00:00Z?

>>

>>Regards,

>>

>>Bruce.

>

>Date: Fri, 4 May 2018 04:11:59 -0700 (MST)

>From: Baby Octopus <jagadishkamathk at gmail.com<mailto:jagadishkamathk at gmail.com>>

>To: gstreamer-devel at lists.freedesktop.org<mailto:gstreamer-devel at lists.freedesktop.org>

>Subject: Re: MPEG TS PCR and PTS

>Message-ID: <1525432319688-0.post at n4.nabble.com<mailto:1525432319688-0.post at n4.nabble.com>>

>Content-Type: text/plain; charset=us-ascii

>

>Have you gone through the code of mpegtsdemux in gst-plugins-bad? Is there some part of code that >you do not understand there? Typically first PCR is used as base time and then subsequent PTS >computation involves subtracting this PCR from the PTS and then applying skew for compensating >sender vs receiver's clock variation



Tl;Dr; how do I relate the time-stamp from the TDT which comes via the bus to the pts I get from buffers in the pipeline?



Yes. Actually gstreamer is a case where you seem to be required to go through the code, and jump around a lot, to work out how to use some parts of the various libraries (I don't know how users from other languages that are not C literate deal with that). Maybe I can help with the documentation in the future. Currently, I have multiple learning curves of MPEG-TS, DVB, gobject, gstreamer, gstreamermm to deal with so there are some gaps in my knowledge at present.



I can see that the struct _MpegTSParse2 contains three PCR variables as part of its structure. I don't think I am supposed to access these directly but rather though either the buffers passed between elements and/or bus messages. Its not so obvious how that happens.

If I dump the values of buffer->get_pts()  I receive downstream they seem to increment at the expected rate (i.e. roughly 1s/s) but it is not clear from the name get_pts()  that the PCR is involved. Unfortunately both MPEG-TS and gstreamer overload the same term "presentation time stamp". Does the PTS in gstreamer (in the buffers to be precise) combine both the PTS and PCR from MPEG TS?



>From here (https://stackoverflow.com/questions/34646208/maximum-value-of-pcr/36810049#36810049 ) it seems that the PCR wraps every 26 hours or so. Thus is it not the absolute time-stamp I was looking for. It seems to be used just to sync audio and video tracks with each other.



It seems the absolute time-stamps I want in are the TDT section which is DVB specific but how do I relate the time-stamps I get there to the gstreamer pts (or the MPEG-TS PCR & PTS)? The TDT section comes via the gstreamer bus but the gstreamer pts is included in the buffers sent along the pipe-line.

To further confuse me I have some hardware that takes some DVB inputs and provides TSoIP outputs but seem to strip out the TDT sections (possibly because it combines parts of several different incoming transport streams). I don't know if that is normal. For many applications relative time-stamps are enough. I ideally want to keep in sync with the encoding/transmission time rather than the reception time (or get an idea of the transmission delay) so if there is another way to get an absolute time-stamp that is part of plain MPEG TS or TSoIP (if that differs) it would be useful to know.
In the future I am going to have to support other standards in addition to DVB, such as ISDB-T (where the TDT won't be available).

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20180504/6379df15/attachment.html>


More information about the gstreamer-devel mailing list