To access an Ip Camera, first, I recommend you to install it like you are going to use for the standard application, without any code, using normal software.
After this, you have to know that for different cameras, we have different codes. There is a website where you can see what code you can use to access them:
https://www.ispyconnect.com/sources.aspx
But be careful, for my camera (Intelbras S3020) it does not work. The right way is to ask the company of your camera, and if they are a good company they will provide it.
When you know your code just add it like:
cap = cv2.VideoCapture("http://LOGIN:PASSWORD@IP/cgi-bin/mjpg/video.cgi?&subtype=1")
Instead LOGIN you will put your login, and instead PASSWORD you will put your password.
To find out camera's IP address there is many softwares that you can download and provide the Ip address to you. I use the software from Intelbras, but I also recommend EseeCloud because they work for almost all cameras that I've bought:
https://eseecloud.software.informer.com/1.2/
In this example, it shows the protocol http to access the Ip camera, but you can also use rstp, it depends on the camera, as I said.
If you have any further questions just let me know.