how to stream h264 video with rtsp in opencv- partially answered
I've been struggling with this for a few months now and thought I should consolidate my efforts and "research" into this question all in one place. Mainly I am doing this to help those that have this issue or will face it in the future, so they don't have to waste valuable time.
It appears that others have struggled as well, since OpenCV uses ffmpeg library for rtsp and such, but has decoding errors for at least h264 video streaming (See link1, link2, link3 for some examples of broken images).
I have multiple IP cameras that I connected to a switch, and then need to process the video feeds through the rtsp commands that was given by the camera manufacturer: "rtsp://username:[email protected]:554" (Here, 554 is the RTSP port number assigned to the camera, which may require you to go an adjust the number by logging into the camera and accessing the camera settings)
I wanted to use my OpenCV code but could not just use: VideoCapture cap1("rtsp://username:[email protected]:554"); or, cap1.open("rtsp://username:[email protected]:554"); because of the broken video feeds from FFMPEG as explained above.
Trying to do the TCP protocol instead of UDP may have fixed the issue for others, but this is already incorporated in the latest versions of OpenCV (it was for 2.4.11. and a new update should fix it for 3.0.0; see this bug report) and did not work for me.
I will shortly post some solutions I've come up with, that will hopefully help others in similar struggles. I just have to wait 2 days according to the site rules.
may be a pull request would be better
Hi #LBerger, what is a pull request and how do you do one?
If your code is really good you can share it here but you can propose that your code will be insert in github (a pull request). That's not very difficult. You can follow this or this post. You can see some new pull request here
Thanks LBerger! That is a great option, thanks for letting me know! Mine is how to get all the pieces and integration done, not necessarily a source code to solve it all. The source code that I do use is online, so I reference that, but mostly it's about all the troubleshooting I had to go through to get libVLC installed, integrated, and talking with OpenCV on MS Visual Studio for a Windows machine. Nothing great, but thought it would be helpful for others since it took me many weeks and tons of frustrated days to get to this point. lol I do also like the idea of writing a tutorial maybe in the future for stuff that's more heavy-duty, so thanks for the quick help and advice #LBerger! :)