blakeblackshear / frigate-hass-integration

Frigate integration for Home Assistant
MIT License
728 stars 114 forks source link

After upgrade to 0.13.1 and the 5.0.0 version of the integration, delay in stream #617

Closed Remko76 closed 8 months ago

Remko76 commented 8 months ago

After the latest update/upgrade of Firgate and the integration I am experiencing a 6 to 7 second delay in opening a stream when selecting one of the cameras. I have Frigate setup in docker and use Go2RTC for the streams management and this has been working flawelessly for more than half a year. I have a few cards on my dashboard which show a still image of the camera, when I click it, it opens a window in which the stream gets started. All works basically, just ever since the upgrade there is this delay after opening the camera. I see the same delay when I go to "Settings - Devices&Services - Frigate" and select one of my cameras there.

When I use the Frigate webpage and view one of the RTC streams there, it is almost instant, the same as it was before the upgrade of the docker container and the integration.

I am seeing the same issue on 2 systems, my own with the docker setup as well as on my das's system who runs HAOS on a older Core i5 Mini PC, with Frigate running as add on.

I am testing on my system all inside my local network, so no remote problems. Unfortunately the logs do not give me much info...

Homeasisstant debug log:

home-assistant_frigate_2024-02-02T20-13-04.352Z.log

Frigate Log:

