Multi Stream and Multi Network issue

hailo@loranetpcie-H510MH-2-0:/local/workspace/tappas/apps/h8/gstreamer/general/multistream_detection$ sudo ./test3.sh
xvinfo:  Unable to open display
Creating RTSP sources...
Building pipeline...
Running detection on multiple streams
Outputs available via TCP on ports 8554 to 8569
To view the outputs, use a media player like VLC and open the network streams: tcp://HAILO_IP:PORT
For example: tcp://HAILO_IP:8554, tcp://HAILO_IP:8555, etc.
gst-launch-1.0 hailoroundrobin mode=0 name=fun1 ! queue name=hailo_pre_infer_q_1 leaky=downstream max-size-buffers=5 max-size-bytes=0 max-size-time=0 ! hailonet hef-path=/local/workspace/tappas/apps/h8/gstreamer/general/multistream_detection/resources/yolov5m_wo_spp_60p.hef scheduling-algorithm=0 device-count=1 nms-score-threshold=0.3 nms-iou-threshold=0.45 output-format-type=HAILO_FORMAT_TYPE_FLOAT32 ! queue name=hailo_postprocess1 leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! hailofilter so-path=/local/workspace/tappas/apps/h8/gstreamer/libs/post_processes//libyolo_hailortpp_post.so qos=false ! queue name=hailo_draw1 leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! hailooverlay ! hailostreamrouter name=sid1 src_0::input-streams="<sink_0>" src_0::output-streams="<src_0>" src_1::input-streams="<sink_1>" src_1::output-streams="<src_1>" src_2::input-streams="<sink_2>" src_2::output-streams="<src_2>" src_3::input-streams="<sink_3>" src_3::output-streams="<src_3>" src_4::input-streams="<sink_4>" src_4::output-streams="<src_4>" src_5::input-streams="<sink_5>" src_5::output-streams="<src_5>" src_6::input-streams="<sink_6>" src_6::output-streams="<src_6>" src_7::input-streams="<sink_7>" src_7::output-streams="<src_7>" hailoroundrobin mode=0 name=fun2 ! queue name=hailo_pre_infer_q_2 leaky=downstream max-size-buffers=5 max-size-bytes=0 max-size-time=0 ! hailonet hef-path=/local/workspace/tappas/apps/h8/gstreamer/general/multistream_detection/resources/yolov5m_wo_spp_60p.hef scheduling-algorithm=0 device-count=1 nms-score-threshold=0.3 nms-iou-threshold=0.45 output-format-type=HAILO_FORMAT_TYPE_FLOAT32 ! queue name=hailo_postprocess2 leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! hailofilter so-path=/local/workspace/tappas/apps/h8/gstreamer/libs/post_processes//libyolo_hailortpp_post.so qos=false ! queue name=hailo_draw2 leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! hailooverlay ! hailostreamrouter name=sid2 src_8::input-streams="<sink_8>" src_8::output-streams="<src_8>" src_9::input-streams="<sink_9>" src_9::output-streams="<src_9>" src_10::input-streams="<sink_10>" src_10::output-streams="<src_10>" src_11::input-streams="<sink_11>" src_11::output-streams="<src_11>" src_12::input-streams="<sink_12>" src_12::output-streams="<src_12>" src_13::input-streams="<sink_13>" src_13::output-streams="<src_13>" src_14::input-streams="<sink_14>" src_14::output-streams="<src_14>" src_15::input-streams="<sink_15>" src_15::output-streams="<src_15>" rtspsrc location=rtsp://admin:[email protected]:8554/cam01 name=source_0 message-forward=true ! rtph264depay ! queue name=hailo_preprocess_q_0 leaky=no max-size-buffers=5 max-size-bytes=0 max-size-time=0 ! decodebin ! queue leaky=downstream max-size-buffers=5 max-size-bytes=0 max-size-time=0 ! videoscale n-threads=12 ! video/x-raw,format=RGB,pixel-aspect-ratio=1/1 ! videoconvert n-threads=8 ! video/x-raw,width=640,height=640,pixel-aspect-ratio=1/1 ! fun1.sink_0 rtspsrc location=rtsp://admin:[email protected]:8555/cam02 name=source_1 message-forward=true ! rtph264depay ! queue name=hailo_preprocess_q_1 leaky=no max-size-buffers=5 max-size-bytes=0 max-size-time=0 ! decodebin ! queue leaky=downstream max-size-buffers=5 max-size-bytes=0 max-size-time=0 ! videoscale n-threads=12 ! video/x-raw,format=RGB,pixel-aspect-ratio=1/1 ! videoconvert n-threads=8 ! video/x-raw,width=640,height=640,pixel-aspect-ratio=1/1 ! fun1.sink_1 rtspsrc location=rtsp://admin:[email protected]:8556/cam03 name=source_2 message-forward=true ! rtph264depay ! queue name=hailo_preprocess_q_2 leaky=no max-size-buffers=5 max-size-bytes=0 max-size-time=0 ! decodebin ! queue leaky=downstream max-size-buffers=5 max-size-bytes=0 max-size-time=0 ! videoscale n-threads=12 ! video/x-raw,format=RGB,pixel-aspect-ratio=1/1 ! videoconvert n-threads=8 ! video/x-raw,width=640,height=640,pixel-aspect-ratio=1/1 ! fun1.sink_2 rtspsrc location=rtsp://admin:[email protected]:8557/cam04 name=source_3 message-forward=true ! rtph264depay ! queue name=hailo_preprocess_q_3 leaky=no max-size-buffers=5 max-size-bytes=0 max-size-time=0 ! decodebin ! queue leaky=downstream max-size-buffers=5 max-size-bytes=0 max-size-time=0 ! videoscale n-threads=12 ! video/x-raw,format=RGB,pixel-aspect-ratio=1/1 ! videoconvert n-threads=8 ! video/x-raw,width=640,height=640,pixel-aspect-ratio=1/1 ! fun1.sink_3 rtspsrc location=rtsp://admin:[email protected]:8558/cam05 name=source_4 message-forward=true ! rtph264depay ! queue name=hailo_preprocess_q_4 leaky=no max-size-buffers=5 max-size-bytes=0 max-size-time=0 ! decodebin ! queue leaky=downstream max-size-buffers=5 max-size-bytes=0 max-size-time=0 ! videoscale n-threads=12 ! video/x-raw,format=RGB,pixel-aspect-ratio=1/1 ! videoconvert n-threads=8 ! video/x-raw,width=640,height=640,pixel-aspect-ratio=1/1 ! fun1.sink_4 rtspsrc location=rtsp://admin:[email protected]:8559/cam06 name=source_5 message-forward=true ! rtph264depay ! queue name=hailo_preprocess_q_5 leaky=no max-size-buffers=5 max-size-bytes=0 max-size-time=0 ! decodebin ! queue leaky=downstream max-size-buffers=5 max-size-bytes=0 max-size-time=0 ! videoscale n-threads=12 ! video/x-raw,format=RGB,pixel-aspect-ratio=1/1 ! videoconvert n-threads=8 ! video/x-raw,width=640,height=640,pixel-aspect-ratio=1/1 ! fun1.sink_5 rtspsrc location=rtsp://admin:[email protected]:8560/cam07 name=source_6 message-forward=true ! rtph264depay ! queue name=hailo_preprocess_q_6 leaky=no max-size-buffers=5 max-size-bytes=0 max-size-time=0 ! decodebin ! queue leaky=downstream max-size-buffers=5 max-size-bytes=0 max-size-time=0 ! videoscale n-threads=12 ! video/x-raw,format=RGB,pixel-aspect-ratio=1/1 ! videoconvert n-threads=8 ! video/x-raw,width=640,height=640,pixel-aspect-ratio=1/1 ! fun1.sink_6 rtspsrc location=rtsp://admin:[email protected]:8561/cam08 name=source_7 message-forward=true ! rtph264depay ! queue name=hailo_preprocess_q_7 leaky=no max-size-buffers=5 max-size-bytes=0 max-size-time=0 ! decodebin ! queue leaky=downstream max-size-buffers=5 max-size-bytes=0 max-size-time=0 ! videoscale n-threads=12 ! video/x-raw,format=RGB,pixel-aspect-ratio=1/1 ! videoconvert n-threads=8 ! video/x-raw,width=640,height=640,pixel-aspect-ratio=1/1 ! fun1.sink_7 rtspsrc location=rtsp://admin:[email protected]:8562/cam09 name=source_8 message-forward=true ! rtph264depay ! queue name=hailo_preprocess_q_8 leaky=no max-size-buffers=5 max-size-bytes=0 max-size-time=0 ! decodebin ! queue leaky=downstream max-size-buffers=5 max-size-bytes=0 max-size-time=0 ! videoscale n-threads=12 ! video/x-raw,format=RGB,pixel-aspect-ratio=1/1 ! videoconvert n-threads=8 ! video/x-raw,width=640,height=640,pixel-aspect-ratio=1/1 ! fun2.sink_8 rtspsrc location=rtsp://admin:[email protected]:8563/cam10 name=source_9 message-forward=true ! rtph264depay ! queue name=hailo_preprocess_q_9 leaky=no max-size-buffers=5 max-size-bytes=0 max-size-time=0 ! decodebin ! queue leaky=downstream max-size-buffers=5 max-size-bytes=0 max-size-time=0 ! videoscale n-threads=12 ! video/x-raw,format=RGB,pixel-aspect-ratio=1/1 ! videoconvert n-threads=8 ! video/x-raw,width=640,height=640,pixel-aspect-ratio=1/1 ! fun2.sink_9 rtspsrc location=rtsp://admin:[email protected]:8564/cam11 name=source_10 message-forward=true ! rtph264depay ! queue name=hailo_preprocess_q_10 leaky=no max-size-buffers=5 max-size-bytes=0 max-size-time=0 ! decodebin ! queue leaky=downstream max-size-buffers=5 max-size-bytes=0 max-size-time=0 ! videoscale n-threads=12 ! video/x-raw,format=RGB,pixel-aspect-ratio=1/1 ! videoconvert n-threads=8 ! video/x-raw,width=640,height=640,pixel-aspect-ratio=1/1 ! fun2.sink_10 rtspsrc location=rtsp://admin:[email protected]:8565/cam12 name=source_11 message-forward=true ! rtph264depay ! queue name=hailo_preprocess_q_11 leaky=no max-size-buffers=5 max-size-bytes=0 max-size-time=0 ! decodebin ! queue leaky=downstream max-size-buffers=5 max-size-bytes=0 max-size-time=0 ! videoscale n-threads=12 ! video/x-raw,format=RGB,pixel-aspect-ratio=1/1 ! videoconvert n-threads=8 ! video/x-raw,width=640,height=640,pixel-aspect-ratio=1/1 ! fun2.sink_11 rtspsrc location=rtsp://admin:[email protected]:8566/cam13 name=source_12 message-forward=true ! rtph264depay ! queue name=hailo_preprocess_q_12 leaky=no max-size-buffers=5 max-size-bytes=0 max-size-time=0 ! decodebin ! queue leaky=downstream max-size-buffers=5 max-size-bytes=0 max-size-time=0 ! videoscale n-threads=12 ! video/x-raw,format=RGB,pixel-aspect-ratio=1/1 ! videoconvert n-threads=8 ! video/x-raw,width=640,height=640,pixel-aspect-ratio=1/1 ! fun2.sink_12 rtspsrc location=rtsp://admin:[email protected]:8567/cam14 name=source_13 message-forward=true ! rtph264depay ! queue name=hailo_preprocess_q_13 leaky=no max-size-buffers=5 max-size-bytes=0 max-size-time=0 ! decodebin ! queue leaky=downstream max-size-buffers=5 max-size-bytes=0 max-size-time=0 ! videoscale n-threads=12 ! video/x-raw,format=RGB,pixel-aspect-ratio=1/1 ! videoconvert n-threads=8 ! video/x-raw,width=640,height=640,pixel-aspect-ratio=1/1 ! fun2.sink_13 rtspsrc location=rtsp://admin:[email protected]:8568/cam15 name=source_14 message-forward=true ! rtph264depay ! queue name=hailo_preprocess_q_14 leaky=no max-size-buffers=5 max-size-bytes=0 max-size-time=0 ! decodebin ! queue leaky=downstream max-size-buffers=5 max-size-bytes=0 max-size-time=0 ! videoscale n-threads=12 ! video/x-raw,format=RGB,pixel-aspect-ratio=1/1 ! videoconvert n-threads=8 ! video/x-raw,width=640,height=640,pixel-aspect-ratio=1/1 ! fun2.sink_14 rtspsrc location=rtsp://admin:[email protected]:8569/cam16 name=source_15 message-forward=true ! rtph264depay ! queue name=hailo_preprocess_q_15 leaky=no max-size-buffers=5 max-size-bytes=0 max-size-time=0 ! decodebin ! queue leaky=downstream max-size-buffers=5 max-size-bytes=0 max-size-time=0 ! videoscale n-threads=12 ! video/x-raw,format=RGB,pixel-aspect-ratio=1/1 ! videoconvert n-threads=8 ! video/x-raw,width=640,height=640,pixel-aspect-ratio=1/1 ! fun2.sink_15 sid1.src_0 ! queue ! videoconvert ! videorate ! video/x-raw,framerate=10/1 ! x264enc tune=zerolatency bitrate=6000 speed-preset=superfast ! video/x-h264,profile=high ! h264parse ! mpegtsmux ! tcpserversink host=0.0.0.0 port=8554 sync=false sid1.src_1 ! queue ! videoconvert ! videorate ! video/x-raw,framerate=10/1 ! x264enc tune=zerolatency bitrate=6000 speed-preset=superfast ! video/x-h264,profile=high ! h264parse ! mpegtsmux ! tcpserversink host=0.0.0.0 port=8555 sync=false sid1.src_2 ! queue ! videoconvert ! videorate ! video/x-raw,framerate=10/1 ! x264enc tune=zerolatency bitrate=6000 speed-preset=superfast ! video/x-h264,profile=high ! h264parse ! mpegtsmux ! tcpserversink host=0.0.0.0 port=8556 sync=false sid1.src_3 ! queue ! videoconvert ! videorate ! video/x-raw,framerate=10/1 ! x264enc tune=zerolatency bitrate=6000 speed-preset=superfast ! video/x-h264,profile=high ! h264parse ! mpegtsmux ! tcpserversink host=0.0.0.0 port=8557 sync=false sid1.src_4 ! queue ! videoconvert ! videorate ! video/x-raw,framerate=10/1 ! x264enc tune=zerolatency bitrate=6000 speed-preset=superfast ! video/x-h264,profile=high ! h264parse ! mpegtsmux ! tcpserversink host=0.0.0.0 port=8558 sync=false sid1.src_5 ! queue ! videoconvert ! videorate ! video/x-raw,framerate=10/1 ! x264enc tune=zerolatency bitrate=6000 speed-preset=superfast ! video/x-h264,profile=high ! h264parse ! mpegtsmux ! tcpserversink host=0.0.0.0 port=8559 sync=false sid1.src_6 ! queue ! videoconvert ! videorate ! video/x-raw,framerate=10/1 ! x264enc tune=zerolatency bitrate=6000 speed-preset=superfast ! video/x-h264,profile=high ! h264parse ! mpegtsmux ! tcpserversink host=0.0.0.0 port=8560 sync=false sid1.src_7 ! queue ! videoconvert ! videorate ! video/x-raw,framerate=10/1 ! x264enc tune=zerolatency bitrate=6000 speed-preset=superfast ! video/x-h264,profile=high ! h264parse ! mpegtsmux ! tcpserversink host=0.0.0.0 port=8561 sync=false sid2.src_8 ! queue ! videoconvert ! videorate ! video/x-raw,framerate=10/1 ! x264enc tune=zerolatency bitrate=6000 speed-preset=superfast ! video/x-h264,profile=high ! h264parse ! mpegtsmux ! tcpserversink host=0.0.0.0 port=8570 sync=false sid2.src_9 ! queue ! videoconvert ! videorate ! video/x-raw,framerate=10/1 ! x264enc tune=zerolatency bitrate=6000 speed-preset=superfast ! video/x-h264,profile=high ! h264parse ! mpegtsmux ! tcpserversink host=0.0.0.0 port=8571 sync=false sid2.src_10 ! queue ! videoconvert ! videorate ! video/x-raw,framerate=10/1 ! x264enc tune=zerolatency bitrate=6000 speed-preset=superfast ! video/x-h264,profile=high ! h264parse ! mpegtsmux ! tcpserversink host=0.0.0.0 port=8572 sync=false sid2.src_11 ! queue ! videoconvert ! videorate ! video/x-raw,framerate=10/1 ! x264enc tune=zerolatency bitrate=6000 speed-preset=superfast ! video/x-h264,profile=high ! h264parse ! mpegtsmux ! tcpserversink host=0.0.0.0 port=8573 sync=false sid2.src_12 ! queue ! videoconvert ! videorate ! video/x-raw,framerate=10/1 ! x264enc tune=zerolatency bitrate=6000 speed-preset=superfast ! video/x-h264,profile=high ! h264parse ! mpegtsmux ! tcpserversink host=0.0.0.0 port=8574 sync=false sid2.src_13 ! queue ! videoconvert ! videorate ! video/x-raw,framerate=10/1 ! x264enc tune=zerolatency bitrate=6000 speed-preset=superfast ! video/x-h264,profile=high ! h264parse ! mpegtsmux ! tcpserversink host=0.0.0.0 port=8575 sync=false sid2.src_14 ! queue ! videoconvert ! videorate ! video/x-raw,framerate=10/1 ! x264enc tune=zerolatency bitrate=6000 speed-preset=superfast ! video/x-h264,profile=high ! h264parse ! mpegtsmux ! tcpserversink host=0.0.0.0 port=8576 sync=false sid2.src_15 ! queue ! videoconvert ! videorate ! video/x-raw,framerate=10/1 ! x264enc tune=zerolatency bitrate=6000 speed-preset=superfast ! video/x-h264,profile=high ! h264parse ! mpegtsmux ! tcpserversink host=0.0.0.0 port=8577 sync=false
Pipeline constructed:
Running Pipeline...
[HailoRT] [warning] Trying to register a vdevice to hailo-monitor, while other vdevice is registered. Monitor currently supports single vdevice, which will result in non-consistent tracing.
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Progress: (open) Opening Stream
Progress: (open) Opening Stream
Progress: (open) Opening Stream
Progress: (open) Opening Stream
Progress: (connect) Connecting to rtsp://admin:[email protected]:8569/cam16
Progress: (open) Opening Stream
Progress: (connect) Connecting to rtsp://admin:[email protected]:8568/cam15
Progress: (connect) Connecting to rtsp://admin:[email protected]:8567/cam14
Progress: (open) Opening Stream
Progress: (connect) Connecting to rtsp://admin:[email protected]:8565/cam12
Progress: (connect) Connecting to rtsp://admin:[email protected]:8566/cam13
Progress: (open) Opening Stream
Progress: (open) Opening Stream
Progress: (open) Opening Stream
Progress: (connect) Connecting to rtsp://admin:[email protected]:8564/cam11
Progress: (connect) Connecting to rtsp://admin:[email protected]:8563/cam10
Progress: (open) Opening Stream
Progress: (connect) Connecting to rtsp://admin:[email protected]:8562/cam09
Progress: (open) Opening Stream
Progress: (connect) Connecting to rtsp://admin:[email protected]:8561/cam08
Progress: (open) Opening Stream
Progress: (connect) Connecting to rtsp://admin:[email protected]:8560/cam07
Progress: (connect) Connecting to rtsp://admin:[email protected]:8559/cam06
Progress: (open) Opening Stream
Progress: (connect) Connecting to rtsp://admin:[email protected]:8558/cam05
Progress: (open) Opening Stream
Progress: (open) Opening Stream
Progress: (connect) Connecting to rtsp://admin:[email protected]:8557/cam04
Progress: (open) Opening Stream
Progress: (connect) Connecting to rtsp://admin:[email protected]:8556/cam03
Progress: (connect) Connecting to rtsp://admin:[email protected]:8555/cam02
Pipeline is PREROLLED ...
Prerolled, waiting for progress to finish...
Progress: (connect) Connecting to rtsp://admin:[email protected]:8554/cam01
Progress: (open) Retrieving server options
Progress: (open) Retrieving server options
Progress: (open) Retrieving server options
Progress: (open) Retrieving server options
Progress: (open) Retrieving server options
Progress: (open) Retrieving server options
Progress: (open) Retrieving server options
Progress: (open) Retrieving server options
Progress: (open) Retrieving server options
Progress: (open) Retrieving server options
Progress: (open) Retrieving server options
Progress: (open) Retrieving server options
Progress: (open) Retrieving server options
Progress: (open) Retrieving server options
Progress: (open) Retrieving server options
Progress: (open) Retrieving server options
Progress: (open) Retrieving media info
Progress: (open) Retrieving media info
Progress: (open) Retrieving media info
Progress: (open) Retrieving media info
Progress: (open) Retrieving media info
Progress: (open) Retrieving media info
Progress: (open) Retrieving media info
Progress: (open) Retrieving media info
Progress: (open) Retrieving media info
Progress: (open) Retrieving media info
Progress: (open) Retrieving media info
Progress: (open) Retrieving media info
Progress: (open) Retrieving media info
Progress: (open) Retrieving media info
Progress: (open) Retrieving media info
Progress: (open) Retrieving media info
Progress: (request) SETUP stream 0
Progress: (request) SETUP stream 0
Progress: (request) SETUP stream 0
Progress: (request) SETUP stream 0
Progress: (request) SETUP stream 0
Progress: (request) SETUP stream 1
Progress: (request) SETUP stream 1
Progress: (request) SETUP stream 1
Progress: (request) SETUP stream 1
Progress: (request) SETUP stream 1
Progress: (request) SETUP stream 0
Progress: (request) SETUP stream 0
Progress: (request) SETUP stream 0
ERROR: from element /GstPipeline:pipeline0/GstRTSPSrc:source_7: Could not write to resource.
Additional debug info:
../gst/rtsp/gstrtspsrc.c(7661): gst_rtspsrc_setup_streams_start (): /GstPipeline:pipeline0/GstRTSPSrc:source_7:
Error (400): Bad Request
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
Freeing pipeline ...

