It’s probably worth mentioning some of the reasons I think I have isolated for cameras not displaying correctly… Althought if you look at my “I tried all the cameras” post, you will note that the reliability score I put there are the cases where I don’t think it was these things that were causing the cameras to not display.
1) Overloaded CPU (/GPU?) on your server: Any time you are taking an h.264 stream and displaying it as MJPEG, there is one ffmpeg instance being created for each camera being displayed on each frontend device. 4 cameras being displayed on 3 devices? 12 instances. Each of these instances uses something like 8-10% of my CPU so displaying more than 8 of these cameras is impossible on my old core duo mac mini. I’ve never tried to see what was possible with GPU, my understanding from an FR is that the NUC hass.io image has the ability to use the intel integrated GPU, so people running intel NUC’s with hass.io may be utilizing GPU resources for this, so it would be good to check those too.
Solutions:
- Activate streaming component so that your cameras display as HLS instead of MJPEG (though you will pay for this with lag, which in my case is about 10 seconds.
- Use proxy camera component to re-serve the stream. This magically seems to not use much of any CPU, though it does also make the camera stream less reliable so that sometimes it still won’t come up.
- Buy a better server
2) Limited number of streams available from your camera
Some cameras will only allow one stream of a certain type or one stream at a time from a type of device. Keep in mind that generally homeassistant is not re-casting your streams. When you open a stream to display on the frontend, it opens that stream from the camera or DVR that you’ve configured. It means you are likely to have many streams going to the camera and/or DVR at once if you have multiple displays (like I do with my tablets).
A couple examples of this that I’ve encountered are that
-
My Hikvision cameras are only able to serve one MJPEG stream at a time, so the second device to try opening will get a blank card. They seem happy to stream many h.264 camera streams, though.
-
My reolink camera will only allow streaming via the app or via the stream that the reolink beta component uses at a time. So, as soon as I open the reolink app, all the homeassistant streams vanish.
Solutions:
- Try using h.264 instead of MJPEG
- Account for everything that’s using the camera and try to close clients to see if it allows more clients to connect.
3) Overloaded CPU on your cameras
This is one I realized too late to really assess it properly, as I didn’t have a sensor for it until I got the ONVIF cameras going. But basically cameras have very limited CPU resources, and if you are running some of the features like motion detection, line crossing, tampering, camera rotation in addition to certain types of apparently demanding streams like MJPEG or to a lesser extent the proxy camera component, you can overload the CPU. That being said, mine still seem to work pretty well when almost maxed out but I’m sure it caused some of my problems.
Solution:
- Avoid MJPEG cameras. For whatever reason they have high CPU load
- Avoid rotating your cameras. This causes me some additional load
- Avoid proxy camera. Adds some small load
- Don’t use camera motion detection features (you can do this on the synology or DVR for example)
4) Overloaded browser on the frontend
I see this sometime on my kindle fire tablets if I am trying to display 4x 1080p stream cameras with live view enabled. But instead of not displaying the camera, fully kiosk browser just crashes, so a bit different. But your frontend devices do have limits.
Solutions:
- Use a less demanding camera type (non live stream, mjpeg appears easier to stream on the frontend than ALS using stream).
- Get a stronger frontend device. A modern iOS device seems to be able to keep up with just about anything I’ve tried, compared to a low powered Kindle Fire device. YMMV.
All that being said, there are many, many cases that I can’t explain. The cases I can’t explain are shown as a lower reliability score in my “I tried all the cameras” post.