blakeblackshear / frigate

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

[Camera Support]: Hikvision camear disconnectiong wont stay live - DS-2CD2383G0-I #4251

Closed sesipod closed 1 year ago

sesipod commented 1 year ago

Describe the problem you are having

I have a Hikvision camera ( DS-2CD2383G0-I ) that will not stay live and it will not record. This camera is also causing errors in the docker log file. I am also running nvidia-docker2 with NVIDIA 1650TI for ffmpeg you can see in my config below.

Version

0.11.1-2eada21

Frigate config file

mqtt:
  host: 10.0.35.216
############################################################
############################################################
detectors:
  # Required: name of the detector
  cpu1:
    type: cpu
    num_threads: 2
  cpu2:
    type: cpu
    num_threads: 2
############################################################
############################################################
birdseye:
  enabled: True
  width: 1920
  height: 1080
  quality: 10 # 1 highest 31 is the lowest. Lower quality feeds utilize less CPU resources.
  mode: continuous
############################################################
############################################################
motion:
  # Optional: The threshold passed to cv2.threshold to determine if a pixel is different enough to be counted as motion. (default: shown below)
  # Increasing this value will make motion detection less sensitive and decreasing it will make motion detection more sensitive.
  # The value should be between 1 and 255.
  threshold: 30
  # Optional: Minimum size in pixels in the resized motion image that counts as motion (default: 30)
  # Increasing this value will prevent smaller areas of motion from being detected. Decreasing will
  # make motion detection more sensitive to smaller moving objects.
  # As a rule of thumb:
  #  - 15 - high sensitivity
  #  - 30 - medium sensitivity
  #  - 50 - low sensitivity
  contour_area: 30
  # Optional: Alpha value passed to cv2.accumulateWeighted when averaging the motion delta across multiple frames (default: shown below)
  # Higher values mean the current frame impacts the delta a lot, and a single raindrop may register as motion.
  # Too low and a fast moving person wont be detected as motion.
  delta_alpha: 0.2
  # Optional: Alpha value passed to cv2.accumulateWeighted when averaging frames to determine the background (default: shown below)
  # Higher values mean the current frame impacts the average a lot, and a new object will be averaged into the background faster.
  # Low values will cause things like moving shadows to be detected as motion for longer.
  # https://www.geeksforgeeks.org/background-subtraction-in-an-image-using-concept-of-running-average/
  frame_alpha: 0.2
  # Optional: Height of the resized motion frame  (default: 50)
  # This operates as an efficient blur alternative. Higher values will result in more granular motion detection at the expense
  # of higher CPU usage. Lower values result in less CPU, but small changes may not register as motion.
  frame_height: 50
  # Optional: motion mask
  # NOTE: see docs for more detailed info on creating masks
##  mask: 0,900,1080,900,1080,1920,0,1920
  # Optional: improve contrast (default: shown below)
  # Enables dynamic contrast improvement. This should help improve night detections at the cost of making motion detection more sensitive
  # for daytime.
  improve_contrast: False
  # Optional: Delay when updating camera motion through MQTT from ON -> OFF (default: shown below).
  mqtt_off_delay: 15
############################################################
############################################################
record:
  enabled: True
  expire_interval: 60 # Optional: Number of minutes to wait between cleanup runs
  retain: # Optional: Retention settings for recording
    # Optional: Number of days to retain recordings regardless of events | 
    # NOTE: This should be set to 0 and retention should be defined in events section below if you only want to retain recordings of events.
    days: 3
    # Optional: Mode for retention. Available options are: all, motion, and active_objects
    #   all - save all recording segments regardless of activity
    #   motion - save all recordings segments with any detected motion
    #   active_objects - save all recording segments with active/moving objects
    # NOTE: this mode only applies when the days setting above is greater than 0
    mode: all
  # Optional: Event recording settings
  events:
    # Optional: Number of seconds before the event to include (default: shown below)
    pre_capture: 10
    # Optional: Number of seconds after the event to include (default: shown below)
    post_capture: 15
    # Optional: Objects to save recordings for. (default: all tracked objects)
    objects:
      - person
      - car
      - motorcycle
      - bus
      - bicycle
      - cat
      - dog
    # Optional: Restrict recordings to objects that entered any of the listed zones (default: no required zones)
    required_zones: []
    # Optional: Retention settings for recordings of events
    retain:
      # Required: Default retention days (default: shown below)
      default: 3
      # Optional: Mode for retention. (default: shown below)
      #   all - save all recording segments for events regardless of activity
      #   motion - save all recordings segments for events with any detected motion
      #   active_objects - save all recording segments for event with active/moving objects
      #
      # NOTE: If the retain mode for the camera is more restrictive than the mode configured
      #       here, the segments will already be gone by the time this mode is applied.
      #       For example, if the camera retain mode is "motion", the segments without motion are
      #       never stored, so setting the mode to "all" here won't bring them back.
      mode: all
      # Optional: Per object retention days
      objects:
        person: 3
        car: 3 
        motorcycle: 3
        bus: 3
        bicycle: 3
        cat: 3
        dog: 3
