blakeblackshear / frigate

NVR with realtime local object detection for IP cameras
https://frigate.video
MIT License
19.21k stars 1.76k forks source link

Playing events from recordings fails, but works from events? [0.9.0 beta 2] #1567

Closed jasonpstokes closed 3 years ago

jasonpstokes commented 3 years ago

Two of my six RLC-520A cameras throw errors every 10-20 seconds soon after startup, in both v8 and 9. Whilst I didn't notice any issues within Frigate in 8, in 9 these two cameras won't play anything from the Recordings interface - but will play the same Events from the Events interface. The other 4x cameras play Recordings and Events as expected.

Anyone seen this or have any ideas please?

All cameras have the same camera firmware and stream settings. I reset one of these cameras again this morning but no difference. Only Frigate config diff is that these two cameras also track 'vehicle' from my custom labelmap - but (not surprisingly) removing this didn't stop the error.

v9 screenshot: image

Frigate is amazing, thanks for all your work on it!

Versions of frigate 0.8.4-5043040 0.9.0-3340952

Config file Driveway throws error, Entrance does not. Other four cameras repeat this config, except for some object tracking differences

database:
  path: /media/frigate/database/frigate.db

detectors:
  coral:
    type: edgetpu
    device: usb

ffmpeg:
  hwaccel_args:
    - -hwaccel
    - vaapi
    - -hwaccel_device
    - /dev/dri/renderD128

mqtt:
  host: 192.168.1.5
  port: 1883
  user: user
  password:

cameras:
  Driveway:
    ffmpeg:
      inputs:
        - path: rtmp://192.168.1.71/bcs/channel0_sub.bcs?channel=0&stream=0&user=admin&password={FRIGATE_RTSP_PASSWORD}
          roles:
            - detect
        - path: rtmp://192.168.1.71/bcs/channel0_main.bcs?channel=1&stream=0&user=admin&password={FRIGATE_RTSP_PASSWORD}
          roles:
            - record
            - rtmp
      input_args:
        - -fflags
        - nobuffer
        - -flags
        - low_delay
        - -strict
        - experimental
        - -rw_timeout
        - '5000000'
        - -f
        - live_flv
    detect:
      width: 640
      height: 480
      fps: 7

    motion:
      mask:
        - 222,469,222,447,417,447,417,469

    objects:
      track:
        - person
        - vehicle
        - dog

    record:
      enabled: true
      retain_days: 8
      events:
        enabled: true
        pre_capture: 3
        retain:
          default: 8

    snapshots:
      retain:
        default: 8

  Entrance:
    ffmpeg:
      inputs:
        - path: rtmp://192.168.1.72/bcs/channel0_sub.bcs?channel=0&stream=0&user=admin&password={FRIGATE_RTSP_PASSWORD}
          roles:
            - detect
        - path: rtmp://192.168.1.72/bcs/channel0_main.bcs?channel=1&stream=0&user=admin&password={FRIGATE_RTSP_PASSWORD}
          roles:
            - record
            - rtmp
      input_args:
        - -fflags
        - nobuffer
        - -flags
        - low_delay
        - -strict
        - experimental
        - -rw_timeout
        - '5000000'
        - -f
        - live_flv
    detect:
      width: 640
      height: 480
      fps: 7

    motion:
      mask:
        - 222,469,222,447,417,447,417,469

    objects:
      track:
        - person
        - dog

    record:
      enabled: true
      retain_days: 8
      events:
        enabled: true
        pre_capture: 3
        retain:
          default: 8

    snapshots:
      retain:
        default: 8

labelmap.txt

0  person
1  bicycle
2  vehicle
3  vehicle
4  airplane
5  bus
6  train
7  vehicle
8  boat
9 ...etc.

Frigate container logs These errors are repeated every 10-20 seconds

