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:

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

… 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:

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

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

ffmpeg:
  global_args: -hide_banner -loglevel error
  hwaccel_args: preset-vaapi
  input_args: -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -flags low_delay -strict experimental -analyzeduration 1000M -probesize 1000M -rw_timeout 5000000

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.

    • ari_verse@lemm.eeOP
      link
      fedilink
      arrow-up
      3
      ·
      10 months ago

      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.

  • ari_verse@lemm.eeOP
    link
    fedilink
    arrow-up
    1
    ·
    10 months ago

    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
  • SolidGrue@lemmy.world
    link
    fedilink
    English
    arrow-up
    1
    ·
    10 months ago

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