frigate: FFMPEG will not run on Debian 64 bit when configured with h264_v4l2m2m

Describe the bug When I add the h264_v4l2m2m config ffmpeg falls over. Looking at the doc it seem that ffmpeg 4.3 is required but Debian report 4.1.6 as the stable version. I am not certain this is the issue but the problem in it’s most basic sense that I get green screens (no image at all) when I add the h264_v4l2m2m options

Version of frigate Frigate NVR Beta (0.9.0) Current version: 2.4

Config file Include your full config file wrapped in triple back ticks.

mqtt:
  host: 192.168.1.9
ffmpeg:
  global_args: -hide_banner -loglevel error

ffmpeg:
  hwaccel_args:
    - -c:v
    - h264_v4l2m2m

cameras:

  # Name of your camera
  front_door:
    ffmpeg:
      inputs:
#        - path: rtsp://HA:HA123456@192.168.10.121:554/cam/realmonitor?channel=1&subtype=1&unicast=true&proto=Onvif
#        - path: rtsp://HA:HA123456@192.168.10.121:554/cam/realmonitor?channel=1&subtype=1
        - path: rtsp://HA:HA123456@192.168.10.121:554
          roles:
            - detect
            - rtmp
    objects:
      track: 
        - person  
 
detectors:
  coral:
    type: edgetpu
    device: usb

Frigate container logs

[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.
[2021-09-29 16:42:20] frigate.app                    INFO    : Starting Frigate (0.9.0-aa807d2)
[2021-09-29 16:42:20] frigate.app                    INFO    : Creating directory: /tmp/cache
Starting migrations
[2021-09-29 16:42:20] peewee_migrate                 INFO    : Starting migrations
There is nothing to migrate
[2021-09-29 16:42:20] peewee_migrate                 INFO    : There is nothing to migrate
[2021-09-29 16:42:20] frigate.mqtt                   INFO    : MQTT connected
[2021-09-29 16:42:20] frigate.app                    INFO    : Output process started: 216
[2021-09-29 16:42:20] detector.coral                 INFO    : Starting detection process: 214
[2021-09-29 16:42:20] ws4py                          INFO    : Using epoll
[2021-09-29 16:42:20] frigate.app                    INFO    : Camera processor started for front_door: 221
[2021-09-29 16:42:20] frigate.app                    INFO    : Capture process started for front_door: 222
[2021-09-29 16:42:20] ws4py                          INFO    : Using epoll
[2021-09-29 16:42:20] frigate.edgetpu                INFO    : Attempting to load TPU as usb
[2021-09-29 16:42:23] frigate.edgetpu                INFO    : TPU found
[2021-09-29 16:42:25] frigate.video                  INFO    : front_door: ffmpeg sent a broken frame. memoryview assignment: lvalue and rvalue have different structures
[2021-09-29 16:42:25] frigate.video                  INFO    : front_door: ffmpeg process is not running. exiting capture thread...
[2021-09-29 16:42:40] watchdog.front_door            ERROR   : FFMPEG process crashed unexpectedly for front_door.
[2021-09-29 16:42:40] watchdog.front_door            ERROR   : The following ffmpeg logs include the last 100 lines prior to exit.
[2021-09-29 16:42:40] watchdog.front_door            ERROR   : You may have invalid args defined for this camera.
[2021-09-29 16:42:40] ffmpeg.front_door.detect       ERROR   : Guessed Channel Layout for Input Stream #0.1 : mono
[2021-09-29 16:42:40] ffmpeg.front_door.detect       ERROR   : [h264_v4l2m2m @ 0x268d9a0] Could not find a valid device
[2021-09-29 16:42:40] ffmpeg.front_door.detect       ERROR   : [h264_v4l2m2m @ 0x268d9a0] can't configure decoder
[2021-09-29 16:42:40] ffmpeg.front_door.detect       ERROR   : Error while opening decoder for input stream #0:0 : Invalid 

Frigate stats

Output from frigate's /api/stats endpoint

FFprobe from your camera

Run the following command and paste output below

ffprobe version 4.1.6-1~deb10u1 Copyright (c) 2007-2020 the FFmpeg developers
  built with gcc 8 (Debian 8.3.0-6)
  configuration: --prefix=/usr --extra-version='1~deb10u1' --toolchain=hardened --libdir=/usr/lib/aarch64-linux-gnu --incdir=/usr/include/aarch64-linux-gnu --arch=arm64 --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-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
[rtsp @ 0xaaaaf5a8f150] max delay reached. need to consume packet
[rtsp @ 0xaaaaf5a8f150] RTP: missed 51 packets
[h264 @ 0xaaaaf5a92070] error while decoding MB 77 26, bytestream -5
[h264 @ 0xaaaaf5a92070] concealing 5012 DC, 5012 AC, 5012 MV errors in P frame
Input #0, rtsp, from 'rtsp://HA:HA123456@192.168.10.121:554':
  Metadata:
    title           : Media Server
  Duration: N/A, start: 0.040000, bitrate: N/A
    Stream #0:0: Video: h264 (Main), yuvj420p(pc, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 5 fps, 5 tbr, 90k tbn, 10 tbc
    Stream #0:1: Audio: pcm_alaw, 8000 Hz, 1 channels, s16, 64 kb/s

Screenshots Capture

Computer Hardware

  • RPI 4
  • Debian buster
  • HA install process doc
  • Docker
  • Coral USB
  • Cameras hardwired on separate local network

Camera Info:

  • Dahua
  • Model IPC-HDW5231R-ZE and several 2231
  • mainstream 1920x1080 substream
  • Stream #0:0: Video: h264 (Main), yuvj420p(pc, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 5 fps, 5 tbr, 90k tbn, 10 tbc Stream #0:1: Audio: pcm_alaw, 8000 Hz, 1 channels, s16, 64 kb/s

Additional context Debian reports ffmpeg version => 4.1.6-1~deb10u1 Copyright © 2000-2020 the FFmpeg developers That appears to be the current version

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 2
  • Comments: 31 (8 by maintainers)

Most upvoted comments

Downgrading the kernel and firmware from 5.10.63 to 5.10.60 using rpi-update to this commit resolves the issue:

sudo rpi-update fb7c402191aa56c8982982b8f31a0bb41743bea1
sudo reboot
# uname -a
Linux 5.10.60-v8+ #1448 SMP PREEMPT Sat Aug 21 10:48:18 BST 2021 aarch64 GNU/Linux

I just tried the new raspbian 64-bit release from this month on my Pi4. I then reverted my kernel as mentioned above. I still get the same missing decoder error. @DeviantUK does my config look any different from yours?

ffmpeg:
  hwaccel_args:
    - -c:v
    - h264_v4l2m2m
root@raspberrypi:~/docker# uname -a
Linux raspberrypi 5.10.60-v8+ #1448 SMP PREEMPT Sat Aug 21 10:48:18 BST 2021 aarch64 GNU/Linux

Nm, finally got it working. Privileged was not required with my intel decoder on my server, but it was required for v4l2 on my pi. Unfortunately I can only get 2 of my 4 cameras working on my pi4 8gb with video memory set to 512. If I add the second 2 I get python bus errors. Guess it just can’t handle them. The decoder is definitely working though. It’s probably because I’m using hi-res rtsp streams so I get clear recordings. Update once updating docker shm to 1G I got all 4 cameras running at high resolution and barely any cpu utilization. Nice!!