My goal was to create multi stream and multi network. since 1 hailo device can handle 8 streams. we have PCIE with 6 hailo 8.

Any can help me with this everytime i run i end with error from gstreamer.

i follow also multistream detection rtsp guide from tappas. if i combine all the streams in one there will be bottleneck in the middle so simplifying the network might be the case.

the full code is here:

#!/bin/bash

function init_variables() {
    # ... (keep existing variable initializations)
    print_help_if_needed $@
    script_dir=$(dirname $(realpath "$0"))
    source $script_dir/../../../../../scripts/misc/checks_before_run.sh

    readonly SRC_0="rtsp://admin:[email protected]:8554/cam01"
    readonly SRC_1="rtsp://admin:[email protected]:8555/cam02"
    readonly SRC_2="rtsp://admin:[email protected]:8556/cam03"
    readonly SRC_3="rtsp://admin:[email protected]:8557/cam04"
    readonly SRC_4="rtsp://admin:[email protected]:8558/cam05"
    readonly SRC_5="rtsp://admin:[email protected]:8559/cam06"
    readonly SRC_6="rtsp://admin:[email protected]:8560/cam07"
    readonly SRC_7="rtsp://admin:[email protected]:8561/cam08"
    readonly SRC_8="rtsp://admin:[email protected]:8562/cam09"
    readonly SRC_9="rtsp://admin:[email protected]:8563/cam10"
    readonly SRC_10="rtsp://admin:[email protected]:8564/cam11"
    readonly SRC_11="rtsp://admin:[email protected]:8565/cam12"
    readonly SRC_12="rtsp://admin:[email protected]:8566/cam13"
    readonly SRC_13="rtsp://admin:[email protected]:8567/cam14"
    readonly SRC_14="rtsp://admin:[email protected]:8568/cam15"
    readonly SRC_15="rtsp://admin:[email protected]:8569/cam16"


    readonly RESOURCES_DIR="$TAPPAS_WORKSPACE/apps/h8/gstreamer/general/multistream_detection/resources"
    readonly POSTPROCESS_DIR="$TAPPAS_WORKSPACE/apps/h8/gstreamer/libs/post_processes/"
    readonly HEF_PATH_1="$RESOURCES_DIR/yolov5m_wo_spp_60p.hef"
    readonly HEF_PATH_2="$RESOURCES_DIR/yolov5m_wo_spp_60p.hef"
    readonly POSTPROCESS_SO_1="$POSTPROCESS_DIR/libyolo_hailortpp_post.so"
    readonly POSTPROCESS_SO_2="$POSTPROCESS_DIR/libyolo_hailortpp_post.so"
    readonly tcp_port=8554


    num_of_src=16
    debug=false
    gst_top_command=""
    additional_parameters=""
    rtsp_sources=""
    streamrouter_input_streams=""
    decode_scale_elements="decodebin ! queue leaky=downstream max-size-buffers=5 max-size-bytes=0 max-size-time=0 ! videoscale n-threads=12 ! video/x-raw,format=RGB,pixel-aspect-ratio=1/1"
    
    export HAILO_MONITOR=1
}

