blakeblackshear / frigate

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

[Config Support]: Clips recording starting too late. #3972

Closed Calimerorulez closed 1 year ago

Calimerorulez commented 1 year ago

Describe the problem you are having

Hi,

I've moved my install to a smaller server, and now the recorded clips are starting too late. The snapshot is correct, but the recording of the clips of the events start 10 seconds later or so.

Eg. snapshot time is 7:10:45, clip starts at 7:10:55 or so. It's not always 10 seconds, and in rare cases the clip is fine, about one out of ten times.

CPU usage in the container is not an issue. I'm not using hardware acceleration.

Version

0.11.0

Frigate config file

detectors:
  coral_pci:
    type: edgetpu
    device: pci
mqtt:
  # Required: host name
  host: 192.168.1.7
  # Optional: port (default: shown below)
  port: 1883
  # Optional: topic prefix (default: shown below)
  # WARNING: must be unique if you are running multiple instances
  topic_prefix: frigate
  # Optional: client id (default: shown below)
  # WARNING: must be unique if you are running multiple instances
  client_id: frigate
  # Optional: user
  user: frigate
  # Optional: password
  # NOTE: Environment variables that begin with 'FRIGATE_' may be referenced in {}.
  #       eg. password: '{FRIGATE_MQTT_PASSWORD}'
  password: frigate
  # Optional: interval in seconds for publishing stats (default: shown below)
  stats_interval: 60

record:
  enabled: true
  retain:
    days: 0
    mode: motion
  events:
    pre_capture: 10
    post_capture: 10
    retain:
      default: 14
      mode: active_objects      
#    max_seconds: 90

cameras:
  flex_nw:
    mqtt:
      timestamp: False
      bounding_box: False
      crop: True
      quality: 100
      height: 1080
    ffmpeg:
      global_args:
        - -hide_banner
        - -loglevel
        - debug
        - -skip_frame 
        - nokey
        - -an
      input_args:
#        - -c:v
#        - h264_cuvid
        - -rtsp_transport
        - tcp
#      hwaccel_args:
#        - -hwaccel
#        - vaapi
#        - -hwaccel_device
#        - /dev/dri/renderD128
      inputs:
        - path: rtsp://192.168.1.4:7447/lt4UFRNGNfKb7rLG
          roles:
            - detect
            - rtmp
            - record
    snapshots:
      enabled: True
      timestamp: false
      bounding_box: true
      retain:
        default: 7
    #clips:
    #  enabled: True
    #  retain:
    #    default: 7
    objects:
      track:
        - person
        - car
        - truck
        - bicycle
        - motorcycle
        - cat
        - dog
        # Optional: save clips configuration
      filters:
        car:
          mask:
            - 530,522,473,205,0,276,0,626
            - 1256,113,1264,187,662,214,656,137
    detect:
      width: 1920
      height: 1080
      fps: 5
    motion:
      mask:
        - 691,1080,492,707,0,813,0,1080
        - 630,0,803,329,524,408,384,289,191,0
        - 1760,0,1674,325,1445,329,1233,0
    zones:
      oprit:
        coordinates: 673,1080,1569,671,1258,652,547,856
      vooroprit:
        coordinates: 1012,618,1209,780,622,1000,478,772
  # Name of your camera
  flex_n:
    mqtt:
      timestamp: False
      bounding_box: False
      crop: True
      quality: 100
      height: 576
    ffmpeg:
      global_args:
        - -hide_banner
        - -loglevel
        - debug
        - -skip_frame
        - nokey
        - -an
      input_args:
        - -rtsp_transport
        - tcp