############################################################
############################################################
snapshots:
  # Optional: Enable writing jpg snapshot to /media/frigate/clips (default: shown below)
  # This value can be set via MQTT and will be updated in startup based on retained value
  enabled: True
  # Optional: save a clean PNG copy of the snapshot image (default: shown below)
  clean_copy: False
  # Optional: print a timestamp on the snapshots (default: shown below)
  timestamp: True
  # Optional: draw bounding box on the snapshots (default: shown below)
  bounding_box: True
  # Optional: crop the snapshot (default: shown below)
  ##crop: False
  # Optional: height to resize the snapshot to (default: original size)
  ##height: 175
  # Optional: Restrict snapshots to objects that entered any of the listed zones (default: no required zones)
  ##required_zones: []
  # Optional: Camera override for retention settings (default: global values)
  retain:
    # Required: Default retention days (default: shown below)
    default: 1
    # Optional: Per object retention days
    objects:
      person: 2
      car: 1
############################################################
############################################################
# Optional: RTMP configuration
# NOTE: Can be overridden at the camera level
rtmp:
  # Optional: Enable the RTMP stream (default: True)
  enabled: True
############################################################
############################################################
# Optional: Live stream configuration for WebUI
# NOTE: Can be overridden at the camera level
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: 1440
  # Optional: Set the encode quality of the live stream (default: shown below)
  # 1 is the highest quality, and 31 is the lowest. Lower quality feeds utilize less CPU resources.
  quality: 5
################################################################################################
################################################################################################
  Back-Left:
    ffmpeg:
      hwaccel_args: -c:v h264_cuvid
      inputs:
        - path: rtsp://admin:REDACTED_POST@192.168.1.105:554/ISAPI/Streaming/Channels/101       
          roles:
            - detect
            - record
            - rtmp
    #####
    detect:
      width: 1920
      height: 1080
      fps: 5
      enabled: True
      # Optional: Number of frames without a detection before frigate considers an object to be gone. (default: 5x the frame rate)
      max_disappeared: 25
      # Optional: Configuration for stationary object tracking
      stationary:
        # Optional: Frequency for confirming stationary objects (default: shown below)
        # When set to 0, object detection will not confirm stationary objects until movement is detected.
        # If set to 10, object detection will run to confirm the object still exists on every 10th frame.
        interval: 5
        # Optional: Number of frames without a position change for an object to be considered stationary (default: 10x the frame rate or 10s)
        threshold: 50
    #####
    best_image_timeout: 60
    #####
    ui:
      order: 3 #sort order
      dashboard: True #show in dashboard
    #####
    objects:
    # Optional: list of objects to track from labelmap.txt (default: shown below)
      track:
        - person
        - car
        - motorcycle
        - bus
        - bicycle
        - cat
        - dog
      filters:
          person:
             # Optional: minimum score for the object to initiate tracking (default: shown below)
             min_score: 0.6
             # Optional: minimum decimal percentage for tracked object's computed score to be considered a true positive (default: shown below)
             threshold: 0.65
             #mask: 0,720,1280,720,1280,250,1210,226,1137,198,1055,169,938,138,838,78,833,163,555,78,346,77,0,132
          car:
             # Optional: minimum score for the object to initiate tracking (default: shown below)
             min_score: 0.6
             # Optional: minimum decimal percentage for tracked object's computed score to be considered a true positive (default: shown below)
             threshold: 0.65 
             #mask: 0,720,1280,720,1280,250,1210,226,1137,198,1055,169,938,138,838,78,833,163,555,78,346,77,0,132
          motorcycle:
             # Optional: minimum score for the object to initiate tracking (default: shown below)
             min_score: 0.6
             # Optional: minimum decimal percentage for tracked object's computed score to be considered a true positive (default: shown below)
             threshold: 0.65
             #mask: 0,720,1280,720,1280,250,1210,226,1137,198,1055,169,938,138,838,78,833,163,555,78,346,77,0,132
          bus:
             # Optional: minimum score for the object to initiate tracking (default: shown below)
             min_score: 0.6
             # Optional: minimum decimal percentage for tracked object's computed score to be considered a true positive (default: shown below)
             threshold: 0.65
             #mask: 0,720,1280,720,1280,250,1210,226,1137,198,1055,169,938,138,838,78,833,163,555,78,346,77,0,132
          bicycle:
             # Optional: minimum score for the object to initiate tracking (default: shown below)
             min_score: 0.6
             # Optional: minimum decimal percentage for tracked object's computed score to be considered a true positive (default: shown below)
             threshold: 0.65
             #mask: 0,720,1280,720,1280,250,1210,226,1137,198,1055,169,938,138,838,78,833,163,555,78,346,77,0,132
          cat:
             # Optional: minimum score for the object to initiate tracking (default: shown below)
             min_score: 0.6
             # Optional: minimum decimal percentage for tracked object's computed score to be considered a true positive (default: shown below)
             threshold: 0.65
             #mask: 0,720,1280,720,1280,250,1210,226,1137,198,1055,169,938,138,838,78,833,163,555,78,346,77,0,132
          dog:
             # Optional: minimum score for the object to initiate tracking (default: shown below)
             min_score: 0.6
             # Optional: minimum decimal percentage for tracked object's computed score to be considered a true positive (default: shown below)
             threshold: 0.65
             #mask: 0,720,1280,720,1280,250,1210,226,1137,198,1055,169,938,138,838,78,833,163,555,78,346,77,0,132