2024-02-02 21:01:19.876795869  [INFO] Preparing Frigate...
2024-02-02 21:01:19.898737048  [INFO] Starting Frigate...
2024-02-02 21:01:21.701956832  [2024-02-02 21:01:21] frigate.app                    INFO    : Starting Frigate (0.13.1-34fb1c2)
2024-02-02 21:01:21.815103658  [2024-02-02 21:01:21] peewee_migrate.logs            INFO    : Starting migrations
2024-02-02 21:01:21.834993294  [2024-02-02 21:01:21] peewee_migrate.logs            INFO    : Migrate "013_create_timeline_table"
2024-02-02 21:01:21.835195275  [2024-02-02 21:01:21] peewee_migrate.logs            INFO    : sql ('CREATE TABLE IF NOT EXISTS "timeline" ("timestamp" DATETIME NOT NULL, "camera" VARCHAR(20) NOT NULL, "source" VARCHAR(20) NOT NULL, "source_id" VARCHAR(30), "class_type" VARCHAR(50) NOT NULL, "data" JSON)',)
2024-02-02 21:01:21.835404068  [2024-02-02 21:01:21] peewee_migrate.logs            INFO    : sql ('CREATE INDEX IF NOT EXISTS "timeline_camera" ON "timeline" ("camera")',)
2024-02-02 21:01:21.835746137  [2024-02-02 21:01:21] peewee_migrate.logs            INFO    : sql ('CREATE INDEX IF NOT EXISTS "timeline_source" ON "timeline" ("source")',)
2024-02-02 21:01:21.836044894  [2024-02-02 21:01:21] peewee_migrate.logs            INFO    : sql ('CREATE INDEX IF NOT EXISTS "timeline_source_id" ON "timeline" ("source_id")',)
2024-02-02 21:01:21.837612362  [2024-02-02 21:01:21] peewee_migrate.logs            INFO    : Done 013_create_timeline_table
2024-02-02 21:01:21.841318167  [2024-02-02 21:01:21] peewee_migrate.logs            INFO    : Migrate "014_event_updates_for_fp"
2024-02-02 21:01:21.841454710  [2024-02-02 21:01:21] peewee_migrate.logs            INFO    : add_column ('event', 'score', <FloatField: Event.score>)
2024-02-02 21:01:21.842016763  [2024-02-02 21:01:21] peewee_migrate.logs            INFO    : add_column ('event', 'model_hash', <CharField: Event.model_hash>)
2024-02-02 21:01:21.842562033  [2024-02-02 21:01:21] peewee_migrate.logs            INFO    : add_column ('event', 'detector_type', <CharField: Event.detector_type>)
2024-02-02 21:01:21.843075014  [2024-02-02 21:01:21] peewee_migrate.logs            INFO    : add_column ('event', 'model_type', <CharField: Event.model_type>)
2024-02-02 21:01:21.843461213  [2024-02-02 21:01:21] peewee_migrate.logs            INFO    : drop_not_null ('event', 'area')
2024-02-02 21:01:21.850424605  [2024-02-02 21:01:21] peewee_migrate.logs            INFO    : drop_not_null ('event', 'false_positive')
2024-02-02 21:01:21.855286134  [2024-02-02 21:01:21] peewee_migrate.logs            INFO    : apply_default ('event', 'false_positive', <BooleanField: Event.false_positive>)
2024-02-02 21:01:21.856231893  [2024-02-02 21:01:21] peewee_migrate.logs            INFO    : Done 014_event_updates_for_fp
2024-02-02 21:01:21.866541670  [2024-02-02 21:01:21] peewee_migrate.logs            INFO    : Migrate "015_event_refactor"
2024-02-02 21:01:21.866772456  [2024-02-02 21:01:21] peewee_migrate.logs            INFO    : drop_not_null ('event', 'top_score')
2024-02-02 21:01:21.871742893  [2024-02-02 21:01:21] peewee_migrate.logs            INFO    : drop_not_null ('event', 'score')
2024-02-02 21:01:21.876230017  [2024-02-02 21:01:21] peewee_migrate.logs            INFO    : drop_not_null ('event', 'region')
2024-02-02 21:01:21.880629300  [2024-02-02 21:01:21] peewee_migrate.logs            INFO    : drop_not_null ('event', 'box')
2024-02-02 21:01:21.885072372  [2024-02-02 21:01:21] peewee_migrate.logs            INFO    : drop_not_null ('event', 'area')
2024-02-02 21:01:21.889418305  [2024-02-02 21:01:21] peewee_migrate.logs            INFO    : drop_not_null ('event', 'ratio')
2024-02-02 21:01:21.894483652  [2024-02-02 21:01:21] peewee_migrate.logs            INFO    : add_column ('event', 'data', <JSONField: Event.data>)
2024-02-02 21:01:21.903733311  [2024-02-02 21:01:21] peewee_migrate.logs            INFO    : Done 015_event_refactor
2024-02-02 21:01:21.909957585  [2024-02-02 21:01:21] peewee_migrate.logs            INFO    : Migrate "016_sublabel_increase"
2024-02-02 21:01:21.910212856  [2024-02-02 21:01:21] peewee_migrate.logs            INFO    : change_column ('event', 'sub_label', <CharField: Event.sub_label>)
2024-02-02 21:01:21.915313467  [2024-02-02 21:01:21] peewee_migrate.logs            INFO    : Done 016_sublabel_increase
2024-02-02 21:01:21.931226286  [2024-02-02 21:01:21] peewee_migrate.logs            INFO    : Migrate "017_update_indexes"
2024-02-02 21:01:21.931389982  [2024-02-02 21:01:21] peewee_migrate.logs            INFO    : sql ('CREATE INDEX "recordings_camera_segment_size" ON "recordings" ("camera", "segment_size")',)
2024-02-02 21:01:21.932773046  [2024-02-02 21:01:21] peewee_migrate.logs            INFO    : Done 017_update_indexes
2024-02-02 21:01:21.934505435  [2024-02-02 21:01:21] peewee_migrate.logs            INFO    : Migrate "018_add_dbfs"
2024-02-02 21:01:21.934659256  [2024-02-02 21:01:21] peewee_migrate.logs            INFO    : add_column ('recordings', 'dBFS', <IntegerField: Recordings.dBFS>)
2024-02-02 21:01:21.935471403  [2024-02-02 21:01:21] peewee_migrate.logs            INFO    : Done 018_add_dbfs
2024-02-02 21:01:21.936444695  [2024-02-02 21:01:21] peewee_migrate.logs            INFO    : Migrate "019_create_regions_table"
2024-02-02 21:01:21.936596845  [2024-02-02 21:01:21] peewee_migrate.logs            INFO    : sql ('CREATE TABLE IF NOT EXISTS "regions" ("camera" VARCHAR(20) NOT NULL PRIMARY KEY, "last_update" DATETIME NOT NULL, "grid" JSON)',)
2024-02-02 21:01:21.937173067  [2024-02-02 21:01:21] peewee_migrate.logs            INFO    : Done 019_create_regions_table
2024-02-02 21:01:21.938181137  [2024-02-02 21:01:21] peewee_migrate.logs            INFO    : Migrate "020_update_index_recordings"
2024-02-02 21:01:21.938340365  [2024-02-02 21:01:21] peewee_migrate.logs            INFO    : sql ('DROP INDEX recordings_end_time_start_time',)
2024-02-02 21:01:21.938551219  [2024-02-02 21:01:21] peewee_migrate.logs            INFO    : sql ('CREATE INDEX "recordings_camera_start_time_end_time" ON "recordings" ("camera", "start_time" DESC, "end_time" DESC)',)
2024-02-02 21:01:21.939263594  [2024-02-02 21:01:21] peewee_migrate.logs            INFO    : sql ('CREATE INDEX "recordings_api_recordings_summary" ON "recordings" ("camera", "start_time" DESC, "duration", "motion", "objects")',)
2024-02-02 21:01:21.940108705  [2024-02-02 21:01:21] peewee_migrate.logs            INFO    : sql ('CREATE INDEX "recordings_start_time" ON "recordings" ("start_time")',)
2024-02-02 21:01:21.940942130  [2024-02-02 21:01:21] peewee_migrate.logs            INFO    : Done 020_update_index_recordings
2024-02-02 21:01:21.950093520  [2024-02-02 21:01:21] frigate.app                    INFO    : Recording process started: 298
2024-02-02 21:01:21.955179788  [2024-02-02 21:01:21] frigate.app                    INFO    : go2rtc process pid: 89
2024-02-02 21:01:21.996782623  [2024-02-02 21:01:21] detector.coral                 INFO    : Starting detection process: 308
2024-02-02 21:01:24.639321938  [2024-02-02 21:01:22] frigate.app                    INFO    : Output process started: 313
2024-02-02 21:01:24.639960063  [2024-02-02 21:01:22] frigate.app                    INFO    : Camera processor started for esszimmer: 320
2024-02-02 21:01:24.645137828  [2024-02-02 21:01:21] frigate.detectors.plugins.edgetpu_tfl INFO    : Attempting to load TPU as usb
2024-02-02 21:01:24.645467904  [2024-02-02 21:01:22] frigate.app                    INFO    : Camera processor started for garage: 322
2024-02-02 21:01:24.645624365  [2024-02-02 21:01:24] frigate.detectors.plugins.edgetpu_tfl INFO    : TPU found
2024-02-02 21:01:24.645804110  [2024-02-02 21:01:22] frigate.app                    INFO    : Camera processor started for garten: 324
2024-02-02 21:01:24.645917681  [2024-02-02 21:01:22] frigate.app                    INFO    : Camera processor started for carport: 327
2024-02-02 21:01:24.646024882  [2024-02-02 21:01:22] frigate.app                    INFO    : Camera processor started for werkstatt: 330
2024-02-02 21:01:24.646123057  [2024-02-02 21:01:22] frigate.app                    INFO    : Camera processor started for eingang: 332
2024-02-02 21:01:24.646209057  [2024-02-02 21:01:22] frigate.app                    INFO    : Capture process started for esszimmer: 334
2024-02-02 21:01:24.646303650  [2024-02-02 21:01:22] frigate.app                    INFO    : Capture process started for garage: 339
2024-02-02 21:01:24.646402660  [2024-02-02 21:01:22] frigate.app                    INFO    : Capture process started for garten: 341
2024-02-02 21:01:24.646496698  [2024-02-02 21:01:22] frigate.app                    INFO    : Capture process started for carport: 347
2024-02-02 21:01:24.646589933  [2024-02-02 21:01:22] frigate.app                    INFO    : Capture process started for werkstatt: 354
2024-02-02 21:01:24.646677752  [2024-02-02 21:01:22] frigate.app                    INFO    : Capture process started for eingang: 365
2024-02-02 21:01:30.858692495  [2024-02-02 21:01:30] frigate.comms.dispatcher       INFO    : Turning off recordings for esszimmer
2024-02-02 21:01:31.337422695  [2024-02-02 21:01:31] frigate.comms.dispatcher       INFO    : Turning off snapshots for esszimmer
2024-02-02 21:01:32.567440485  [2024-02-02 21:01:32] frigate.comms.dispatcher       INFO    : Turning off recordings for garten
2024-02-02 21:01:33.055236074  [2024-02-02 21:01:33] frigate.comms.dispatcher       INFO    : Turning off snapshots for garten
2024-02-02 21:01:34.869558647  [2024-02-02 21:01:34] frigate.comms.dispatcher       INFO    : Turning off recordings for werkstatt
2024-02-02 21:01:35.305679262  [2024-02-02 21:01:35] frigate.comms.dispatcher       INFO    : Turning off snapshots for werkstatt

