blakeblackshear / frigate

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

[Config Support]: 12th Gen Intel Hwaccel Issues #7054

Closed xeb10154 closed 1 year ago

xeb10154 commented 1 year ago

Describe the problem you are having

Hi, I am updating my Frigate from 0.11 to the latest 0.12 release on my Ubuntu Server (22.04). My previous setup used RTMP streams, but since that has been deprecated in 0.12, I have now updated my config file to use go2rtc with http streams according to the docs for Reolink cameras. I have Reolink RLC-822a cameras and they worked fine with RTMP in 0.11.

But I am getting this error:

ERROR   : [AVHWDeviceContext @ 0x56357199a040] Error setting child device handle: -17

The limited information I could find online suggests my FFMPEG and drivers might be too old for CPU my (intel i5-12400) in this post.

So I then installed the latest intel drivers by following this guide. I tried installing this on the host machine first, which did not work, so I installed the same inside the docker container afterwards, but it's still giving me the same error. I remember getting a similar problem when I first installed Frigate 0.11 last year, and the fix I came across was to apt-add the testing debian repository to the sources.list within the Docker container (which is running Bullseye it seems). This was the command I used in 0.11, but it didn't work in 0.12. I'm a novice in Linux and have never really dealt with drivers much, so not exactly sure why it worked the last time but not now:

echo 'deb http://deb.debian.org/debian testing main non-free' >> /etc/apt/sources.list && 
apt -y update && apt -y -t testing install intel-media-va-driver-non-free

I have attached more information about my frigate config, docker-compose.yml file and my CPU info below. I appreciate any help I could get. And thanks for making awesome software like this open source.

Version

0.12.1-367d724

Frigate config file

# Simplified version of my config containing only 1 camera
mqtt:
  ...

database:
  ...

go2rtc:
  streams:
    front_door:
      - http://192.168.1.2/flv?port=1935&app=bcs&stream=channel0_main.bcs&user=[REDACTED]&password=[REDACTED]
    front_door_sub:
      - http://192.168.1.2/flv?port=1935&app=bcs&stream=channel0_ext.bcs&user=[REDACTED]&password=[REDACTED]

cameras:
  Front_Door: # <------ Name the camera
    ffmpeg:
      inputs:
        - path: rtsp://127.0.0.1:8554/front_door
          input_args: preset-rtsp-restream
          roles:
            - record
        - path: rtsp://127.0.0.1:8554/front_door_sub
          input_args: preset-rtsp-restream
          roles:
            - detect

record:
  enabled: True
  retain:
    days: 16
    mode: all
  events:
    retain:
      default: 16
      mode: active_objects

detect:
  width: 640
  height: 360
  fps: 10

ffmpeg:
  hwaccel_args: preset-intel-qsv-h264
  # hwaccel_args: preset-vaapi

Relevant log output

...frigate.video                  ERROR   : Front_Door: Unable to read frames from ffmpeg process.
...frigate.video                  ERROR   : Front_Door: ffmpeg process is not running. exiting capture thread...
...watchdog.Front_Door            ERROR   : Ffmpeg process crashed unexpectedly for Front_Door.
...watchdog.Front_Door            ERROR   : The following ffmpeg logs include the last 100 lines prior to exit.
...ffmpeg.Front_Door.detect       ERROR   : [AVHWDeviceContext @ 0x56357199a040] Error setting child device handle: -17
...watchdog.Front_Door            ERROR   : No new recording segments were created for Front_Door in the last 120s. restarting the ffmpeg record process...
...watchdog.Front_Door            INFO    : Terminating the existing ffmpeg process...
...watchdog.Front_Door            INFO    : Waiting for ffmpeg to exit gracefully...

Frigate stats

...
"Front_Door": {
"camera_fps": 0,
"capture_pid": 591,
"detection_enabled": 1,
"detection_fps": 0,
"ffmpeg_pid": 1299499,
"pid": 580,
"process_fps": 0,
"skipped_fps": 0
},
...

Operating system

Other Linux

Install method

