Configuring deepstream source in yml based pipline for rtsp reconnect config

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU) : GPU: A40
• DeepStream Version. : 7.0
• JetPack Version (valid for Jetson only)
• TensorRT Version
• NVIDIA GPU Driver Version (valid for GPU only)
• Issue Type( questions, new requirements, bugs). bugs
• How to reproduce the issue ? (This is for bugs. Including which sample app is using, the configuration files content, the command line used and other details for reproducing)

When I am using txt based deepstream pipline, I can easily configure source(RTSP) to handle reconnections and attempt reconnection in case of failure, but not able to do so in yml based pipleine.

I want to do it in yml because al lot of my production pipleines are using yml based config for Deepstream.

Below is the config txt based that works (Handles RTSP reconnections/failures etc)

enable-perf-measurement=1
perf-measurement-interval-sec=1

# Sources 
[source-list]
num-source-bins=1
list=rtsp://10.150.7.16:9554/live
sensor-id-list=test1
sensor-name-list=test1_name
# Set use-nvmultiurisrcbin to 1 to enable sensor provisioning/update feature
use-nvmultiurisrcbin=1
stream-name-display=1
max-batch-size=1
http-ip=localhost
http-port=9005

[source-attr-all]
enable=1
type=3
num-sources=1
gpu-id=0
cudadec-memtype=0
latency=100
rtsp-reconnect-interval-sec=5
rtsp-reconnect-attempts=-1
select-rtp-protocol=0
udp-buffer-size=2000000

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

[sink1]
enable=0
#Type - 1=FakeSink 2=EglSink 3=File 4=UDPSink 5=nvoverlaysink 6=MsgConvBroker
type=6
#msg-conv-config=ds-msgconv-config.txt
#(0): PAYLOAD_DEEPSTREAM - Deepstream schema payload
#(1): PAYLOAD_DEEPSTREAM_MINIMAL - Deepstream schema payload minimal
#(256): PAYLOAD_RESERVED - Reserved type
#(257): PAYLOAD_CUSTOM   - Custom schema payload
msg-conv-payload-type=2
#(0): Create payload using NvdsEventMsgMeta
#(1): New Api to create payload using NvDsFrameMeta
msg-conv-msg2p-new-api=0
#Frame interval at which payload is generated
msg-conv-frame-interval=1
msg-broker-proto-lib=/opt/nvidia/deepstream/deepstream/lib/libnvds_kafka_proto.so
#Provide your msg-broker-conn-str here
#msg-broker-conn-str=qvs-ds-kafka-01;9092;metromind-raw
#topic=metromind-raw
# msg-broker-conn-str=mdx-kafka-cluster-kafka-brokers;9092;mdx-raw
msg-broker-conn-str=localhost;9092;mdx-raw
#topic=mdx-raw
topic=mdx-raw
#Optional:
msg-broker-config=ds-kafka-config.txt
#new-api=0
#(0) Use message adapter library api's
#(1) Use new msgbroker library api's

[sink2]
enable=0
type=3
#1=mp4 2=mkv
container=1
#1=h264 2=h265 3=mpeg4
## only SW mpeg4 is supported right now.
codec=3
sync=1
bitrate=2000000
output-file=out.mp4
source-id=0

[osd]
enable=1
gpu-id=0
border-width=1
text-size=15
text-color=1;1;1;1;
text-bg-color=0.3;0.3;0.3;1
font=Arial
show-clock=0
clock-x-offset=800
clock-y-offset=820
clock-text-size=12
clock-color=1;0;0;0
nvbuf-memory-type=0

[streammux]
gpu-id=0
##Boolean property to inform muxer that sources are live
live-source=0
batch-size=1
##time out in usec, to wait after the first buffer is available
##to push the batch even if the complete batch is not formed
batched-push-timeout=30000
## Set muxer output width and height
width=640
height=640
##Enable to maintain aspect ratio wrt source, and allow black borders, works
##along with width, height properties
enable-padding=1
nvbuf-memory-type=0
## If set to TRUE, system timestamp will be attached as ntp timestamp
## If set to FALSE, ntp timestamp from rtspsrc, if available, will be attached
attach-sys-ts-as-ntp=0
drop-pipeline-eos=1

# config-file property is mandatory for any gie section.
# Other properties are optional and if set will override the properties set in
# the infer config file.
[primary-gie]
enable=1
gpu-id=0
#Required to display the PGIE labels, should be added even when using config-file
#property
batch-size=1
#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;1;1;1
bbox-border-color3=0;1;0;1
interval=1
nvbuf-memory-type=0
config-file=pgie_yolov8s_config_gpu0.txt

