frigate icon indicating copy to clipboard operation
frigate copied to clipboard

[Config Support]: Enable HEVC/H.265 on Friagte

Open bracan12 opened this issue 2 years ago • 10 comments

Describe the problem you are having

I am using frigate in Home Assistant installed on a Raspberry PI4B and try to configure a Reolink RLC810A for detecting in 4K(Main Stream). I noticed H.265 works without Hardware Acceleration but with very high CPU usage and very laggy. I added the following flags to hwaccel_args and I get a green screen.

Is there a way to encode H265 with hwaccel_args on PI4?

Version

0.10.1-83481AF

Frigate config file

mqtt:
  host: -
  user: -
  password: -  
cameras:
  cam1:
    ffmpeg:
      inputs:
        - path: rtsp://admin:@ipaddress:554//h265Preview_01_main
          roles:
            - detect
      hwaccel_args:
        - -c:v
        - h264_v4l2m2m
    rtmp:
      enabled: False
    detect:
      fps: 3
      width: 3840
      height: 2160      
    snapshots:
      enabled: True

Relevant log output

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[2022-07-30 12:36:25] frigate.app                    INFO    : Starting Frigate (0.10.1-83481af)
[2022-07-30 12:36:25] frigate.app                    INFO    : Creating directory: /tmp/cache
Starting migrations
[2022-07-30 12:36:25] peewee_migrate                 INFO    : Starting migrations
There is nothing to migrate
[2022-07-30 12:36:25] peewee_migrate                 INFO    : There is nothing to migrate
[2022-07-30 12:36:25] frigate.app                    INFO    : Output process started: 218
[2022-07-30 12:36:25] detector.cpu                   INFO    : Starting detection process: 217
[2022-07-30 12:36:25] frigate.app                    INFO    : Camera processor started for cam1: 221
[2022-07-30 12:36:25] frigate.edgetpu                WARNING : CPU detectors are not recommended and should only be used for testing or for trial purposes.
[2022-07-30 12:36:25] frigate.app                    INFO    : Capture process started for cam1: 222
[2022-07-30 12:36:25] ws4py                          INFO    : Using epoll
[2022-07-30 12:36:25] ws4py                          INFO    : Using epoll

Frigate stats

No response

Operating system

HassOS

Install method

HassOS Addon

Coral version

CPU (no coral)

Any other information that may be helpful

The hardware acceleration flags work with H264 substream but I need to work it with H265 Main Stream

bracan12 avatar Jul 30 '22 10:07 bracan12

The hardware acceleration flag is h264_v4l2m2m so naturally it will only work with h264. Did you try hevc_v4l2m2m ?

NickM-27 avatar Jul 30 '22 11:07 NickM-27

Thank you. I tried it with hevc_v4l2m2m but unfortunately it had no effect, still showing a green screen. Debug Camera FPS is also at 0.

ghost avatar Jul 30 '22 12:07 ghost

You can run ffmpeg -decoders inside the frigate container to see what decoders are supported

NickM-27 avatar Jul 30 '22 14:07 NickM-27

Yes the command gave me a bunch of codecs but from my research the only suitable codec for my PI4 is actually hevc_v4l2m2m. But I can't explain why it is not working.

ghost avatar Jul 30 '22 20:07 ghost

Maybe try frigate 0.11 RC it has a new ffmpeg build that could work better

NickM-27 avatar Jul 31 '22 12:07 NickM-27

I don't believe the Pi has hwaccel for h265

blakeblackshear avatar Jul 31 '22 12:07 blakeblackshear

I don't believe the Pi has hwaccel for h265

Oh yeah, looks like it is an open issue in the jellyfin repo https://github.com/jellyfin/jellyfin-ffmpeg/issues/129

NickM-27 avatar Jul 31 '22 13:07 NickM-27

workaround to use h264-streams from RLC810A:

  1. upgrade Fw to last from here
  2. change encode resolution for "clear"-stream to 2560*1440
  3. enable RMTP under Network-Settings/Port-Settings
  4. you can use following h264 RMTP-streams now: clean (2560x1440): rtmp://{IP}/bcs/channel0_main.bcs?channel=0&stream=0&user=admin&password={password} balanced (896x512): rtmp://{IP}/bcs/channel0_ext.bcs?channel=0&stream=2&user=admin&password={password} fluent (640x360): rtmp://{IP}/bcs/channel0_sub.bcs?channel=0&stream=1&user=admin&password={password}

mdkeil avatar Aug 24 '22 12:08 mdkeil

I don't believe the Pi has hwaccel for h265

It does... https://datasheets.raspberrypi.com/rpi4/raspberry-pi-4-datasheet.pdf

H.265 (HEVC) hardware decode (up to 4Kp60)
H.264 hardware decode (up to 1080p60)

mpietruschka avatar Aug 31 '22 15:08 mpietruschka

I don't believe the Pi has hwaccel for h265

It does... https://datasheets.raspberrypi.com/rpi4/raspberry-pi-4-datasheet.pdf

H.265 (HEVC) hardware decode (up to 4Kp60)
H.264 hardware decode (up to 1080p60)

It supports h265 but ffmpeg does not currently support it

NickM-27 avatar Aug 31 '22 15:08 NickM-27

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Oct 01 '22 00:10 github-actions[bot]