i try to use gstreamer to read rstp without latency as below:
import cv2
url = "rtsp://admin:abcd1234@192.168.1.104:554/Streaming/Channels/101?transportmode=mcast&profile=Profile_1"
pipeline = 'rtspsrc location=%s latency=0 ! decodebin ! ' % url
cvt_pipeline = (
'videoscale ! '
'video/x-raw, width=(int)%d, height=(int)%d !'
'videoconvert ! appsink sync=false'
% (1920, 1080)
)
cap = cv2.VideoCapture(pipeline + cvt_pipeline, cv2.CAP_GSTREAMER)
while True:
ret,frame = cap.read()
if not ret:
print('empty frame')
continue
it is work, but it use cpu too much.
i find out that, i can use gstreamer with nvcodec. (Install NVDEC and NVENC as GStreamer plugins · GitHub)
but don’t know how to implement it. Could you guide me to do it?