首页 > 其他分享 >读取视频流

读取视频流

时间:2023-02-14 13:44:35浏览次数:35  
标签:读取 stream read 视频流 cv2 URL import

读取视频流

从网站读取

import cv2 # opencv2 package for python.
import pafy # pafy allows us to read videos from youtube.
URL = "https://www.youtube.com/watch?v=dQw4w9WgXcQ" #URL to parse
play = pafy.new(self._URL).streams[-1] #'-1' means read the lowest quality of video.
assert play is not None # we want to make sure their is a input to read.
stream = cv2.VideoCapture(play.url) #create a opencv video stream.

从摄像头读取

import cv2
stream = cv2.VideoCapture(0) # 0 means read from local camera.

从IP摄像头读取

import cv2
camera_ip = "rtsp://username:password@IP/port"
stream = cv2.VideoCapture(camera_ip)

标签:读取,stream,read,视频流,cv2,URL,import
From: https://www.cnblogs.com/mlxpp/p/17119288.html

相关文章