blakeblackshear / frigate

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

[HW Accel Support]: RPi4 - Failed to find Size=2560x1920, fmt=NV12 in 1 frame size enums #5678

Closed krcm0209 closed 1 year ago

krcm0209 commented 1 year ago

Describe the problem you are having

Frigate / FFmpeg cannot process the RTSP video stream when I attempt to use hardware accelerated decoding. I currently have my camera set to use h.264 encoding because I figured it would be less problematic than h.265. Everything works when I am not attempting to use hardware accelerated decoding. That is, when I comment out the ffmpeg global section in the frigate.yml file.

# ffmpeg:
#   hwaccel_args: preset-rpi-64-h264

Version

0.12.0-beta9

Frigate config file

mqtt:
  host: 10.0.0.177
  user: frigate
  password: frigate

detectors:
  coral:
    type: edgetpu
    device: usb

ffmpeg:
  hwaccel_args: preset-rpi-64-h264

cameras:
  front_door:
    ffmpeg:
      inputs:
        - path: rtsp://username:password@10.0.0.54:554/cam/realmonitor?channel=1&subtype=0&authbasic=64
          roles:
            - detect
    rtmp:
      enabled: False
    detect:
      width: 2560
      height: 1920

docker-compose file or Docker CLI command

N/A

Relevant log output

2023-03-08 18:09:44.319944774  [2023-03-08 13:09:44] frigate.video                  ERROR   : front_door: Unable to read frames from ffmpeg process.
2023-03-08 18:09:44.320461305  [2023-03-08 13:09:44] frigate.video                  ERROR   : front_door: ffmpeg process is not running. exiting capture thread...
2023-03-08 18:09:49.112138152  [2023-03-08 13:09:49] watchdog.front_door            ERROR   : Ffmpeg process crashed unexpectedly for front_door.
2023-03-08 18:09:49.125779061  [2023-03-08 13:09:49] watchdog.front_door            ERROR   : The following ffmpeg logs include the last 100 lines prior to exit.
2023-03-08 18:09:49.126632477  [2023-03-08 13:09:49] ffmpeg.front_door.detect       ERROR   : [h264_v4l2m2m @ 0x558e8ca4c0] Failed to find Size=2560x1920, fmt=NV12 in 1 frame size enums
2023-03-08 18:09:49.127279545  [2023-03-08 13:09:49] ffmpeg.front_door.detect       ERROR   : Error while opening decoder for input stream #0:0 : Invalid argument

FFprobe output from your camera

ffprobe version 4.2.7-0ubuntu0.1 Copyright (c) 2007-2022 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.1)
  configuration: --prefix=/usr --extra-version=0ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
[rtsp @ 0x55c98f22ba00] UDP timeout, retrying with TCP
[rtsp @ 0x55c98f22ba00] method SETUP failed: 461 Unsupported transport
[rtsp @ 0x55c98f22ba00] Could not find codec parameters for stream 0 (Video: h264, none): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, rtsp, from 'rtsp://username:password@10.0.0.54:554/cam/realmonitor?channel=1&subtype=0&authbasic=64':
  Metadata:
    title           : Media Server
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: h264, none, 90k tbr, 90k tbn, 180k tbc
    Stream #0:1: Audio: aac, 8000 Hz, mono, fltp

Operating system

HassOS

Install method

HassOS Addon

Network connection

Wireless

Camera make and model

Amcrest AD410

Any other information that may be helpful

I did not increase the allocated RAM for the Pi4 GPU to at least 128 as recommended in the beta docs, because according to the official Pi documentation for the Pi4, 76 is the default allocation, and the gpu_mem recommended maximum is also 76.

image

NickM-27 commented 1 year ago

The RPi hardware decoder does not support resolutions greater than 1920x1080 for h264

krcm0209 commented 1 year ago

The RPi hardware decoder does not support resolutions greater than 1920x1080 for h264

Are you aware of support for higher resolutions with h265?

NickM-27 commented 1 year ago

The RPi hardware decoder does not support resolutions greater than 1920x1080 for h264

Are you aware of support for higher resolutions with h265?

It is higher at 3840x2160 but ffmpeg doesn't have much support for the RPi h.265 decoder

krcm0209 commented 1 year ago

I can verify that setting my camera to a lower output resolution fixed this issue.

On h.265: I can't recall the specifics, but I think I had tried switching to h.265 as a troubleshooting step, and was met with different errors, but ultimately it still would not work. At this time, is Frigate unable to support hardware decoding at 4K on Raspberry Pi 4 until the RPi distribution of ffmpeg supports it?

NickM-27 commented 1 year ago

At this time, is Frigate unable to support hardware decoding at 4K on Raspberry Pi 4 until the RPi distribution of ffmpeg supports it?

No, it won't be supported until then.

mhoogenbosch commented 1 year ago

to be clear, would it be better to just don't use hardware acceleration and accept performance penalties but using higher resolution because of the supporting cam, using a coral. Or should you lower the resolution to ensure the hwaccel is getting utilized?

krcm0209 commented 1 year ago

When I wasn't using HW acceleration in my setup, I was seeing CPU usage percentages higher than I'd like. Probably more of a case-by-case thing folks need to determine for themselves based on their own setups and tolerances.

github-actions[bot] commented 1 year ago

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.