HA + Frigate and Reolink WiFi cams - how to avoid ffmpeg crashes

If you use Reolink wifi cams via the Frigate integration in homeassistant, you may be used to seeing tons of “ffmpeg has crashed unexpectedly” in your frigate logs. I have 3 older reolink wifi cams in frigate (510WA, 511WA) which most in the community seems to advise against and indeed since I’ve been running frigate, while they worked, they have been problematic since Frigate 0.12 and the arrival of go2rtc

Cutting down to the chase, when I was using the standard common configuration with these cameras:


<span style="color:#323232;">go2rtc:
</span><span style="color:#323232;">  streams:
</span><span style="color:#323232;">    driveway:
</span><span style="color:#323232;">      - "http://192.168.x.y/flv?port=1935&app=bcs&stream=channel0_main.bcs&user=USER&password=PASSWORD#video=copy"
</span><span style="color:#323232;">    driveway_sub:
</span><span style="color:#323232;">      - "http://192.168.x.y/flv?port=1935&app=bcs&stream=channel0_sub.bcs&user=USER&password=PASSWORD"
</span>

… frigate would generally work with them however in the logs I could see that the ffmpeg process that frigate creates for each re-stream would crash every few minutes, accumulating thousands of crashes over time. I assume that the crashes would also cause event detection to be unavailable for a brief period each time they happened.

With Frigate 0.13, it got even worse, as with each crash, the HA dashboard would show a black image with a “No frames received” message that would only go away after a manual dashboard refresh.

I believe the issue is that go2rtc was unable to properly handle the streams from these old cams, while in the past, ffmpeg directly in frigate could do it, adding some ffmpeg parameter.

The solution I found a few days ago that ALMOST COMPLETELY eliminated all the “ffmpeg crashed unexpectedly” situations (I went from THOUSANDS of errors to just one or two errors after a few days) is to change the go2rtc configuration so that it uses ffmpeg instead of it’s own code to connect to the cams:


<span style="color:#323232;">go2rtc:
</span><span style="color:#323232;">  streams:
</span><span style="color:#323232;">    driveway:
</span><span style="color:#323232;">      - "ffmpeg:http://192.168.x.y/flv?port=1935&app=bcs&stream=channel0_main.bcs&user=USER&password=PASSWORD#video=copy"
</span><span style="color:#323232;">    driveway_sub:
</span><span style="color:#323232;">      - "ffmpeg:http://192.168.x.y/flv?port=1935&app=bcs&stream=channel0_sub.bcs&user=USER&password=PASSWORD"
</span>

I also have the following global ffmpeg configuration in frigate’s config file, not sure if it helps or not:


<span style="color:#323232;">ffmpeg:
</span><span style="color:#323232;">  global_args: -hide_banner -loglevel error
</span><span style="color:#323232;">  hwaccel_args: preset-vaapi
</span><span style="color:#323232;">  input_args: -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -flags low_delay -strict experimental -analyzeduration 1000M -probesize 1000M -rw_timeout 5000000
</span>

This go2rtc configuration decreased CPU utilization significantly (frigate 0.13 itself also helped apparently). Hoping this will help others in the same situation, as the cams themselves are not bad, it’s just their software that sucks, but that can be worked around quite nicely with ffmpeg.

AlternateRoute,

Isn’t this exactly what the Camera Specific Configuration in the frigate documentation tells you to do?

ari_verse,

I just checked that link and YES, actually it is, thanks for pointing it out. The docs must have been updated for v0.13, they added the ffmpeg prefix to the go2rtc stance, this wasn’t there before. I found this originally in a github bug discussion with the frigate dev, where he suggested the person having issues to try this out and see what happens. There was no follow up after that suggestion though.

solidgrue,
@solidgrue@lemmy.world avatar

Nice writeup! My old Foscam cams are similarly tetchy. I should look at that harder now that I have things more dialed in.

ari_verse,

Note - another helpful tip for 510WA cams: in this github listing: Reolink Firmware Archive, you can find a link to version 3.1.0.1387 which I have been running for a week, this version is much newer than the latest official release (.764), it adds two useful new options in t he Stream configuration section (which is only accessible via the Web interface of the cam),

  • interframe space: set it to 1X
  • frame rate mode: set it to fixed
  • All
  • Subscribed
  • Moderated
  • Favorites
  • homeassistant@lemmy.world
  • ngwrru68w68
  • DreamBathrooms
  • khanakhh
  • magazineikmin
  • InstantRegret
  • tacticalgear
  • thenastyranch
  • Youngstown
  • rosin
  • slotface
  • modclub
  • everett
  • kavyap
  • Durango
  • JUstTest
  • osvaldo12
  • normalnudes
  • cubers
  • ethstaker
  • mdbf
  • provamag3
  • GTA5RPClips
  • cisconetworking
  • Leos
  • tester
  • megavids
  • anitta
  • lostlight
  • All magazines