Generic NVR cameras with high resolution

Hi. I have Dahua NVR, with 4 cameras that gives 3072x2040 resolution each. All cameras are added to HA as generic camera. Problem is, that it looks like that HA is hard to display/refresh so big res images, as in Lovelace the images refreshes really slowly - more than 10 sec (could not refresh at all and show grey screen), and if I open the camera window, it also loads really slow. For my Dafang cameras, the refresh rate is normlal (only fullhd res), 1sec if I open the camera, ~10 sec at lovelace card view.

Is there any way to resize the generic camera stream, but not to lower the resolution of the camera itsefl? i tried to add the NVR cameras as ffmpeg, but HA does not display them.

What hardware are you running home assistant on?

minimum - Rpi3 :slight_smile: but the avg cpu and ram usage is small:

cpu 14%
RAM 35%

I used to run 2x 5Mpixel cameras on a pi3. No issue with the generic camera component (10 sec card updates, 1 sec more info pop-up updates).

I wonder if you have network throughput issues?

Are you using wired or wireless?

all cameras are wired poe. But I think the problem is that they run via Dahua NVR box. And generic camera link is not to the camera, but to NVR box.

added like this:

  - platform: generic
    name: ShedCam
    still_image_url: http://192.168.1.1/cgi-bin/snapshot.cgi?channel=3
    authentication: digest
    username: 
    password:

Localy they work perfectly, I also can connect to NVR box via dahua app, and camera fps is about 20fps

so resolution is not the issue, strange.

also got lot of these in logs:

2019-09-27 16:37:09 ERROR (SyncWorker_5) [homeassistant.components.generic.camera] Error getting camera image: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

2019-09-27 16:37:14 ERROR (SyncWorker_0) [homeassistant.components.generic.camera] Error getting camera image: HTTPConnectionPool(host='192.168.1.1', port=80): Read timed out. (read timeout=10)

That’s interesting.

Are you sure you have the NVR generic camera configured correctly (both in HA and in the NVR)?

I guess so, because it does show image at some point. Also I can open the link in a browser, and it does load the snapshot quite quickly.

But I have not done any special configuration in NVR for generic camera. Is there anything specific?

Authentication perhaps?

changed digest to basic, tried username and password in URL, but nothing helps yet.

Got the same errors in LOG :frowning:

I’ve got the same issue. It looks like generic.camera is trying to refresh all of the camera images too quickly for the NVR to handle. Is there some way to stagger the http pull requests for still image updates?

When working with individual cameras, it doesn’t matter that you’re requesting the still images at the same time. NVRs are generally under powered and take time to respond. Trying to pull all the still images at once is overwhelming it.

What type of NVR?

Lorex LNR600 series. Pretty sure its a Dahua rebranded. Some of the IP cameras are directly connected to the NVR and on a non-routable network, therefore I can’t access the cameras directly to pull the snapshots from. I also have a mix of cameras that output varying image resolutions, which then show up in Lovelace as different sizes.

What I’ve done to overcome, for the time being, is setup a cron job to run a shell script every minute to:
1.) Download the images from the NVR sequentially
2.) Convert them to a standard image resolution 1920x1080
3.) Place in directory so another instance of apache can host them.
4.) Configured generic.camera snapshot url as the apache server.

#!/bin/bash
curl -s --digest --user admin:mypass http://[NVR_IP]/cgi-bin/snapshot.cgi?channel=1 | convert - -resize 1920x1080^ -gravity center -extent 1920x1080 -quality 90 camera-1.jpg
curl -s --digest --user admin:mypass http://[NVR_IP]/cgi-bin/snapshot.cgi?channel=2 | convert - -resize 1920x1080^ -gravity center -extent 1920x1080 -quality 90 camera-2.jpg
...
curl -s --digest --user admin:mypass http://[NVR_IP]/cgi-bin/snapshot.cgi?channel=16 | convert - -resize 1920x1080^ -gravity center -extent 1920x1080 -quality 90 camera-16.jpg

It would be nice to have these features directly in generic.camera.
1.) Option to sequentially download images rather than simultaneously.
2.) Option to resize snapshot to uniform size

This is working very well and completely resolved the errors being generated from HA and the images not refreshing in Lovelace.

What url and camera type were you using to get images into HA? Snapshot.cgi was very hit or miss for me… I ended up using ffmpeg camera with the RTSP url …
rtsp://user:pwd@ip:port/cam/realmonitor?channel=1&subtype=0

Subtype of 0 is the full resolution “Main” stream and a subtype of 1 gives you the slightly lower quality stream.

I just tried with ffmpeg. It leaves streaks in every snapshot now. No good

ffmpeg.camera

camera:
  - platform: ffmpeg
    name: FrontDoor
    input: "rtsp://admin:passwd@[nvrip]:554/cam/realmonitor?channel=1&subtype=0"
  - platform: ffmpeg
    name: Front Yard
    input: "rtsp://admin:passwd@[nvrip]:554/cam/realmonitor?channel=2&subtype=0"

generic.camera

camera:
  - platform: generic
    name: FrontDoor
    stream_source: "rtsp://admin:passwd@[nvrip]:554/cam/realmonitor?channel=1&subtype=0"
    still_image_url: "http://127.0.0.1:32768/camera-1.jpg"
    authentication: digest
  - platform: generic
    name: Front Yard
    stream_source: "rtsp://admin:passwd@[nvrip]:554/cam/realmonitor?channel=2&subtype=0"
    still_image_url: "http://127.0.0.1:32768/camera-2.jpg"
    authentication: digest

Image with ffmpeg
driveway-ffmpeg

Try subtype 1

Same problem with subtype 1. It also reduces the resolution of the stream while playing, which is a non-starter.

The solution is simple, provide a feature in generic.camera to sequentially download the images and ideally allow for resizing. Else, I’ll keep what I’ve got going.

Ever find a better solution for this? I’m running the same NVR as you and Hassio on an RPi3 and experience the exact same issues (including the image size differences) but I cannot implement your solution on HASSOS for obvious reasons.

I can confirm the NVR is the problem. I have a couple of my cams on a separate POE switch and can access them directly with zero issues. Same model cams accessed through the NVR produce the errors you mention - and a lot of them (I currently have 12 cams set up, 8 of them are 4K.).

I do not think it is related to multiple cams requesting at the same time though. Setting up even just one camera through the NVR produces the errors. Reducing the resolution on the camera does not prevent the error from occurring.

If I can’t come up with another solution I might just end up having to get a POE switch to connect all the cams to instead of connecting them to the NVR so I can access them directly which feels like throwing good money after bad.

ERROR (SyncWorker_10) [homeassistant.components.generic.camera] Error getting camera image: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

ERROR (SyncWorker_18) [homeassistant.components.generic.camera] Error getting camera image: HTTPConnectionPool(host='192.168.1.100', port=80): Read timed out. (read timeout=10)