Relevant log output

[2022-11-04 22:28:19] watchdog.Back-Left             ERROR   : Ffmpeg process crashed unexpectedly for Back-Left.

[2022-11-04 22:28:19] watchdog.Back-Left             ERROR   : The following ffmpeg logs include the last 100 lines prior to exit.

[2022-11-04 22:28:19] ffmpeg.Back-Left.detect        ERROR   : [segment @ 0x55879bda1e00] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly

[2022-11-04 22:28:19] ffmpeg.Back-Left.detect        ERROR   : [flv @ 0x55879bdacf00] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly

[2022-11-04 22:28:19] ffmpeg.Back-Left.detect        ERROR   : [segment @ 0x55879bda1e00] Non-monotonous DTS in output stream 0:0; previous: 0, current: 0; changing to 1. This may result in incorrect timestamps in the output file.

[2022-11-04 22:28:19] ffmpeg.Back-Left.detect        ERROR   : av_interleaved_write_frame(): Connection reset by peer

[2022-11-04 22:28:19] ffmpeg.Back-Left.detect        ERROR   : Finishing stream 2:0 without any data written to it.

[2022-11-04 22:28:19] ffmpeg.Back-Left.detect        ERROR   : [flv @ 0x55879bdacf00] Failed to update header with correct duration.

[2022-11-04 22:28:19] ffmpeg.Back-Left.detect        ERROR   : [flv @ 0x55879bdacf00] Failed to update header with correct filesize.

[2022-11-04 22:28:19] ffmpeg.Back-Left.detect        ERROR   : Error writing trailer of rtmp://127.0.0.1/live/Back-Left: Connection reset by peer

[2022-11-04 22:28:19] ffmpeg.Back-Left.detect        ERROR   : Error closing file rtmp://127.0.0.1/live/Back-Left: Broken pipe

[2022-11-04 22:28:21] frigate.video                  ERROR   : Back-Left: Unable to read frames from ffmpeg process.

[2022-11-04 22:28:21] frigate.video                  ERROR   : Back-Left: ffmpeg process is not running. exiting capture thread...

FFprobe output from your camera

root@336f2f3e97a3:/opt/frigate# ffprobe rtsp://admin:REDACTED_POST@192.168.1.105:554/ISAPI/Streaming/Channels/101
ffprobe version n5.1-2-g915ef932a3-20220731 Copyright (c) 2007-2022 the FFmpeg developers
  built with gcc 12.1.0 (crosstool-NG 1.25.0.55_3defb7b)
  configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-ffbuild-linux-gnu- --arch=x86_64 --target-os=linux --enable-gpl --enable-version3 --disable-debug --enable-iconv --enable-libxml2 --enable-zlib --enable-libfreetype --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-libvorbis --enable-opencl --enable-libpulse --enable-libvmaf --enable-libxcb --enable-xlib --enable-amf --enable-libaom --enable-libaribb24 --enable-avisynth --enable-libdav1d --enable-libdavs2 --disable-libfdk-aac --enable-ffnvcodec --enable-cuda-llvm --enable-frei0r --enable-libgme --enable-libass --enable-libbluray --enable-libjxl --enable-libmp3lame --enable-libopus --enable-mbedtls --enable-librist --enable-libtheora --enable-libvpx --enable-libwebp --enable-lv2 --enable-libmfx --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopenmpt --enable-librav1e --enable-librubberband --disable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libsvtav1 --enable-libtwolame --enable-libuavs3d --enable-libdrm --enable-vaapi --enable-libvidstab --enable-vulkan --enable-libshaderc --enable-libplacebo --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --enable-libzvbi --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-ldexeflags=-pie --extra-libs='-ldl -lgomp' --extra-version=20220731
  libavutil      57. 28.100 / 57. 28.100
  libavcodec     59. 37.100 / 59. 37.100
  libavformat    59. 27.100 / 59. 27.100
  libavdevice    59.  7.100 / 59.  7.100
  libavfilter     8. 44.100 /  8. 44.100
  libswscale      6.  7.100 /  6.  7.100
  libswresample   4.  7.100 /  4.  7.100
  libpostproc    56.  6.100 / 56.  6.100
