blakeblackshear / frigate

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

[HW Accel Support]: i3 8.gen Iris graphics #7326

Closed mesistostefre closed 11 months ago

mesistostefre commented 11 months ago

Describe the problem you are having

Frigate "System" page shows: GPU detected. But ... ffmeg does not seem to use it: CPU load with HW enabled is slightly higher than with GPU disabled.

Ok, I read the docs, have the "full access" version running, disabled this proteced mode within HAOS, globally set hwaccel_args: preset-vaapi and yes: "System" page shows GPU. Usage: 0,28% Memory: -%. At the same time I have a CPU usage of 21% on my NUC-style "Geekom" i3, dedicated to Homeassistant

When I turn off hardware acceleration everything keeps on working just fine, but theCPU load of the overall system is actually lower: 18%. When I stop the Frigate add-on, the CPU load is 4%.

I set up proper masks, remote saving of recording, have a TPU, limit the cams to their minimum of 7fps for detection. Continue to detect with 5fps.

Running out of ideas... :-/

Version

Frigate (Full Access) Current version: 0.12.1

Frigate config file

record:
  retain:
    days: 0
    mode: active_objects
  events:
    objects:
      - person
      - car
    retain:
      default: 10
      mode: active_objects

mqtt:
  enabled: True
  host: 192.168.xxx.xx
  port: 1883
  topic_prefix: frigate
  client_id: frigate
  user: someuser
  password: somepw

database:
  path: /config/frigate.db

detectors: 
  coral:
    type: edgetpu
    device: usb

objects:
  track:
    - person
    - car
    - bird
    - dog
    - cat

birdseye:
  enabled: True
  mode: continuous

environment_vars:
  LIBVA_DRIVER_NAME: iHD

ffmpeg:
  global_args: -hide_banner -loglevel info
  hwaccel_args: preset-vaapi
  # hwaccel_args: -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format yuv420p

  output_args:
    record: preset-record-generic-audio-aac

go2rtc:
  streams:
    CameraGarageDetect:
      - rtsp://user1:pw@someip:554/h264Preview_01_sub
    CameraGarageRecord:
      - rtsp://user1:pw@someip:554/h264Preview_01_main
    CameraFrontDoorDetect:
      - rtsp://user2:pw2@someotherip:554/h264Preview_01_sub
    CameraFrontDoorRecord:
      - rtsp://user2:pw2@someotherip:554/h265Preview_01_main
      - "ffmpeg:CameraFrontDoorRecord#video=h264#hardware"

cameras:
  CameraFrontDoor: 
    enabled: True
    ffmpeg:
      inputs:
#        - path: rtsp://127.0.0.1:8554/CameraFrontDoorDetect?video=copy
        - path: rtsp://127.0.0.1:8554/CameraFrontDoorDetect
          input_args: preset-rtsp-restream
          roles:
            - detect
        - path: rtsp://127.0.0.1:8554/CameraFrontDoorRecord?video=copy&audio=aac
#        - path: rtsp://127.0.0.1:8554/CameraFrontDoorRecord?audio=aac
          input_args: preset-rtsp-restream
          roles:
            - record
    detect:
      enabled: True # <---- disable detection until you have a working camera feed
      width: 640 
      height: 360 
      fps: 5
    record: 
      enabled: True
    snapshots: 
      enabled: True

    live:
      stream_name: CameraFrontDoorRecord

    motion:
      mask:
        - 0,0,0,360,386,360,386,0
        - 640,0,524,0,524,44,613,111,611,174,640,180
    zones:
      Haustür:
        coordinates: 400,321,518,360,640,360,640,275,523,245,506,21,391,23
      Parkplatz_1:
        coordinates: 640,360,640,337,151,318,115,360
      Parkplatz_2:
        coordinates: 541,114,511,117,510,78,574,68,619,99,640,184,543,184
      Briefkasten:
        coordinates: 553,248,640,185,572,188,544,175,510,179,510,259

  CameraGarage: 
    enabled: True
    ffmpeg:
      inputs:
#        - path: rtsp://127.0.0.1:8554/CameraGarageDetect?video=copy
        - path: rtsp://127.0.0.1:8554/CameraGarageDetect
          input_args: preset-rtsp-restream
          roles:
            - detect
        - path: rtsp://127.0.0.1:8554/CameraGarageRecord?video=copy&audio=aac
          input_args: preset-rtsp-restream
          roles:
            - record
    detect:
      enabled: True 
      width: 640 
      height: 480 
      fps: 5
    record: 
      enabled: True
    snapshots: 
      enabled: True

    live:
      stream_name: CameraGarageRecord

    motion:
      mask:
        - 640,0,640,242,571,231,475,0
        - 279,0,0,0,0,65,277,68
        - 284,103,323,108,382,134,394,214,383,275,308,289,267,225,248,127
        - 522,0,557,41,422,78,388,108,364,138,290,103,279,56,287,0

    zones:
      EinliegerHinten:
        coordinates: 383,119,418,378,250,371,276,81
      GarageHinten:
        coordinates: 640,375,640,480,0,480,0,0,258,138,245,366
      TerrasseMauer:
        coordinates: 394,257,571,225,500,51,376,70