#      hwaccel_args:
#        - -hwaccel
#        - vaapi
#        - -hwaccel_device
#        - /dev/dri/renderD128
      inputs:
        - path: rtsp://192.168.1.4:7447/Oyed89k7zkuKxlqz
          roles:
          - detect
          - rtmp
          - record
    snapshots:
      enabled: True
      timestamp: false
      bounding_box: true
      retain:
        default: 7
    #clips:
    #  enabled: True
    #  retain:
    #    default: 7
    objects:
      track:
        - person
        - bicycle
        - dog
        - cat
        # Optional: save clips configuration
    detect:
      width: 1024
      height: 576
      fps: 5
    zones:
      zijoprit:
        coordinates: 564,576,981,478,855,306,21,377,71,576
  # Name of your camera
  flex_sw:
    mqtt:
      timestamp: False
      bounding_box: False
      crop: True
      quality: 100
      height: 500
    ffmpeg:
      global_args:
        - -hide_banner
        - -loglevel
        - debug
        - -skip_frame
        - nokey
        - -an
      input_args:
#        - -c:v
#        - h264_cuvid
        - -rtsp_transport
        - tcp
#      hwaccel_args:
#        - -hwaccel
#        - vaapi
#        - -hwaccel_device
#        - /dev/dri/renderD128
      inputs:
        - path: rtsp://192.168.1.4:7447/eqFchgafmZoxHufA
          roles:
          - detect
          - rtmp
          - record
    snapshots:
      enabled: True
      timestamp: false
      bounding_box: true
      retain:
        default: 7
    #clips:
    #  enabled: True
    #  retain:
    #    default: 7
    objects:
      track:
        - person
        - car
        - truck
        - bicycle
        - motorcycle
        - cat
        - dog
        # Optional: save clips configuration
      filters:
        car:
          mask:
            - 982,396,967,234,651,214,589,347
            - 425,306,429,199,324,205,267,296
            - 189,177,186,257,118,271,21,266,24,197
    detect:
      width: 1024
      height: 576
      fps: 5
    motion:
      mask:
        - 1024,0,1024,245,955,247,869,125,923,0
        - 841,108,813,163,781,159,765,105,801,70,784,69
        - 432,0,653,0,693,97,675,196,534,306,463,250,383,99
        - 872,576,865,450,197,312,79,461,329,576
        - 211,137,305,150,308,177,230,191,150,200,140,152
  # Name of your camera

Relevant log output

not relevant, no errors.

Frigate stats

No response

Operating system

Proxmox

Install method

Docker Compose

Coral version

PCIe

Any other information that may be helpful

Debian VM on Proxmox, fully patched. PCIe Coral passed through.

NickM-27 commented 1 year ago

Can you run ffprobe on your cameras?

What iframe interval is set on your cameras?

Calimerorulez commented 1 year ago

Hi @NickM-27

I haven't used the ffmpeg in the Frigate container, but the ffmpeg on a pi I'm having outputs:

