Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

python - Delay/Lag in OpenCV VideoCapture

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:@[email protected]")
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.

question from:https://stackoverflow.com/questions/65683036/delay-lag-in-opencv-videocapture

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...