vidgear: CamGear :: ERROR :: 'thumbnails' in youtube mode
Description
I get a , thumbnails, error when I use camgear to play youtube videos. I also got the same error when I tried it with older vidgear versions
Acknowledgment
- I have searched the issues for my issue and found nothing related or helpful.
- I have read the Documentation.
- I have read the Issue Guidelines.
Environment
- VidGear version: 0.1.8
- Branch:
- Python version: 3.6
- pip version: 9.0.1
- Operating System and version: Ubuntu 18.04
Expected Behavior
Opencv to play youtube video stream
Actual Behavior
CamGear :: ERROR :: ‘thumbnails’ Traceback (most recent call last): File “/home/gdfutbos/.local/lib/python3.6/site-packages/vidgear/gears/camgear.py”, line 92, in init source_object = pafy.new(url) File “/home/gdfutbos/.local/lib/python3.6/site-packages/pafy/pafy.py”, line 124, in new return Pafy(url, basic, gdata, size, callback, ydl_opts=ydl_opts) File “/home/gdfutbos/.local/lib/python3.6/site-packages/pafy/backend_youtube_dl.py”, line 31, in init super(YtdlPafy, self).init(*args, **kwargs) File “/home/gdfutbos/.local/lib/python3.6/site-packages/pafy/backend_shared.py”, line 97, in init self._fetch_basic() File “/home/gdfutbos/.local/lib/python3.6/site-packages/pafy/backend_youtube_dl.py”, line 57, in _fetch_basic self._bestthumb = self._ydl_info[‘thumbnails’][0][‘url’] KeyError: ‘thumbnails’ Traceback (most recent call last): File “/home/gdfutbos/.local/lib/python3.6/site-packages/vidgear/gears/camgear.py”, line 92, in init source_object = pafy.new(url) File “/home/gdfutbos/.local/lib/python3.6/site-packages/pafy/pafy.py”, line 124, in new return Pafy(url, basic, gdata, size, callback, ydl_opts=ydl_opts) File “/home/gdfutbos/.local/lib/python3.6/site-packages/pafy/backend_youtube_dl.py”, line 31, in init super(YtdlPafy, self).init(*args, **kwargs) File “/home/gdfutbos/.local/lib/python3.6/site-packages/pafy/backend_shared.py”, line 97, in init self._fetch_basic() File “/home/gdfutbos/.local/lib/python3.6/site-packages/pafy/backend_youtube_dl.py”, line 57, in _fetch_basic self._bestthumb = self._ydl_info[‘thumbnails’][0][‘url’] KeyError: ‘thumbnails’
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File “testvidgear.py”, line 6, in <module> stream = CamGear(source=‘https://youtu.be/dQw4w9WgXcQ’, y_tube=True, logging=True).start() File “/home/gdfutbos/.local/lib/python3.6/site-packages/vidgear/gears/camgear.py”, line 116, in init “[CamGear:ERROR] :: YouTube Mode is enabled and the input YouTube URL is invalid!” ValueError: [CamGear:ERROR] :: YouTube Mode is enabled and the input YouTube URL is invalid!
Steps to reproduce
from vidgear.gears import CamGear
import cv2
stream = CamGear(source='https://youtu.be/dQw4w9WgXcQ', y_tube=True, logging=True).start()
while True:
frame = stream.read()
if frame is None:
break
cv2.imshow("Output Frame", frame)
key = cv2.waitKey(1) & 0xFF
if key == ord("q"):
break
cv2.destroyAllWindows()
stream.stop()
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 3
- Comments: 20 (7 by maintainers)
Seems they have changed something important in youtube-dl, so consider to update youtube-dl https://github.com/ytdl-org/youtube-dl/blob/master/README.md#how-do-i-update-youtube-dl
Use VPN.
@fspider It is a bug in FFmpeg provided by OpenCV. And only possible workaround for this bug is: https://github.com/abhiTronix/vidgear/issues/133#issuecomment-638567443