[tests]
file-loop=1

Below is my yml based pipline:

################################################################################
# SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: LicenseRef-NvidiaProprietary
#
# NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
# property and proprietary rights in and to this material, related
# documentation and any modifications thereto. Any use, reproduction,
# disclosure or distribution of this material and related documentation
# without an express license agreement from NVIDIA CORPORATION or
# its affiliates is strictly prohibited.
################################################################################

application:
  enable-perf-measurement: 1
  perf-measurement-interval-sec: 1
  #gie-kitti-output-dir: streamscl

source:
 csv-file-path: sources_gpu0.csv

sink0:
  enable: 1
  #Type - 1=FakeSink 2=EglSink 3=File
  type: 1
  sync: 1
  source-id: 0
  gpu-id: 0
  nvbuf-memory-type: 0

sink1:
  enable: 1
  #Type - 1=FakeSink 2=EglSink 3=File 4=UDPSink 5=nvdrmvideosink 6=MsgConvBroker
  type: 6
  # msg2p-newapi: 1 
  # frame-interval: 60
  msg-conv-config: dstest5_msgconv_sample_config.yml
  msg-conv-msg2p-new-api: 1
  #(0): PAYLOAD_DEEPSTREAM - Deepstream schema payload
  #(1): PAYLOAD_DEEPSTREAM_MINIMAL - Deepstream schema payload minimal
  #(256): PAYLOAD_RESERVED - Reserved type
  #(257): PAYLOAD_CUSTOM   - Custom schema payload
  msg-conv-payload-type: 1
  msg-conv-frame-interval: 1
  msg-broker-proto-lib: /opt/nvidia/deepstream/deepstream-7.0/lib/libnvds_kafka_proto.so
  #Provide your msg-broker-conn-str here
  msg-broker-conn-str: localhost;9092;dumpster_topic_vehicle
  # topic: <topic>
  #Optional:
  #msg-broker-config: ../../deepstream-test4/cfg_kafka.txt

sink2:
  enable: 0
  type: 3
  #1=mp4 2=mkv
  container: 1
  #1=h264 2=h265 3=mpeg4
  ## only SW mpeg4 is supported right now.
  codec: 1
  sync: 1
  bitrate: 2000000
  # output-file:  /out_videos/nvds_analytics_roi_final_output12.mp4
  output-file:  /opt/nvidia/deepstream/deepstream-7.0/dumpster/data/out1_drive_thru_new_rec.mp4
  source-id: 0

osd:
  enable: 1
  gpu-id: 0
  border-width: 1
  text-size: 15
  text-color: 1;1;1;1
  text-bg-color: 0.3;0.3;0.3;1
  font: Arial
  show-clock: 0
  clock-x-offset: 800
  clock-y-offset: 820
  clock-text-size: 12
  clock-color: 1;0;0;0
  nvbuf-memory-type: 0

streammux:
  gpu-id: 0
  ##Boolean property to inform muxer that sources are live
  live-source: 0
  batch-size: 1
  ##time out in usec, to wait after the first buffer is available
  ##to push the batch even if the complete batch is not formed
  batched-push-timeout: 40000
  ## Set muxer output width and height
  width: 640
  height: 640
  ##Enable to maintain aspect ratio wrt source, and allow black borders, works
  ##along with width, height properties
  enable-padding: 1
  nvbuf-memory-type: 0
  ## If set to TRUE, system timestamp will be attached as ntp timestamp
  ## If set to FALSE, ntp timestamp from rtspsrc, if available, will be attached
  # attach-sys-ts-as-ntp: 1

primary-gie:
  enable: 1
  gpu-id: 0
  batch-size: 1
  # input-tensor-meta: 1      # keep 0 for full frame inference
  ## 0=FP32, 1=INT8, 2=FP16 mode
  bbox-border-color0: 1;0;0;1
  bbox-border-color1: 0;1;1;1
  bbox-border-color2: 0;1;1;1
  bbox-border-color3: 0;1;0;1
  nvbuf-memory-type: 0
  interval: 0
  config-file: pgie_yolov8s_config_gpu0.txt
  #infer-raw-output-dir: ../../../../../samples/primary_detector_raw_output/

