RTSP Stream Delay Deepstream 7.0

Please provide complete information as applicable to your setup.

**• Hardware Platform (Jetson)
**• DeepStream Version 7.0

I’m experiencing delays and encountering the error message “gstnvtracker: Unable to acquire a user meta buffer” when running deepstream-app 7.0 in RTSP stream mode, even at 10 fps, with potential FPS being constrained. Could anyone recommend adjustments to the user-meta-pool-size parameter or other optimizations to mitigate this issue and enhance performance? Any advice would be greatly appreciated. Thank you.

You can refer to our Guide miscellaneous-data-output.

I have look through the guide but what is causing the 5-7 second delay observed when streaming RTSP output through a sink in our DeepStream application, which sends analytics (such as face detection, gender, and age estimation) to MQTT?

Additionally, on our DeepStream 7 machine, a warning ‘**PERF: 9.99 (9.99) gstnvtracker: Unable to acquire a user meta buffer. Try increasing user-meta-pool-size’ appears in the terminal when RTSP Streaming (Option 4) output sink-2 is enabled and the application is running.

Could you attach the whole pipeline you are using? This 5-7 second delay may not be caused by the nvtracker. You can refer to the Enable Latency measurement for deepstream sample apps to get the latency of the plugins.

We’re not changing the default deepstream-app setup. We’re just adding our own models (both primary and secondary) and tweaking the analytics_done_buf_prob setting to extract frame metadata

OK. Could you try that with our demo so that we can reproduce that on our side?

For your reference, this is my source code file

################################################################################
# Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
################################################################################
[application]
enable-perf-measurement=1
perf-measurement-interval-sec=1
[tiled-display]
enable=1
rows=1
columns=1
width=1280
height=720
gpu-id=0
[source0]
enable=1
#Type - 1=CameraV4L2 2=URI 3=MultiURI
type=1
num-sources=1
#uri=file:///home/glueck/Videos/test.mp4
#uri=file://../../streams/rajeshStevenRosini.mp4
#uri=rtsp://root:Glueck321@192.168.1.18/axis-media/media.amp?streamprofile=H264
uri=rtsp://root:Glueck321@10.0.1.30/axis-media/media.amp?videocodec=h264&camera=1
#drop-frame-interval=2
gpu-id=0
camera-width=1280
camera-height=720
#camera-fps-n=10
#camera-fps-d=1
camera-v4l2-dev-node=0
[streammux]
gpu-id=0
batch-size=1
batched-push-timeout=40000
## Set muxer output width and height
width=1920
height=1080
[sink0]
enable=0
#Type - 1=FakeSink 2=EglSink 3=File
type=2
sync=0
source-id=0
gpu-id=0
[osd]
enable=0
gpu-id=0
border-width=3
text-size=15
text-color=1;1;1;1;
text-bg-color=0.3;0.3;0.3;1
font=Arial
[primary-gie]
enable=1
gpu-id=0
# Modify as necessary
#model-engine-file=../../models/Primary_FaceDetector/resnet18_detector.etlt_b1_gpu0_fp16.engine
batch-size=1
bbox-bg-color0=0;1;0;0.3
#Required by the app for OSD, not a plugin property
#bbox-border-color0=1;0;0;1
#bbox-border-color1=0;1;1;1
#bbox-border-color2=0;0;1;1
#bbox-border-color3=0;1;0;1
gie-unique-id=1
config-file=config_infer_primary_facedetectir.txt
[sink1]
enable=0
type=3
#1=mp4 2=mkv
container=1
#1=h264 2=h265 3=mpeg4
codec=1
#encoder type 0=Hardware 1=Software
enc-type=0
sync=0
bitrate=2000000
#H264 Profile - 0=Baseline 2=Main 4=High
#H265 Profile - 0=Main 1=Main10
profile=0
output-file=out.mp4
source-id=0
##RTSP Output
[sink2]
enable=1
#Type - 1=FakeSink 2=EglSink 3=File 4=RTSPStreaming 5=Overlay
type=4
#1=h264 2=h265
codec=1
#encoder type 0=Hardware 1=Software
enc-type=0
sync=0
bitrate=4000000
#H264 Profile - 0=Baseline 2=Main 4=High
#H265 Profile - 0=Main 1=Main10
profile=0
# set below properties in case of RTSPStreaming
rtsp-port=8554
udp-port=5400
[tracker]
enable=1
# For NvDCF and DeepSORT tracker, tracker-width and tracker-height must be a multiple of 32, respectively
tracker-width=640
tracker-height=384
ll-lib-file=/opt/nvidia/deepstream/deepstream/lib/libnvds_nvmultiobjecttracker.so
# ll-config-file required to set different tracker types
# ll-config-file=/opt/nvidia/deepstream/deepstream/samples/configs/deepstream-app/config_tracker_IOU.yml
ll-config-file=/opt/nvidia/deepstream/deepstream/samples/configs/deepstream-app/config_tracker_NvDCF_perf.yml
# ll-config-file=/opt/nvidia/deepstream/deepstream/samples/configs/deepstream-app/config_tracker_NvDCF_accuracy.yml
# ll-config-file=/opt/nvidia/deepstream/deepstream/samples/configs/deepstream-app/config_tracker_DeepSORT.yml
gpu-id=0
enable-batch-process=1
enable-past-frame=1
display-tracking-id=1
[secondary-gie0]
enable=1
model-engine-file=/opt/nvidia/deepstream/deepstream-7.0/samples/models/genderv11/gender11.caffemodel_b16_gpu0_fp16.engine
gpu-id=0
batch-size=1
bbox-bg-color0=0;1;0;0.3
#Required by the app for OSD, not a plugin property
bbox-border-color0=1;0;0;1
bbox-border-color1=0;1;1;1
bbox-border-color2=0;0;1;1
bbox-border-color3=0;1;0;1
gie-unique-id=2
operate-on-gie-id=1
operate-on-class-ids=0;
config-file=config_infer_genderv11_classifier.txt
[secondary-gie1]
enable=1
model-engine-file=/opt/nvidia/deepstream/deepstream-7.0/samples/models/age_model/age.model_b16_gpu0_fp16.engine
gpu-id=0
batch-size=1
gie-unique-id=3
operate-on-gie-id=1
operate-on-class-ids=0;
config-file=config_infer_age_classifier.txt
[secondary-gie2]
enable=0
model-engine-file=../../models/Secondary_Emotion/emotion_2convs_iter_3000.caffemodel_b16_gpu0_fp16.engine
gpu-id=0
batch-size=16
gie-unique-id=4
operate-on-gie-id=1
operate-on-class-ids=0;
config-file=config_infer_emotion_classifier.txt
[tests]
file-loop=1