Go2RTC Log:

2024-02-02 21:01:19.886213444  [INFO] Preparing new go2rtc config...
2024-02-02 21:01:20.409572465  [INFO] Not injecting WebRTC candidates into go2rtc config as it has been set manually
2024-02-02 21:01:20.464305564  [INFO] Starting go2rtc...
2024-02-02 21:01:20.562761404  21:01:20.562 INF go2rtc version 1.8.4 linux/amd64
2024-02-02 21:01:20.563795161  21:01:20.563 INF [api] listen addr=:1984
2024-02-02 21:01:20.564189489  21:01:20.564 INF [rtsp] listen addr=:8554
2024-02-02 21:01:20.564789514  21:01:20.564 INF [webrtc] listen addr=:8555
2024-02-02 21:01:29.877226198  [INFO] Starting go2rtc healthcheck service...

Frigate Config:

mqtt:
  host: 192.168.76.6
  user: USER
  password: PASS

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

ffmpeg:
  hwaccel_args: preset-vaapi
  output_args:
    record: preset-record-generic-audio-aac

detectors:
  coral:
    type: edgetpu
    device: usb

birdseye:
  enabled: True
  mode: continuous

# Resolutions 
# Wansview W5: High: 1920x1080, Low: 768x432 (15fps)
# Reolink E1Pro: High: 2560 x 1440, Low: 640x360 (15fps)
# Reolink RLC410W: High: 2560 x 1440, Low: 640x360 (15fps)