[rtsp @ 0x556f95de5180] jitter buffer full
[rtsp @ 0x556f95de5180] RTP: missed 114 packets
[h264 @ 0x556f95dea1c0] concealing 23376 DC, 23376 AC, 23376 MV errors in I frame
Input #0, rtsp, from 'rtsp://admin:REDACTED_POST@192.168.1.105:554/ISAPI/Streaming/Channels/101':
  Metadata:
    title           : Media Presentation
  Duration: N/A, start: 0.067000, bitrate: N/A
  Stream #0:0: Video: h264 (High), yuvj420p(pc, bt709, progressive), 3840x2160 [SAR 1:1 DAR 16:9], 15 fps, 15 tbr, 90k tbn
  Stream #0:1: Data: none
Unsupported codec with id 0 for input stream 1
root@336f2f3e97a3:/opt/frigate#

Frigate stats

{"Back-Left":{"camera_fps":0.0,"capture_pid":252,"detection_fps":0.0,"pid":234,"process_fps":0.5,"skipped_fps":0.0},"Front-Door":{"camera_fps":5.1,"capture_pid":243,"detection_fps":0.0,"pid":231,"process_fps":5.1,"skipped_fps":0.0},"Front-Left":{"camera_fps":5.1,"capture_pid":236,"detection_fps":10.2,"pid":228,"process_fps":5.1,"skipped_fps":0.0},"Front-Right":{"camera_fps":5.1,"capture_pid":239,"detection_fps":14.3,"pid":230,"process_fps":5.1,"skipped_fps":0.0},"Side-Right":{"camera_fps":5.1,"capture_pid":246,"detection_fps":0.0,"pid":233,"process_fps":5.1,"skipped_fps":0.0},"detection_fps":24.5,"detectors":{"cpu1":{"detection_start":1667600731.931516,"inference_speed":39.33,"pid":220},"cpu2":{"detection_start":1667600731.952977,"inference_speed":38.59,"pid":222}},"service":{"latest_version":"0.11.1","storage":{"/dev/shm":{"free":467.8,"mount_type":"tmpfs","total":536.9,"used":69.1},"/media/frigate/clips":{"free":956406.7,"mount_type":"ext4","total":1080090.4,"used":68742.6},"/media/frigate/recordings":{"free":956406.7,"mount_type":"ext4","total":1080090.4,"used":68742.6},"/tmp/cache":{"free":957.5,"mount_type":"tmpfs","total":1000.0,"used":42.5}},"temperatures":{},"uptime":2132,"version":"0.11.1-2eada21"}}

Operating system

Debian

Install method

Docker Compose

Coral version

CPU (no coral)

Network connection

Wired

Camera make and model

hikvision DS-2CD2383G0-I

Any other information that may be helpful

Docker compose file -

version: "3.9" services: frigate: container_name: frigate-GPU privileged: true # this may not be necessary for all setups restart: unless-stopped image: blakeblackshear/frigate:stable deploy: # <------------- Nvidia GPU resources: reservations: devices:

  • driver: nvidia device_ids: ['0'] # this is only needed when using multiple GPUs capabilities: [gpu] # <------------- Nvidia GPU shm_size: "512mb" # update for your cameras based on calculation above volumes:
    • /var/lib/docker/volumes/frigate-config/_data/config.yml:/config/config.yml:ro
    • /var/lib/docker/volumes/frigate-media/_data:/media/frigate
    • /var/lib/docker/volumes/frigate-db/_data:/db
    • type: tmpfs # Optional: 1GB of memory, reduces SSD/SD Card wear target: /tmp/cache tmpfs: size: 1000000000 ports:
    • "5000:5000"
NickM-27 commented 1 year ago

bitrate is probably too high for RTMP, recommend disabling it:

rtmp:
  enabled: false
sesipod commented 1 year ago

Great that seems to have fixed it. I do have 4 other cameras that are Amcrest 8MP should I also disable rtmp on those or if I dont have any issues leave them alone?

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.

NickM-27 commented 1 year ago

if you have no issues can leave it alone

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.