Is it possible to stream video from https:// (e.g. YouTube) into python with OpenCV?

后端 未结 4 533
囚心锁ツ
囚心锁ツ 2020-12-13 20:09

This link has a tidy little example of how to use python\'s OpenCV library, cv2 to stream data from a camera into your python shell. I\'m looking to do some exp

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-13 20:51

    it is possible with pafy (https://pypi.python.org/pypi/pafy)

    import cv2, pafy
    
    url = "https://www.youtube.com/watch?v=aKX8uaoy9c8"
    videoPafy = pafy.new(url)
    best = videoPafy.getbest(preftype="webm")
    
    video=cv2.VideoCapture(best.url)
    

提交回复
热议问题