go2rtc:
  streams:
    esszimmer:
      - rtsp://USER:PASS@192.168.76.63:554/live/ch0
      - ffmpeg:esszimmer#audio=opus
    esszimmer_sub:
      - rtsp://USER:PASS@192.168.76.63:554/live/ch1
      - ffmpeg:esszimmer_sub#audio=opus
    carport:
      - rtsp://USER:PASS@192.168.76.61:554/live/ch0
      - ffmpeg:carport#audio=opus   
    carport_sub:
      - rtsp://USER:PASS@192.168.76.61:554/live/ch1
      - ffmpeg:carport_sub#audio=opus
    garten:
      - rtsp://admin:PASS@192.168.76.60:554/h264Preview_01_main
      - ffmpeg:garten#audio=opus
    garten_sub:
      - rtsp://admin:PASS@192.168.76.60:554/h264Preview_01_sub
      - ffmpeg:garten_sub#audio=opus
    garage:
      - rtsp://USER:PASS@192.168.76.62:554/live/ch0
      - ffmpeg:garage#audio=opus
    garage_sub:
      - rtsp://USER:PASS@192.168.76.62:554/live/ch1
      - ffmpeg:garage_sub#audio=opus
    eingang:
      - rtsp://admin:PASS@192.168.76.64:554/h264Preview_01_main
      - ffmpeg:eingang#audio=opus
    eingang_sub:
      - rtsp://admin:PASS@192.168.76.64:554/h264Preview_01_sub
      - ffmpeg:eingang_sub#audio=opus
    werkstatt:
      - rtsp://admin:PASS@192.168.76.65:554/h264Preview_01_main
      - ffmpeg:werkstatt#audio=opus
    werkstatt_sub:
      - rtsp://admin:PASS@192.168.76.65:554/h264Preview_01_sub
      - ffmpeg:werkstatt_sub#audio=opus
  webrtc:
    candidates:
    - 192.168.76.6:8555
    - stun:8555
##########################################################
cameras:
  esszimmer:
    ui:
      order: 4
    ffmpeg:
      inputs:
        #High Res
        - path: rtsp://127.0.0.1:8554/esszimmer
          roles:
            - record
        #Low Res    
        - path: rtsp://127.0.0.1:8554/esszimmer_sub
          roles:
            - detect
    detect:
      enabled: true
      width: 768
      height: 432
      fps: 5
    snapshots:
      enabled: true
    record:
      enabled: true
      retain:
        days: 7
        mode: motion
      events:
        retain:
          default: 10    

##########################################################
  garage:
    ui:
      order: 6
    ffmpeg:
      inputs:
        #High Res
        - path: rtsp://127.0.0.1:8554/garage
          roles:
            - record
        #Low Res    
        - path: rtsp://127.0.0.1:8554/garage_sub
          roles:
            - detect
    detect:
      enabled: true
      width: 768
      height: 432
      fps: 5
    snapshots:
      enabled: true
    record:
      enabled: true
      retain:
        days: 7
        mode: motion
      events:
        retain:
          default: 10    
    objects:
      track:
        - person
        - car
