I want to decode multi-stream rtsp with h264 HW of jetson nano and opencv.
I use jetpack 4.2.2 and opencv-3.4.6 build from source with gstreamer support.
when I use this elements, I get correct results, but the problem is that memory usage gradually increased and I get reasoable cpu usage and Actived NVDEC.
gstream_elemets = ( 'rtspsrc location=RTSP latency=300 !' 'rtph264depay !' 'h264parse !' 'omxh264dec enable-max-performance=1 enable-low-outbuffer=1 !' 'nvvidconv ! video/x-raw, format=(string)BGRx!' 'videoconvert !' 'appsink').
cv2.VideoCapture(gstream_elemets, cv2.CAP_GSTREAMER)
The problem caused bucause I input rtsp frame_rate = 25 and I limited to 5-1 FPS in the while loop like this :
While cap.isOpened():
framer = cap.read()[1]
sleep(0.1)
I decide to define frame_rate in the gstreamer elemets like this whitout sleep in while loop:
gstream_elemets = (
'rtspsrc location=RTSP latency=300 !'
'rtph264depay !'
'h264parse !'
'omxh264dec enable-max-performance=1 enable-low-outbuffer=1 !'
'nvvidconv ! video/x-raw, format=(string)BGRx!'
'videorate ! video/x-raw, framerate=(fraction)10/1'
'videoconvert !'
'appsink')
cv2.VideoCapture(gstream_elemets, cv2.CAP_GSTREAMER)
This is also corectly work and ram is fixed but CPU usage is about 2x increased.
My goal is that:
if I input frame_rate is variable like 25, I want to used best pipeline in opencv to get frames in the spesific frame_rate in the output like 10.
at least cpu usage and without memory leakage.