I am trying to get frames from youtube videoby using cv2.VideoCapture("https://www.youtube.com/watch?v=MNn9qKG2UFI")
But I got this error in that line:
[ERROR:0@35.877] global cap.cpp:166 cv::VideoCapture::open VIDEOIO(CV_IMAGES): raised OpenCV exception:
OpenCV(4.9.0) D:\a\opencv-python\opencv-python\opencv\modules\videoio\src\cap_images.cpp:244: error: (-5:Bad argument) CAP_IMAGES: error, expected '0?[1-9][du]' pattern, got: https://rr5---sn-gqn-h5ql.googlevideo.com/videoplayback?expire=1718740198&ei=hpBxZqz4L-jHhcIPyNij4As&ip=79.116.51.250&id=o-ADaf5LIaX_fmw8x7qkORnOnk8Xd_YcZPAlGO-x7wSd7G&itag=399&aitags=133%2C134%2C135%2C136%2C137%2C160%2C242%2C243%2C244%2C247%2C248%2C278%2C394%2C395%2C396%2C397%2C398%2C399&source=youtube&requiressl=yes&xpc=EgVo2aDSNQ%3D%3D&mh=ie&mm=31%2C29&mn=sn-gqn-h5ql%2Csn-h5qzened&ms=au%2Crdu&mv=m&mvi=5&pl=18&initcwndbps=1551250&bui=AbKP-1Ou_aPDhJ6NbNyODPNnPnMT7SaoPGj_4RtZwL2wwjgy1mE-ytzZSIJZcmmCoNWYkzZ7_LeFnhzV&spc=UWF9f8OSPOaONTAjHWHxTRdKyS6Bjk-dn16MMJs6L8dSe04ZWfev5QD0cUhl&vprv=1&svpuc=1&mime=video%2Fmp4&ns=HE3e8r-pUwRgKyp2br4AEbkQ&rqh=1&gir=yes&clen=39381266&dur=334.400&lmt=1718323461473667&mt=1718718318&fvip=5&keepalive=yes&c=WEB&sefc=1&txp=5537434&n=HxNg9pBnbKvHN4RNaN&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cxpc%2Cbui%2Cspc%2Cvprv%2Csvpuc%2Cmime%2Cns%2Crqh%2Cgir%2Cclen%2Cdur%2Clmt&sig=AJfQdSswRQIgQTnMDTJYo6qSjTzkx6vObJNVEx-lwijLn7Tw2HAY-foCIQCK-ZQTuFQvf2xb-JaLLCsukOQ09AzvNfXYOqhL1721bA%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AHlkHjAwRQIhAK47l0DUWd7OGEZJ3MPibXYOMZtGQ9LHWo5sn_mcLQKrAiBhga8vE5GIee3IEzBNykiGW_nuQEZvdqF1908CwCq0Aw%3D%3D&ratebypass=yes in function 'cv::icvExtractPattern'
My code is this:
check_requirements(('pafy', 'youtube_dl==2020.12.2'))
import pafy
s = pafy.new(source).getbest(preftype='mp4').url
self.cap = cv2.VideoCapture(s)
self.q = queue.Queue()
t = threading.Thread(target=self._reader)
t.daemon = True
t.start()
I would like to have your help
Thank you in advance