From 24e49b72180c9e74312f5141f151782e1932627a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=80=E5=96=B5?= Date: Tue, 30 Jun 2026 17:13:39 +0800 Subject: [PATCH] =?UTF-8?q?2026.6.30=E5=B0=8F=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- videotest.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 videotest.py diff --git a/videotest.py b/videotest.py new file mode 100644 index 0000000..ab54a20 --- /dev/null +++ b/videotest.py @@ -0,0 +1,20 @@ +import cv2 +import os + +os.environ['OPENCV_FFMPEG_CAPTURE_OPTIONS'] = 'rtsp_transport;tcp' + +# 改用正确的地址 +rtsp_url = "rtsp://192.168.144.25:8554/main.264" + +print(f"[测试] 正在尝试连接: {rtsp_url}") +cap = cv2.VideoCapture(rtsp_url, cv2.CAP_FFMPEG) + +if not cap.isOpened(): + print("[结果] 无法打开视频流。") +else: + ret, frame = cap.read() + if not ret or frame is None: + print("[结果] 读取帧失败,视频流可能为空。") + else: + print(f"[结果] 成功读取第一帧!图像尺寸为: {frame.shape}") + cap.release() \ No newline at end of file