• Hardware Platform (Jetson / GPU) ORIN
• DeepStream Version 7.1
• JetPack Version (valid for Jetson only) 6.2
• TensorRT Version 10.3.0.30
• NVIDIA GPU Driver Version (valid for GPU only)
When using capture-main.py for RTSP stream retrieval:
- Successful stream capture occurs when using avdec_h264 decoder
- Failure occurs when using nvv4l2decoder
capture-main.py is shown below
import cv2
import time
def capture():
# 启动拉流
url = "rtsp://192.168.137.1:554/1"
gst_str = (
'rtspsrc location={} latency=200 protocols=4 '
'! rtph264depay '
'! h264parse '
'! nvv4l2decoder enable-max-performance=1 '
'! nvvidconv output-buffers=2 '
'! video/x-raw, format=BGRx '
'! videoconvert '
'! video/x-raw, format=BGR '
'! appsink drop=true sync=false max-buffers=10'
).format(url)
#gst_str = (
# 'rtspsrc location={} latency=200 protocols=4 '
# '! rtph264depay '
# '! h264parse '
# '! avdec_h264 '
# '! nvvidconv output-buffers=2 '
# '! video/x-raw, format=BGRx '
# '! videoconvert '
# '! video/x-raw, format=BGR '
# '! appsink drop=true sync=false max-buffers=10'
#).format(url)
cap = None
frame_num = 0
while True:
print("before VideoCapture")
#cap = cv2.VideoCapture(url) #OK
cap = cv2.VideoCapture(gst_str, cv2.CAP_GSTREAMER)
print("after VideoCapture")
flag = True if cap.isOpened() else False
# ret, img = cap.read()
if flag:
print('VideoCapture success')
else:
print('VideoCapture failed')
cap.release()
time.sleep(0.1)
continue
while(flag):
flag, img = cap.read()
# logger.debug("Pantographs structure analysis, time %f" % (time.time() - time_start1))
# 执行分析
if img is None:
print('>>> Image data is None , drop it !')
time.sleep(0.001)
continue
print("cap.read")
frame_num += 1
#analysis(frame_num, img) # 输入帧号和图片信息
if frame_num ==2000:
return
cap.release()
if __name__ == '__main__':
capture()
using avdec_h264
using nvv4l2decoder
please help me solve this problem,thank you

