I am new to home assistant and frigate, just started to work with it over the last month or so.
I exprience an increase in latency the longer frigate runs. after a restart of frigate, I have subsecond latency on the video of my webrtc live-stream (both in the frigate ui, as well as in the hass frigate card). A few hours later, when I start the live streaam again, latency increases to multiple seconds (5 to 10 seconds).
audio stays fine though - no increase in latency here.
I run frigate and home assistant in docker on a dell optiplex i3.
live stream is 4 fps - 640x480
go2rtc / rtsp streaming is used
object and motion detection are both OFF.
cpu usage on the optiplex is around 5 - 10%, memory usage is about 25% (of 8 GB).
Where do I need to look to get to the root cause? I am very thankfull for suggestions!
thank you very much.
What version of go2rtc are you running? The default in frigate or have you upgraded it?
If you are running the default version then go2rtc can’t have latency as it is using UDP, the only explanation for latency would be latency from the cameras.
thanks for your input.
I use the frigate version.
I use a reolink E1Zoom camera. there is no latency in the reolink camera app itself, initially after restart of frigate there is no latency in the frigate UI and in the HASS frigate card either, but only after running the frigate container for some time (hours) the latency is building up.
The reolink app uses entirely different protocol for communication so that is mostly irrelevant. UDP can have dropped frames but it can’t have delay so it will be coming from the network or the camera.
ok. Just to help me understand some of the technicalities… why is latency perfectly fine after a restart of frigate and then after letting the container run for some time, it starts to degrade? what is actually being “reset” with a frigate restart, so that latency is completely fine after such a restart?
thanks for being patient with me
I don’t know that answer otherwise the answer / solution would be more clear. All I am saying is that the latency can’t come from WebRTC itself.
It depends how you have it setup but it could be some issue with the fact that frigate has been connected to the camera for hours which has bogged it down / increased its memory usage and restarting frigate resets that.
Or if you are using the restream as frigate’s camera source then maybe the connection is experiencing latency (does frigate detect process see any latency during this?)
all in all, I’d suggest updating go2rtc as that should help with other things if not this
thanks for being so responsive.
As I am not really an advanced Linux user, I am hesitent to tinker with the system too much, the frigate docu for upgrading go2rtc does not tell me exactly what to do. Are there plans to upgrade go2rtc within the standard frigate container some time soon?
Did you find a solution yet? I have a Outdoor E1 camera and I have the exact same issue. I’ve tried everything, but the only thing that resets the delay is to restart frigate. I’ve spend hours on this, compared all settings to a friend of mine who also has a Reolink cam but doesn’t experience the same issue. Even after matching all settings in frigate.yaml the issue seems to persist.
Also experiencing the same video drift over time with a RLC-833A on firmware
v3.1.0.1648_22122727. Restreaming to frigate from go2rtc. Audio remains on target always, within half a second. Just the video feed is the issue.
Seems to drift as much as 1 full second every hour. I left it running overnight and it was up to 13 seconds over RTSP, and appears to drift the same with ONVIF.
Trying to reduce the interframe space to 1x from 2x [clear] / 4x [fluent] as mentioned in what @NeoID posted. Would like to avoid RTMP [port 1935] as that incurs a ~2-4 second delay of its own.
I am also now testing a VLC session streaming directly from the camera feed to see if it also begins to drift as well. This should narrow down if it’s something to do with go2rtc/frigate or Reolink’s firmware/settings.
An update on this for anyone who stumbles across the thread… the http/flv stream appears to have no video drift and with subsecond delay. This is the same stream that the Reolink Client application uses. I’m currently testing an updated firmware for Reolink support that they’re asking if it fixes the RTSP/ONVIF drift. But here are the working streams to use in go2rtc for a RLC-833A, operating at a reduced 1440p/2K resolution so that it outputs as h264 instead of h265 (other Reolink cameras likely similar):
If it helps, I encountered this problem on some of my reolink cameras.
Increasing video latency problems in webRTC were due to the frame rate parameter which was not set to “constant” in the camera’s video stream settings.