python链接海康摄像头,并以弹出框的方式播放实时视频流,
这种方式是以弹出框的形式播放。本地测试可以,实际业务场景不建议使用。可以采用rtsp转rtmp的方式
@shared_task def parse_video(rtsp_address=None): winname = 'Video' if not rtsp_address: raise exceptions.ParseError('摄像头rstp地址错误!') cap = cv2.VideoCapture(rtsp_address) if not cap.isOpened(): raise exceptions.ParseError('视频播放失败!') while cap.isOpened(): ret, frame = cap.read() if not ret: break cv2.putText(frame, 'Please press "ESC" to close the window', (900, 20), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (55, 255, 155), 1) cv2.imshow(winname, frame) k = cv2.waitKey(1) if cv2.getWindowProperty(winname, cv2.WND_PROP_AUTOSIZE) < 1: break if k == 27: break cap.release() cv2.destroyAllWindows()
Mac 安装nginx-rtmp
https://blog.csdn.net/fy_java1995/article/details/98942718