function print_usage() {
    echo "Multistream Detection RTSP with Multiple TCP Outputs - pipeline usage:"
    echo ""
    echo "Options:"
    echo "  --help                  Show this help"
    echo "  --debug                 Setting debug mode. using gst-top to print time and memory consuming elements"
    echo "  --show-fps              Printing fps"
    echo "  --num-of-sources NUM    Setting number of rtsp sources to given input (default value is 8)"
    echo "  --print-gst-launch      Print the ready gst-launch command without running it"
    echo "  --tcp_port PORT         Set the base TCP server port (default is 8554)"
    exit 0
}

function print_help_if_needed() {
    while test $# -gt 0; do
        if [ "$1" = "--help" ] || [ "$1" == "-h" ]; then
            print_usage
        fi
        shift
    done
}

function parse_args() {
    while test $# -gt 0; do
        if [ "$1" = "--debug" ]; then
            echo "Setting debug mode. using gst-top to print time and memory consuming elements"
            debug=true
            gst_top_command="SHOW_FPS=1 GST_DEBUG=GST_TRACER:13 GST_DEBUG_DUMP_TRACE_DIR=. gst-top-1.0"
        elif [ "$1" = "--print-gst-launch" ]; then
            print_gst_launch_only=true
        elif [ "$1" = "--show-fps" ]; then
            echo "Printing fps"
            additional_parameters="-v | grep hailo_display"
        elif [ "$1" = "--num-of-sources" ]; then
            shift
            echo "Setting number of rtsp sources to $1"
            num_of_src=$1
        elif [ "$1" = "--tcp_port" ]; then
            shift
            tcp_port=$1
            echo "Setting base TCP server port to $tcp_port"
        else
            echo "Received invalid argument: $1. See expected arguments below:"
            print_usage
            exit 1
        fi
        shift
    done
}


