IP摄像机RTSP连接问题



我有flir blackfly的bfs- page -04s2c-cs型网络摄像机。我有poe注入器,连接到路由器和相机。我可以找到相机ip。我的问题是无法连接rtsp。

使用EasyPySpin,我可以用下面的代码得到一个框架。

import cv2
import EasyPySpin
cap = EasyPySpin.VideoCapture(0)
print(cap.get(0))
for i in range(100):
ret, frame = cap.read()
cv2.imwrite("frame.png", frame)

cap.release()

我需要rtsp连接我的其他进程,ip在我的系统中显示与匹配的mac地址。我试过了

import cv2
import os
RTSP_URL = 'rtsp://192.168.1.240'
os.environ['OPENCV_FFMPEG_CAPTURE_OPTIONS'] = 'rtsp_transport;udp'
cap = cv2.VideoCapture(RTSP_URL, cv2.CAP_FFMPEG)
if not cap.isOpened():
print('Cannot open RTSP stream')
exit(-1)
while True:
_, frame = cap.read()
print('hehe')
cv2.imshow('RTSP stream', frame)
if cv2.waitKey(1) == 27:
break
cap.release()
cv2.destroyAllWindows()

我无法连接此代码。

要验证RTSP绑定是否正确,请使用第三方应用程序。在我的情况下,我使用"VLC媒体播放器"。如果你有正确的链接,但它在Python中不起作用,检查你是否下载了ffmpeg。对我来说,这就是问题所在。

原来Blackfly S GigE不支持rtsp流。它使用GVSP, GVSP是一种用于大数据流的协议。

我用Go语言手工创建了一个简单的rtsp服务器,然后使用gstreamer管道和aravis插件。

gst-launch-1.0 aravissrc ! video/x-raw,format=RGB ! videoconvert !  video/x-raw,format=I420 ! x264enc speed-preset=ultrafast ! rtspclientsink protocols=tcp location=rtsp://localhost:8554/flir

最新更新