ffprobe version 4.3.4-0+deb11u1+rpt3 Copyright (c) 2007-2021 the FFmpeg developers
  built with gcc 10 (Raspbian 10.2.1-6+rpi1)
  configuration: --prefix=/usr --extra-version=0+deb11u1+rpt3 --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --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-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --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-opencl --enable-opengl --enable-sdl2 --enable-mmal --enable-neon --enable-rpi --enable-v4l2-request --enable-libudev --enable-epoxy --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared --libdir=/usr/lib/arm-linux-gnueabihf --cpu=arm1176jzf-s --arch=arm
  WARNING: library configuration mismatch
  avutil      configuration: --prefix=/usr --extra-version=0+deb11u1+rpt3 --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --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-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --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-opencl --enable-opengl --enable-sdl2 --enable-mmal --enable-neon --enable-rpi --enable-v4l2-request --enable-libudev --enable-epoxy --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --libdir=/usr/lib/arm-linux-gnueabihf/neon/vfp --cpu=cortex-a7 --arch=armv6t2 --disable-thumb --enable-shared --disable-doc --disable-programs
  avcodec     configuration: --prefix=/usr --extra-version=0+deb11u1+rpt3 --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --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-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --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-opencl --enable-opengl --enable-sdl2 --enable-mmal --enable-neon --enable-rpi --enable-v4l2-request --enable-libudev --enable-epoxy --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --libdir=/usr/lib/arm-linux-gnueabihf/neon/vfp --cpu=cortex-a7 --arch=armv6t2 --disable-thumb --enable-shared --disable-doc --disable-programs
  avformat    configuration: --prefix=/usr --extra-version=0+deb11u1+rpt3 --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --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-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --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-opencl --enable-opengl --enable-sdl2 --enable-mmal --enable-neon --enable-rpi --enable-v4l2-request --enable-libudev --enable-epoxy --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --libdir=/usr/lib/arm-linux-gnueabihf/neon/vfp --cpu=cortex-a7 --arch=armv6t2 --disable-thumb --enable-shared --disable-doc --disable-programs
  avdevice    configuration: --prefix=/usr --extra-version=0+deb11u1+rpt3 --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --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-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --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-opencl --enable-opengl --enable-sdl2 --enable-mmal --enable-neon --enable-rpi --enable-v4l2-request --enable-libudev --enable-epoxy --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --libdir=/usr/lib/arm-linux-gnueabihf/neon/vfp --cpu=cortex-a7 --arch=armv6t2 --disable-thumb --enable-shared --disable-doc --disable-programs
  avfilter    configuration: --prefix=/usr --extra-version=0+deb11u1+rpt3 --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --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-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --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-opencl --enable-opengl --enable-sdl2 --enable-mmal --enable-neon --enable-rpi --enable-v4l2-request --enable-libudev --enable-epoxy --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --libdir=/usr/lib/arm-linux-gnueabihf/neon/vfp --cpu=cortex-a7 --arch=armv6t2 --disable-thumb --enable-shared --disable-doc --disable-programs
  avresample  configuration: --prefix=/usr --extra-version=0+deb11u1+rpt3 --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --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-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --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-opencl --enable-opengl --enable-sdl2 --enable-mmal --enable-neon --enable-rpi --enable-v4l2-request --enable-libudev --enable-epoxy --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --libdir=/usr/lib/arm-linux-gnueabihf/neon/vfp --cpu=cortex-a7 --arch=armv6t2 --disable-thumb --enable-shared --disable-doc --disable-programs
  swscale     configuration: --prefix=/usr --extra-version=0+deb11u1+rpt3 --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --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-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --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-opencl --enable-opengl --enable-sdl2 --enable-mmal --enable-neon --enable-rpi --enable-v4l2-request --enable-libudev --enable-epoxy --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --libdir=/usr/lib/arm-linux-gnueabihf/neon/vfp --cpu=cortex-a7 --arch=armv6t2 --disable-thumb --enable-shared --disable-doc --disable-programs
  swresample  configuration: --prefix=/usr --extra-version=0+deb11u1+rpt3 --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --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-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --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-opencl --enable-opengl --enable-sdl2 --enable-mmal --enable-neon --enable-rpi --enable-v4l2-request --enable-libudev --enable-epoxy --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --libdir=/usr/lib/arm-linux-gnueabihf/neon/vfp --cpu=cortex-a7 --arch=armv6t2 --disable-thumb --enable-shared --disable-doc --disable-programs
  postproc    configuration: --prefix=/usr --extra-version=0+deb11u1+rpt3 --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --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-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --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-opencl --enable-opengl --enable-sdl2 --enable-mmal --enable-neon --enable-rpi --enable-v4l2-request --enable-libudev --enable-epoxy --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --libdir=/usr/lib/arm-linux-gnueabihf/neon/vfp --cpu=cortex-a7 --arch=armv6t2 --disable-thumb --enable-shared --disable-doc --disable-programs
  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
