I'm trying to read an rtsp stream from an ip camera using opencv's VideoCapture Class on Ubuntu 20.04 with opencv 4.5. There is a lag in the video on ubuntu but none when I run the same code on a windows 10 machine.
cap.set(cv2.CAP_PROP_BUFFERSIZE, size)
returns false and the cameras default buffer size does not change.
cap = cv2.VideoCapture("rtsp://admin:@dmin123@192.168.1.64")
while (cap.isOpened()):
ret, frame = cap.read()
cv2.imshow("Live", frame)
if cv2.waitKey(1) & 0xFF == ord('q'): #press q to quit
break
cap.release()
The stream works well when I play it using ffplay with the following parameters:
'''ffplay -fflags nobuffer -flags low_delay -tune zerolatency -framedrop -rtsp_transport tcp "rtsp://192.168.1.64"'''
Need help on how to reduce/handle the lag in my code.