3

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:

  • Tried to stream with ffserver and ffmpeg but even when I got it working, I could see the stream only in the browser with very high latency, and not working in opencv
  • Tried to stream directly to udp with ffmpeg but again, no luck
  • Tried this script, but all I got was corrupted and unusable images.

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:[email protected]:554/onvif1

2
  • We used to make do with just cap=cv2.VideoCapture("rtsp://link_here"). But if it wasn't good on ffserver, it seems like your stream doesn't work quite well. Commented May 3, 2017 at 1:17
  • I've read that opencv does not behave quite well with the rtsp protocol, hence the need to use ffserver. I'm convinced that I'm doing something wrong with ffserver, because often I cannot see the stream on my browser too :/ Commented May 3, 2017 at 8:01

1 Answer 1

1

I had the same problem. You might be able to solve it with some additional codes.

import os

os.environ["OPENCV_FFMPEG_CAPTURE_OPTIONS"] = "rtsp_transport;udp"

vcap = cv2.VideoCapture("rtsp://[IP_CAM_ADDRESS]", cv2.CAP_FFMPEG)

Hope to be helpful to somebody.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.