Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I want to get the live stream from youtube, and for that, I have used opencv along with the package vidgear. But while running the code, I am getting the following error. I am sure that there is no problem with the URL. I have tried with pafy and streamlink. Even though both have given the result but after few frames, it was getting stuck and I want sequential frames without any pause. #23

Closed
adithya6aj opened this issue Jun 17, 2019 · 3 comments
Labels
DUPLICATE ♻️ Similar issue or PR already exists SOLVED 🏁 This issue/PR is resolved now. Goal Achieved!

Comments

@adithya6aj
Copy link

import cv2
from vidgear.gears import CamGear
stream = CamGear(source="https://www.youtube.com/watch?v=VIk_6OuYkSo", y_tube =True, time_delay=1, logging=True).start() # YouTube Video URL as input

while True:

frame = stream.read()
if frame is None:
    break

cv2.imshow("Output Frame", frame)


key = cv2.waitKey(30) 

if key == ord("q"):

    break

cv2.destroyAllWindows()
stream.stop()

'NoneType' object has no attribute 'extension'
Traceback (most recent call last):
File "C:\Users\CamfyVision\AppData\Local\Programs\Python\Python36\lib\site-packages\vidgear\gears\camgear.py", line 120, in init
print('Extension: {}'.format(_source.extension))
AttributeError: 'NoneType' object has no attribute 'extension'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "DronrStream.py", line 4, in
stream = CamGear(source="https://www.youtube.com/watch?v=VIk_6OuYkSo", y_tube =True, time_delay=1, logging=True).start() # YouTube Video URL as input
File "C:\Users\CamfyVision\AppData\Local\Programs\Python\Python36\lib\site-packages\vidgear\gears\camgear.py", line 125, in init
raise ValueError('YouTube Mode is enabled and the input YouTube Url is invalid!')

@abhiTronix abhiTronix added the DUPLICATE ♻️ Similar issue or PR already exists label Jun 17, 2019
@abhiTronix
Copy link
Owner

abhiTronix commented Jun 17, 2019

@adithya6aj This issue is already been Solved in commit 03ec554 . Kindly see issue #16 and its solution is in my comment.

@abhiTronix abhiTronix added the WAITING TO TEST ⏲️ Asked user to test the suggested example/binary/solution label Jun 17, 2019
@abhiTronix abhiTronix added SOLVED 🏁 This issue/PR is resolved now. Goal Achieved! and removed WAITING TO TEST ⏲️ Asked user to test the suggested example/binary/solution labels Jun 17, 2019
@abhiTronix
Copy link
Owner

Closed. Feel free to reopen if something related doesn't work for you.

@abhiTronix
Copy link
Owner

abhiTronix commented Dec 4, 2021

@adithya6aj I think #274 resolves this issue too.

Clone and Install development branch:

  # clone the repository and get inside
  git clone https://github.com/abhiTronix/vidgear.git && cd vidgear

  # checkout the latest development branch
  git checkout development

  # install normally
  pip install .[core]

  # OR install with asyncio support
  pip install .[asyncio]

Test your code:

# import required libraries
from vidgear.gears import CamGear
import cv2

options = {"STREAM_RESOLUTION": "720p"}

# Add YouTube Video URL as input source (for e.g https://youtu.be/bvetuLwJIkA)
# and enable Stream Mode (`stream_mode = True`)
stream = CamGear(
    source="https://youtu.be/j1GLs_fMn1s", stream_mode=True, logging=True, **options
).start()

# loop over
while True:

    # read frames from stream
    frame = stream.read()

    # check for frame if Nonetype
    if frame is None:
        break

    # {do something with the frame here}

    # Show output window
    cv2.imshow("Output", frame)

    # check for 'q' key if pressed
    key = cv2.waitKey(1) & 0xFF
    if key == ord("q"):
        break

# close output window
cv2.destroyAllWindows()

# safely close video stream
stream.stop()

@abhiTronix abhiTronix reopened this Dec 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DUPLICATE ♻️ Similar issue or PR already exists SOLVED 🏁 This issue/PR is resolved now. Goal Achieved!
Projects
None yet
Development

No branches or pull requests

2 participants