
python打开rtsp视频流
【代码】python打开rtsp视频流。
·
import cv2
def open_rtsp_stream(rtsp_url):
cap = cv2.VideoCapture(rtsp_url)
if not cap.isOpened():
print(f"Error: Unable to open RTSP stream at {rtsp_url}")
return
while True:
ret, frame = cap.read()
if not ret:
print("Error: Failed to read frame from the RTSP stream")
break
cv2.imshow('RTSP Stream', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
if __name__ == "__main__":
# 替换为你的RTSP视频流地址
i=input("请输入:")
rtsp_url = i
open_rtsp_stream(rtsp_url)
更多推荐
所有评论(0)