如何使用openCV python阅读Youtube实时流? [英] How to read Youtube live stream using openCV python?
本文介绍了如何使用openCV python阅读Youtube实时流?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从youtube读取实时流以执行一些基本的CV事情,可能我们必须以某种方式剥离youtube URL才能将其转换为openCV可以读取的格式,例如?:
I want to read a live stream from youtube to perform some basic CV things, probably we have to somehow strip of the youtube URL to convert it in a format that might be readable by openCV like?:
cap = cv2.VideoCapture('https://www.youtube.com/watch?v=_9OBhtLA9Ig')
有人做过吗?
推荐答案
我确定您现在已经知道答案了,但是我将为其他搜索相同主题的人解答.您可以使用Pafy做到这一点.首先你需要
import pafy
I am sure you already know the answer by now, but I will answer for others searching the same topic. You can do this by using Pafy. First you need to
import pafy
然后添加此
url = "https://www.youtube.com/watch?v=_9OBhtLA9Ig"
video = pafy.new(url)
best = video.getbest(preftype="mp4")
capture = cv2.VideoCapture()
capture.open(best.url)
应该就是这样.
这篇关于如何使用openCV python阅读Youtube实时流?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文