Skip to content

Instantly share code, notes, and snippets.

@Mxhmovd
Created October 22, 2018 20:36
Show Gist options
  • Save Mxhmovd/41e7690114e7ddad8bcd761a76272cc3 to your computer and use it in GitHub Desktop.
Save Mxhmovd/41e7690114e7ddad8bcd761a76272cc3 to your computer and use it in GitHub Desktop.
Read Youtube videos with OpenCV without downloading it locally.
#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()
@ovshake
Copy link

ovshake commented Nov 2, 2022

Which would be faster, reading from the URL or reading from the downloaded video?

@imvickykumar999
Copy link

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.

@msloan10
Copy link

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