tracker:
  enable: 1
  # For NvDCF and NvDeepSORT tracker, tracker-width and tracker-height must be a multiple of 32, respectively
  tracker-width: 640
  tracker-height: 640
  ll-lib-file: /opt/nvidia/deepstream/deepstream-7.0/lib/libnvds_nvmultiobjecttracker.so
  # ll-config-file required to set different tracker types
  # ll-config-file: ../../../../../samples/configs/deepstream-app/config_tracker_IOU.yml
  ll-config-file: ../../../../../samples/configs/deepstream-app/config_tracker_NvSORT.yml
  # ll-config-file: ../../../../../samples/configs/deepstream-app/config_tracker_NvDCF_perf.yml
  # ll-config-file: ../../../../../samples/configs/deepstream-app/config_tracker_NvDCF_accuracy.yml
  # ll-config-file: ../../../../../samples/configs/deepstream-app/config_tracker_NvDeepSORT.yml
  gpu-id: 0
  display-tracking-id: 1

tests:
  file-loop: 0

I want to modify this yml based pipleine to incorporate following functionality

# Sources 
[source-list]
num-source-bins=1
list=rtsp://10.150.7.16:9554/live
sensor-id-list=test1
sensor-name-list=test1_name
# Set use-nvmultiurisrcbin to 1 to enable sensor provisioning/update feature
use-nvmultiurisrcbin=1
stream-name-display=1
max-batch-size=1
http-ip=localhost
http-port=9005

[source-attr-all]
enable=1
type=3
num-sources=1
gpu-id=0
cudadec-memtype=0
latency=100
rtsp-reconnect-interval-sec=5
rtsp-reconnect-attempts=-1
select-rtp-protocol=0
udp-buffer-size=2000000

I have tried below piepline but its not working, tried the commented out source config also but that also didnt worked

################################################################################
# SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: LicenseRef-NvidiaProprietary
#
# NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
# property and proprietary rights in and to this material, related
# documentation and any modifications thereto. Any use, reproduction,
# disclosure or distribution of this material and related documentation
# without an express license agreement from NVIDIA CORPORATION or
# its affiliates is strictly prohibited.
################################################################################

application:
  enable-perf-measurement: 1
  perf-measurement-interval-sec: 1
  #gie-kitti-output-dir: streamscl

# source0:
#   enable: 1
#   type: 3
#   uri: rtsp://10.150.7.16:9554/live
#   num-sources: 1
#   gpu-id: 0
#   latency: 100
#   cudadec-memtype: 0
#   # nvbuf-memory-type: 0
#   select-rtp-protocol: 0
#   rtsp-reconnect-interval-sec: 5
#   rtsp-reconnect-attempts: -1
#   udp-buffer-size: 2000000

# source:
#   csv-file-path: sources_gpu0.csv
source-list:
  num-source-bins: 1
  list: rtsp://10.150.7.16:9554/live;
  sensor-id-list: test1
  sensor-name-list: test1_name
  # Set use-nvmultiurisrcbin to 1 to enable sensor provisioning/update feature
  use-nvmultiurisrcbin: 1
  stream-name-display: 1
  max-batch-size: 1
  http-ip: localhost
  http-port: 9005

source-attr-all:
  enable: 1
  type: 3
  num-sources: 1
  gpu-id: 0
  cudadec-memtype: 0
  latency: 100
  rtsp-reconnect-interval-sec: 5
  rtsp-reconnect-attempts: -1
  select-rtp-protocol: 0
  udp-buffer-size: 2000000

# source:
#   csv-file-path: sources_gpu0.csv
#   # location: rtsp://10.150.7.16:9554/live
#   type: 3
#   num-sources: 1
#   gpu-id: 0
#   latency: 100
#   cudadec-memtype: 0
#   # nvbuf-memory-type: 0
#   select-rtp-protocol: 0
#   rtsp-reconnect-interval-sec: 5
#   rtsp-reconnect-attempts: -1
#   udp-buffer-size: 2000000
 
sink0:
  enable: 1
  #Type - 1=FakeSink 2=EglSink 3=File
  type: 1
  sync: 0
  source-id: 0
  gpu-id: 0
  nvbuf-memory-type: 0

sink1:
  enable: 0
  #Type - 1=FakeSink 2=EglSink 3=File 4=UDPSink 5=nvdrmvideosink 6=MsgConvBroker
  type: 6
  # msg2p-newapi: 1 
  # frame-interval: 60
  msg-conv-config: dstest5_msgconv_sample_config.yml
  msg-conv-msg2p-new-api: 1
  #(0): PAYLOAD_DEEPSTREAM - Deepstream schema payload
  #(1): PAYLOAD_DEEPSTREAM_MINIMAL - Deepstream schema payload minimal
  #(256): PAYLOAD_RESERVED - Reserved type
  #(257): PAYLOAD_CUSTOM   - Custom schema payload
  msg-conv-payload-type: 1
  msg-conv-frame-interval: 1
  msg-broker-proto-lib: /opt/nvidia/deepstream/deepstream-7.0/lib/libnvds_kafka_proto.so
  #Provide your msg-broker-conn-str here
  msg-broker-conn-str: localhost;9092;dumpster_topic_vehicle
  # topic: <topic>
  #Optional:
  #msg-broker-config: ../../deepstream-test4/cfg_kafka.txt

