I have an automation that streams media from a camera to Google hubs when motion is detected at my front door. It was built with the integrated automation builder and works very well. However, the stream is started at a point roughly 20 seconds before the automation is triggered. In a way, this is good, as it allows me to see precisely what triggered the (Hue Outdoor) motion detector, but 20 seconds is a bit too much; going back five seconds would be ideal and streaming the live camera view is the expected behaviour.
To get 20second buffer it has to constantly capture or have some small amount in memory. My guess is that the 20 seconds is setup at the camera side/not HA automation. Posting automation and provide camera details will answer this.
Thanks, the automation is below. The camera is a Uniview. I do have “Preload Stream” selected in the configuration of this camera in HA, done through the ONVIF intergration. However, when I click the stream on my dashboard, it shows the live image and the preload serves its intended function of making that instant (not sure if this is relevant to the automation). If I run this automation without a preloaded stream, the delay until an image appears makes it less desirable than the current situation.
It occurs to me that HA has long delay for live view camera for many people. Curious if this also shows in recorded video. The live delay for me is about 20seconds
Verify your live view is actually real time live
Your automation doesn’t have any delay so you need to verify integration is live. This means make sure delay isn’t always there.
I’m not sure is preload adds that delay. You could turn it off and check if it changes
Yes, the live view is real-time. For example, I have the stream displayed in one dashboard. In general it displays an image with a refresh rate of roughly 1 per 10 seconds. If I click that, a stream of roughly 3FPS is displayed and that is real-time. With stream preload enabled, this is displayed instantly (real-time), which is the intended function of the preload.
As I am starting to wonder if this is an issue with the stream preload, I will disable that and see how the automation behaves.
Real time means stand in front of camera and live view camera. When you move, the camera shows movement immediately with no delay.
Real time does not mean live view camera and immediately see image.
Just need to verify we have same understanding of this as I know of noone using HA with actual 1 to 1 real time. Maybe 3 second delay is what I’d expect you to have at best. I think this delay will also show in recorded video as “record start”/automation start point of 12:43 would actually show the 3 second lag(really buffer I guess) and actual recording start at 12:40
It looks like the gap is roughly 2 seconds between an action and the reflection of that in HA, with or without preload enabled (even in an NVR, there is a comparable gap, however). This sort of delay would be ideal for my application. The 20 second gap is confusing, however, as it means that the stream shown starts before the triggering of the automation.
It would be easy to surmise that the automation is showing the stream from the beginning of the preload. However, the expected behaviour is that it shows the same stream that is shown when clicking on the camera media. I will try to confirm this preload theory in the morning.
Even with preload disabled, the stream displayed from this automation is 20 seconds in the past whereas the “live” stream is roughly 2 seconds delayed.
I don’t understand the ONVIF integration or play_media protocol well enough to even hypothesize on why this is happening.
Tried switching from media_player.play_media to camera.play_stream but still have the 20 second gap in time. Checked camera configuration for anything that might be an issue, but do not see anything. Any insights are appreciated.
You can try play media to TV or other device and check stream there, I expect same 20 sec delay
Honestly I expect this is normal and nothing you can do. By normal I mean affect effect everyone the same.
You can submit problem in GitHub and maybe get better answer there. Complaints about stream delays(lag behind real time) are many so maybe check that closely and someone have same issue with more info. I saw some but didn’t post here since it’s was vaguely related and no resolution.