How to extract the timestamp information from the buffer to measure latency

nvds_set_input_system_timestamp (inbuf, GST_ELEMENT_NAME (osd1));

this function i have used in the element i want to extract the timestamp information from the buffer, how can i access it?

Please refer to this FAQ, which provides how to obtain latency information.

thank you! but it is for deepstream app application right i want to use the |gboolean nvds_set_output_system_timestamp|(|GstBuffer *|buffer,gchar ,element_name)
function to set the timestamp how to use this am not understanding…

You can refer to gst_nvinfer_submit_input_buffer in /opt/nvidia/deepstream/deepstream/sources/gst-plugins/gst-nvinfer.

nvds_set_input_system_timestamp(inbuf, GST_ELEMENT_NAME(nvinfer));

.......

nvds_set_output_system_timestamp(inbuf, GST_ELEMENT_NAME(nvinfer));

These two functions are used to count the processing time of GstBuffer in element, and then add them to metadata.

They will only be processed on deepstream related plugins

Detailed function description in comments

/sources/includes/nvds_latency_meta.h

Thank you so much am going through the plugin… if i want to extract the timer information from the buffer using probes how do i do it from our pipeliene application?

What do you mean by this? Do you mean pts/dts? They are members of GstBuffer and can be accessed directly

Comp name = nvv4l2decoder0 in_system_timestamp = 1593689758799.982910 out_system_timestamp = 1593689758998.961914 component latency= 198.979004
Comp name = src_bin_muxer source_id = 0 pad_index = 0 frame_num = 1442 in_system_timestamp = 1593689758999.022949 out_system_timestamp = 1593689759070.697021 component_latency = 71.674072
Comp name = primary_gie in_system_timestamp = 1593689759070.767090 out_system_timestamp = 1593689759137.716064 component latency= 66.948975
Comp name = tracking_tracker in_system_timestamp = 1593689759137.745117 out_system_timestamp = 1593689759147.971924 component latency= 10.226807
Comp name = tiled_display_tiler in_system_timestamp = 1593689759148.038086 out_system_timestamp = 1593689759152.321045 component latency= 4.282959
Comp name = nvosd0 in_system_timestamp = 1593689759153.775879 out_system_timestamp = 1593689759153.791016 component latency= 0.015137
Source id = 0 Frame_num = 1442 Frame latency = 369.830078 (ms)

i want to extract these information from my gstreamer pipeline am not understanding how deepstream app application is extracting the structure…

You can refer to the FAQ I mentioned above for this.

i am able to extract the information from the NvDsMetaCompLatency structure that is input time stamp but not output time stamp it is 0.0 am not understanding what this NvDsMetaSubCompLatency structure is used for??

what is the difference between components and subcomponents?

can you please reply…

I don’t quite understand why you need to access NvDsMetaCompLatency structure.
1.If you want to measure latency, use nvds_measure_buffer_latency to get NvDsFrameLatencyInfo structure is enough
Please ignore NvDsMetaSubCompLatency for now, it is not really used at the moment

2.NvDsMetaCompLatency can only be accessed by nvstreammux, which is open source.

3.nvds_set_input_system_timestamp records the input time of element and nvds_set_output_system_timestamp records the output time of element.
A simple implementation would be like below

out_system_timestamp = nvds_get_current_system_timestamp();

To avoid data corruption, programs should not, and should not, access this timestamp.

Thank you so much

is it application level or element level?? the return value of the function is big integer value but as per the deepatsream app application code it is number of sources in batch…

please let me know how to use in the application level

Have you tried the FAQ above?

For applications, measuring latency is the only correct thing to do.

For element, if you add your own track point, I have also given the answer.

Thank you so much

I am able to get the logs from custom pipeline .
Thsese are the logs from the Deepstream -App Application
BATCH-NUM = 92**
Comp name = nvv4l2decoder0 in_system_timestamp = 1707715163885.787109 out_system_timestamp = 1707715163902.273926 component latency= 16.486816
Comp name = nvstreammux-src_bin_muxer source_id = 0 pad_index = 0 frame_num = 92 in_system_timestamp = 1707715163902.341064 out_system_timestamp = 1707715163918.968018 component_latency = 16.626953
Comp name = primary_gie in_system_timestamp = 1707715163919.112061 out_system_timestamp = 1707715163987.248047 component latency= 68.135986
Comp name = tracking_tracker in_system_timestamp = 1707715163987.279053 out_system_timestamp = 1707715163989.566895 component latency= 2.287842
Comp name = tiled_display_tiler in_system_timestamp = 1707715163989.830078 out_system_timestamp = 1707715163990.043945 component latency= 0.213867
Comp name = osd_conv in_system_timestamp = 1707715163990.506104 out_system_timestamp = 1707715163990.712891 component latency= 0.206787
Comp name = nvosd0 in_system_timestamp = 1707715163990.785889 out_system_timestamp = 1707715163990.802002 component latency= 0.016113
Source id = 0 Frame_num = 92 Frame latency = 107.229004 (ms)

                                     AND 

Below are the logs from the custom elements+ custom application…

BATCH-NUM = 92**
Comp name = nvv4l2decoder0 in_system_timestamp = 1707715214759.726074 out_system_timestamp = 1707715214780.343994 component latency= 20.617920
Comp name = nvstreammux-nvstreammux source_id = 0 pad_index = 0 frame_num = 92 in_system_timestamp = 1707715214780.379883 out_system_timestamp = 1707715214833.425049 component_latency = 53.045166
Comp name = nvinfer in_system_timestamp = 1707715214833.428955 out_system_timestamp = 1707715214843.457031 component latency= 10.028076
Comp name = nvtracker in_system_timestamp = 1707715214843.477051 out_system_timestamp = 1707715214843.496094 component latency= 0.019043
Comp name = nvsosd in_system_timestamp = 1707715214843.504883 out_system_timestamp = 1707715214847.997070 component latency= 4.492188
Source id = 0 Frame_num = 92 Frame latency = 88.307861 (ms)
Total Latency for Batch 92 = 88.307861 (ms)
total latency 7830.617432

at least for decoder and streammux the latency should be same right??? why they are differing ??

There is no relationship between them. The data is the time it takes to process the data in the element.

Thank you