MPEG-TS latency

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

MPEG-TS latency

JamesGKent
I'm working with MPEG-TS streams and looking to get a better understanding of the latencies imposed by the tsparse and tsdemux elements.
If I stream from one device to another using only raw h264 (no encapsulation) then I can achieve ~50ms of latency within gstreamer (h264parse and v4l2h264dec each add 1 frame of latency and kmssink 15ms for a total 48.333ms)

However when I add encapsulation I get additional latency from tsparse (100ms) and tsdemux (700ms but configurable) if I try and change the latency on tsdemux I can get a playable stream at 20ms for a total pipeline latency of ~168ms, but if I try and go any lower I get breakup and stale frames in the decoder.

Firstly, I understand that the 100ms in tsparse is the maximum delay between PCR to allow for sync/smoothing, but surely there is a better strategy that buffering the entire period between PCRs and attempting to smooth all packets over that interval so as not to impose so much latency?

Secondly why does tsdemux need to add so much latency if it is effectively acting as a filter? it can't need the whole 700ms to keep everything in sync. I've seen this post which said it was part of the spec, but I agree with this post stating it doesn't need 700ms of latency.

lastly I want to understand what is happening to the buffers when using the encapsulation that means if I try to reduce the latency the video gets broken up, yet when passing raw h264 its fine?

Can anyone offer some insight?

Thanks