keshavdv / unifi-cam-proxy

Enable non-Ubiquiti cameras to work with Unifi NVR
MIT License
1.6k stars 226 forks source link

snapshot-url not rendering initial live view image in Protect #195

Closed daltskin closed 2 years ago

daltskin commented 2 years ago

Describe the bug Trying to save some CPU cycles on the RPi by providing the --snapshot-url parameter eg: --snapshot-url=http://{user}:{password}@{ip}/ISAPI/Streaming/channels/201/picture however the image is not being displayed in the Protect portal live view. Url has been verified and tested to work in a web browser.

To Reproduce Steps to reproduce the behavior:

  1. Set --snapshot-url within docker-compose
  2. Open Protect and view the camera output image

Additional context Also tried by adding a file name to the end of the url eg: --snapshot-url=http://{user}:{password}@{ip}/ISAPI/Streaming/channels/201/picture/snapshot.jpg this also works in a web browser, but not in Protect portal.

Highest resolution snapshot image supported by DVR is: 960x576 using: http://{user}:{password}@{ip}/ISAPI/Streaming/channels/201/picture?videoResolutionWidth=960&videoResolutionHeight=576/snapshot.jpg could this be an image format or resolution issue?

When removing the --snapshot-url altogether, the snapshot from each camera loads fine in the Protect portal.

keshavdv commented 2 years ago

Can you please share output of the proxy with the --verbose flag enabled? Also, based on the URL, it sounds like this might be a Hikvision compatible camera. Have you considered using the hikvision implementation which should pick try and use the correct snapshot url by default?

mrMiimo commented 2 years ago

maybe it's silly what I say but ... I think you should use ' to specify the URL address for example: --snapshot-url='http://{user}:{password}@{ip}/ISAPI/Streaming/channels/201/picture/snapshot.jpg'

daltskin commented 2 years ago

So figured it out by looking at the screen.jpg file that was being created - which was an 401 xml message.

image

The verbose output didn't show any errors, looking at the code it was just uploading the xml response to the unifi endpoint regardless.

The fix was to change the NVR Configuration web auth to use digest/basic instead of just digest eg:

image