[udp @ 0xe783e0] attempted to set receive buffer to size 393216 but it only ended up set as 360448
[udp @ 0xe88720] attempted to set receive buffer to size 393216 but it only ended up set as 360448
[udp @ 0xe99240] attempted to set receive buffer to size 393216 but it only ended up set as 360448
[udp @ 0xea94e0] attempted to set receive buffer to size 393216 but it only ended up set as 360448
[udp @ 0xeb9f30] attempted to set receive buffer to size 393216 but it only ended up set as 360448
[udp @ 0xeca280] attempted to set receive buffer to size 393216 but it only ended up set as 360448
Input #0, rtsp, from 'rtsp://192.168.1.4:7447/lt4UFRNGNfKb7rLG':
  Metadata:
    title           : 18E829080F6F_0
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Audio: aac (LC), 48000 Hz, mono, fltp
    Stream #0:1: Audio: opus, 48000 Hz, stereo, fltp
    Stream #0:2: Video: h264 (Main), yuvj420p(pc, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc

This is from one cam, a Unifi G3 Flex, the other cameras are the same type and make.

NickM-27 commented 1 year ago

If you go into the recordings directory do you see a recording segment that you'd expect to be at the start of the clip?

Calimerorulez commented 1 year ago

I indeed see the recording if I lookup one, but also here is the snapshot earlier than the start of the clip, although a second or so:

A482ED95-9D92-4E3E-AA47-25465E3F8FB5_1_201_a

This one is close, but often the 'delay/gap' between the two is much greater.

Calimerorulez commented 1 year ago

Like this one:

F26ED5B8-872E-42E5-993B-C9C5A1F2F332_1_201_a

The detected person isn't in the clip. Snapshot on the snapshot tab is from 08:53:48 (the preview says 08:53:43), the clip starts at 08:53:52 and ends at 08:54:00.

Calimerorulez commented 1 year ago

I've added the api stats: {"detection_fps":0.0,"detectors":{"coral_pci":{"detection_start":0.0,"inference_speed":7.95,"pid":216}},"flex_n":{"camera_fps":6.0,"capture_pid":231,"detection_fps":0.0,"pid":223,"process_fps":6.0,"skipped_fps":0.0},"flex_nw":{"camera_fps":6.0,"capture_pid":229,"detection_fps":0.0,"pid":221,"process_fps":6.0,"skipped_fps":0.0},"flex_sw":{"camera_fps":6.0,"capture_pid":235,"detection_fps":0.0,"pid":225,"process_fps":6.0,"skipped_fps":0.0},"service":{"latest_version":"0.11.0","storage":{"/dev/shm":{"free":60.7,"mount_type":"tmpfs","total":67.1,"used":6.4},"/media/frigate/clips":{"free":71829.3,"mount_type":"ext4","total":82944.9,"used":6855.2},"/media/frigate/recordings":{"free":71829.3,"mount_type":"ext4","total":82944.9,"used":6855.2},"/tmp/cache":{"free":71829.3,"mount_type":"overlay","total":82944.9,"used":6855.2}},"temperatures":{"apex_0":51.55},"uptime":1100,"version":"0.11.0-3846a13"}}

NickM-27 commented 1 year ago

I'd definitely check your cameras iframe interval setting

Calimerorulez commented 1 year ago

Is this dependent for the server hardware I'm using for Frigate then? On a beefier server, I don't have the problem. I'm going to search for i-frame interval, but I haven't seen this option in Unifi Protect, or in the camera settings though.

NickM-27 commented 1 year ago

I honestly have no idea why performance would matter. But a servers performance is only one aspect of it, there can be many different variables between two different servers so I am currently just treating it as that is not a factor.

Calimerorulez commented 1 year ago

Sadly the i-frame interval isn't configurable for Unifi, so I'm out of options. I've tweaked the ffmpeg parameters some more as per the documentation, but it does not help.

nlindn commented 1 year ago

I have this exact same issue. Frigate 0.11.0 is running in docker on ubuntu server with intel i5 gen 8 with usb coral. The snapshot shows for example a detected driving car but it is not visible in the recording because it started too late and the car drove away. The recording does start at some-point near the snapshot timestamp but I have in config Pre_capture: 10 so quite strange that it starts most often after the snapshot timestamp. The camera is hikvision and detection stream is 4fps with i-frame 4 and the recording stream is 20fps with i-frame 40.