OK. Just from your config file, you need to set the source type= 4 when you use rtsp source and set live-source=1 for streammux. You can refer to our Guide to set some parameters related to rtsp source.

Actually we are using a webcam as a source

[source0]
enable=1
#Type - 1=CameraV4L2 2=URI 3=MultiURI
type=1
num-sources=1
#uri=file:///home/glueck/Videos/test.mp4
#uri=file://../../streams/rajeshStevenRosini.mp4
#uri=rtsp://root:Glueck321@192.168.1.18/axis-media/media.amp?streamprofile=H264
#uri=rtsp://root:Glueck321@10.0.1.30/axis-media/media.amp?videocodec=h264&camera=1
#drop-frame-interval=2
gpu-id=0
camera-width=640
camera-height=480
camera-fps-n=30
camera-fps-d=1
camera-v4l2-dev-node=0
latency=8000

and streaming using sink

##RTSP Output
[sink2]
enable=1
#Type - 1=FakeSink 2=EglSink 3=File 4=RTSPStreaming 5=Overlay
type=4
#1=h264 2=h265
codec=1
#encoder type 0=Hardware 1=Software
enc-type=1
sync=0
bitrate=4000000
#H264 Profile - 0=Baseline 2=Main 4=High
#H265 Profile - 0=Main 1=Main10
profile=0
# set below properties in case of RTSPStreaming
rtsp-port=8554
udp-port=5400
latency=8000

can i set source as rtsp for webcam? And I’ve tried it but no visuals popping, after a bit of fine tuning, the delay is reduced around 5 to 7 seconds, but can it be reduced more?

OK. But what you attached earlier was using rtsp source.

