Created
October 22, 2018 20:36
-
-
Save Mxhmovd/41e7690114e7ddad8bcd761a76272cc3 to your computer and use it in GitHub Desktop.
Read Youtube videos with OpenCV without downloading it locally.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pip install pafy | |
#sudo pip install --upgrade youtube_dl | |
import cv2, pafy | |
url = "https://www.youtube.com/watch______" | |
video = pafy.new(url) | |
best = video.getbest(preftype="webm") | |
#documentation: https://pypi.org/project/pafy/ | |
capture = cv2.VideoCapture(best.url) | |
check, frame = capture.read() | |
print (check, frame) | |
cv2.imshow('frame',frame) | |
cv2.waitKey(10) | |
capture.release() | |
cv2.destroyAllWindows() |
Which would be faster, reading from the URL or reading from the downloaded video?
raise IOError(str(e).replace('YouTube said', 'Youtube says'))
OSError: ERROR: Unable to extract uploader id; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see https://yt-dl.org/update on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
I am getting this error.
I am getting the same error mentioned by @imvickykumar999
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
only video is being played through this code....what about the audio ?? I am new to opencv can you please tell how to play the audio too with the youtube video ?