Latency measurement frame number stuck at 0 with camera source

I’m trying to use the latency measurement functionality from the deepstream-app sample.

When my source is a video file, it works correctly. The frame number increases, and the latency is computed correctly.

If I use a camera source the reported frame number is stuck at 0, and the per-frame latency isn’t calculated correctly. See console output below. I’ve tried a V4L2 camera, and an source using the Aravis library. Both give the same result.

I confirmed that my source is setting the GstBuffer offset correctly when it is pushed onto the pipeline, but by the time nvds_measure_buffer_latency() gets called, the value of buffer->offset is -1.

It seems some other element in the deepstream pipeline is clobbering the buffer offset for a camera source. I’m not sure where. Is there somewhere else deepstream_app.c:latency_measurement_buf_prob() can get the frame number from such as some NVDS metadata?

Console output below showing frame_num = 0, frame latency miscalculated. The frame latency shown in the video overlay is the same (incorrect).

DeepStream version is 4.0.2, running on a TX2.

************BATCH-NUM = 199**************
Comp name = src_bin_muxer source_id = 0 pad_index = 0 frame_num = 0               in_system_timestamp = 1583457792462.908936 out_system_timestamp = 1583457792463.787109               component_latency = 0.878174
Comp name = primary_gie_classifier in_system_timestamp = 1583457792463.978027 out_system_timestamp = 1583457792502.768066               component latency= 38.790039
Comp name = tiled_display_tiler in_system_timestamp = 1583457792503.020996 out_system_timestamp = 1583457792504.729004               component latency= 1.708008
Comp name = nvosd0 in_system_timestamp = 1583457792505.832031 out_system_timestamp = 1583457792507.922119               component latency= 2.090088
Source id = 0 Frame_num = 0 Frame latency = 1583457792509.444092 (ms)

************BATCH-NUM = 200**************
Comp name = src_bin_muxer source_id = 0 pad_index = 0 frame_num = 0               in_system_timestamp = 1583457792498.487061 out_system_timestamp = 1583457792499.410889               component_latency = 0.923828
Comp name = primary_gie_classifier in_system_timestamp = 1583457792499.604980 out_system_timestamp = 1583457792539.282959               component latency= 39.677979
Comp name = tiled_display_tiler in_system_timestamp = 1583457792539.616943 out_system_timestamp = 1583457792541.226074               component latency= 1.609131
Comp name = nvosd0 in_system_timestamp = 1583457792542.456055 out_system_timestamp = 1583457792544.235107               component latency= 1.779053
Source id = 0 Frame_num = 0 Frame latency = 1583457792545.691895 (ms)

Hi,
Please share steps(config file, patch, commands, …) so that we can reproduce the failure. It is probably not supported, and we would need to reproduce it and check with our teams.