Pipeline latency

hello,

I have an application in python that’s running pipeline:

udpsrc → tsdemux → h265parse → queue → avdec_h265 → x264enc → rtph264pay → appsink → appsrc → webrtcbin.
I want to measure the latency of the pipeline:
how much time in average (in ms) does it takes for a frame to travel from udpsrc to the sink of webrtcbin.

My problem is that I can’t use probes (insert the time to a queue in udpsrc/tsdemux probe and then pop in webrtcbin’s probe) because the probes triggers different times per second (the probes and signals of the elements don’t directly align)

I also tried using buffers (subtract pts) but the buffers can be duplicated, split, or delayed, and there’s no guarantee that the buffer I see at tsdemux is the same one I send through appsrc.

I also tried streaming the same pcap (with timeoverlay element to see differences) with pipeline:
udpsrc → tsdemux → h265parse → queue → avdec_h265 →autovideosink
and look for differences in ms in the timer of timeoverlay (to see the latency of the pipeline from encoding to webrtcbin).

but it turned out that the pipeline with autovideosink has more latency than mine so I can’t really measure the latency with this method.

Ideas anyone?

I guess hardware acceleration is not applied here because of avdec_h265.

Actually I forgot to mention that I do use GPU elements.
I have 2 pipelines, one uses GPU elements (for decoding - nvh265dec, for encoding - nvh264enc).
when GPU elements can’t be initialized (in my test environment for example, or for any other reason) I use the cpu pipeline.

I brought the CPU pipeline for example here, but if there’s

a solution to my problem with the GPU pipeline it’s still highly relevant!

my GPU pipeline:
udpsrc → tsdemux → h265parse → queue → nvh265dec → nvh264enc→ rtph264pay → appsink → appsrc → webrtcbin.

Hi @shirb GstShark is a great tool for measuring the latency of a GStreamer pipeline, its open-source, here is the link for the several tracers the tool has, the Interlatency tool may be the one that serves you best in this case:
https://developer.ridgerun.com/wiki/index.php/GstShark_-_Tracers

I hope this helps!
Regards!
Luis Merayo
Embedded SW Engineer at RidgeRun