【问题标题】:OpenCV HLS youtube stream stops after a couple framesOpenCV HLS youtube 流在几帧后停止
【发布时间】:2020-02-19 22:54:07
【问题描述】:

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

【问题讨论】:

  • 你解决过这个问题吗?

标签: python opencv youtube http-live-streaming pafy


【解决方案1】:

我在 youtube 的实时 HSL 流中也遇到了这个问题。

我确实使用了解决方法:

https://github.com/streamlink/streamlink/issues/857

在这种情况下,我使用 streamlink 创建文件 /tmp/stream. 使用 opencv 我正在读取文件 /tmp/stream..

(缺点:你必须停止流,否则文件会变大)

【讨论】:

    猜你喜欢
    • 2013-07-05
    • 1970-01-01
    • 2018-10-22
    • 2017-04-08
    • 1970-01-01
    • 2021-04-08
    • 1970-01-01
    • 2019-09-25
    • 2012-09-18
    相关资源
    最近更新 更多