digiMoot:

Frigate NVR: Reolink Camera Configuration

Frigate NVR Reolink Camera ConfigurationThis Frigate NVR: Reolink Camera Configuration article will help you optimize your Reolink camera settings for your Frigate NVR setup. This optimization is essential as without it you will have choppy recordings, recordings that are missing / dropping frame and/or recordings with random artifacts.

This article is the third in an article series “Best Security System Setup using Frigate NVR” intended to help you get Frigate NVR setup with network storage and Home Assistant integration. Here is a list of the articles in this series for you to jump to:

  1. Best Security System Setup using Frigate NVR (Overview Article)
  2. Frigate NVR: Linux Manual Install
  3. Frigate NVR: Reolink Camera Configuration
  4. TrueNAS: NFS Network Share
  5. Frigate NVR: Home Assistant Integration

This is part of digiMoot’s series of articles on NVR and series of articles on TrueNAS installations, configurations and setup.

Reolink Camera Configuration for Frigate NVR

All of the configuration is going to be done within the frigate.yml. The location of this file will vary based on your installation method. If you have installed following digiMoot’s Frigate NVR: Linux Manual Install article, then it will be located in ~/docker-compose/frigate/config/frigate.yml.

I’ve include an example of the frigate.yml file below which you will need to update based on the following items:

First modification to the frigate.yml file, is that you will need to be using the RTMP streams from your camera. These have worked much better for me than the RTSP streams. These stream links will look something like:

rtmp://10.10.11.45/bcs/channel0_main.bcs?channel=0&stream=0&user=admin&password=password


OR

rtmp://10.10.11.45/bcs/channel0_sub.bcs?channel=0&stream=0&user=admin&password=password

The difference between the two above items, if you look carefully, is that one is the main stream and the other is the sub stream. The main stream corresponds to the ‘clear’ stream in the Reolink camera webUI and the sub stream corresponds with the ‘fluent’ stream in the Reolink camera webUI. You can access the webUI by using a web browser to navigate to the IP address of your camera and then logging in. Click on the device settings icon in the top right and then navigate to Camera -> Stream. When putting this information in to the file below, you will need to update these links with the correct IP address, username and password and determine if you wish to use the main or sub stream. The main steam will take more decoding power as it higher resolution.

Second modification to the frigate.yml file is that you will need to ensure you are using the correct video resolution for the stream. On the Reolink webUI Stream configuration page you will need to take note of the stream resolution you have set for the stream you will be using. If you don’t use the correct resolution in the yaml file, then things will look really funky.

Third modification to you the frigate.yml file is that you need to make sure you are using the optimized hardware acceleration and input arguments. Now your mileage may vary depending on the hardware Frigate is running on, but this has worked rock solid for me.

For hardware acceleration arguments, you only need to use one argument: -hwaccel_output_format to yuv420p. For input arguments, you also only need to use one argument: -avoid_negative_ts to make_zero. You can see how both of these are implemented in the example frigate.yml below.

mqtt:
  host: 10.10.11.199
  user: mqtt-user
  password: password

cameras:
  front_camera_frigate:
    rtmp:
      enabled: false
    ffmpeg:
      hwaccel_args:
    #   - -hwaccel
    #   - vaapi
    #   - -hwaccel_device
    #   - /dev/dri/renderD128
        - -hwaccel_output_format
        - yuv420p
      input_args:
        - -avoid_negative_ts
        - make_zero
    #   - -fflags
    #   - nobuffer
    #   - -flags
    #   - low_delay
    #   - -strict
    #   - experimental
    #   - -fflags
    #   - +genpts+discardcorrupt
    #   - -rw_timeout
    #   - "5000000"
    #   - -use_wallclock_as_timestamps
    #   - "1"  
      inputs:
        - path: rtmp://10.10.11.45/bcs/channel0_main.bcs?channel=0&stream=0&user=admin&password=password
          roles:
            - clips
            - detect
            - record
#       - path: rtmp://10.10.11.45/bcs/channel0_sub.bcs?channel=0&stream=0&user=admin&password=password
#         roles:
#           - detect
    width: 2560
    height: 1920
#   width: 640
#   height: 480
    fps: 10
    objects:
      track:
        - person
        - car
        - dog
    snapshots:
      enabled: true
      timestamp: false
      bounding_box: true
      retain:
        default: 10
    clips:
      enabled: true
      pre_capture: 10
      post_capture: 10
      retain:
        default: 10
    record:
      enabled: true
      retain_days: 10
 detectors:
  cpu1:
    type: cpu
  cpu2:
    type: cpu
  cpu3:
    type: cpu
  cpu4:
    type: cpu

You will note in this file that I have included both main and sub stream options, but I have commented out the sub stream so that it will not be used. It is possible to use both streams for different roles. For example, you could use the sub stream for detection (lowering the processing requirements) and use the main stream for clips and recording.

You will also note that i have included a number of commented out hardware acceleration options and input arguments. Feel free to explore different combinations of options to see if anything gets you better performance.

Conclusion

Alright! That’s it. You’ve finished this Frigate NVR: Reolink Camera Configuration article and your Reolink cameras should now be optimized for use in Frigate.

Happy…. uh… Reolinkin’?

~digiMoot Sources:

Frigate – Optimizing Performance: https://blakeblackshear.github.io/frigate/configuration/optimizing
Reolink Stuttery Clips: https://github.com/blakeblackshear/frigate/issues/896

Liked it? Take a second to support digiMoot on Patreon!

2 thoughts on “Frigate NVR: Reolink Camera Configuration

Leave a Reply

Your email address will not be published. Required fields are marked *