[2021-08-20 08:37:53] ffmpeg.Balcony.record_rtmp     ERROR   : av_interleaved_write_frame(): Connection reset by peer,
[2021-08-20 08:37:53] ffmpeg.Balcony.record_rtmp     ERROR   : [flv @ 0x564814fe1cc0] Failed to update header with correct duration.,
[2021-08-20 08:37:53] ffmpeg.Balcony.record_rtmp     ERROR   : [flv @ 0x564814fe1cc0] Failed to update header with correct filesize.,
[2021-08-20 08:37:53] ffmpeg.Balcony.record_rtmp     ERROR   : Error writing trailer of rtmp://127.0.0.1/live/Balcony: Connection reset by peer,
[2021-08-20 08:37:53] watchdog.Balcony               INFO    : Terminating the existing ffmpeg process...,
[2021-08-20 08:37:53] watchdog.Balcony               INFO    : Waiting for ffmpeg to exit gracefully...,
[2021-08-20 08:37:54] ffmpeg.Driveway.record_rtmp    ERROR   : av_interleaved_write_frame(): Connection reset by peer,
[2021-08-20 08:37:54] ffmpeg.Driveway.record_rtmp    ERROR   : [flv @ 0x55ca8cc6e640] Failed to update header with correct duration.,
[2021-08-20 08:37:54] ffmpeg.Driveway.record_rtmp    ERROR   : [flv @ 0x55ca8cc6e640] Failed to update header with correct filesize.,
[2021-08-20 08:37:54] ffmpeg.Driveway.record_rtmp    ERROR   : Error writing trailer of rtmp://127.0.0.1/live/Driveway: Connection reset by peer,
[2021-08-20 08:37:54] watchdog.Driveway              INFO    : Terminating the existing ffmpeg process...,
[2021-08-20 08:37:54] watchdog.Driveway              INFO    : Waiting for ffmpeg to exit gracefully...,

after a reboot of Frigate

[2021-08-20 10:07:40] ffmpeg.Driveway.record_rtmp    ERROR   : av_interleaved_write_frame(): Connection reset by peer,
[2021-08-20 10:07:40] ffmpeg.Driveway.record_rtmp    ERROR   : [flv @ 0x55de542619c0] Failed to update header with correct duration.,
[2021-08-20 10:07:40] ffmpeg.Driveway.record_rtmp    ERROR   : [flv @ 0x55de542619c0] Failed to update header with correct filesize.,
[2021-08-20 10:07:40] ffmpeg.Driveway.record_rtmp    ERROR   : Error writing trailer of rtmp://127.0.0.1/live/Driveway: Connection reset by peer,
[2021-08-20 10:07:40] watchdog.Driveway              INFO    : Terminating the existing ffmpeg process...,
[2021-08-20 10:07:40] watchdog.Driveway              INFO    : Waiting for ffmpeg to exit gracefully...,
[2021-08-20 10:07:40] ffmpeg.Balcony.record_rtmp     ERROR   : av_interleaved_write_frame(): Connection reset by peer,
[2021-08-20 10:07:40] ffmpeg.Balcony.record_rtmp     ERROR   : [flv @ 0x55f920537980] Failed to update header with correct duration.,
[2021-08-20 10:07:40] ffmpeg.Balcony.record_rtmp     ERROR   : [flv @ 0x55f920537980] Failed to update header with correct filesize.,
[2021-08-20 10:07:40] ffmpeg.Balcony.record_rtmp     ERROR   : Error writing trailer of rtmp://127.0.0.1/live/Balcony: Connection reset by peer,
[2021-08-20 10:07:40] watchdog.Balcony               INFO    : Terminating the existing ffmpeg process...,
[2021-08-20 10:07:40] watchdog.Balcony               INFO    : Waiting for ffmpeg to exit gracefully...,
[2021-08-20 10:08:30] ffmpeg.Balcony.record_rtmp     ERROR   : av_interleaved_write_frame(): Connection reset by peer,

Frigate stats

{"Balcony":{"camera_fps":7.0,"capture_pid":256,"detection_fps":0.0,"pid":233,"process_fps":7.0,"skipped_fps":0.0},"Deck":{"camera_fps":7.1,"capture_pid":244,"detection_fps":0.0,"pid":229,"process_fps":7.1,"skipped_fps":0.0},"Driveway":{"camera_fps":7.0,"capture_pid":234,"detection_fps":0.0,"pid":223,"process_fps":7.0,"skipped_fps":0.0},"Entrance":{"camera_fps":7.0,"capture_pid":238,"detection_fps":7.5,"pid":224,"process_fps":7.1,"skipped_fps":0.0},"Laundry":{"camera_fps":7.1,"capture_pid":252,"detection_fps":0.0,"pid":232,"process_fps":7.1,"skipped_fps":0.0},"Rumpus":{"camera_fps":7.1,"capture_pid":240,"detection_fps":0.0,"pid":227,"process_fps":7.1,"skipped_fps":0.0},"detection_fps":7.5,"detectors":{"coral":{"detection_start":0.0,"inference_speed":15.18,"pid":218}},"service":{"storage":{"/dev/shm":{"free":61.6,"mount_type":"tmpfs","total":67.1,"used":5.5},"/media/frigate/clips":{"free":966375.4,"mount_type":"nfs4","total":1298700.9,"used":331788.6},"/media/frigate/recordings":{"free":966375.4,"mount_type":"nfs4","total":1298700.9,"used":331788.6},"/tmp/cache":{"free":1951.7,"mount_type":"tmpfs","total":2000.0,"used":48.3}},"uptime":17054,"version":"0.9.0-3340952"}}

