How to read Youtube live stream using openCV python?

I want to read a direct stream from youtube to do some basic CV stuff, maybe we need to remove the youtube url somehow to convert it to a format that can be read by openCV like ?:

cap = cv2.VideoCapture('https://www.youtube.com/watch?v=_9OBhtLA9Ig')

Has anyone done this?

+3


source to share


1 answer


I'm sure you already know the answer, but I'll be in charge of others looking for the same topic. You can do this using Pafy. First you need 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 it should be.

+1


source







All Articles