我需要通过python中的CV2从YT读取实时流,以下代码对于youtube视频正常工作,但是当链接到youtube实时流时出现错误消息。
from vidgear.gears import CamGear
import cv2
url = 'https://youtu.be/pZiQuaTLJ48'
stream = CamGear(source=url, y_tube =True, time_delay=0, logging=True).start() # YouTube Video URL as input
while True:
frame = stream.read()
if frame is None:
break
b = cv2.resize(frame, (800, 600), fx=0, fy=0, interpolation=cv2.INTER_CUBIC)
cv2.imshow("LiveVid", b)
key = cv2.waitKey(1) & 0xFF
if key == ord("q"):
break
cv2.destroyAllWindows()
stream.stop()
任何帮助都很感激。