Docker Compose

Coral version

M.2

Any other information that may be helpful

FFPROBE output

ffprobe version n5.1-2-g915ef932a3-20220731 Copyright (c) 2007-2022 the FFmpeg developers
  built with gcc 12.1.0 (crosstool-NG 1.25.0.55_3defb7b)
  configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-ffbuild-linux-gnu- --arch=x86_64 --target-os=linux --enable-gpl --enable-version3 --disable-debug --enable-iconv --enable-libxml2 --enable-zlib --enable-libfreetype --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-libvorbis --enable-opencl --enable-libpulse --enable-libvmaf --enable-libxcb --enable-xlib --enable-amf --enable-libaom --enable-libaribb24 --enable-avisynth --enable-libdav1d --enable-libdavs2 --disable-libfdk-aac --enable-ffnvcodec --enable-cuda-llvm --enable-frei0r --enable-libgme --enable-libass --enable-libbluray --enable-libjxl --enable-libmp3lame --enable-libopus --enable-mbedtls --enable-librist --enable-libtheora --enable-libvpx --enable-libwebp --enable-lv2 --enable-libmfx --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopenmpt --enable-librav1e --enable-librubberband --disable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libsvtav1 --enable-libtwolame --enable-libuavs3d --enable-libdrm --enable-vaapi --enable-libvidstab --enable-vulkan --enable-libshaderc --enable-libplacebo --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --enable-libzvbi --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-ldexeflags=-pie --extra-libs='-ldl -lgomp' --extra-version=20220731
  libavutil      57. 28.100 / 57. 28.100
  libavcodec     59. 37.100 / 59. 37.100
  libavformat    59. 27.100 / 59. 27.100
  libavdevice    59.  7.100 / 59.  7.100
  libavfilter     8. 44.100 /  8. 44.100
  libswscale      6.  7.100 /  6.  7.100
  libswresample   4.  7.100 /  4.  7.100
  libpostproc    56.  6.100 / 56.  6.100
Input #0, flv, from 'http://192.168.1.2/flv?port=1935&app=bcs&stream=channel0_main.bcs&user=[REDACTED]&password=[REDACTED]':
  Metadata:
    displayWidth    : 2560
    displayHeight   : 1440
  Duration: 00:00:00.00, start: 0.000000, bitrate: N/A
  Stream #0:0: Video: h264 (High), yuv420p(progressive), 2560x1440, 25 fps, 25 tbr, 1k tbn
  Stream #0:1: Audio: aac (LC), 16000 Hz, mono, fltp

docker-compose.yml

version: "3.9"
services:
  mqtt:
    container_name: mqtt
    image: eclipse-mosquitto
    volumes:
      - ./mosquitto/logs/:/mosquitto/logs/
      - ./mosquitto/mosquitto.conf:/mosquitto/config/mosquitto.conf
      - ./mosquitto/mqtt-auth.conf:/mosquitto/config/mqtt-auth.conf
      - ./mosquitto/mqtt-acl.conf:/mosquitto/config/mqtt-acl.conf
    restart: unless-stopped
    networks:
      - default
    ports:
      - 1883:1883
  frigate:
    container_name: frigate
    privileged: true
    restart: unless-stopped
    networks:
      - default
    depends_on:
      - mqtt
    image: ghcr.io/blakeblackshear/frigate:stable
    shm_size: "64mb"
    devices:
     - /dev/apex_0:/dev/apex_0
     - /dev/dri/renderD128
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - ./frigate/frigate_config/config.yml:/config/config.yml
      - ./frigate/media:/media/frigate
      - ./frigate/database:/database/
      - type: tmpfs
        target: /tmp/cache
        tmpfs:
          size: 1000000000
    ports:
      - "5000:5000" # Web client
      - "8554:8554" # RTSP feeds
      - "1935:1935" # RTMP feeds
      - "8555:8555/tcp" # WebRTC over tcp
      - "8555:8555/udp" # WebRTC over udp
    environment:
      FRIGATE_RTSP_PASSWORD: [REDACTED]

  homeassistant:
    container_name: homeassistant
    image: "ghcr.io/home-assistant/home-assistant:stable"
    volumes:
      - ./home-assistant/config:/config
      - /etc/localtime:/etc/localtime:ro
    ports:
      - "8123:8123"
    restart: unless-stopped
    privileged: true
    networks:
      - default

