blakeblackshear / frigate

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

[Support]: Why no recording found for event #3209

Closed TheQue42 closed 2 years ago

TheQue42 commented 2 years ago

Describe the problem you are having

Once every blue moon, I run into having HA notifications receieved with snapshots, and what is supposed to be a clip as well.

Initially it had to do with the fact that the clip wasnt ready yet, but with the mqtt-updates indicating "end" of event,. most of those problems go away.

Whats left is scenarios, when there for some reason, is no file at all. No clip/recording has been made at all. I can find the event in the event log, but the clip/recording just isnt there when I try to play it.

Version

Debug 0.10.1-83481af

Frigate config file

mqtt:
  host: vimes.disc-world.se
  client_id: frigate
  topic_prefix: frigate
  user: user
  password: password
cameras:
  fr_framsida:
    mqtt:
      timestamp: False
      bounding_box: True
      crop: True
      height: 480
      quality: 85
    record:
      enabled: true
      events:
        required_zones:
          - fr_entre
    snapshots:
      enabled: true
      required_zones:
        - fr_entre
    ffmpeg:
      inputs:
        - path: <RTSP-stuff>
          roles:
            - detect
        - path: <RTSP-stuff>
          roles:
            - rtmp
            - record
    detect:
      width: 640
      height: 480
      fps: 5
    motion:
      mask:
        - 0,303,72,276,38,192,113,187,123,274,309,257,387,227,405,196,401,157,363,129,461,136,540,243,558,299,532,335,481,349,469,480,640,480,640,0,329,0,117,0,0,0
        - 0,480,117,480,35,401,0,285
    objects:
      track:
        - person
        - car
        - bicycle
        - motorcycle
      filters:
        motorcycle:
          mask: 383,336,378,256,329,210,115,220,124,340,0,405,0,480,454,480,467,335
        car:
          mask: 383,336,378,256,329,210,115,220,124,340,0,405,0,480,454,480,467,335
    zones:
      fr_entre:
        coordinates:  383,336,378,256,329,210,115,220,124,340,0,405,0,480,454,480,467,335
        objects:
            - person
      fr_driveway:
        coordinates: 75,279,0,302,21,371,137,317,380,330,473,332,589,333,577,241,557,212,532,192,484,184,472,150,441,151,377,249,237,237,89,233,68,243
        objects:
          - car
          - bicycle
          - motorcycle
  fr_baksidan:
    mqtt:
      timestamp: False
      bounding_box: True
      crop: True
      height: 576
      quality: 85
    ffmpeg:
      inputs:
        - path: <RTSP-stuff>
          roles:
            - detect
            - rtmp
        - path: <RTSP-stuff>
          roles:
            - record
    detect:
      width: 1024
      height: 576
      fps: 5
    motion:
      mask:
        - 170,101,137,185,0,327,0,190,0,0,589,0,1024,0,1024,150,965,147,941,187,813,157,775,190,764,113
        - 643,576,1024,576,1024,447
    objects:
      track:
        - person
  fr_hallen:
    mqtt:
      timestamp: False
      bounding_box: true
      crop: True
      height: 480
      quality: 75
    ffmpeg:
      inputs:
        #- path: <RTSP-stuff>
        - path: <RTSP-stuff>
          roles:
            - detect
        #- path: <RTSP-stuff>
        - path: <RTSP-stuff>
          roles:
            - rtmp
            - record
      input_args:
        - -avoid_negative_ts
        - make_zero
        - -fflags
        - nobuffer+genpts+discardcorrupt
        - -flags
        - low_delay
        - -strict
        - experimental
        - -analyzeduration
        - 1000M
        - -probesize
        - 1000M
        - -rw_timeout
        - "5000000"
    motion:
      mask:
       - 0,0,0,278,255,146,260,0
    detect:
      width: 640
      height: 480
      fps: 7
    objects:
      track:
        - person
  fr_vardagsrum:
    mqtt:
      timestamp: False
      bounding_box: true
      crop: True
      height: 576
    ffmpeg:
      inputs:
        - path: <RTSP-stuff>
          roles:
            - detect
            - rtmp
        - path: <RTSP-stuff>
          roles:
            - record
    detect:
      width: 1024
      height: 576
      fps: 5
    motion:
      mask:
       - 463,136,458,0,1024,0,1024,376,928,351,962,85,840,63,788,214
       - 964,87,948,240,843,214,866,69
       - 198,162,364,136,363,24,172,49
    objects:
      track:
        - person
detectors:
  coral_pci:
    type: edgetpu
    device: pci

ffmpeg:
  global_args: -hide_banner -loglevel info
  hwaccel_args:
    - -hwaccel
    - vaapi
    - -hwaccel_device
    - /dev/dri/renderD128
    - -hwaccel_output_format
    - yuv420p

detect:
  stationary:
    interval: 50     # Default 0
    max_frames:
      default: 3000 # Default forever

objects:
  track:
    - person
  filters:
    person:
      min_area: 2000
      max_area: 100000
      min_score: 0.65
      threshold: 0.76

record:
  enabled: True
  retain:
    days: 0
    mode: active_objects
  events:
    max_seconds: 180 # Default: 300
    pre_capture: 4
    post_capture: 5
    retain:
      default: 1
      mode: active_objects
      objects:
        person: 3

motion:
  threshold: 25 #default

snapshots:
  enabled: False
  retain:
    default: 1
    objects:
      person: 2
  timestamp: False
  bounding_box: true
  crop: True
  # Optional: height to resize the snapshot to (default: original size)
  #height: 175

live:
  # Optional: Set the height of the live stream. (default: 720)
  # This must be less than or equal to the height of the detect stream. Lower resolutions
  # reduce bandwidth required for viewing the live stream. Width is computed to match known aspect ratio.
  #height: 720
  # Optional: Set the encode quality of the live stream (default: 8)
  # 1 is the highest quality, and 31 is the lowest. Lower quality feeds utilize less CPU resources.
  quality: 16

birdseye:
  enabled: True
  mode: objects

logger:
  default: debug
  logs:
    frigate.mqtt: warning
    peewee.sqliteq: warning
    peewee: warning
#    ffmpeg.fr_hallen: debug
#    frigate.record: debug
#    frigate.event: debug

Relevant log output

Frigate Log:

[2022-05-12 13:20:46] frigate.object_processing      DEBUG   : Not creating snapshot for 1652354014.44075-u7elfr because it did not enter required zones
[2022-05-12 13:20:46] frigate.object_processing      DEBUG   : Not creating clip for 1652354014.44075-u7elfr because it did not enter required zones
[2022-05-12 13:20:46] frigate.events                 DEBUG   : Event received: update fr_framsida 1652354014.44075-u7elfr
[2022-05-12 13:20:51] frigate.http                   ERROR   : No recordings found for the requested time range
[2022-05-12 13:20:51] frigate.http                   ERROR   : Event does not have recordings: 1652353876.216857-x7lq64
[2022-05-12 13:20:52] frigate.http                   ERROR   : Event does not have recordings: 1652353876.216857-x7lq64
[2022-05-12 13:20:55] frigate.events                 DEBUG   : Event received: update fr_vardagsrum 1652353876.216857-x7lq64
[2022-05-12 13:21:01] frigate.http                   ERROR   : Event does not have recordings: 1652353876.216857-x7lq64
[2022-05-12 13:21:01] frigate.http                   ERROR   : Event does not have recordings: 1652353876.216857-x7lq64
[2022-05-12 13:21:02] frigate.http                   ERROR   : Event does not have recordings: 1652353876.216857-x7lq64
[2022-05-12 13:21:05] frigate.http                   ERROR   : Event does not have recordings: 1652353876.216857-x7lq64
[2022-05-12 13:21:05] frigate.http                   ERROR   : Event does not have recordings: 1652353876.216857-x7lq64
[2022-05-12 13:21:06] frigate.http                   ERROR   : Event does not have recordings: 1652353876.216857-x7lq64
[2022-05-12 13:21:46] frigate.object_processing      DEBUG   : Not creating snapshot for 1652354014.44075-u7elfr because it did not enter required zones
[2022-05-12 13:21:46] frigate.object_processing      DEBUG   : Not creating clip for 1652354014.44075-u7elfr because it did not enter required zones
[2022-05-12 13:21:46] frigate.events                 DEBUG   : Event received: update fr_framsida 1652354014.44075-u7elfr
[2022-05-12 13:21:56] frigate.events                 DEBUG   : Event received: update fr_vardagsrum 1652353876.216857-x7lq64
[2022-05-12 13:21:58] frigate.events                 DEBUG   : Event received: start fr_framsida 1652354518.329152-6sowwa
[2022-05-12 13:21:58] frigate.events                 DEBUG   : Event received: start fr_framsida 1652354518.329152-sgzpcg
[2022-05-12 13:21:59] frigate.events                 DEBUG   : Event received: end fr_vardagsrum 1652353876.216857-x7lq64
[2022-05-12 13:21:59] frigate.http                   ERROR   : ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
[2022-05-12 13:21:59] frigate.http                   ERROR   : ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
[2022-05-12 13:21:59] frigate.http                   ERROR   : ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
[2022-05-12 13:21:59] frigate.http                   ERROR   : ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
[2022-05-12 15:13:20] ws4py                          INFO    : Managing websocket [Local => 127.0.0.1:8082 | Remote => 127.0.0.1:49966]

HA:Log

2022-05-12 13:21:59 WARNING (MainThread) [homeassistant.components.automation.motionpcon_send_mqtt_snapshots_to_telegram_camera_group] MotionPCON - Send Frigate MQTT Snapshots to Telegram Camera Group: Already running
2022-05-12 13:21:59 WARNING (SyncWorker_8) [homeassistant.components.telegram_bot] Status code 404 (retry #1) loading https://vimes.disc-world.se:888/api/frigate/notifications/1652353876.216857-x7lq64/fr_vardagsrum/clip.mp4
2022-05-12 13:21:59 WARNING (SyncWorker_8) [homeassistant.components.telegram_bot] Status code 500 (retry #2) loading https://vimes.disc-world.se:888/api/frigate/notifications/1652353876.216857-x7lq64/fr_vardagsrum/clip.mp4
2022-05-12 13:21:59 WARNING (SyncWorker_8) [homeassistant.components.telegram_bot] Status code 500 (retry #3) loading https://vimes.disc-world.se:888/api/frigate/notifications/1652353876.216857-x7lq64/fr_vardagsrum/clip.mp4
2022-05-12 13:21:59 WARNING (SyncWorker_8) [homeassistant.components.telegram_bot] Status code 500 (retry #4) loading https://vimes.disc-world.se:888/api/frigate/notifications/1652353876.216857-x7lq64/fr_vardagsrum/clip.mp4
2022-05-12 13:21:59 WARNING (SyncWorker_8) [homeassistant.components.telegram_bot] Status code 500 (retry #5) loading https://vimes.disc-world.se:888/api/frigate/notifications/1652353876.216857-x7lq64/fr_vardagsrum/clip.mp4
2022-05-12 13:21:59 WARNING (SyncWorker_8) [homeassistant.components.telegram_bot] Can't load data in https://vimes.disc-world.se:888/api/frigate/notifications/1652353876.216857-x7lq64/fr_vardagsrum/clip.mp4 after 5 retries

FFprobe output from your camera

#> ffprobe rtsp://10.9.24.22:7447/5fa1837ae4b03c3c3c629b46_1
ffprobe version 3.4.2 Copyright (c) 2007-2018 the FFmpeg developers
  built with gcc 7 (SUSE Linux)
  configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --incdir=/usr/include/ffmpeg --extra-cflags='-fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g' --optflags='-fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g' --disable-htmlpages --enable-pic --disable-stripping --enable-shared --disable-static --enable-gpl --disable-openssl --enable-avresample --enable-libcdio --enable-gnutls --enable-ladspa --disable-cuda --disable-cuvid --enable-libass --enable-libbluray --enable-libcelt --enable-libcdio --enable-libdc1394 --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libzvbi --enable-vaapi --enable-vdpau --enable-muxers --enable-demuxers --disable-encoders --disable-decoders --disable-decoder='mpeg4,h263,h264,hevc,vc1' --enable-encoder='apng,ass,ayuv,bmp,ffv1,ffvhuff,flac,gif,huffyuv,jpegls,libgsm,libmp3lame,libopenjpeg,libopus,libschroedinger,libspeex,libtheora,libtwolame,libvorbis,libvpx_vp8,libvpx_vp9,libwebp,libwebp_anim,mjpeg,mp2,mp2fixed,pam,pbm,pcm_alaw,pcm_f32be,pcm_f32le,pcm_f64be,pcm_f64le,pcm_mulaw,pcm_s16be,pcm_s16be_planar,pcm_s16le,pcm_s16le_planar,pcm_s24be,pcm_s24le,pcm_s24le_planar,pcm_s32be,pcm_s32le,pcm_s32le_planar,pcm_s8,pcm_s8_planar,pcm_u16be,pcm_u16le,pcm_u24be,pcm_u24le,pcm_u32be,pcm_u32le,pcm_u8,pcx,pgm,pgmyuv,png,ppm,sgi,srt,ssa,sunrast,targa,text,tiff,v210,v308,v408,v410,vorbis,xbm,xwd,y41p,yuv4,zlib,' --enable-decoder='ac3,ansi,apng,ass,ayuv,bmp,dirac,exr,ffv1,ffvhuff,ffwavesynth,flac,gif,gsm,huffyuv,libcelt,libgsm,libopenjpeg,libopus,libschroedinger,libspeex,libvorbis,libvpx_vp8,libvpx_vp9,mjpeg,mpeg1video,mpeg2video,,mp1,mp1float,mp2,mp2float,mp3,mp3float,opus,pam,pbm,pcm_alaw,pcm_bluray,pcm_dvd,pcm_f32be,pcm_f32le,pcm_f64be,pcm_f64le,pcm_mulaw,pcm_s16be,pcm_s16be_planar,pcm_s16le,pcm_s16le_planar,pcm_s24be,pcm_s24le,pcm_s24le_planar,pcm_s32be,pcm_s32le,pcm_s32le_planar,pcm_s8,pcm_s8_planar,pcm_u16be,pcm_u16le,pcm_u24be,pcm_u24le,pcm_u32be,pcm_u32le,pcm_u8,pcx,pgm,pgmyuv,pgssub,png,ppm,rawvideo,sgi,srt,ssa,sunrast,targa,text,theora,tiff,v210,v210x,v308,v408,v410,vorbis,vp3,vp5,vp6,vp6a,vp6f,vp8,vp9,webp,xbm,xwd,y41p,yuv4,zlib,'
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libavresample   3.  7.  0 /  3.  7.  0
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
[rtsp @ 0x5596d40bd020] max delay reached. need to consume packet
[rtsp @ 0x5596d40bd020] RTP: missed 15 packets
[rtsp @ 0x5596d40bd020] max delay reached. need to consume packet
[rtsp @ 0x5596d40bd020] RTP: missed 11 packets
[rtsp @ 0x5596d40bd020] max delay reached. need to consume packet
[rtsp @ 0x5596d40bd020] RTP: missed 10 packets
[rtsp @ 0x5596d40bd020] max delay reached. need to consume packet
[rtsp @ 0x5596d40bd020] RTP: missed 6 packets
[rtsp @ 0x5596d40bd020] Could not find codec parameters for stream 1 (Video: h264 (Main), none(progressive)): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, rtsp, from 'rtsp://10.9.24.22:7447/5fa1837ae4b03c3c3c629b46_1':
  Metadata:
    title           : 18E829CFD405_1
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Audio: aac, 48000 Hz, 1 channels
    Stream #0:1: Video: h264 (Main), none(progressive), 90k tbr, 90k tbn, 90k tbc
Unsupported codec with id 86018 for input stream 0
Unsupported codec with id 28 for input stream 1

Frigate stats

{"detection_fps":0.4,"detectors":{"coral_pci":{"detection_start":0.0,"inference_speed":8.89,"pid":225}},"fr_baksidan":{"camera_fps":5.1,"capture_pid":262,"detection_fps":0.0,"pid":234,"process_fps":5.1,"skipped_fps":0.0},"fr_framsida":{"camera_fps":5.0,"capture_pid":259,"detection_fps":0.3,"pid":231,"process_fps":5.0,"skipped_fps":0.0},"fr_hallen":{"camera_fps":7.1,"capture_pid":265,"detection_fps":0.0,"pid":236,"process_fps":7.1,"skipped_fps":0.0},"fr_vardagsrum":{"camera_fps":5.1,"capture_pid":268,"detection_fps":0.1,"pid":258,"process_fps":5.1,"skipped_fps":0.0},"service":{"storage":{"/dev/shm":{"free":62.9,"mount_type":"tmpfs","total":67.1,"used":4.2},"/media/frigate/clips":{"free":94357.9,"mount_type":"btrfs","total":124787.9,"used":29878.2},"/media/frigate/recordings":{"free":94357.9,"mount_type":"btrfs","total":124787.9,"used":29878.2},"/tmp/cache":{"free":2125.1,"mount_type":"tmpfs","total":2147.5,"used":22.4}},"temperatures":{"apex_0":41.05},"uptime":909,"version":"0.10.1-83481af"}}

Operating system

Other Linux

Install method

Docker CLI

Coral version

M.2

Network connection

Wired

Camera make and model

Mix of hikvison, reolink and unifi.

Any other information that may be helpful

The frigate instance has been restarted since the issue, which may affect the stats output I suspect.

All attempts when I manually turn on the detect/recording switches in HA, everything works fine. Logg-state on the switch.fr_vardagsrum shows that recording was active at the time of the event.

NickM-27 commented 2 years ago

Does this only affect a specific camera in the config or call of them? Also describe the event, was a someone walking by, a stationary car, etc?

TheQue42 commented 2 years ago

This specific time, it was in a (to the best of my knowledge) a still livingroom, with a false positive on some cushions in a sofa. Since 99% of my clip-triggers are on the front porch (which is an imou bullet new, instead of a unifi flex in the livingroom), it feels like it doesnt have to do with the camera, but thats a bit of a wild guess.

NickM-27 commented 2 years ago

One thing is I notice the record and events have recordings set as active_objects. So a still couch cushion may never have "moved" so no clips were saved as a result.

TheQue42 commented 2 years ago

Ah, okey that sounds logical. Its a bit tricky to keep the consequences of all the settings in my mind :-)

But how did it trigger to begin with then? Doesnt it take some movement for the object-detection to kick-in? And whats the relation to sending MQTT notifications if there is a clip available?

What is unfortunately a bit confusing, is the HA log. The automation listed above: motionpcon_send_mqtt_snapshots_to_telegram_camera_group, does NOT try to send any clips.

But the log clearly seems to indicate that my OTHER automation, that waits for the "END" marker in the mqtt and has a {{ trigger.payload_json.after.has_clip == true }} condition, HAS triggered.

NickM-27 commented 2 years ago

Ah, okey that sounds logical. Its a bit tricky to keep the consequences of all the settings in my mind :-)

But how did it trigger to begin with then? Doesnt it take some movement for the object-detection to kick-in? And whats the relation to sending MQTT notifications if there is a clip available?

What is unfortunately a bit confusing, is the HA log. The automation listed above: motionpcon_send_mqtt_snapshots_to_telegram_camera_group, does NOT try to send any clips.

But the log clearly seems to indicate that my OTHER automation, that waits for the "END" marker in the mqtt and has a {{ trigger.payload_json.after.has_clip == true }} condition, HAS triggered.

That does add to the complexity. Motion is required for an object to be detected, and if has_clip is set then it likely had a clip at some point but that clip may have been deleted.

Without steps to reproduce (which would require consistent behavior) it is difficult to say what the issue is as there could be a number of different things happening. If you can get the mqtt payload (viewing in the HA debug trace) of an event that triggered but didn't have any clip that may be helpful.

blakeblackshear commented 2 years ago

Frigate scans for objects on startup regardless of motion. Also, has_clip is based on whether or not recording was enabled and does not actually confirm that a file exists. It assumes if you have recording enabled that recordings were captured.

TheQue42 commented 2 years ago

@blakeblackshear : Trying to wrap my head around this. It was not at startup of frigate. We had left the house some time ago, and frigate had definitely been running for a while. But, if I understand correctly, could this have been caused by light-changes in the livingroom window, that triggered motion/object detection, found a false positive, but since my since my retain_mode: is set to active_objects, no recording was made? And this is by design? Its a bit confusing that has_clip can be set, even when no clip is saved. I have verified that recording was enabled, at least according to HA entity states.

blakeblackshear commented 2 years ago

You shouldn't see events for objects that never move (bounding box movement, not lighting changes) from the initial location. If the bounding box grows and shrinks a lot while detecting lighting changes, this is often seen as an object changing location. Active objects should save any recording segment with a frame where that movement occurred.

I most often see this happen because the of corrupt recording segments from flaky connections to the camera. Do you ever see Discarding a corrupt recording segment in the logs? has_clip should always be accurate unless your recordings are unexpectedly missing. It is not by design for has_clip to be true and the video to not be available.

TheQue42 commented 2 years ago

I cant of course be sure, but I dont think I've had any issues with these cameras. My two unifi cameras (receiving the stream from unifi-video) are my best performers(stability-wise), and if this had concered my reolink 520, I wouldnt even have bothered creating a ticket, since I know that frigate doesnt seem to fond of the stream it recieves from that one.

stale[bot] commented 2 years 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.