You can compare the difference between direct display to the screen and RTSP Output first. If the delay is caused by the rtsp output, there is basically no room for reduction.

alright ill compare and update in a while about the difference

i tried on the rtsp on source, had a 10 seconds delay, so as you mentioned up there, there’s nothing we can do about it is it?, But as i said, im not using the rtsp source as my main camera, this time we are using a logitech webcam, with this i can’t reduce the delays?

It should reduce the delays.

Have you done the comparison I suggest above?

yes, i did the comparison by doing direct screen and rtsp method, having around 5 to 7 seconds delay

for your reference ill paste my updated code here:

[application]
enable-perf-measurement=1
perf-measurement-interval-sec=1

[tiled-display]
enable=1
rows=1
columns=1
width=1280
height=720
gpu-id=0

[source0]
enable=1
#Type - 1=CameraV4L2 2=URI 3=MultiURI
type=1
num-sources=1
#uri=file:///home/glueck/Videos/test.mp4
#uri=file://../../streams/rajeshStevenRosini.mp4
#uri=rtsp://root:Glueck321@192.168.1.18/axis-media/media.amp?streamprofile=H264
#uri=rtsp://root:Glueck321@10.0.1.30/axis-media/media.amp?videocodec=h264&camera=1
#uri=rtsp:rtsp://localhost:8554/ds-test
#drop-frame-interval=2
gpu-id=0
camera-width=640
camera-height=480
camera-fps-n=30
camera-fps-d=1
camera-v4l2-dev-node=0
#latency=8000

[streammux]
gpu-id=0
batch-size=1
batched-push-timeout=40000
## Set muxer output width and height
width=1920
height=1080
live-source=1 

[sink0]
enable=1
#Type - 1=FakeSink 2=EglSink 3=File
type=2
sync=0
source-id=0
gpu-id=0

[osd]
enable=1
gpu-id=0
border-width=3
text-size=15
text-color=1;1;1;1;
text-bg-color=0.3;0.3;0.3;1
font=Arial

[primary-gie]
enable=1
gpu-id=0
# Modify as necessary
#model-engine-file=../../models/Primary_FaceDetector/resnet18_detector.etlt_b1_gpu0_fp16.engine
batch-size=1
bbox-bg-color0=0;1;0;0.3
#Required by the app for OSD, not a plugin property
#bbox-border-color0=1;0;0;1
#bbox-border-color1=0;1;1;1
#bbox-border-color2=0;0;1;1
#bbox-border-color3=0;1;0;1
gie-unique-id=1
config-file=/opt/nvidia/deepstream/deepstream-6.3/samples/configs/deepstream-app-glueck/config_infer_primary_facedetectir.txt

[sink1]
enable=0
type=3
#1=mp4 2=mkv
container=1
#1=h264 2=h265 3=mpeg4
codec=1
#encoder type 0=Hardware 1=Software
enc-type=0
sync=0
bitrate=2000000
#H264 Profile - 0=Baseline 2=Main 4=High
#H265 Profile - 0=Main 1=Main10
profile=0
output-file=out.mp4
source-id=0

##RTSP Output
[sink2]
enable=1
#Type - 1=FakeSink 2=EglSink 3=File 4=RTSPStreaming 5=Overlay
type=4
#1=h264 2=h265
codec=1
#encoder type 0=Hardware 1=Software
enc-type=1
sync=0
bitrate=4000000
#H264 Profile - 0=Baseline 2=Main 4=High
#H265 Profile - 0=Main 1=Main10
profile=0
# set below properties in case of RTSPStreaming
rtsp-port=8554
udp-port=5400
#latency=8000

[tracker]
enable=1
# For NvDCF and DeepSORT tracker, tracker-width and tracker-height must be a multiple of 32, respectively
tracker-width=640
tracker-height=384
ll-lib-file=/opt/nvidia/deepstream/deepstream/lib/libnvds_nvmultiobjecttracker.so
# ll-config-file required to set different tracker types
# ll-config-file=/opt/nvidia/deepstream/deepstream/samples/configs/deepstream-app/config_tracker_IOU.yml
ll-config-file=/opt/nvidia/deepstream/deepstream/samples/configs/deepstream-app/config_tracker_NvDCF_perf.yml
# ll-config-file=/opt/nvidia/deepstream/deepstream/samples/configs/deepstream-app/config_tracker_NvDCF_accuracy.yml
# ll-config-file=/opt/nvidia/deepstream/deepstream/samples/configs/deepstream-app/config_tracker_DeepSORT.yml
gpu-id=0
#enable-batch-process=1
#enable-past-frame=1
display-tracking-id=1
user-meta-pool-size=128


