blakeblackshear / frigate

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

[HW Accel Support]: docker crashing when adding ffmpeg in config #5633

Closed wokkieman closed 1 year ago

wokkieman commented 1 year ago

Describe the problem you are having

Stream from Eufy camera is working fine. I can see it in VLC and I can in Frigate when removing 'hwaccel_args'

I just migrated Frigate to a new Intel i5-12400 box and therefor changed hardware acceleration in config.yml to ffmpeg: hwaccel_args: -c:v h264_qsv

As soon as I do that, the camera's change to a green box. Without it the camera shows up fine.

FFMPEG is showing (a lot of times) Error while decoding stream #0:0: Invalid argument [h264_qsv @ 0x563878e32780] Error initializing an internal MFX session: unsupported (-3) [h264_qsv @ 0x563878e32780] Error initializing an MFX session [h264_qsv @ 0x563878e32780] Error initializing the MFX video decoder: invalid handle (-6)

I get the same results when running the test command: ffmpeg -c:v h264_qsv -re -stream_loop -1 -i https://streams.videolan.org/ffmpeg/incoming/720p60.mp4 -f rawvideo -pix_fmt yuv420p pipe: > /dev/null

ls /dev/dri (in docker container)

ls /dev/dri 
card0  renderD128

Could someone point me in the right direction here?

Note: Coral USB TPU (also?) gets detected without issues

Version

0.10.1-83481AF

Frigate config file

mqtt:
  host: 192.168.1.XXX
  user: XXX
  password: XXX

detectors:
  coral:
    type: edgetpu
    device: usb

database:
  path: /db/frigate.db

ffmpeg:
  hwaccel_args: -c:v h264_qsv

cameras:
  eufy_front: # <------ Name the camera
    ffmpeg:
      inputs:
        - path: rtsp://xxx:xxx@192.168.1.XXX/live0 # <----- Update for your camera
          roles:
            - detect
            #- record
            - rtmp
    rtmp:
      enabled: True # <-- RTMP should be disabled if your stream is not H264
    detect:
      enabled: True
      width: 1920 # <---- update for your camera's resolution
      height: 1080 # <---- update for your camera's resolution

docker-compose file or Docker CLI command

frigate:
    container_name: frigate
    privileged: true # this may not be necessary for all setups
    restart: unless-stopped
    image: blakeblackshear/frigate:stable-amd64
    shm_size: "64mb" # update for your cameras based on calculation above
    devices:
      - /dev/bus/usb:/dev/bus/usb # passes the USB Coral, needs to be modified for other versions
      #- /dev/apex_0:/dev/apex_0 # passes a PCIe Coral, follow driver instructions here https://coral.ai/docs/m2/get-started/#2a-on-linux
      - /dev/dri/renderD128 # for intel hwaccel, needs to be updated for your hardware

    volumes:
      - /etc/localtime:/etc/localtime:ro
      - ${USERDIR}/frigate/config.yml:/config/config.yml:ro
      - /xxx/Frigate_Media:/media/frigate
      - ${USERDIR}/frigate/db:/db
      - type: tmpfs # Optional: 1GB of memory, reduces SSD/SD Card wear
        target: /tmp/cache
        tmpfs:
          size: 1000000000
    ports:
      - "5000:5000"
      - "1935:1935" # RTMP feeds
    environment:
      FRIGATE_RTSP_PASSWORD: "xxx"

Relevant log output

see above

FFprobe output from your camera

ffprobe version 4.3.1 Copyright (c) 2007-2020 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.3.0-17ubuntu1~20.04)
  configuration: --disable-debug --disable-doc --disable-ffplay --enable-shared --enable-avresample --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-gpl --enable-libfreetype --enable-libvidstab --enable-libmfx --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libxcb --enable-libx265 --enable-libxvid --enable-libx264 --enable-nonfree --enable-openssl --enable-libfdk_aac --enable-postproc --enable-small --enable-version3 --enable-libzmq --extra-libs=-ldl --prefix=/opt/ffmpeg --enable-libopenjpeg --enable-libkvazaar --enable-libaom --extra-libs=-lpthread --enable-vaapi --extra-cflags=-I/opt/ffmpeg/include --extra-ldflags=-L/opt/ffmpeg/lib
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100
[rtsp @ 0x55972ff8db80] method SETUP failed: 461 Unsupported transport
Input #0, rtsp, from 'rtsp://xx@192.168.1.xxx/live0':
  Metadata:
    title           : H.264 Video,leco stream
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: h264, yuv420p(tv, bt709, progressive), 1920x1080, 15 fps, 60 tbr, 90k tbn, 30 tbc
    Stream #0:1: Audio: aac, 16000 Hz, mono, fltp

Operating system

Debian

Install method

Docker Compose

Network connection

Wired

Camera make and model

eufy indoor cam (wireless)

Any other information that may be helpful

No response

NickM-27 commented 1 year ago

You're running an old version of frigate, you should update to 0.11.1

wokkieman commented 1 year ago

I've updated to 0.11.1-2EADA21 (Had to remove the amd-64 part, so now it's image: blakeblackshear/frigate:stable ...)

Docker doesn't crash, but we're still 'green'

[2023-03-03 14:53:15] ffmpeg.eufy_front.detect       ERROR   : Error while decoding stream #0:0: Input/output error
[2023-03-03 14:53:15] ffmpeg.eufy_front.detect       ERROR   : [h264_qsv @ 0x55a781bf69c0] Error during QSV decoding.: device failed (-17)
[2023-03-03 14:52:15] ffmpeg.eufy_front.detect       ERROR   : Finishing stream 1:0 without any data written to it.
[2023-03-03 14:52:15] ffmpeg.eufy_front.detect       ERROR   : [flv @ 0x55aff85add40] Failed to update header with correct duration.
[2023-03-03 14:52:15] ffmpeg.eufy_front.detect       ERROR   : [flv @ 0x55aff85add40] Failed to update header with correct filesize.
[2023-03-03 14:52:18] ws4py                          INFO    : Terminating websocket [Local => 127.0.0.1:5002 | Remote => 127.0.0.1:50628]
[2023-03-03 14:52:30] ws4py                          INFO    : Managing websocket [Local => 127.0.0.1:5002 | Remote => 127.0.0.1:56204]
[2023-03-03 14:52:35] watchdog.eufy_front            INFO    : No frames received from eufy_front in 20 seconds. Exiting ffmpeg...
[2023-03-03 14:52:35] watchdog.eufy_front            INFO    : Waiting for ffmpeg to exit gracefully...
[2023-03-03 14:52:35] frigate.video                  ERROR   : eufy_front: Unable to read frames from ffmpeg process.
[2023-03-03 14:52:35] frigate.video                  ERROR   : eufy_front: ffmpeg process is not running. exiting capture thread...`
NickM-27 commented 1 year ago

Cool, that error is what we've seen for other 12th gen users. This is fixed in 0.12 which is currently in beta

wokkieman commented 1 year ago

ok! thanks for the quick support and the awesome software :)

wokkieman commented 1 year ago

can confirm that it works with: 0.12.0-beta2

Thanks again

NickM-27 commented 1 year ago

@rjwonder just so you're aware beta2 is a very old version of the betas. Newer versions will not be posted to dockerhub as they are now hosted exclusively on github

NickM-27 commented 1 year ago

Feel free to create a new issue if something else comes up

wokkieman commented 1 year ago

@rjwonder just so you're aware beta2 is a very old version of the betas. Newer versions will not be posted to dockerhub as they are now hosted exclusively on github

thanks, also changed that part