Embed stream of IP camera requiring Digest Authentication Scheme

I would like to embed the video of an IP camera in a Perspective view. If I navigate to http://<cameraIpAddress>/mjpg/video.mjpg and sign in I can view the stream in the web browser. If I put the same string in the VideoPlayer component (and check the liveFeed property), I can view the stream in a perspective project as long as I’ve already signed into the stream directly in the web browser.

If I open the perspective project in another web browser (eg. Edge), this error message comes up in the developer console:

video.mjpg:1 GET http://10.40.30.100/mjpg/video.mjpg 401 (Unauthorized)

and the component shows Error Loading Media: File Not Valid.

If I navigate directly to http://<cameraIpAddress>/mjpg/video.mjpg and sign in, then go back to the perspective project, the stream works with no error message.

It seems like a lack of authentication is my problem. Is there any way to provide this authentication either through the VideoPlayer component or through a third-party module component?






Further Information:
Out of curiousity, I sent a get request through system.net.httpClient to http://<cameraIpAddress>/mjpg/video.mjpg using this script:

client = system.net.httpClient()
response = client.get('http://10.40.30.100/mjpg/video.mjpg')
print response.getHeaders()['www-authenticate']

It returns (formatting mine for readability):

[
    Digest realm="AXIS_ACCC8EB6906D",
    nonce="HoZDFv7bBQA=a8380a34fc54dcb09a6aa64272921dd4cde20552",
    algorithm=MD5,
    qop="auth"
]

This leads me to believe that the authentication scheme may be ‘Digest,’ but at this point I’m far past my area of expertise.

It is going to depend entirely on what camera you are using, but typically the user name and password can be included in the URL.
This is just an example:

http://user:pass@192.168.1.20/videostream.cgi?user=user&pwd=pass&resolution=32

1 Like

The camera is an AXIS M3046-V.

Interestingly, http://<user>:<password>@<cameraIP>/mjpg/video.mjpg does correctly authenticate me directly in the browser (Chrome and Edge), but it does not work in a Perspective Client. I don’t get the
video.mjpg:1 GET http://10.40.30.100/mjpg/video.mjpg 401 (Unauthorized)
error anymore, but it still doesn’t display anything in the component. There’s also no error message in the gateway logs or the browser developer tools console.

The same results for all the permutations I tried of your URL above.

Does anyone know why the browser and the VideoPlayer component work differently in this case?

Honestly ive struggled with this quite a bit. If you have ssl/tls enabled, it wont work at all due to chromium blocking mixed content. I have used a batch file to run a VLC command that re-streamed the RTSP stream from a camera, then used that URL in the video player component.

Good to know. Sounds like I may have to resort to some interesting work-arounds.

Thanks for the help.

You may want to check out Phil’s module.

1 Like

@zacht, how did you tackle it?

I modified the project requirements so I didn't have to deal with this. In my case, no one asked for these features, I was just trying to be extra nice to the operators. Since it was going to be a challenge I put it on the perpetually growing list of "things I'd like to get back to someday."

1 Like

Haha, ok, that sounds like a great soution.