I tried all the camera platforms so you don't have to

here is the PR

1 Like

There is an issue where viewing the full stream of an Onvif camera can cause excessive CPU usage even after you close it out. I’m using the Onvif integration with ffmpeg. I only have 2 cameras. If I use the main stream at [email protected] I can watch one, one time and the cpu will jump to 30-40% and stay there. View the second stream it jumps up to 80% or so and stays there. Close it out and open it again and HA becomes nearly unresponsive with 100% cpu. I have to reboot the VM at that point. This is running hassio on win 10 with an i7. There is no way only 2 1080p streams should kill a system like that. I’m watching those same streams on my 3700X box using VLC and am literally using .2 cpu total for vlc. Windows task manager uses more cpu.

I’m at a loss at this point.

I’d bet if you reduced the frame rate it wouldn’t be as bad, but yes, that does sound even worse than I’d experienced.

Is there a way to reduce the frame rate in the integration? I’m not going to reduce it on the camera. I want that frame rate and resolution so if/when I need to review footage I can see what someone is doing.

Only option for that is the camera proxy. It should definitely help you a lot with CPU usage.

Though I never understood the purpose of high framerate security cameras. I will trade high image quality and low CPU, network, and disk use for a high framerate any day. 4FPS is plenty to capture anything that might happen unless you are trying to get pictures of bullets.

1 Like

More frames means more chances at capturing a clear image of some minute detail like a license plate.

At my house we’ve had issues with hit and run’s concerning our cars being parked on the street. My truck has been hit twice in the same corner, the wifes car once less then 3 months after she bought it. I think she only had like 2K miles on it. And then my mothers SUV had the door collapsed in by the neighbors boyfriend. He couldn’t run away from that one the whole neighborhood heard it. Since then I installed cameras on the driveway and on the front of the house to catch anyone who might smash into our cars again. I want a nice shot of the plate the next time it happens. I don’t care about network or hard disk usage if it means the next time I can beat someone silly for running. Hard disk space is cheap and so is cat6, multiple insurance claims not so much.

1 Like

In that case, I suggest the Xeon Platinum 8276. Should solve all your problems :wink:

haha. I don’t have an issue saving footage. the cameras save directly to the file server. No problems there. I just want to be able to watch a live stream at a decent res and frame rate from with in HA while I’m out and about. Right now I’m using Onvifer. So many apps and steps just to be able to see a live feed.

Again, the Xeon Platinum 8276 and the FFMPEG component is all you need for 30FPS, crystal clear 4k streams on as many devices as you like :slight_smile:

Yea, I’m not gonna be justifying a $9k cpu to the wife. I’ll stick with onvifer and just remove the integration. The cameras can handle the encoding and saving to the file server. Eventually I’ll get a synology with its security station.

That being said there is something certainly wrong with the way HA handles the streams. If it had used just 20% of the cpu while viewing it and then returned back to its normal 1-5% after closing out the stream it wouldn’t be an issue at all. But its like it keeps encoding in the background even after its closed out. And then the next stream just adds on to the work load even more. It should not behave like that.

I went ahead and tried the ONVIF integration to see if I could reduce latency on a view that I have but I haven’t been successful so far. I commented out stream: in my config and added ffmpeg: and I set up my camera with ONVIF but I’m still seeing more than 7-8 seconds of latency at minimum. Any suggestions would be appreciated, I’m running Reolink RLC-420s if that matters at all. Thanks!

you shouldn’t need ffmpeg: in your config. It will do it automatically if you turn off stream: (but that must be turned off). Try to reduce the iframe interval on your cameras to 1 a second and then make sure that live view is turned on in the lovelace card. It’s also worth connecting to the same camera with VLC and see what latency you get there just to see if it’s possible to get it better. In my experience, whatever you get from VLC is the best you can hope to get from hass, and in reality you will never get it quite as low latency as VLC or synology for example.

Is there a way with the ONVIF integration to pick which stream I want from my camera? Or is that limited to my camera possibly only serving one stream via ONVIF?

I just can’t get the latency down and I feel like I must have set something up wrong.

1 Like

Yes, you can grab any of the available streams. When you go into the device setting in the HA Integrations GUI the sub and third streams will be disabled by default but you just turn them on. For lovelace I just use a substream to reduce the bandwidth to my phone but have the full res main stream going to my NVR

I did not have the option of picking a stream in my ONVIF configuration. Or are you putting the main stream or substream as part of the URL when setting up ONVIF?

You select it after its been added:

Ah, for whatever reason Home Assistant decided to automatically disable the substream so it was hidden.

No matter, the substream still has way too much latency. VLC is within ~2 seconds of latency, but I’ve never gotten a camera down to sub 8 second latency in Home Assistant. Super frustrating.

As I mentioned above, the sub streams are disabled by default.

You definitely have stream: disabled in your HA config? (because that causes lag)

Completely glossed over you already stating that, I am sorry.

But yes, I completely deleted stream: from my configuration.yaml file and rebooted. Still crappy latency and still seems like it’s creating a buffer when I open the cameras up in Developer Tools or in my Lovelace view.

Hmm. Not sure what else could be doing it. In a Lovelace card do you have camera_view: live set? Make sure you do