NickM-27 commented 1 year ago

I have this exact same issue. Frigate 0.11.0 is running in docker on ubuntu server with intel i5 gen 8. The snapshot shows for example a detected driving car but it is not visible in the recording because it started too late and the car drove away. The recording does start at some-point near the snapshot timestamp but I have in config Pre_capture: 10 so quite strange that it starts most often after the snapshot timestamp. The camera is hikvision and detection stream is 4fps with i-frame 4 and the recording stream is 20fps with i-frame 40.

OP is using one stream for all, in your case it could very well be that the main stream is behind the detect stream.

nlindn commented 1 year ago

OP is using one stream for all, in your case it could very well be that the main stream is behind the detect stream.

Good point. I have the hikvision camera with substream as detection and rtmp and main stream as record. I added a new camera to the frigate config with the main stream from the same camera as rtmp. So I had from the same camera both substream and mainstream in frigate as rtmp. Now when I did testing looking at the frigate live view there is a delay of ~1 second and the substream is behind the mainstream. The delays between the streams could be the root cause but with this small delay and pre_capture: 10 it could match the problem OP has. Have to do some more testing.

Calimerorulez commented 1 year ago

I'm using pre_capture too, but that does not help, even if I make it 20 seconds

NickM-27 commented 1 year ago

I'd recommend trying to set the recording mode to all and see if that makes a difference. With pre_capture of 20 when does the recording start vs the snapshot?

nlindn commented 1 year ago

Noticed that when looking at a clip the video the banner says for example 2022-10-04 17:51:02 [38s, Car 84%]. I guess the 38s should indicate the length of the event? However the video is only 30s long, so it is missing 8 seconds. When looking at the record folder there is no recording segment that would match the expected starting of the clip. The starting of the clip matches the first recording segment available of the situation. So the problem is that some recording segment is/are missing and clip can't therefor display what has happened earlier. Is this just a config issue or something else? How should the config be if you just want the events of active objects saved with pre_capture of 10s?

This my current config:

record:
  enabled: True
  events:
    pre_capture: 10
    post_capture: 5
    retain:
      default: 10
      mode: active_objects
NickM-27 commented 1 year ago

Noticed that when looking at a clip the video the banner says for example 2022-10-04 17:51:02 [38s, Car 84%]. I guess the 38s should indicate the length of the event? However the video is only 30s long, so it is missing 8 seconds. When looking at the record folder there is no recording segment that would match the expected starting of the clip. The starting of the clip matches the first recording segment available of the situation. So the problem is that some recording segment is/are missing and clip can't therefor display what has happened earlier. Is this just a config issue or something else? How should the config be if you just want the events of active objects saved with pre_capture of 10s?

This my current config:


record:

  enabled: True

  events:

    pre_capture: 10

    post_capture: 5

    retain:

      default: 10

      mode: active_objects

The problem may be your iframe interval, you'll want it to be the same as fps.

What are the lengths of your segments? It sounds like they're going to be inconsistent, or there's errors in the logs for recording but I'm assuming that's not the case

nlindn commented 1 year ago

What are the lengths of your segments? It sounds like they're going to be inconsistent, or there's errors in the logs for recording but I'm assuming that's not the case

No errors in the default logs. The segments are always  ~10 seconds. Here is the recording list for the above event with 2022-10-04 17:51:02 [38s, Car 84%]

$ ls ../media/frigate/recordings/2022-10/04/17/camera1

...
38.29.mp4
51.08.mp4 <--
51.19.mp4 <--
51.28.mp4 <--
52.19.mp4
...
NickM-27 commented 1 year ago

What % of events did this happen in? Seems like something is out of sync for sure, would expect 4 ~10s segments for 38 seconds

nlindn commented 1 year ago

