RTSP流在python上不起作用,但在VLC上起作用。为什么?

问题描述 投票:0回答:1

[我正在尝试让我的PTZ摄像机使用python 3和openCV进行流传输。我在代码中使用的URL适用于VLC流,但不适用于代码。

import cv2
import numpy as np

cap = cv2.VideoCapture(src="rtsp://USER:[email protected]:XXX/Streaming/Channels/101/")
FRAME_WIDTH = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
FRAME_HIGTH = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
print('Frame Size: ', FRAME_WIDTH, 'x', FRAME_HIGTH)

if cap.isOpened():
    ret, frame = cap.read()
else:
    ret = False

while ret:
    ret, frame = cap.read()
    cv2.imshow('Camera', frame)

    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

cap.release()
cv2.destroyAllWindows()

当我运行它时,出现下一个错误:

Traceback (most recent call last):   File "C:/Users/.../CameraTest/TEST.py", line 4, in <module>
    cap = cv2.VideoCapture(src="rtsp://.../Streaming/Channels/101/") TypeError: Required argument 'index' (pos 1) not found

这是HIKVISON PTZ摄像机。请问如何让她直播的任何提示。

预先TNX。

python opencv debugging rtsp ip-camera
1个回答
0
投票

一个小小的改变,从cv2.VideoCapture()方法中删除src =。它应该看起来像,

cap = cv2.VideoCapture("rtsp://USER:[email protected]:XXX/Streaming/Channels/101/")
© www.soinside.com 2019 - 2024. All rights reserved.