ValueError: [CamGear:ERROR] :: Stream Mode is enabled but Input URL is invalid! [Bug]:
Closed this issue · 3 comments
Description
When I try to read YouTube video I am getting following errors even with valid YouTube video links.
Traceback (most recent call last):
File "D:\github codes\deepds\test_file.py", line 25, in <module>
stream = CamGear(
File "D:\github codes\deepds\make_dataset\lib\site-packages\vidgear\gears\camgear.py", line 310, in __init__
raise ValueError(
ValueError: [CamGear:ERROR] :: Stream Mode is enabled but Input URL is invalid!
My code looks like following
from vidgear.gears import CamGear
import cv2
stream = CamGear(
source="https://www.youtube.com/watch?v=7lDpCPsLcQg",
stream_mode=True,
logging=True,
).start()
while True:
frame = stream.read()
if frame is None:
break
cv2.imshow("Output", frame)
# check for 'q' key if pressed
key = cv2.waitKey(1) & 0xFF
if key == ord("q"):
break
cv2.destroyAllWindows()
stream.stop()
I previously used this amazing library in my cli script to download frames from YouTube. This Code was working fine. Now its not working anymore. I am using this library in one of my open source projects but Invalid URL error is appearing every time I try with new URLS (although URLs are valid). I can not track the origin of this error.
Issue Checklist
- I have searched open or closed issues for my problem and found nothing related or helpful.
- I have read the Documentation and found nothing related to my problem.
- I've read the Issue Guidelines and wholeheartedly agree.
Expected behaviour
The code should display the YouTube video captures using VidGear and display using OpenCV
Actual behaviour
The program thinks the URLs are invalid. Although I am providing valid URLs for displaying the YouTube videos. When the URL is valid so the code should display the frames but it is not executing as expected so I think this is an internal bug in CamGear.
Steps to reproduce
- After installation of OpenCV and VidGear run following code
from vidgear.gears import CamGear
import cv2
stream = CamGear(
source="https://www.youtube.com/watch?v=7lDpCPsLcQg",
stream_mode=True,
logging=True,
).start()
while True:
frame = stream.read()
if frame is None:
break
cv2.imshow("Output", frame)
# check for 'q' key if pressed
key = cv2.waitKey(1) & 0xFF
if key == ord("q"):
break
cv2.destroyAllWindows()
stream.stop()
Terminal log output
(make_dataset) PS D:\github codes\deepds> python .\test_file.py
08:02:22 :: Helper :: INFO :: Running VidGear Version: 0.3.0
08:02:22 :: Helper :: WARNING :: GStreamer not found!
08:02:22 :: Helper :: DEBUG :: Selecting `best` resolution for streams.
08:02:22 :: CamGear :: INFO :: Verifying Streaming URL using yt-dlp backend. Please wait...
ERROR: [youtube] WX7bNiLofIA: Unable to extract uploader id; please report this issue on https://github.com/yt-dlp/yt-dlp/issues?q= , filling out the appropriate issue template. Confirm you are on the latest version using yt-dlp -U
Traceback (most recent call last):
File "D:\github codes\deepds\make_dataset\lib\site-packages\yt_dlp\YoutubeDL.py", line 1502, in wrapper
return func(self, *args, **kwargs)
File "D:\github codes\deepds\make_dataset\lib\site-packages\yt_dlp\YoutubeDL.py", line 1578, in __extract_info
ie_result = ie.extract(url)
File "D:\github codes\deepds\make_dataset\lib\site-packages\yt_dlp\extractor\common.py", line 680, in extract
ie_result = self._real_extract(url)
File "D:\github codes\deepds\make_dataset\lib\site-packages\yt_dlp\extractor\youtube.py", line 4049, in _real_extract
'uploader_id': self._search_regex(r'/(?:channel|user)/([^/?&#]+)', owner_profile_url, 'uploader id') if owner_profile_url else None,
File "D:\github codes\deepds\make_dataset\lib\site-packages\yt_dlp\extractor\common.py", line 1228, in _search_regex
raise RegexNotFoundError('Unable to extract %s' % _name)
yt_dlp.utils.RegexNotFoundError: [youtube] WX7bNiLofIA: Unable to extract uploader id; please report this issue on https://github.com/yt-dlp/yt-dlp/issues?q= , filling out the appropriate issue template. Confirm you are on the latest version using yt-dlp -U
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\github codes\deepds\make_dataset\lib\site-packages\vidgear\gears\camgear.py", line 146, in __extract_meta
extracted_data = ydl.extract_info(self.source_url, download=False)
File "D:\github codes\deepds\make_dataset\lib\site-packages\yt_dlp\YoutubeDL.py", line 1491, in extract_info
return self.__extract_info(url, self.get_info_extractor(key), download, extra_info, process)
File "D:\github codes\deepds\make_dataset\lib\site-packages\yt_dlp\YoutubeDL.py", line 1520, in wrapper
self.report_error(str(e), e.format_traceback())
File "D:\github codes\deepds\make_dataset\lib\site-packages\yt_dlp\YoutubeDL.py", line 1012, in report_error
self.trouble(f'{self._format_err("ERROR:", self.Styles.ERROR)} {message}', *args, **kwargs)
File "D:\github codes\deepds\make_dataset\lib\site-packages\yt_dlp\YoutubeDL.py", line 952, in trouble
raise DownloadError(message, exc_info)
yt_dlp.utils.DownloadError: ERROR: [youtube] WX7bNiLofIA: Unable to extract uploader id; please report this issue on https://github.com/yt-dlp/yt-dlp/issues?q= , filling out the appropriate issue template. Confirm you are on the latest version using yt-dlp -U
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\github codes\deepds\make_dataset\lib\site-packages\vidgear\gears\camgear.py", line 270, in __init__
ytbackend = YT_backend(
File "D:\github codes\deepds\make_dataset\lib\site-packages\vidgear\gears\camgear.py", line 108, in __init__
self.meta_data = self.__extract_meta()
File "D:\github codes\deepds\make_dataset\lib\site-packages\vidgear\gears\camgear.py", line 149, in __extract_meta
raise RuntimeError(" [Backend] : " + str(e))
RuntimeError: [Backend] : ERROR: [youtube] WX7bNiLofIA: Unable to extract uploader id; please report this issue on https://github.com/yt-dlp/yt-dlp/issues?q= , filling out the appropriate issue template. Confirm you are on the latest version using yt-dlp -U
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\github codes\deepds\test_file.py", line 25, in <module>
stream = CamGear(
File "D:\github codes\deepds\make_dataset\lib\site-packages\vidgear\gears\camgear.py", line 310, in __init__
raise ValueError(
ValueError: [CamGear:ERROR] :: Stream Mode is enabled but Input URL is invalid!
### Python Code(Optional)
```python
from vidgear.gears import CamGear
import cv2
stream = CamGear(
source="https://www.youtube.com/watch?v=7lDpCPsLcQg",
stream_mode=True,
logging=True,
).start()
while True:
frame = stream.read()
if frame is None:
break
cv2.imshow("Output", frame)
# check for 'q' key if pressed
key = cv2.waitKey(1) & 0xFF
if key == ord("q"):
break
cv2.destroyAllWindows()
stream.stop()
VidGear Version
0.3.0
Python version
3.9.0
OpenCV version
4.7.0.68
Operating System version
Windows 11 Pro with OS Build 21996.1
Any other Relevant Information?
#133 suggests to use different backend but I think the issue is not with the backend as the error suggests that URL is invalid.
Thanks for opening this issue, a maintainer will get back to you shortly!
In the meantime:
- Read our Issue Guidelines, and update your issue accordingly. Please note that your issue will be fixed much faster if you spend about half an hour preparing it, including the exact reproduction steps and a demo.
- Go comprehensively through our dedicated FAQ & Troubleshooting section.
- For any quick questions and typos, please refrain from opening an issue, as you can reach us on Gitter community channel.
@qaixerabbas this is a old bug yt-dlp/yt-dlp#6247 (comment) and already fixed. Kindly update your yt-dlp installation.
pip install -U yt-dlp
@abhiTronix thanks for the comment. I was previously trying to upgrade but it was not working. I upgraded it yt-dlp installation and it works fine now. Thanks.