问题
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')
has anyone done it?
回答1:
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
Then add this
url = "https://www.youtube.com/watch?v=_9OBhtLA9Ig"
video = pafy.new(url)
best = video.getbest(preftype="mp4")
capture = cv2.VideoCapture()
capture.open(best.url)
And that should be it.
来源:https://stackoverflow.com/questions/43032163/how-to-read-youtube-live-stream-using-opencv-python