sink2:
  enable: 0
  type: 3
  #1=mp4 2=mkv
  container: 1
  #1=h264 2=h265 3=mpeg4
  ## only SW mpeg4 is supported right now.
  codec: 1
  sync: 1
  bitrate: 2000000
  # output-file:  /out_videos/nvds_analytics_roi_final_output12.mp4
  output-file:  /opt/nvidia/deepstream/deepstream-7.0/dumpster/data/out1_drive_thru_new_rec.mp4
  source-id: 0

osd:
  enable: 1
  gpu-id: 0
  border-width: 1
  text-size: 15
  text-color: 1;1;1;1
  text-bg-color: 0.3;0.3;0.3;1
  font: Arial
  show-clock: 0
  clock-x-offset: 800
  clock-y-offset: 820
  clock-text-size: 12
  clock-color: 1;0;0;0
  nvbuf-memory-type: 0

streammux:
  gpu-id: 0
  ##Boolean property to inform muxer that sources are live
  live-source: 0
  batch-size: 1
  ##time out in usec, to wait after the first buffer is available
  ##to push the batch even if the complete batch is not formed
  batched-push-timeout: 40000
  ## Set muxer output width and height
  width: 640
  height: 640
  ##Enable to maintain aspect ratio wrt source, and allow black borders, works
  ##along with width, height properties
  enable-padding: 1
  nvbuf-memory-type: 0
  # attach-sys-ts-as-ntp: 0
  drop-pipeline-eos: 1
  ## If set to TRUE, system timestamp will be attached as ntp timestamp
  ## If set to FALSE, ntp timestamp from rtspsrc, if available, will be attached
  # attach-sys-ts-as-ntp: 1


primary-gie:
  enable: 1
  gpu-id: 0
  batch-size: 1
  # input-tensor-meta: 1      # keep 0 for full frame inference
  ## 0=FP32, 1=INT8, 2=FP16 mode
  bbox-border-color0: 1;0;0;1
  bbox-border-color1: 0;1;1;1
  bbox-border-color2: 0;1;1;1
  bbox-border-color3: 0;1;0;1
  nvbuf-memory-type: 0
  interval: 0
  config-file: pgie_yolov8s_config_gpu0.txt
  #infer-raw-output-dir: ../../../../../samples/primary_detector_raw_output/

tracker:
  enable: 1
  # For NvDCF and NvDeepSORT tracker, tracker-width and tracker-height must be a multiple of 32, respectively
  tracker-width: 640
  tracker-height: 640
  ll-lib-file: /opt/nvidia/deepstream/deepstream-7.0/lib/libnvds_nvmultiobjecttracker.so
  # ll-config-file required to set different tracker types
  # ll-config-file: ../../../../../samples/configs/deepstream-app/config_tracker_IOU.yml
  ll-config-file: ../../../../../samples/configs/deepstream-app/config_tracker_NvSORT.yml
  # ll-config-file: ../../../../../samples/configs/deepstream-app/config_tracker_NvDCF_perf.yml
  # ll-config-file: ../../../../../samples/configs/deepstream-app/config_tracker_NvDCF_accuracy.yml
  # ll-config-file: ../../../../../samples/configs/deepstream-app/config_tracker_NvDeepSORT.yml
  gpu-id: 0
  display-tracking-id: 1

tests:
  file-loop: 0

below is sources_gpu0.csv

enable,type,uri,num-sources,gpu-id,nvbuf-memory-type
1,3,rtsp://10.150.7.16:9554/live,1,0,0

Basically I want to port the below functionalit to my yml based piepline, I wnat not able to find relevantdoc for yml based pipeline

I want reconnection when my stream goes down and comes back using some sort of interval

latency=100
rtsp-reconnect-interval-sec=5
rtsp-reconnect-attempts=-1
select-rtp-protocol=0
udp-buffer-size=2000000

Seems you are talking about the deepstream-app sample.

The “source-list” configuration parsing is implemented in /opt/nvidia/deepstream/deepstream/sources/apps/sample_apps/deepstream-app/deepstream_app_config_parser.c, it is not implemented in /opt/nvidia/deepstream/deepstream/sources/apps/sample_apps/deepstream-app/deepstream_app_config_parser_yaml.cpp. The deepstream-app configuration parsing is open source, you can implement by yourself if you need.

The sample applications are all open source for showing how to use DeepStream APIs.

1 Like

understood, thanks.

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