Streaming the output of openCV real-time as an RTSP stream with ffmpeg

asked 2015-03-09 17:13:14 -0600

ourChariot gravatar image

I receive an RTSP video stream from an IP camera into my OpenCV program, which I then process for pedestrian detection; I now want to send the video comprising of bounding boxes around people detected as an rtsp stream over the network.

I am trying to use ffmpeg to do this; I can write the video using OpenCV video writer and also stream video file using ffmpeg as an rtsp stream, but I am unable to do both of this simultaneously so that it is real-time.

Most search results talk about how to receive an RTSP stream into OpenCV and I have not found much help in this regard.

edit retag flag offensive close merge delete


Well basically this is because when writing away frames, OpenCV treats your output as an object and locks it. So the RTSP stream cannot read from it before OpenCV releases its lock on it. Maybe using seperate threads could be the solution here?

StevenPuttemans gravatar imageStevenPuttemans ( 2015-03-10 05:33:18 -0600 )edit

Hi sir! How can you stream the video out by using VideoWriter, I cannot open the output stream, error in while open. Thanks

BAHRAMUDIN ADIL gravatar imageBAHRAMUDIN ADIL ( 2017-10-30 04:49:34 -0600 )edit

I would suggest you to open your own question, since reviving old ones will not help you get your answer faster :)

StevenPuttemans gravatar imageStevenPuttemans ( 2017-10-31 04:46:31 -0600 )edit