使用Opencv和python获取RTSP流 [英] Getting RTSP stream with Opencv and python
问题描述
我知道这可能是第100个此类问题,但是我挖了google和所有内容,但找不到任何有效的方法.
我需要在python中使用opencv
获取RTSP
流,但我没有主意.
这是我到目前为止尝试过的:
I know this could be the 100th question of this kind, but I dug up google and everything, and I could not find anything working.
I need to get an RTSP
stream with opencv
in python, and I'm out of ideas.
Here's what I tried so far:
- 试图与
ffserver
和ffmpeg
进行流传输,但是即使我可以正常工作,我也只能在具有很高延迟的浏览器中看到该流,而不能在opencv
中工作
- 试图通过
ffmpeg
直接流到udp
,但再次没有运气 - 尝试了此脚本,但是我得到的所有内容已损坏,并且无法使用的图片.
- Tried to stream with
ffserver
andffmpeg
but even when I got it working, I could see the stream only in the browser with very high latency, and not working inopencv
- Tried to stream directly to
udp
withffmpeg
but again, no luck - Tried this script, but all I got was corrupted and unusable images.
有什么想法吗?我在Mac OSX Sierra上运行,已经在支持ffmpeg
的情况下编译了OpenCV 3.2.0
,并且正在使用Python 2.7
.
我的cam是一个Sricam SP09,我的RTSP
网址如下:
Any ideas? I'm running on Mac OSX Sierra, I have compiled OpenCV 3.2.0
with ffmpeg
support and I'm using Python 2.7
.
My cam is a Sricam SP09 and my RTSP
url is the following:
rtsp://973704:888888@192.168.1.78:554/onvif1
推荐答案
我遇到了同样的问题. 您也许可以通过一些其他代码来解决它.
I had the same problem. You might be able to solve it with some additional codes.
导入操作系统
os.environ ["OPENCV_FFMPEG_CAPTURE_OPTIONS"] ="rtsp_transport; udp"
os.environ["OPENCV_FFMPEG_CAPTURE_OPTIONS"] = "rtsp_transport;udp"
vcap = cv2.VideoCapture("rtsp://[IP_CAM_ADDRESS]",cv2.CAP_FFMPEG)
vcap = cv2.VideoCapture("rtsp://[IP_CAM_ADDRESS]", cv2.CAP_FFMPEG)
希望对别人有帮助.
这篇关于使用Opencv和python获取RTSP流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!