How to re-stream RTSP input or sink separately each RTSP output streaming in DS4.0

Hi guys,
I have multiple RTSP input streaming to DeepStream 4.0.
How can I re-stream each of input streaming in different URL or sink separately output of each RTSP streaming?
Currently, DS concatenate all of the input streaming output into 1 streaming.
I have tried config sink correspond with source input but it’s not successful

     [source0]
     enable = 1
     type = 4
     uri = rtsp://192.168.31.203:8080/h264_pcm.sdp
    gpu-id = 0
    nvbuf-memory-type = 0
    [sink0]
    enable = 1
    type = 4
    codec = 2
    sync = 0
    source-id = 0
    gpu-id = 0
    bitrate = 1000000
    rtsp-port = 8554
    width = 640
    height = 480

    [source1]
    enable = 1
    type = 4
    uri = rtsp://192.168.31.203:8080/h264_pcm.sdp
    gpu-id = 0
    nvbuf-memory-type = 0

    [sink1]
    enable = 1
    type = 4
    codec = 2
    sync = 0
    source-id = 1
    gpu-id = 0
    bitrate = 1000000
    rtsp-port = 8555
    width = 640
    height = 480

    [source2]
    enable = 1
    type = 4
    uri = rtsp://192.168.31.203:8080/h264_pcm.sdp
    gpu-id = 0
    nvbuf-memory-type = 0

    [sink2]
    enable = 1
    type = 4
    codec = 2
    sync = 0
    source-id = 2
    gpu-id = 0
    bitrate = 1000000
    rtsp-port = 8556
    width = 640
    height = 480

Hi,
Yo can use nvstreamdemux. Please refer to the posts:


Thank you so much. It works

Hi @DaneLLL,
I have updated my config file to this:

[application]
enable-perf-measurement = 1
perf-measurement-interval-sec = 5    
[tiled-display]
enable = 0
rows = 1
columns = 1
width = 1280
height = 720
gpu-id = 0
nvbuf-memory-type = 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
live-source = 0
batch-size = 2
batched-push-timeout = 40000
width = 1920
height = 1080
enable-padding = 0
nvbuf-memory-type = 0

[primary-gie]
enable = 1
gpu-id = 0
batch-size = 1
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
interval = 4
gie-unique-id = 1
nvbuf-memory-type = 0
int8-calib-file = ../../../../../samples/models/Resnet18_Face_Detection/calibration.bin
labelfile-path = ../../../../../samples/models/Resnet18_Face_Detection/labels.txt
tlt-encoded-model = ../../../../../samples/models/Resnet18_Face_Detection/resnet18_detector.etlt
config-file = ../../../../../samples/configs/deepstream-app/config_infer_face_primary.txt

[tracker]
enable = 1
tracker-width = 600
tracker-height = 300
ll-lib-file = /opt/nvidia/deepstream/deepstream-4.0/lib/libnvds_mot_klt.so
gpu-id = 0
enable-batch-process = 0

[tests]
file-loop = 0

[source0]
enable = 1
type = 4
uri = rtsp://10.10.1.48:8554/test
gpu-id = 0
nvbuf-memory-type = 0

[sink0]
enable = 1
type = 4
codec = 2
sync = 1
source-id = 0
gpu-id = 0
bitrate = 1000000
rtsp-port = 8554
width = 640
height = 480

[source1]
enable = 1
type = 4
uri = rtsp://10.10.1.39:8080/h264_pcm.sdp
gpu-id = 0
nvbuf-memory-type = 0

[sink1]
enable = 1
type = 4
codec = 2
sync = 1
source-id = 1
gpu-id = 0
bitrate = 1000000
rtsp-port = 8555
width = 640
height = 480

So 2 have 2 output streaming. But in each output streaming, they mix 2 inputs together.
For example, 1st frame of the 1st output stream belongs to the output of frame of the input stream 1
2nd frame of the 1st output stream belongs to the output of frame of the input stream 2
How can I fix it?

Hi,
Several settings look not right. For RTSP sources, please set live-source=1 in [streammux]. If the framerate is not 30fps, you also have to adjust batched-push-timeout. And in [primary-gie], it should be batch-size=2.