Computer Hardware

docker-compose.yml

version: '3'
services:
  frigate:
    container_name: frigate-9.0
    image: blakeblackshear/frigate:0.9.0-beta2-amd64
    hostname: frigate-9.0
    # privileged: true
    restart: always
    devices:
      - /dev/bus/usb:/dev/bus/usb
      - /dev/dri/renderD128
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /usr/docker/frigate-9.0/config.yml:/config/config.yml:ro
      - /usr/docker/frigate-9.0/labelmap.txt:/labelmap.txt:ro
      - /usr/docker/frigate-9.0/database:/media/frigate/database
      - /mnt/nas_storage/frigate:/media/frigate
      - type: tmpfs
        target: /tmp/cache
        tmpfs:
          size: 2000000000
    network_mode: bridge
    ports:
      - 5000:5000
      - 1935:1935 # RTMP feeds
    environment:
      FRIGATE_RTSP_PASSWORD: ""
      LIBVA_DRIVER_NAME: "radeonsi"
ozett commented 3 years ago

looks like the same error at my testing of 09.x https://github.com/blakeblackshear/frigate/discussions/1502#discussioncomment-1204555

(your docker-compose shows that your are using "libva_driver" for decoding rtsp? cool)

sinamics commented 3 years ago

Can confirm same behavior on my dev pc. All clips from yesterday after 21:00 does not work for some reason. I get cors error in browser. All clips from today works.

Access to XMLHttpRequest at 'http://localhost:5000/vod/2021-08/19/21/picamera/index.m3u8' from origin 'http://localhost:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
VIDEOJS: ERROR: (CODE:2 MEDIA_ERR_NETWORK) HLS playlist request error at URL: http://localhost:5000/vod/2021-08/19/21/picamera/index.m3u8.
MediaError {code: 2, status: 0, message: "HLS playlist request error at URL: http://localhost:5000/vod/2021-08/19/21/picamera/index.m3u8.", responseText: ""}
GET http://localhost:5000/vod/2021-08/19/21/picamera/index.m3u8 net::ERR_FAILED

screendump

jasonpstokes commented 3 years ago

(your docker-compose shows that your are using "libva_driver" for decoding rtsp? cool)

I'm using rtmp, but TBH I just copied that from the docs when I started with Frigate (without a Coral), trying to get the best setup for my AMD. But I didn't know what I was doing and never got far with the mesa-va-drivers on Debian, to know how to best use it or if it was even helping. When my Coral arrived and my CPU was no longer an issue, I moved on pretty quickly! :-)

jasonpstokes commented 3 years ago

An update: switching to the MQ (Balanced) stream for detect has made a big improvement for me. This is most evident at night, if (re)starting Frigate when the cameras are in B&W mode: using the LQ (fluent) stream for detect, Frigate would show green screens for up to a minute on several (random) cameras and log lots of broken frame errors - whereas the MQ streams show immediately!

I'm also using http streams as MarkGodwin suggested (here) and, whilst it's only been 4 days, overall these two changes have made a big improvement. Far fewer broken frames messages and the camera recordings work.

However, I am now seeing the detection process get stuck a few times a day - anyone else seen this ? EDIT: Switched to 0.8 (running the same docker and Frigate config) and within an hour got the same error.