function create_rtsp_sources_1() {
    for ((n = 0; n < 8; n++)); do
        src_name="SRC_${n}"
        src_name="${!src_name}"
        rtsp_sources_1+="rtspsrc location=$src_name name=source_$n message-forward=true ! \
                       rtph264depay ! \
                       queue name=hailo_preprocess_q_$n leaky=no max-size-buffers=5 max-size-bytes=0 max-size-time=0 ! \
                       $decode_scale_elements ! videoconvert n-threads=8 ! \
                       video/x-raw,width=640,height=640,pixel-aspect-ratio=1/1 ! \
                       fun1.sink_$n "
        streamrouter_input_streams_1+=" src_$n::input-streams=\"<sink_$n>\" src_$n::output-streams=\"<src_$n>\""
    done
}

function create_rtsp_sources_2() {
    for ((n = 8; n < 16; n++)); do
        src_name="SRC_${n}"
        src_name="${!src_name}"
        rtsp_sources_2+="rtspsrc location=$src_name name=source_$n message-forward=true ! \
                       rtph264depay ! \
                       queue name=hailo_preprocess_q_$n leaky=no max-size-buffers=5 max-size-bytes=0 max-size-time=0 ! \
                       $decode_scale_elements ! videoconvert n-threads=8 ! \
                       video/x-raw,width=640,height=640,pixel-aspect-ratio=1/1 ! \
                       fun2.sink_$n "
        streamrouter_input_streams_2+=" src_$n::input-streams=\"<sink_$n>\" src_$n::output-streams=\"<src_$n>\""
    done
}

