Multi-stream rtsp using Gstreamer in python code

Hello guys,
I’m working on multi-stream decoder using gstreamer + opencv python code with jetson nano.
Q1- I want to know, what’s best gstreamer pipeline with opencv in python code?
I used this :

gstream_elemets = (
    'rtspsrc location=rtsp latency=300 !'
    'queue leaky=2 !'
    'rtph264depay !'
    'h264parse !'
    'omxh264dec enable-max-performance=1 enable-low-outbuffer=1 !'
    'video/x-raw(memory:NVMM),format=(string)NV12 !'
    'nvvidconv ! video/x-raw, width=(int)300, height=(int)300, format=(string)BGRx !'
    'videoconvert ! video/x-raw, format=(string)BGR !'
    'appsink').
cv2.VideoCapture(gstream_elemets, cv2.CAP_GSTREAMER)

My input frame-rate is above 20 FPS and I want the output frame rate to be under 10 FPS.

Q1.1- in your opinion, Is it better to use enable-low-outbuffer=1 ?
Q1.2 - what’s difference using of 'videoconvert ! ’ instead of ‘videoconvert ! video/x-raw, format=(string)BGR !’ ? In two case, It’s on and correctly work. I want to know, which of case have extra processing step and is time-consuming and resource-consuming?
Q1.3- why we use rtph264depay? Is it needed in rtsp?

As you know, the opencv only supported CPU buffer, because of this, we use videoconvert ! video/x-raw, format=(string)BGR !.
Q2- Is it possile to grap the batch of decoded streamed without opencv? I don’t know to CPU buffer to be bottleneck for me.

Q3- I used multi-thread python for handeling multi-stream decoding and the NVDEC of jetson nano is activated. Because my output is lower than input, I defined a dynamic programming that give me a given FPS of output, like this snnipet code: Is this way is efficient?

while cap.isOpened():
    frame = cap.read()[1]
    sleep(1./frame_rate_output)

and I used 6 streams and I runned as multi-thread and is corrctly work. my problem is in the capturing of 6 decode frames at the same time, not with for loop like this:

frames = []
for cam in cams
      frames.append(cam.read())

It’s work and ok, One thing to mention, time-consuming of this for loop is 1 ms in my opinion this value is very samll, perhapse It’s not neccesory to use multi-thread for capturing the batch of frames, right?

Hi,
The information are provided and shared by other users:



The solution is optimal for using gstreamer + OpenCV. If you don’t need OpenCV, you may try DeepStream SDK. There are python samples: