blakeblackshear / frigate

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

Frigate on Raspberry Pi 4 8GB / Home Assistant OS 5.8 64-bit -h264_v4l2m2m - Could not find a valid device #396

Closed alexmarsaudon closed 3 years ago

alexmarsaudon commented 3 years ago

Describe the bug Having issues getting Frigate to play nice, running Home Assistant OS 64-bit on a Raspberry Pi 4 8GB w/ Google Coral connected via USB. I apologize in advance if I am missing something obvious. Logs just loop the following indefinitely:

Fontconfig error: Cannot load default config file
On connect called
Starting detection process: 20
Attempting to load TPU as usb:0
Camera capture process started for back: 22
Camera process started for back: 23
Creating ffmpeg process...
ffmpeg -hide_banner -loglevel info -c:v h264_v4l2m2m -avoid_negative_ts make_zero -fflags nobuffer -flags low_delay -strict experimental -fflags +genpts+discardcorrupt -rtsp_transport tcp -stimeout 5000000 -use_wallclock_as_timestamps 1 -i rtsp://admin:CENSORED@10.10.110.18:554/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif -r 5 -f rawvideo -pix_fmt yuv420p pipe:
 * Serving Flask app "detect_objects" (lazy loading)
 * Environment: development
 * Debug mode: off
Input #0, rtsp, from 'rtsp://admin:CENSORED@10.10.110.18:554/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif':
  Metadata:
    title           : Media Server
  Duration: N/A, start: 1608250829.900667, bitrate: N/A
    Stream #0:0: Video: h264, yuvj420p(pc, bt709, progressive), 3840x2160 [SAR 7713:7712 DAR 857:482], 15 fps, 15 tbr, 90k tbn, 30 tbc
    Stream #0:1: Data: none
[h264_v4l2m2m @ 0x5588a6dc10] Could not find a valid device
[h264_v4l2m2m @ 0x5588a6dc10] can't configure decoder
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (h264_v4l2m2m) -> rawvideo (native))
Error while opening decoder for input stream #0:0 : Invalid argument
back: ffmpeg sent a broken frame. something is wrong.
back: ffmpeg process is not running. exiting capture thread...
TPU found

Version of frigate Running Frigate 1.3

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

web_port: 5000
detectors:
  coral:
    type: edgetpu
    device: 'usb:0'
save_clips:
  max_seconds: 300
  clips_dir: /media/frigate
  cache_dir: /cache
mqtt:
  host: core-mosquitto.local.hass.io
  port: 1883
  topic_prefix: frigate
  client_id: frigate
  user: homeassistant
  password: CENSORED
ffmpeg:
  global_args:
    - '-hide_banner'
    - '-loglevel'
    - info
  hwaccel_args:
    - '-c:v'
    - h264_v4l2m2m
  input_args:
    - '-avoid_negative_ts'
    - make_zero
    - '-fflags'
    - nobuffer
    - '-flags'
    - low_delay
    - '-strict'
    - experimental
    - '-fflags'
    - +genpts+discardcorrupt
    - '-rtsp_transport'
    - tcp
    - '-stimeout'
    - '5000000'
    - '-use_wallclock_as_timestamps'
    - '1'
  output_args:
    - '-f'
    - rawvideo
    - '-pix_fmt'
    - yuv420p
cameras:
  back:
    ffmpeg:
      input: >-
        rtsp://admin:CENSORED@10.10.110.18:554/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif
    height: 720
    width: 1280
    fps: 5
    mask: 'poly,0,900,1080,900,1080,1920,0,1920'
    best_image_timeout: 60
    mqtt:
      crop_to_region: true
      snapshot_height: 300
    zones:
      front_steps:
        coordinates: '545,1077,747,939,788,805'
        filters:
          person:
            min_area: 5000
            max_area: 100000
            threshold: 0.8
    save_clips:
      enabled: false
      pre_capture: 30
      objects:
        - person
    snapshots:
      show_timestamp: true
      draw_zones: false
      draw_bounding_boxes: true
    objects:
      track:
        - person
        - car
      filters:
        person:
          min_area: 5000
          max_area: 100000
          min_score: 0.5
          threshold: 0.85
objects:
  track:
    - person
  filters:
    person:
      min_area: 5000
      max_area: 100000
      min_score: 0.5
      threshold: 0.85

Computer Hardware

Camera Info: I have tried several cameras, but currently I am using the following:

Additional context I haven't ever had this working before, so it is possible or likely I am missing something obvious in the config.

blakeblackshear commented 3 years ago

Turn off protection mode for the addon.

alexmarsaudon commented 3 years ago

Wow, missed that option. Thanks a ton for your prompt reply. That definitely changed the behavior. Now it is looping the following in the logging:

Press [q] to stop, [?] for help
No frames received from back in 5 seconds. Exiting ffmpeg...
Waiting for ffmpeg to exit gracefully...
FFmpeg didnt exit. Force killing...
back: ffmpeg sent a broken frame. something is wrong.
back: ffmpeg sent a broken frame. something is wrong.
back: ffmpeg process is not running. exiting capture thread...
Creating ffmpeg process...
ffmpeg -hide_banner -loglevel info -c:v h264_v4l2m2m -avoid_negative_ts make_zero -fflags nobuffer -flags low_delay -strict experimental -fflags +genpts+discardcorrupt -rtsp_transport tcp -stimeout 5000000 -use_wallclock_as_timestamps 1 -i rtsp://admin:CENSORED@10.10.110.18:554/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif -r 5 -f rawvideo -pix_fmt yuv420p pipe:
frame=    0 fps=0.0 q=0.0 size=       0kB time=-577014:32:22.77 bitrate=  -0.0kbits/s speed=N/A    
frame=    0 fps=0.0 q=0.0 size=       0kB time=-577014:32:22.77 bitrate=  -0.0kbits/s speed=N/A    
frame=    0 fps=0.0 q=0.0 size=       0kB time=-577014:32:22.77 bitrate=  -0.0kbits/s speed=N/A    
frame=    0 fps=0.0 q=0.0 size=       0kB time=-577014:32:22.77 bitrate=  -0.0kbits/s speed=N/A    
frame=    0 fps=0.0 q=0.0 size=       0kB time=-577014:32:22.77 bitrate=  -0.0kbits/s speed=N/A    
frame=    0 fps=0.0 q=0.0 size=       0kB time=-577014:32:22.77 bitrate=  -0.0kbits/s speed=N/A    
frame=    0 fps=0.0 q=0.0 size=       0kB time=-577014:32:22.77 bitrate=  -0.0kbits/s speed=N/A    
frame=    0 fps=0.0 q=0.0 size=       0kB time=-577014:32:22.77 bitrate=  -0.0kbits/s speed=N/A    
frame=    0 fps=0.0 q=0.0 size=       0kB time=-577014:32:22.77 bitrate=  -0.0kbits/s speed=N/A    
frame=    0 fps=0.0 q=0.0 size=       0kB time=-577014:32:22.77 bitrate=  -0.0kbits/s speed=N/A    
frame=    0 fps=0.0 q=0.0 size=       0kB time=-577014:32:22.77 bitrate=  -0.0kbits/s speed=N/A    
frame=    0 fps=0.0 q=0.0 size=       0kB time=-577014:32:22.77 bitrate=  -0.0kbits/s speed=N/A    
frame=    0 fps=0.0 q=0.0 size=       0kB time=-577014:32:22.77 bitrate=  -0.0kbits/s speed=N/A    
frame=    0 fps=0.0 q=0.0 size=       0kB time=-577014:32:22.77 bitrate=  -0.0kbits/s speed=N/A    
frame=    0 fps=0.0 q=0.0 size=       0kB time=-577014:32:22.77 bitrate=  -0.0kbits/s speed=N/A    
Input #0, rtsp, from 'rtsp://admin:CENSORED@10.10.110.18:554/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif':
  Metadata:
    title           : Media Server
  Duration: N/A, start: 1608257828.860578, bitrate: N/A
    Stream #0:0: Video: h264, yuvj420p(pc, bt709, progressive), 3840x2160 [SAR 7713:7712 DAR 857:482], 15 fps, 15 tbr, 90k tbn, 30 tbc
    Stream #0:1: Data: none
[h264_v4l2m2m @ 0x558a09add0] Using device /dev/video10
[h264_v4l2m2m @ 0x558a09add0] driver 'bcm2835-codec' on card 'bcm2835-codec-decode' in mplane mode
[h264_v4l2m2m @ 0x558a09add0] requesting formats: output=H264 capture=YU12
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (h264_v4l2m2m) -> rawvideo (native))
Press [q] to stop, [?] for help
No frames received from back in 5 seconds. Exiting ffmpeg...
Waiting for ffmpeg to exit gracefully...
FFmpeg didnt exit. Force killing...
back: ffmpeg sent a broken frame. something is wrong.
back: ffmpeg process is not running. exiting capture thread...

image

blakeblackshear commented 3 years ago

I think it's taking longer than 5 seconds to start receiving frames. The beta version has a fix for this issue, but the config format is quite a bit different.

alexmarsaudon commented 3 years ago

Awesome! I guess I have too many devices pulling RTSP off the camera in question, so it takes >5s to respond. I pointed it at a new camera, and the logging makes it appear to be functioning:

ontconfig error: Cannot load default config file
Starting detection process: 19
Attempting to load TPU as usb:0
Camera capture process started for back: 21
Camera process started for back: 22
Creating ffmpeg process...
ffmpeg -hide_banner -loglevel info -c:v h264_v4l2m2m -avoid_negative_ts make_zero -fflags nobuffer -flags low_delay -strict experimental -fflags +genpts+discardcorrupt -rtsp_transport tcp -stimeout 5000000 -use_wallclock_as_timestamps 1 -i rtsp://admin:CENSORED@10.10.110.14:554/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif -r 5 -f rawvideo -pix_fmt yuv420p pipe:
 * Serving Flask app "detect_objects" (lazy loading)
 * Environment: development
 * Debug mode: off
On connect called
Input #0, rtsp, from 'rtsp://admin:CENSORED@10.10.110.14:554/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif':
  Metadata:
    title           : Media Server
  Duration: N/A, start: 1608307205.740563, bitrate: N/A
    Stream #0:0: Video: h264, yuvj420p(pc, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 30 fps, 30 tbr, 90k tbn, 60 tbc
    Stream #0:1: Audio: aac, 16000 Hz, mono, fltp
    Stream #0:2: Data: none
[h264_v4l2m2m @ 0x5575aab290] Using device /dev/video10
[h264_v4l2m2m @ 0x5575aab290] driver 'bcm2835-codec' on card 'bcm2835-codec-decode' in mplane mode
[h264_v4l2m2m @ 0x5575aab290] requesting formats: output=H264 capture=YU12
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (h264_v4l2m2m) -> rawvideo (native))
Press [q] to stop, [?] for help
Output #0, rawvideo, to 'pipe:':
  Metadata:
    title           : Media Server
    encoder         : Lavf58.45.100
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1920x1080, q=2-31, 124416 kb/s, 5 fps, 5 tbn, 5 tbc
    Metadata:
      encoder         : Lavc58.91.100 rawvideo
TPU found
frame=    7 fps=0.0 q=-0.0 size=   21262kB time=00:00:01.40 bitrate=124416.0kbits/s dup=5 drop=0 speed=1.97x    
frame=   11 fps=9.0 q=-0.0 size=   33412kB time=00:00:02.20 bitrate=124416.0kbits/s dup=5 drop=16 speed= 1.8x    
frame=   13 fps=7.4 q=-0.0 size=   39488kB time=00:00:02.60 bitrate=124416.0kbits/s dup=5 drop=30 speed=1.48x    
frame=   16 fps=7.1 q=-0.0 size=   48600kB time=00:00:03.20 bitrate=124416.0kbits/s dup=5 drop=42 speed=1.42x    
frame=   18 fps=6.5 q=-0.0 size=   54675kB time=00:00:03.60 bitrate=124416.0kbits/s dup=5 drop=55 speed=1.29x    
frame=   21 fps=6.3 q=-0.0 size=   63788kB time=00:00:04.20 bitrate=124416.0kbits/s dup=5 drop=66 speed=1.25x    
frame=   24 fps=6.2 q=-0.0 size=   72900kB time=00:00:04.80 bitrate=124416.0kbits/s dup=5 drop=83 speed=1.24x    
frame=   27 fps=6.1 q=-0.0 size=   82012kB time=00:00:05.40 bitrate=124416.0kbits/s dup=5 drop=96 speed=1.21x    
frame=   29 fps=5.8 q=-0.0 size=   88088kB time=00:00:05.80 bitrate=124416.0kbits/s dup=5 drop=110 speed=1.17x    
frame=   32 fps=5.8 q=-0.0 size=   97200kB time=00:00:06.40 bitrate=124416.0kbits/s dup=5 drop=123 speed=1.17x    
frame=   35 fps=5.8 q=-0.0 size=  106312kB time=00:00:07.00 bitrate=124416.0kbits/s dup=5 drop=136 speed=1.16x    
frame=   38 fps=5.8 q=-0.0 size=  115425kB time=00:00:07.60 bitrate=124416.0kbits/s dup=5 drop=149 speed=1.16x    
frame=   40 fps=5.7 q=-0.0 size=  121500kB time=00:00:08.00 bitrate=124416.0kbits/s dup=5 drop=161 speed=1.13x    
frame=   42 fps=5.6 q=-0.0 size=  127575kB time=00:00:08.40 bitrate=124416.0kbits/s dup=5 drop=171 speed=1.11x    
frame=   45 fps=5.6 q=-0.0 size=  136688kB time=00:00:09.00 bitrate=124416.0kbits/s dup=5 drop=186 speed=1.12x    
frame=   48 fps=5.6 q=-0.0 size=  145800kB 

Does the Frigate NVR Webui I screenshot above appear correct to you? I thought there might be more output on that tab.

blakeblackshear commented 3 years ago

Make sure your width and height in the config match the video feed.

blakeblackshear commented 3 years ago

And there isn't a WebUI for frigate, so that is what you should be seeing.

alexmarsaudon commented 3 years ago

Thanks a lot for getting me pointed in the right direction! I really appreciate it.