function main() {
    init_variables $@
    parse_args $@
    echo "Creating RTSP sources..."
    create_rtsp_sources_1
    create_rtsp_sources_2
    echo "Building pipeline..."
    pipeline="$gst_top_command gst-launch-1.0 \
         hailoroundrobin mode=0 name=fun1 ! \
         queue name=hailo_pre_infer_q_1 leaky=downstream max-size-buffers=5 max-size-bytes=0 max-size-time=0 ! \
         hailonet hef-path=$HEF_PATH_1 scheduling-algorithm=0 device-count=1 nms-score-threshold=0.3 nms-iou-threshold=0.45 output-format-type=HAILO_FORMAT_TYPE_FLOAT32 ! \
         queue name=hailo_postprocess1 leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! \
         hailofilter so-path=$POSTPROCESS_SO_1 qos=false ! \
         queue name=hailo_draw1 leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! \
         hailooverlay ! hailostreamrouter name=sid1 $streamrouter_input_streams_1 \
         hailoroundrobin mode=0 name=fun2 ! \
         queue name=hailo_pre_infer_q_2 leaky=downstream max-size-buffers=5 max-size-bytes=0 max-size-time=0 ! \
         hailonet hef-path=$HEF_PATH_2 scheduling-algorithm=0 device-count=1 nms-score-threshold=0.3 nms-iou-threshold=0.45 output-format-type=HAILO_FORMAT_TYPE_FLOAT32 ! \
         queue name=hailo_postprocess2 leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! \
         hailofilter so-path=$POSTPROCESS_SO_2 qos=false ! \
         queue name=hailo_draw2 leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! \
         hailooverlay ! hailostreamrouter name=sid2 $streamrouter_input_streams_2 \
         $rtsp_sources_1 $rtsp_sources_2 ${additional_parameters}"

    # Add TCP outputs for first network (0-7)
    for ((n = 0; n < 8; n++)); do
        pipeline+=" sid1.src_$n ! queue ! videoconvert ! videorate ! video/x-raw,framerate=10/1 ! \
                   x264enc tune=zerolatency bitrate=6000 speed-preset=superfast ! \
                   video/x-h264,profile=high ! h264parse ! mpegtsmux ! \
                   tcpserversink host=0.0.0.0 port=$((tcp_port + n)) sync=false"
    done

    # Add TCP outputs for second network (8-15)
    for ((n = 8; n < 16; n++)); do
        pipeline+=" sid2.src_$n ! queue ! videoconvert ! videorate ! video/x-raw,framerate=10/1 ! \
                   x264enc tune=zerolatency bitrate=6000 speed-preset=superfast ! \
                   video/x-h264,profile=high ! h264parse ! mpegtsmux ! \
                   tcpserversink host=0.0.0.0 port=$((tcp_port + n + 8)) sync=false"
    done

    #  GST_DEBUG=3

    echo "Running detection on multiple streams"
    echo "Outputs available via TCP on ports $tcp_port to $((tcp_port + 15))"
    echo "To view the outputs, use a media player like VLC and open the network streams: tcp://HAILO_IP:PORT"
    echo "For example: tcp://HAILO_IP:$tcp_port, tcp://HAILO_IP:$((tcp_port + 1)), etc."
    echo ${pipeline}

    echo "Pipeline constructed:"

    if [ "$print_gst_launch_only" = true ]; then
        exit 0
    fi

    echo "Running Pipeline..."
    eval "${pipeline}"

    if [ "$debug" = true ]; then
        echo "Running in debug mode..."
        if [ -f "gst-top.gsttrace" ]; then
            gst-report-1.0 gst-top.gsttrace >pipeline_report.txt
            gst-report-1.0 --dot gst-top.gsttrace | dot -Tsvg >pipeline_graph.svg
            echo "Most time and memory consuming elements:"
            cat pipeline_report.txt | head -n 4
            echo "Full pipeline report saved to pipeline_report.txt and pipeline_graph.svg"
        else
            echo "Pipeline report creation failed"
        fi
    fi

}

