Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
305 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.


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

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...