Is there any way to send userId, password to rtsp ip camera?

Hello I’m trying to connect multiple ip camera with my c++ code.
I need to use RTSP way to connect, and I have several cameras that use digest authentication.

I already tried 2 ways.
URL ver1. rtsp://userid:password@ip:port/ …
URL ver2. rtsp://ip:port/ …

(My cameras have different rtsp url, so I didn’t write whole url. I checked url is available with VLC player)

But some cameras that have userId, password can’t use URL ver1. (I don’t know why, but the camera company answered me like that. ) So I need to use only ver 2 url.

My question starts now.
In VLC player, when I try ver2 way to connect ip camera, vlc shows this window.

(sorry for other language. That window asks me to enter userId, password)

I really want to do same way with VLC player. But I can’t find way to authenticate in digest method. I use opencv 4.5.1 , c++

Is there any way to send userId, password to rtsp ip camera url that uses digest authentication?

Not sure this is the right forum to ask this kind of question. Anyways, did you try some default credentials? Usually, IP cameras come with default credentials that you can use to gain access to the video feed. Try using your smartphone as your IP camera to isolate the problem and make sure your C++ code is working correctly before connecting with other cameras.

this depends on the backend, i.e. CAP_FFMPEG or CAP_GSTREAMER. OpenCV can’t use VLC.

they are supposed to handle “HTTP authentication”.

you should check if you can get ffmpeg/gstreamer to work standalone with your situation.

Probably not going to work for you but if nothing else does you could try seeing if you can access through ONVIF Device Manager, without having to login to it first. If so you should be able to get a connection string from the live tab for the camera.

I mention this because sometimes you can’t use the password in plain text and the url ends up looking like

rtsp://192.168.1.2:554/user=admin_password=eqFKuJui_channel=1_stream=0.sdp?real_stream

where eqFKuJui is the encoded password. I have seen this on several different non brand Chinese IP camera’s, and I haven’t been able to get the connection string any other way.

Thanx but my code works well with other cameras (ex. smartphone ip camera)

I didn’t try yet, but this way will be helpful. I found Gstreamer option that supports digest authentification. I’ll try it.

maybe this helps:

ffmpeg seems to support RTSP with authentication as well

Thanx! I need to set timeout option for network delay, so maybe I will use ffmpeg option! Your solution was really helpful. Thanks a lot.

Oh I didn’t notice about this case. But so fortunately, in my situation, all cameras don’t match with that case! But thank you for answering :slight_smile:b