opencv读取rtsp流(python)
使用opencv读取rtsp流方法,因其简单将不在解释:
import cv2 def read_rtsp(): cap = cv2.VideoCapture('rtsp://admin:Vrc123456@192.168.2.226:554') fourcc = cv2.VideoWriter_fourcc(*'XVID') size = (int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)), int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))) out = cv2.VideoWriter('./rtsp_video.avi', fourcc,10.0, size) while True: ret, frame = cap.read() out.write(frame) cv2.imshow('frame', frame) cv2.waitKey(1) cap.release() out.release() cv2.destroyAllWindows() if __name__ == '__main__': read_rtsp()