[2021-09-01 22:05:16] ws4py                          INFO    : Terminating websocket [Local => 127.0.0.1:5002 | Remote => 127.0.0.1:46980],
[2021-09-02 06:01:10] frigate.watchdog               INFO    : Detection appears to be stuck. Restarting detection process...,
[2021-09-02 06:01:10] root                           INFO    : Waiting for detection process to exit gracefully...,
[2021-09-02 06:01:40] root                           INFO    : Detection process didnt exit. Force killing...,
[2021-09-02 06:01:40] detector.coral                 INFO    : Starting detection process: 32013,
[2021-09-02 06:01:40] frigate.edgetpu                INFO    : Attempting to load TPU as usb,
[2021-09-02 06:01:43] frigate.edgetpu                INFO    : TPU found,
[2021-09-02 07:23:00] frigate.watchdog               INFO    : Detection appears to be stuck. Restarting detection process...,
[2021-09-02 07:23:00] root                           INFO    : Waiting for detection process to exit gracefully...,
[2021-09-02 07:23:30] root                           INFO    : Detection process didnt exit. Force killing...,
[2021-09-02 07:23:30] detector.coral                 INFO    : Starting detection process: 35948,
[2021-09-02 07:23:30] frigate.edgetpu                INFO    : Attempting to load TPU as usb,
[2021-09-02 07:23:33] frigate.edgetpu                INFO    : TPU found,
[2021-09-02 10:02:25] ws4py                          INFO    : Managing websocket [Local => 127.0.0.1:5002 | Remote => 127.0.0.1:53556],

Here's my 0.9 rc2 config if anyone else with Reolink cameras wants to try this-

config.yml

database:
  path: /media/frigate/database/frigate.db

detectors:
  coral:
    type: edgetpu
    device: usb

mqtt:
  host: 192.168.1.5
  port: 1883
  user: mqtt
  password: "{FRIGATE_MQTT_PASSWORD}"

birdseye:
  mode: continuous
  width: 1792
  height: 1344

detect:
  width: 896
  height: 672
  fps: 5

ffmpeg:
  input_args:
    - -avoid_negative_ts
    - make_zero
    - -fflags
    - nobuffer
    - -fflags
    - +genpts+discardcorrupt
    - -flags
    - low_delay
    - -strict
    - experimental
    - -rw_timeout
    - '5000000'
    - -f
    - live_flv

motion:
  mask:
    - 265,650,265,625,635,625,635,650 # timestamp - mine is set to bottom centre in the cameras

record:
  enabled: true
  retain_days: 1
  events:
    enabled: true
    pre_capture: 3
    retain:
      default: 15

snapshots:
  enabled: true
  clean_copy: false
  bounding_box: true
  retain:
    default: 15

cameras:
  Driveway:
    ffmpeg:
      inputs:
        - path: http://192.168.1.71/flv?port=1935&app=bcs&stream=channel0_ext.bcs&user={FRIGATE_USER}&password={FRIGATE_PASSWORD}
          roles:
            - detect
        - path: http://192.168.1.71/flv?port=1935&app=bcs&stream=channel0_main.bcs&user={FRIGATE_USER}&password={FRIGATE_PASSWORD}
          roles:
            - record
    objects:
      track:
        - person
        - vehicle
        - dog
    rtmp:
      enabled: false
    timestamp_style:
      format: "%d/%m/%Y %H:%M:%S"

  Entrance:
    ffmpeg:
      inputs:
        - path: http://192.168.1.72/flv?port=1935&app=bcs&stream=channel0_ext.bcs&user={FRIGATE_USER}&password={FRIGATE_PASSWORD}
          roles:
            - detect
        - path: http://192.168.1.72/flv?port=1935&app=bcs&stream=channel0_main.bcs&user={FRIGATE_USER}&password={FRIGATE_PASSWORD}
          roles:
            - record
    objects:
      track:
        - person
        - dog
    rtmp:
      enabled: false
    timestamp_style:
      format: "%d/%m/%Y %H:%M:%S"

docker-compose.yml

services:
  frigate:
    container_name: frigate
    image: blakeblackshear/frigate:0.9.0-rc2-amd64
    hostname: frigate
    restart: always
    shm_size: '300m'
    devices:
      - /dev/bus/usb:/dev/bus/usb
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /usr/docker/frigate/config.yml:/config/config.yml:ro
      - /usr/docker/frigate/labelmap.txt:/labelmap.txt:ro
      - /usr/docker/frigate/database:/media/frigate/database
      - /mnt/nas_storage/frigate:/media/frigate
      - type: tmpfs
        target: /tmp/cache
        tmpfs:
          size: 2000000000
    network_mode: bridge
    ports:
      - 5000:5000
    environment:
      FRIGATE_MQTT_PASSWORD: " "
      FRIGATE_USER: " "
      FRIGATE_PASSWORD: " "
jasonpstokes commented 3 years ago

Running with http has made frigate a lot more stable for me.