All of them are like at least one segment is missing. One is a 27s video and there are 2 of  ~10s segments. It feels like only the segments where there were all the time active objects are saved as the first segment. Any ideas how to troubleshoot. Does the camera and frigate need to have the same timesync with NTP server. The camera does not have correct time because blocked access to WAN and NTP.

NickM-27 commented 1 year ago

I believe the default args mean it uses the systems time but also I don't think it would hurt, all my cameras are syncing with my Unraid NAS NTP server

NickM-27 commented 1 year ago

Maybe try changing the retain mode to all for events and see if that makes a difference

nlindn commented 1 year ago

Maybe try changing the retain mode to all for events and see if that makes a difference

Changing the retain mode to "all" for events makes it work as expected but of course just all the segments saved which is not the goal.

When changing back to retain mode "active_objects" and restarting the container something strange happens. Frigate deletes all the "unnecessary" segments and it deletes them to the situation where we are back to the problem as before. So a [38s, Car 84%] has again 3 of ~10s segments and is 30s long when the same event with retain "all" was showing 4 segments with length of 40s. Any ideas?

NickM-27 commented 1 year ago

What happens if you try motion?

Calimerorulez commented 1 year ago

(I haven't had time to test yet, sorry)

nlindn commented 1 year ago

I found probably the issue causing this problem in the src code. If you only have "motion" or "active_objects" for events selected the pre_capture and post_capture parameters are not working as expected.

If you have "active_objevts" selected frigate saves only the segments with active objects. For example this means that if the active object is in the segments first 2 seconds you will have only post capture of 2s because frigate does not save the previous segment with no active objects. Same for post capture and if you have "motion" selected.

This can again lead to the problem OP probably also has that the decoding of the detection stream is so slow that there will become a delay between record and detect stream. Now if there is active object discovered in the detection stream and the segment is for example at 0.5 second time of the 0-10s segment and the record stream is over 0.5s ahead because of detection stream delay the recording will miss the real segment where the obejct was and only save the next one where the detection snapshot is not visible in any frame. This small delay problem would be fixed with the pre_capture but it is not working currently as expected.

Let's look at the code in def store_segment(). Here it is checked if there is an active object or motion in the segment considering saving. If we have post capture 10s and the event happened in the segment at 2 seconds this means that the previous segment will not be saved because of this if statement even though the post capture "would have wanted" the 8s from this segment. So now we can have a [38s, Car 84%] but there is only 3 segments total of 30s saved which was one of the issues.

/frigate/record.py

def store_segment():

       ...

        if (store_mode == RetainModeEnum.motion and motion_count == 0) or (
            store_mode == RetainModeEnum.active_objects and active_count == 0
        ):
            Path(cache_path).unlink(missing_ok=True)
            self.end_time_cache.pop(cache_path, None)
            return
       ...

Ignoring this if statement is not enough because it will be deleted later by RecordingCleanup in def expire_recordings(self):

Here all the saved segments without active obejcts or motion will be deleted even tough they are inside an event time schedule but just have not active object causing pre_capture to break.


        def expire_recordings(self):

                ...
                # Delete recordings outside of the retention window or based on the retention mode
                if (
                    not keep
                    or (
                        config.record.events.retain.mode == RetainModeEnum.motion
                        and recording.motion == 0
                    )
                    or (
                        config.record.events.retain.mode
                        == RetainModeEnum.active_objects
                        and recording.objects == 0
                    )
                ):
                    Path(recording.path).unlink(missing_ok=True)
                    deleted_recordings.add(recording.id)
               ...

Now we just need to find how to fix this without breaking anything.

blakeblackshear commented 1 year ago

This is the intended behavior and by design. Those segments do not contain motion or active objects, so they are dropped. Consider an event for a car that enters your driveway and parks for 3 hours before leaving. The event would last 3 hours, but only the segments during that event with motion would be stored so you can watch the entire event without reviewing hours of footage where no pixels changed.

nlindn commented 1 year ago

So you would not want a change where those segments inside the pre capture to post capture timeline are also saved? So for the car example now only segments with motion or active objects are saved. But instead segments with motion or active objects would be saved including the wanted pre capture and post capture before and after the motion/activity. So with example pre_capture: 10 and post_capture: 10 on the 3 hours of the car the segments with motion/activity would be saved as currently is but also when necessary the previous or later segments needed to full fill the pre/post capture option. So if the car is moving in the 0-10s segment at 5 second timestamp also the previous segment would be saved so we get the 10s pre capture full filled.

blakeblackshear commented 1 year ago

I wouldn't because it would be inconsistent. If you want segments that don't contain motion or active_objects to be saved for events, then specify all as your retain mode for events. The record mode pertains to all segments in the event inclusive of pre/post capture. They shouldn't be treated any differently just because they are pre/post.

NickM-27 commented 1 year ago

@lazygadget can you paste your config file?

@Calimerorulez I'd recommend not overwriting the default input args. At least worth a try to see if it reduces the latency between streams. Or you can simply switch the event retention mode to all

I also notice hwaccel is commented out, does your new machine not have any?

nlindn commented 1 year ago

@lazygadget can you paste your config file?

mqtt:
  host: mqtt_ip
  user: mqtt_user
  password: mqtt_password

detectors:
  coral:
    type: edgetpu
    device: usb

ffmpeg:
  hwaccel_args:
    - -hwaccel
    - vaapi
    - -hwaccel_device
    - /dev/dri/renderD128
    - -hwaccel_output_format
    - yuv420p

cameras:
  camera_1: # <------ Name the camera
    ffmpeg:
      inputs:
        - path: rtsp://user:password@ip:554/Streaming/Channels/102/ # <----- Update for your camera
          roles:
            - detect
            - rtmp
        - path: rtsp://user:password@ip:554/Streaming/Channels/101/ # <----- Update for your camera
          roles:
            - record

    rtmp:
      enabled: True # <-- RTMP should be disabled if your stream is not H264
    detect:
      width: 640 # <---- update for your camera's resolution
      height: 360 # <---- update for your camera's resolution
      fps: 4
    snapshots:
      enabled: True
      timestamp: True

record:
  enabled: True
  events:
    pre_capture: 10
    post_capture: 10
    retain:
      default: 10
      mode: active_objects

objects:
  track:
    - person
    - bicycle
    - car
    - motorcycle
    - cat
    - dog
Calimerorulez commented 1 year ago

@NickM-27 I've change to 'all' for retain mode, and disabled any input arguments (rtsp_transport). I will give it a try.

/edit: I'm now using:

hwaccel_args: -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format yuv420p

as hardware acceleration, but CPU usage isn't any lower. I've passed through the iGPU of my processor in my NUC, to the VM.

Calimerorulez commented 1 year ago

@NickM-27 Well, changing to 'all' and enabling hardware acceleration seems to be working fine now :)

Only thing I noticed, is that the detection ratio is lower than my old server. When a car drives onto my driveway, on the old server detection rate was 100%, the new server is missing some detections.

NickM-27 commented 1 year ago

What do you mean by detection rate? Where are you getting 100% from?

Calimerorulez commented 1 year ago

Well I know exactly when a car enters the driveway, because that can be only two cars that have access. I know the times when the car enters the driveway. Just now, when I came home, my car wasn't detected when entering the zone I've defined. On my old server, the detection ratio was 100%. I'm trying to get my head around why.

Edit: when looking back at the footage, I see myself driving towards the driveway, that's detected, but when entering the driveway zone it isn't an extra detection event. It is part of the driving-to-the-driveway-event. My driveway is perpendicular to the street.

When backup up from the driveway to the street, the car is correctly detected.

NickM-27 commented 1 year ago

You'd just need to compare the debug views in frigate, but there shouldn't be any difference. hwaccel won't affect scores.

Be sure to check logs and make sure there are no errors

github-actions[bot] commented 1 year 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.