docker-compose file or Docker CLI command

HassOS add-on

Relevant log output

{"return_code":0,"stderr":"","stdout":"vainfo:VA-APIversion:1.17(libva2.10.0)nvainfo:Driverversion:InteliHDdriverforIntel(R)GenGraphics-23.1.1()nvainfo:SupportedprofileandentrypointsnVAProfileNone:tVAEntrypointVideoProcnVAProfileNone:tVAEntrypointStatsnVAProfileMPEG2Simple:tVAEntrypointVLDnVAProfileMPEG2Simple:tVAEntrypointEncSlicenVAProfileMPEG2Main:tVAEntrypointVLDnVAProfileMPEG2Main:tVAEntrypointEncSlicenVAProfileH264Main:tVAEntrypointVLDnVAProfileH264Main:tVAEntrypointEncSlicenVAProfileH264Main:tVAEntrypointFEInVAProfileH264Main:tVAEntrypointEncSliceLPnVAProfileH264High:tVAEntrypointVLDnVAProfileH264High:tVAEntrypointEncSlicenVAProfileH264High:tVAEntrypointFEInVAProfileH264High:tVAEntrypointEncSliceLPnVAProfileVC1Simple:tVAEntrypointVLDnVAProfileVC1Main:tVAEntrypointVLDnVAProfileVC1Advanced:tVAEntrypointVLDnVAProfileJPEGBaseline:tVAEntrypointVLDnVAProfileJPEGBaseline:tVAEntrypointEncPicturenVAProfileH264ConstrainedBaseline:tVAEntrypointVLDnVAProfileH264ConstrainedBaseline:tVAEntrypointEncSlicenVAProfileH264ConstrainedBaseline:tVAEntrypointFEInVAProfileH264ConstrainedBaseline:tVAEntrypointEncSliceLPnVAProfileVP8Version0_3:tVAEntrypointVLDnVAProfileVP8Version0_3:tVAEntrypointEncSlicenVAProfileHEVCMain:tVAEntrypointVLDnVAProfileHEVCMain:tVAEntrypointEncSlicenVAProfileHEVCMain:tVAEntrypointFEInVAProfileHEVCMain10:tVAEntrypointVLDnVAProfileHEVCMain10:tVAEntrypointEncSlicenVAProfileVP9Profile0:tVAEntrypointVLDnVAProfileVP9Profile2:tVAEntrypointVLD"}

FFprobe output from your camera

[{"return_code":0,"stderr":"","stdout":{"programs":[],"streams":[{"avg_frame_rate":"7/1","codec_long_name":"H.264/AVC/MPEG-4AVC/MPEG-4part10","height":360,"width":640},{"avg_frame_rate":"0/0","codec_long_name":"AAC(AdvancedAudioCoding)"}]}},{"return_code":0,"stderr":"","stdout":{"programs":[],"streams":[{"avg_frame_rate":"20/1","codec_long_name":"H.265/HEVC(HighEfficiencyVideoCoding)","height":2160,"width":3840},{"avg_frame_rate":"0/0","codec_long_name":"AAC(AdvancedAudioCoding)"}]}}]

[{"return_code":0,"stderr":"","stdout":{"programs":[],"streams":[{"avg_frame_rate":"0/0","codec_long_name":"H.264/AVC/MPEG-4AVC/MPEG-4part10","height":480,"width":640},{"avg_frame_rate":"0/0","codec_long_name":"AAC(AdvancedAudioCoding)"}]}},{"return_code":0,"stderr":"","stdout":{"programs":[],"streams":[{"avg_frame_rate":"0/0","codec_long_name":"H.264/AVC/MPEG-4AVC/MPEG-4part10","height":1296,"width":2304},{"avg_frame_rate":"0/0","codec_long_name":"AAC(AdvancedAudioCoding)"}]}}]

Operating system

HassOS

Install method

HassOS Addon

Network connection

Wired

Camera make and model

Reolink 820A, Reolink 522

Any other information that may be helpful

No response

NickM-27 commented 11 months ago
  1. You should not be overriding global args, you are removing some args that reduce cpu usage
  2. There is no reason to restream the detect stream, restreaming uses CPU and if you are not going to use it for anything else then that is a waste
  3. Is there a reason that you are creating an h264 stream from the h265 camera? That is a high load as well
mesistostefre commented 11 months ago

Thanks for you immediate response. I really appreciate it.

  1. using default global args now: none in frigate.yaml
  2. good hint: detect stream now used directly in camera definition
  3. have an old spare Android which did not play back 265. But I removed the transcoding now

CPU usage changed slightly: with HW accel: from 21% to 20% w/o HW accel: from 18% to 18%

Still do not understand why CPU load with HW accell is higher... and why GPU % is 0,3% and Memory is -%. Maybe the GPU got just nothing to do in my setup? Means: will keep HW accell switched off and live with it.

Thanks anyways for the hint to not restream the detect stream!