#        - motorcycle
        - cat
        - bird
        - mouse

##########################################################
  garten:
    ui:
      order: 3
    ffmpeg:
      inputs:
        #High Res
        - path: rtsp://127.0.0.1:8554/garten
          roles:
            - record
        #Low Res    
        - path: rtsp://127.0.0.1:8554/garten_sub
          roles:
            - detect
    detect:
      enabled: true
      width: 640
      height: 360
      fps: 5
    snapshots:
      enabled: true
    record:
      enabled: true
      retain:
        days: 7
        mode: motion
      events:
        retain:
          default: 10    
    objects:
      track:
        - person
        - cat
        - bird
      filters:
        person:
          threshold: 0.72
          min_area: 2500
    motion:
      mask:
        - 640,0,640,160,517,143,496,91,485,0
        - 0,0,239,0,289,0,292,92,266,203,30,360,0,360

##########################################################
  carport:
    ui:
      order: 2
    ffmpeg:
      inputs:
        #High Res
        - path: rtsp://127.0.0.1:8554/carport
          roles:
            - record
        #Low Res    
        - path: rtsp://127.0.0.1:8554/carport_sub
          roles:
            - detect
    detect:
      enabled: true
      width: 768
      height: 432
      fps: 5
    snapshots:
      enabled: true
      required_zones:
        - carport_under_roof
    record:
      enabled: true
      retain:
        days: 7
        mode: motion
      events:
        retain:
          default: 10    
        required_zones:
          - carport_under_roof
    zones:
      carport_under_roof:
        coordinates: 0,432,768,432,768,207,359,107,0,215
    motion:
      mask:
        - 768,202,312,92,0,182,0,0,768,0
    objects:
      track:
        - person
        - cat
        - bird
        - car
        - motorcycle

##########################################################
  werkstatt:
    ui:
      order: 5
    ffmpeg:
      inputs:
        #High Res
        - path: rtsp://127.0.0.1:8554/werkstatt
          roles:
            - record
        #Low Res    
        - path: rtsp://127.0.0.1:8554/werkstatt_sub
          roles:
            - detect
#    live:
#      stream_name: werkstatt_sub
    detect:
      enabled: true
      width: 640
      height: 360
      fps: 5
    snapshots:
      enabled: true
    record:
      enabled: true
      retain:
        days: 7
        mode: motion
      events:
        retain:
          default: 10    
    objects:
      track:
        - person
        - cat
        - car
        - mouse
#        - motorcycle

##########################################################
  eingang:
    ui:
      order: 1
    ffmpeg:
      inputs:
        #High Res
        - path: rtsp://127.0.0.1:8554/eingang
          roles:
            - record
        #Low Res    
        - path: rtsp://127.0.0.1:8554/eingang_sub
          roles:
            - detect
    detect:
      enabled: true
      width: 640
      height: 360
      fps: 5
    snapshots:
      enabled: true
      required_zones:
        - entry_front_door
    record:
      enabled: true
      retain:
        days: 7
        mode: motion
      events:
        retain:
          default: 10    
        required_zones:
          - entry_front_door
    motion:
      mask:
        - 0,0,39,0,33,22,0,36
        - 354,162,388,180,435,200,412,325,266,331,262,163
    zones:
      entry_carport:
        coordinates: 223,177,229,63,298,58,336,172
      entry_front_door:
        coordinates: 96,360,438,360,315,60,191,66
    objects:
      track:
        - person
        - cat
        - bird
        - car
        - umbrella
        - motorcycle

Screenshot of Frigate System Page: image

I hope someone has an idea or is experiencing the same isseu....

NickM-27 commented 8 months ago

you may want to try enabling webrtc direct stream in the integration settings

Remko76 commented 8 months ago

You are golden...I did not see that was a new option. Cannot thank you enough for the quick reply, I lost my mind over all of this earlier today. Now my inner Monk is happy again...all updated to the latest versions, all working flawelessly again. Even better as before with the tips you gave me on my other issue.

Thanks a lot! I will finally sleep again now....;)

7floor commented 8 months ago

@NickM-27

you may want to try enabling webrtc direct stream in the integration settings

With this setting enabled, I'm getting all my cameras hidden as incompatible in Media Browser/Cameras

image

When I disable it, it works:

image

Is it a bug or some known limitation?

NickM-27 commented 8 months ago

It's expected when viewing on a browser