Latency Measurement in Custom Pipeline

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU)
RTX 5000, x86-64 RHEL
• DeepStream Version
5.1 (nvidia_deepstream:5.1-21.02-devel)
• NVIDIA GPU Driver Version (valid for GPU only)
470.57.02
• Issue Type( questions, new requirements, bugs)
Question

Hi,

I am trying to make use of the nvds_measure_buffer_latency in a custom deepstream pipeline. I have created my own latency_measurement_buf_prob which is a sink probe that gets triggered each cycle (similar to the deepstream-app). When the nvds_measure_buffer_latency method is called I get a segmentation fault. I suspect the function is using some information from info->data that I am not populating properly. Can you provide more insight into how info->data must be populated in order to use the nvds_measure_buffer_latency function in a custom pipeline?

Does it use batch metadata provided by other plugins, such as nvstreammux?

static GstPadProbeReturn latency_measurement_buf_prob_nvidia(GstPad *pad, GstPadProbeInfo *info)
{
static unsigned int frame_num = 0;

GstBuffer buf = (GstBuffer )info->data;
NvDsFrameLatencyInfo latency_info = NULL;
g_print("\n************FRAME NUM = %d
***********\n", frame_num);
nvds_measure_buffer_latency(buf, latency_info);
g_print(“Source id = %d Frame_num = %d Frame latency = %lf (ms) \n”,
latency_info[0].source_id,
latency_info[0].frame_num,
latency_info[0].latency);
frame_num++;
return GST_PAD_PROBE_OK;
}

You can not directly use your created structure NvDsFrameLatencyInfo *latency_info to store the latency info. since overlay_graphics will reference it later. that’s why you got the segmentation issue.
change it to:
latency_info = appCtx->latency_info;

1 Like

Does this mean that nvds_measure_buffer_latency depends on latency_info.comp_in_timestamp being filled in prior to calling? My custom pipeline does not use appCtx. The comment says:
“Holds the system timestamp of the buffer when it arrives at the input of the first component in the pipeline. By default, the decoder is considered to be the first component in the pipeline.”
In theory, if I pass in a valid timestamp, will the structure be filled in properly?

If so, can you provide details on which time API/clock should be used to properly format the timestamp? For example, clock_gettime with CLOCK_MONOTONIC

Populate frame latency info to appCtx->latency_info is for overlay_graphics ease use. you can directly populate it to your declared NvDsFrameLatencyInfo *latency_info, but you need to make sure there no reference to it.
You can not pass in timestamp, there no entrance for you to do it. besides, latency_info.comp_in_timestamp Holds the system timestamp of the buffer when it arrives at the input of the first component in the pipeline. why did you want to change it?

1 Like

My hope was to use the nvds_measure_buffer_latency function to get periodic latency outputs to shell using NVDS_ENABLE_LATENCY_MEASUREMENT in a custom DeepStream pipeline (not one of NVIDIA examples). It appears that these print statements are generated by latency_measurement_buf, using data in the latency_info structure which is populated by NVIDIA’s proprietary nvds_measure_buffer_latency function (I can’t see source for this)
**********FRAME-NUM = 178************
Source id = 0 Frame_num = 178 Frame latency = 999.99999 (ms)

While my custom pipeline does container NVIDIA DeepStream plugins (nvinfer, etc.), I do not think it has the plugin which fills the comp_in_timestamp field of the latency_info structure at the beginning of the pipeline. It appears comp_in_timestamp must be set prior to passing latency_info into the nvds_measure_buffer_latency function, so that it can be used to fill in the other fields of latency_info as an output to the function (then used by the print statement)

Which NVIDIA plugin fills in the comp_in_timestamp field of the latency_info structure and how is it populated? This is not a standard gstreamer pipeline data structure, but something specific to NVIDIA. I would like populate the comp_in_timestamp field either by using the necessary plugin, or (preferably) populating the timestamp myself at the beginning of my custom DeepStream pipeline.

Yes. comp_in_timestamp populated by decoder. i do not think you have entrance to modify it. claimed again just as previous comment, it’s populated into appCtx->latency_info and printed from it also used for function overlay_graphics. you can change based your pipeline.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.