gpt4 book ai didi

python - 几帧后,OpenCV HLS youtube流停止

转载 作者:行者123 更新时间:2023-12-03 05:34:44 46 4
gpt4 key购买 nike

我正在尝试使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()

最佳答案

我也确实遇到了来自YouTube的实时HSL流的问题。
我确实使用了以下方法:
https://github.com/streamlink/streamlink/issues/857
在这种情况下,我使用streamlink来制作文件/ tmp / stream。
使用opencv,我正在读取文件/ tmp / stream。
(缺点:您必须停止流,否则文件变大)

关于python - 几帧后,OpenCV HLS youtube流停止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58527145/

46 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com