[SOLVED] connecting with IP camera using opencv


This Content is from Stack Overflow. Question asked by Smadar

I have a proVisionISR IP camera which I am trying to connect through openCV.videoCapture().
I have inserted RTSP URL like this: “rtsp://user:password@IP:port/”, I also tried to add different ending after the port in the URL, such as profile2 which indicate on the sub stream (pic below),
H264?ch=1&subtype=0 and more results I found while searching.
The code uses cv2.CAP_FFMPEG, but tried also with GSTREAMER pipeline.

I changed some values in the camera dashboard configuration, such as resolution that fit the code, the encoding also was changed to h264, and disabling the audio as well. (The bitrate type is: CBR)

I open the stream in VLC, and it is work just fine. And 2 more IP cameras with RTSP streaming was able to connect with: cv2.videocapture(RTSP URL, cv2.CAP_FFMPEG)

Python version: 3.8
OpenCV version : 4.6.0-dev (installed from source)
ffmpeg version 4.2.7
ubuntu version (If necessary) 20.04

enter image description here



Here u have a working example to connect to a rtsp stream via pyav and show it on a opencv window.


The code is testet with an axis camera and hikvision camera.
If the not work send the error for deeper investigation.

This Question was asked in StackOverflow by Smadar and Answered by Christoph It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?