我正在尝试让 Youtube 直播流与 openCV 一起使用,但在 10 帧后它只是停止并在 2 分钟后重新启动。
错误信息:
[tls @ 000001676fa27400] Unable to read from socket
[tls @ 000001676fa27400] Writing encrypted data to socket failed
[tls @ 000001676fa27400] Failed to send close message
使用的代码:
import cv2
import pafy
url = 'https://youtube.com/watch?v=51djMAqsmIQ'
vPafy = pafy.new(url)
play = vPafy.getbest()
print(play.url)
cap = cv2.VideoCapture(play.url)
while (True):
ret,frame = cap.read()
cv2.imshow('frame',frame)
if cv2.waitKey(20) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()