networks:
  default:

$ lspci -k | grep -EA3 'VGA|3D|Display output

00:02.0 VGA compatible controller: Intel Corporation Device 4692 (rev 0c)
    DeviceName: Onboard - Video
    Subsystem: Micro-Star International Co., Ltd. [MSI] Device 7d42
    Kernel driver in use: i915

lsb_release -a ouput

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.2 LTS
Release:    22.04
Codename:   jammy

vainfo output

error: XDG_RUNTIME_DIR is invalid or not set in the environment.
error: can't connect to X server!
libva info: VA-API version 1.17.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_17
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.17 (libva 2.10.0)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 23.1.2 ()
vainfo: Supported profile and entrypoints
      VAProfileNone                   : VAEntrypointVideoProc
      VAProfileNone                   : VAEntrypointStats
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Simple            : VAEntrypointEncSlice
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointFEI
      VAProfileH264Main               : VAEntrypointEncSliceLP
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointFEI
      VAProfileH264High               : VAEntrypointEncSliceLP
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointEncPicture
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline: VAEntrypointFEI
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointEncSlice
      VAProfileHEVCMain               : VAEntrypointFEI
      VAProfileHEVCMain               : VAEntrypointEncSliceLP
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileHEVCMain10             : VAEntrypointEncSlice
      VAProfileHEVCMain10             : VAEntrypointEncSliceLP
      VAProfileVP9Profile0            : VAEntrypointVLD
      VAProfileVP9Profile0            : VAEntrypointEncSliceLP
      VAProfileVP9Profile1            : VAEntrypointVLD
      VAProfileVP9Profile1            : VAEntrypointEncSliceLP
      VAProfileVP9Profile2            : VAEntrypointVLD
      VAProfileVP9Profile2            : VAEntrypointEncSliceLP
      VAProfileVP9Profile3            : VAEntrypointVLD
      VAProfileVP9Profile3            : VAEntrypointEncSliceLP
      VAProfileHEVCMain12             : VAEntrypointVLD
      VAProfileHEVCMain12             : VAEntrypointEncSlice
      VAProfileHEVCMain422_10         : VAEntrypointVLD
      VAProfileHEVCMain422_10         : VAEntrypointEncSlice
      VAProfileHEVCMain422_12         : VAEntrypointVLD
      VAProfileHEVCMain422_12         : VAEntrypointEncSlice
      VAProfileHEVCMain444            : VAEntrypointVLD
      VAProfileHEVCMain444            : VAEntrypointEncSliceLP
      VAProfileHEVCMain444_10         : VAEntrypointVLD
      VAProfileHEVCMain444_10         : VAEntrypointEncSliceLP
      VAProfileHEVCMain444_12         : VAEntrypointVLD
      VAProfileHEVCSccMain            : VAEntrypointVLD
      VAProfileHEVCSccMain            : VAEntrypointEncSliceLP
      VAProfileHEVCSccMain10          : VAEntrypointVLD
      VAProfileHEVCSccMain10          : VAEntrypointEncSliceLP
      VAProfileHEVCSccMain444         : VAEntrypointVLD
      VAProfileHEVCSccMain444         : VAEntrypointEncSliceLP
      VAProfileAV1Profile0            : VAEntrypointVLD
      VAProfileHEVCSccMain444_10      : VAEntrypointVLD
      VAProfileHEVCSccMain444_10      : VAEntrypointEncSliceLP
NickM-27 commented 1 year ago

You should use preset-vaapi not qsv

xeb10154 commented 1 year ago

You should use preset-vaapi not qsv

Thanks, I tried that at first and it didn't work. But for some reason, it works now! Just one of those days...