Camera.play_stream - Lag issues

Hi Guys,
Looking for a little help here, I have two Axis cameras that are setup on my home assistant. they work pretty awesome on HA even on full quality…

But when I have them stream to my Google Home Hub via the camera.play_stream service they get really laggy. I have dropped the quality on the stream from the camera all the way down.but it looks like a bandwidth issue going to the display.

If i watch the streams on home assistant, on my laptop on wifi they stream fine. so it looks to me like the way that HA streams to chrome cast is very heavy, anyone know how this works? and if we can make changes to it?

Hi,

I had exactly the same problem with my rtsp camera’s. Loading the initial stream on a Chromecast or a Home Hub took 10 to 30 seconds. When it played it only played a few seconds before it started loading again. But I fixed it.

What I did was changing the settings of the rtsp camera. I could modify the following settings:

  • Resolution - Of course.
  • Bit rate - I set that to 512
  • Maximum Frame - This is the setting for the maximum amount of frames per second. I set this to 15.
  • Bit Rate Type - I set this to variable bitrate
  • I Frame Gap - I did a lot of googling on this and it seems to be the inter frame gap. Every few frames the camera sends a full frame and the rest of the frames it sends just the changes to the full frame. I set this to 22.

The settings above work for two camera’s but for one I had to change the Maximum frame and I Frame Gap settings. Those two seem to be the most important settings. I fiddled around with these until I got a stable stream without lag or reloading. So the stream component or the google cast devices probably have some sort of a preference regarding to these stream settings.

So I advise you to fiddle around with the settings of your camera until you find something that works for you.

I also noticed that when fiddeling around it helps to restart Home Assistant after every change, probably even restart the device you are running Home Assistant on. I expect the stream component uses services outside of Home Assistant somewhere on the server.

Good luck and I hoped I have helped you and others!

I have been away frankv

I’ll try this out. thank you for the detailed reply mate.

You are welcome. I did notice that the stuttering of the video still occurs at night when the night vision is active. I therefore expect it has something to do with low bandwidth. A stream in color works great but a black and white stream is still lagging. So more experimenting is needed to find a solution. It could however also be a bug :slight_smile:

Hey Frank, i am facing the same problem. Could you help me how to change this configs? I use two cameras from china, both work with ONVIF protocol and their own mobile apps ( v380 and Isee) . It is not so clear or probably not possible to change all the things u said through their apps, so can i change from another way? My problem starts when i enable stream in my configuration file. When stream is not enabled, both cameras shows their live image in lovelace normally. When i get strem enabled, not only the camera.play_stream is laggy when cast to chromecast, but also is the normal view in lovelace. One of them take almost 25s of lag. Could you help me? Have you found a final solution?

have you managed to get it fix? mine too, very lagy. im using v380 too.

if fix, how you do that?

thanks