[secondary-gie0]
enable=1
model-engine-file=/home/glueck/Downloads/gce-deepstream-master@d60d0d171d5/gce-deepstream/models/genderv11/gender11.caffemodel_b1_gpu0_fp16.engine
gpu-id=0
batch-size=1
bbox-bg-color0=0;1;0;0.3
#Required by the app for OSD, not a plugin property
bbox-border-color0=1;0;0;1
bbox-border-color1=0;1;1;1
bbox-border-color2=0;0;1;1
bbox-border-color3=0;1;0;1
gie-unique-id=2
operate-on-gie-id=1
operate-on-class-ids=0;
config-file=/home/glueck/Downloads/gce-deepstream-master@d60d0d171d5/gce-deepstream/configs/tlt_pretrained_models/config_infer_genderv11_classifier.txt

[secondary-gie1]
enable=1
model-engine-file=/home/glueck/Downloads/gce-deepstream-master@d60d0d171d5/gce-deepstream/models/age_model/age.model_b16_gpu0_fp16.engine
gpu-id=0
batch-size=1
gie-unique-id=3
operate-on-gie-id=1
operate-on-class-ids=0;
config-file=/home/glueck/Downloads/gce-deepstream-master@d60d0d171d5/gce-deepstream/configs/tlt_pretrained_models/config_infer_age_classifier.txt

[secondary-gie2]
enable=0
model-engine-file=../../models/Secondary_Emotion/emotion_2convs_iter_3000.caffemodel_b16_gpu0_fp16.engine
gpu-id=0
batch-size=16
gie-unique-id=4
operate-on-gie-id=1
operate-on-class-ids=0;
config-file=config_infer_emotion_classifier.txt


[tests]
file-loop=1

This basically proves that the delay is caused by RTSPStreaming sink. Just from your config file, you can using software encoder enc-type=1. This may take a long time.

I believe, i used software encoder for the rtsp sink. Or did i miss something?

and if i use the hardware encoder on my jetson, its showing this

glueck@ubuntu:/opt/nvidia/deepstream/deepstream-6.3/samples/configs/deepstream-app-glueck$ sudo deepstream-app -c deepstream_app_source_glueckce.txt 
** ERROR: <create_udpsink_bin:647>: Failed to create 'sink_sub_bin_encoder2'
** ERROR: <create_udpsink_bin:722>: create_udpsink_bin failed
** ERROR: <create_sink_bin:831>: create_sink_bin failed
** ERROR: <create_processing_instance:956>: create_processing_instance failed
** ERROR: <create_pipeline:1576>: create_pipeline failed
** ERROR: <main:697>: Failed to create pipeline
Quitting
nvstreammux: Successfully handled EOS for source_id=0
App run failed

there was another error which was it was calling back for the software encoder and not processing it with the hardware encoder.

Is your board Orin Nano? Orin Nano cannot support hardware encoder.

Yup i checked about it, Orin Nano couldn’t support hardware encoder. Is there any alternative solutions for this?

We can only optimize by modifying the source code as much as possible.

sources\apps\apps-common\src\deepstream_sink_bin.c
  if (config->enc_type == NV_DS_ENCODER_TYPE_SW) {
    //bitrate is in kbits/sec for software encoder x264enc and x265enc
    g_object_set (G_OBJECT (bin->encoder), "bitrate", config->bitrate / 1000, NULL);
+   g_object_set (G_OBJECT (bin->encoder), "speed-preset", 1,  NULL);
  } else {
    g_object_set (G_OBJECT (bin->encoder), "bitrate", config->bitrate, NULL);
    g_object_set (G_OBJECT (bin->encoder), "profile", config->profile, NULL);
    g_object_set (G_OBJECT (bin->encoder), "iframeinterval",
        config->iframeinterval, NULL);
  }

You can try to set the parameters by referring to the x264enc.

1 Like