Hi @DaneLLL,
I have changed these settings as you said. But it doesn’t solve my problem.
I have tested with the following scenario.

  1. Process 2 videos input and get 2 videos output. It works perfectly

  2. But when I change the output to streaming. The error, which I said, happened. And I think it’s a bug of DeepStream

Hi,
Looks like you can see it working in video sinks and saving to files. For RTSP sinks, please configure different udp-port and try again.

1 Like

Thank you so much, I’ve configured upd-port for each output and it works. thanks again!

Hi @DaneLLL,

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

[tiled-display]
enable = 0
rows = 1
columns = 1
width = 1280
height = 720
gpu-id = 0
nvbuf-memory-type = 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
live-source = 1
batched-push-timeout = 4000000
width = 1920
height = 1080
enable-padding = 0
nvbuf-memory-type = 0
batch-size = 4

[primary-gie]
enable = 1
gpu-id = 0
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
interval = 4
gie-unique-id = 1
nvbuf-memory-type = 0
int8-calib-file = …/…/…/…/…/samples/models/Resnet18_Face_Detection/calibration.bin
labelfile-path = …/…/…/…/…/samples/models/Resnet18_Face_Detection/labels.txt
tlt-encoded-model = …/…/…/…/…/samples/models/Resnet18_Face_Detection/resnet18_detector.etlt
tlt-model-key = M3Uyam5hcmQzMWRvaG1jNHFhbGJyamoyaTE6MzE5NTYwMzMtNTUyZS00ZTU0LWFhZGUtNzFhM2EyOWEyMDQ0
config-file = …/…/…/…/…/samples/configs/deepstream-app/config_infer_face_primary.txt
batch-size = 4

[tracker]
enable = 1
tracker-width = 600
tracker-height = 300
ll-lib-file = /opt/nvidia/deepstream/deepstream-4.0/lib/libnvds_mot_klt.so
gpu-id = 0
enable-batch-process = 0

[tests]
file-loop = 0

[source0]
enable = 1
type = 4
uri = rtsp://10.10.1.48:8554/test
gpu-id = 0
nvbuf-memory-type = 0
latency = 200

[sink0]
enable = 1
type = 4
codec = 1
sync = 0
qos = 1
source-id = 0
gpu-id = 0
bitrate = 1000000
rtsp-port = 8554
width = 640
height = 480
udp-port = 5400

[source1]
enable = 1
type = 4
uri = rtsp://10.10.1.48:8554/test
gpu-id = 0
nvbuf-memory-type = 0
latency = 200

[sink1]
enable = 1
type = 4
codec = 1
sync = 0
qos = 1
source-id = 1
gpu-id = 0
bitrate = 1000000
rtsp-port = 8555
width = 640
height = 480
udp-port = 5401

[source2]
enable = 1
type = 4
uri = rtsp://10.10.1.44:8080/h264_pcm.sdp
gpu-id = 0
nvbuf-memory-type = 0
latency = 200

[sink2]
enable = 1
type = 4
codec = 1
sync = 0
qos = 1
source-id = 2
gpu-id = 0
bitrate = 1000000
rtsp-port = 8556
width = 640
height = 480
udp-port = 5402

[source3]
enable = 1
type = 4
uri = rtsp://10.10.1.44:8080/h264_pcm.sdp
gpu-id = 0
nvbuf-memory-type = 0
latency = 200

[sink3]
enable = 1
type = 4
codec = 1
sync = 0
qos = 1
source-id = 3
gpu-id = 0
bitrate = 1000000
rtsp-port = 8557
width = 640
height = 480
udp-port = 5403

That is my config file. When I run with multiple rtsp input and multiple rtsp output.
The rtsp output is really blurred, I even can’t see what is in the streaming.
How can I fix that problem?
(If I change the output to video, It works perfectly)

Hi,
Since it it fine in saved video files, it is more likely an issue in bandwidth or buffering. You may need to tune certain properties and rebuild deepstream-app. Please refer to