main $@

this code is testing only two networks with 16 rtsp streams.
Thank you.

@mohamedstila97
I had also issues with hailoroundrobin with 2 streams. For some reason pipeline stops after few seconds. The reason was not clear but i found a new way, so i am using that.

I have 2 streams with separate subpipeline(the word maybe incorrect). But it just means i have 2 parallel streams and processing i am not combining anywhere.

Stream > some preprocess > hailonet(vdevice-group-id=anyname) > post process > hailooverlay > display…

vdevice-group-id is important when running 2 hailonet elements in parallel.

This might help you. But since you have many sources i think this will cause issues on small devices.

Thank you for your response. to set the vdevice-group-id, i need to choose like how? and also can you share with me the code that is working for you now that u solved the issue.

gst-launch-1.0 \
libcamerasrc camera-name=/base/axi/pcie@120000/rp1/i2c@80000/imx708@1a ! \
video/x-raw, format=RGB, width=640, height=620 ! \
queue name=queue_src_scale leaky=no max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! \
videoscale ! \
video/x-raw, format=RGB,  width=640, height=640, framerate=50/1 ! \
queue name=queue_hailonet leaky=no max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! \
videoconvert n-threads=5 ! \
hailonet vdevice-group-id=my-group hef-path=/home/admin/Desktop/yolov8n.hef batch-size=8 nms-score-threshold=0.3 nms-iou-threshold=0.45 force-writable=true ! \
queue name=queue_hailofilter leaky=no max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! \
hailofilter so-path=/lib/aarch64-linux-gnu/hailo/tappas/post_processes/libyolo_hailortpp_post.so qos=false ! \
queue name=queue_hailotracker leaky=no max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! \
hailotracker ! \
queue name=queue_hailooverlay leaky=no max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! \
hailooverlay ! \
queue name=queue_videoconvert leaky=no max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! \
videoconvert n-threads=5 qos=false ! \
queue name=queue_hailo_display leaky=no max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! \
fpsdisplaysink video-sink=xvimagesink name=hailo_display sync=false text-overlay=true signal-fps-measurements=true \
libcamerasrc camera-name=/base/axi/pcie@120000/rp1/i2c@88000/imx708@1a ! \
video/x-raw, format=RGB, width=640, height=620 ! \
queue name=queue_src_scale_1 leaky=no max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! \
videoscale ! \
video/x-raw, format=RGB,  width=640, height=640, framerate=50/1 ! \
queue name=queue_hailonet_1 leaky=no max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! \
videoconvert n-threads=5 ! \
hailonet vdevice-group-id=my-group hef-path=/home/admin/Desktop/yolov8n.hef batch-size=8 nms-score-threshold=0.3 nms-iou-threshold=0.45 force-writable=true ! \
queue name=queue_hailofilter_1 leaky=no max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! \
hailofilter so-path=/lib/aarch64-linux-gnu/hailo/tappas/post_processes/libyolo_hailortpp_post.so qos=false ! \
queue name=queue_hailotracker_1 leaky=no max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! \
hailotracker ! \
queue name=queue_hailooverlay_1 leaky=no max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! \
hailooverlay ! \
queue name=queue_videoconvert_1 leaky=no max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! \
videoconvert n-threads=5 qos=false ! \
queue name=queue_hailo_display_1 leaky=no max-size-buffers=3 max-size-bytes=0 max-size-time=0 ! \
fpsdisplaysink video-sink=xvimagesink name=hailo_display_1 sync=false text-overlay=true signal-fps-measurements=true

I am using hailo8l on raspberry pi you will have to adjust input source… accordingly. This works for me.

You can inspect hailonet gstreamer element for more information.
you will find what parameters you can pass.

And regarding your last question.
I think you can also pass device number to hailonet in case you have 6 hailo8.

In case you’re working with multiple processes there is also a parameter available in hailonet. you can set to true.

But before that you will have to enable hailort service.

Thank you @saurabh, I tried is-active=True. but the main issue i see is the gstreamer.

it looks like the stream somehow getting bottleneck or maybe the way i setup is wrong.