blakeblackshear / frigate

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

[Camera Support]: Hikvision DS-2CD2387G2P-LSU/SL #8695

Closed pyrodex closed 1 year ago

pyrodex commented 1 year ago

Describe the problem you are having

Camera works in go2rtc, can see it via the go2rtc dashboard and go to links and stream it from there but when I setup the camera in Frigate with the restroom url it throws errors in the logs.

Version

0.13.0-AA93D4F

Frigate config file

mqtt:
  enabled: True
  host: 192.168.xx.104
  port: 1883
  user: user
  password: pass
  client_id: frigate
  topic_prefix: frigate
timestamp_style:
  position: "br"
  format: "%m/%d/%Y %I:%M:%S %p"
  color:
    red: 0
    green: 0
    blue: 0
  thickness: 5
  # Optional: Effect of lettering (default: shown below)
  #           None (No effect),
  #           "solid" (solid background in inverse color of font)
  #           "shadow" (shadow for font)
  effect: shadow
model:
  path: plus://<plus id>
telemetry:
  stats:
    intel_gpu_stats: True
    network_bandwidth: True
  version_check: True
# Default, also tuned at a camera level depending on need.
objects:
  filters:
    dog:
      min_score: .7
      threshold: .9
    cat:
      min_score: .65
      threshold: .8
    face:
      min_score: .7
    package:
      min_score: .65
      threshold: .9
    license_plate:
      min_score: .6
    amazon:
      min_score: .75
    ups:
      min_score: .75
    fedex:
      min_score: .75
    person:
      min_score: .65
      threshold: .85
    car:
      min_score: .65
      threshold: .85

ffmpeg:
  hwaccel_args: preset-vaapi

record:
  enabled: True
  retain:
    days: 90
    mode: motion
  events:
    retain:
      default: 90
      mode: active_objects

detectors:
  coral1:
    type: edgetpu
    device: pci:0
  coral2:
    type: edgetpu
    device: pci:1
  coral3:
    type: edgetpu
    device: pci:2
  coral4:
    type: edgetpu
    device: pci:3

logger:
  default: info
  logs:
    frigate.event: debug
    frigate.storage: debug
    frigate.object_detection: debug
    frigate.record.cleanup: debug

birdseye:
  enabled: True
  restream: True
  width: 1920
  height: 1080
  quality: 4
  mode: motion

snapshots:
  enabled: True
  clean_copy: True
  timestamp: True
  bounding_box: True
  retain:
    default: 90

ui:
  live_mode: webrtc
  time_format: 12hour
  use_experimental: True # Breaks audio in live view

go2rtc:
  webrtc:
    candidates:
      - stun:8555
  rtsp:
    username: "user"
    password: "pass"
  streams:
    # Driveway
    driveway: 
      - rtsp://user:password@192.168.xx.90:554/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif
      - "ffmpeg:driveway#audio=opus"
    driveway_sub: 
      - rtsp://user:password@192.168.xx.90:554/cam/realmonitor?channel=1&subtype=2&unicast=true&proto=Onvif
    # BBQ Deck
    bbq_deck: 
      - rtsp://user:password@192.168.xx.91:554/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif
      - "ffmpeg:bbq_deck#audio=opus"
    bbq_deck_sub: 
      - rtsp://user:password@192.168.xx.91:554/cam/realmonitor?channel=1&subtype=2&unicast=true&proto=Onvif
    # Basement with AC units
    basement_side: 
      - rtsp://user:password@192.168.xx.92:554/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif
      - "ffmpeg:basement_side#audio=opus"
    basement_side_sub: 
      - rtsp://user:password@192.168.xx.92:554/cam/realmonitor?channel=1&subtype=2&unicast=true&proto=Onvif
    # Front walkway
    frontwalkway: 
      - rtsp://user:password@192.168.xx.93:554/Streaming/Channels/101
      - "ffmpeg:frontwa1lkway#video=h264"
    frontwalkway_sub: 
      - rtsp://user:password@192.168.xx.93:554/Streaming/Channels/102
    # Mudroom
    mudroom: 
      - rtsp://user:password@192.168.xx.94:554/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif
      - "ffmpeg:mudroom#audio=opus"
    mudroom_sub: 
      - rtsp://user:password@192.168.xx.94:554/cam/realmonitor?channel=1&subtype=2&unicast=true&proto=Onvif
    # Kiddo's room
    charlotte: 
      - rtsp://user:password@192.168.xx.95:554/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif
      - "ffmpeg:charlotte#audio=opus"
    charlotte_sub: 
      - rtsp://user:password@192.168.xx.95:554/cam/realmonitor?channel=1&subtype=2&unicast=true&proto=Onvif
    # Patio
    patio: 
      - rtsp://user:password@192.168.xx.97:554/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif
      - "ffmpeg:patio#audio=opus"
    patio_sub: 
      - rtsp://user:password@192.168.xx.97:554/cam/realmonitor?channel=1&subtype=2&unicast=true&proto=Onvif
    # Backyard
    backyard: 
      - rtsp://user:password@192.168.xx.98:554/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif
      - "ffmpeg:backyard#audio=opus"
    backyard_sub: 
      - rtsp://user:password@192.168.xx.98:554/cam/realmonitor?channel=1&subtype=2&unicast=true&proto=Onvif
    # Playroom
    playroom: 
      - rtsp://user:password@192.168.xx.99:554/Streaming/Channels/101
      - "ffmpeg:playrom#audio=opus"
    #  - isapi://admin:password@192.168.xx.99:80/

cameras:
  driveway: # Driveway
    record:
      events:
        required_zones:
          - FrontYard
    snapshots:
      required_zones:
          - FrontYard
    ui:
      order: 1
    birdseye:
      order: 1

    ffmpeg:
      output_args:
        record: preset-record-generic-audio-copy
      inputs:
        - path: rtsp://127.0.0.1:8554/driveway # <--- the name here must match the name of the camera in restream
          input_args: preset-rtsp-restream
          roles:
            - record
        - path: rtsp://127.0.0.1:8554/driveway_sub # <--- the name here must match the name of the camera_sub in restream
          input_args: preset-rtsp-restream
          roles:
            - detect
    detect:
      width: 1920
      height: 1080
      enabled: True
      fps: 5
    objects:
      track:
        - person
        - bicycle
        - dog
        - face
        - license_plate
        - amazon
        - fedex
        - ups
        - package
        - car
      filters:
        car:
          min_score: .85
          threshold: .90
    motion:
      mask:
        - 1366,99,1374,28,1860,32,1862,97 # Timestamp from Camera
        - 1422,0,1920,0,1920,298,1419,158,966,.xx.358,145,0,274,0,185,0,0 # Street view
        - 1550,1080,1535,876,874,875,882,1080 # Rose bush
    zones: 
      FrontYard:
        coordinates: 1920,1080,1809,365,1655,231,.xx.,154,754,138,594,153,442,150,0,380,0,1080
        objects:
          - person
          - car
          - face
          - package
          - amazon
          - fedex
          - ups
          - license_plate 
          - dog
        filters:
          car:
            min_area: 55000
      Street:
        coordinates: 348,143,687,113,1144,107,1446,140,1735,223,1920,302,1920,0,529,0,0,0,0,306,183,227
    live:
      stream_name: driveway
  patio: # Patio
    ui:
      order: 3
    birdseye:
      order: 3
    ffmpeg:
      output_args:
        record: preset-record-generic-audio-copy
      inputs:
        - path: rtsp://127.0.0.1:8554/patio # <--- the name here must match the name of the camera in restream
          input_args: preset-rtsp-restream
          roles:
            - record
        - path: rtsp://127.0.0.1:8554/patio_sub # <--- the name here must match the name of the camera_sub in restream
          input_args: preset-rtsp-restream
          roles:
            - detect
    detect:
      width: 1920
      height: 1080
      enabled: True
      fps: 5
    motion:
      mask:
        - 1276,0,1920,663,1920,0,1611,0 # Timestamp + street + neighbors yard
        - 646,0,682,384,1231,384,1238,0 # Kitchen Window/Doors
    objects:
      track:
        - person
      filters:
        person:
          min_area: 30000
          #min_score: 0.9
          #threshold: 0.98
  basement_side: # Basement Side with AC
    record:
      events:
        required_zones:
          - BasementSide
    snapshots:
      required_zones:
          - BasementSide
    ui:
      order: 4
    birdseye:
      order: 4
    ffmpeg:
      output_args:
        record: preset-record-generic-audio-copy
      inputs:
        - path: rtsp://127.0.0.1:8554/basement_side # <--- the name here must match the name of the camera in restream
          input_args: preset-rtsp-restream
          roles:
            - record
        - path: rtsp://127.0.0.1:8554/basement_side_sub # <--- the name here must match the name of the camera_sub in restream
          input_args: preset-rtsp-restream
          roles:
            - detect
    detect:
      width: 1920
      height: 1080
      enabled: True
      fps: 5
    objects:
      track:
        - person
        - dog
    motion:
      mask:
        - 1223,85,1888,84,1880,0,1219,0 # Timestamp from Camera
        - 1920,0,0,0,639,397,1174,529,1320,668,1920,918 # Neighbors side/pool, also bush by camera
        - 839,863,1121,841,1037,745,814,754 # Main AC unit fan
        - 726,645,868,640,857,603,708,609 # upstairs ac unit fan
    zones:
      BasementSide:
        coordinates: 318,0,306,165,771,187,806,372,855,516,1228,734,1920,.xx.1920,1080,552,1080,0,1080,0,0
        objects:
          - person
          - dog
        filters:
          person: 
            min_area: 4000
  bbq_deck: # BBQ Deck
    record:
      events:
        required_zones:
          - BBQ
    snapshots:
      required_zones:
          - BBQ
    ui:
      order: 5
    birdseye:
      order: 5
    ffmpeg:
      output_args:
        record: preset-record-generic-audio-copy
      inputs:
        - path: rtsp://127.0.0.1:8554/bbq_deck # <--- the name here must match the name of the camera in restream
          input_args: preset-rtsp-restream
          roles:
            - record
        - path: rtsp://127.0.0.1:8554/bbq_deck_sub # <--- the name here must match the name of the camera_sub in restream
          input_args: preset-rtsp-restream
          roles:
            - detect
    detect:
      width: 1920
      height: 1080
      enabled: True
      fps: 5
    motion:
      mask:
        - 1874,27,1875,99,1345,97,1342.xx.# Timestamp from Camera
        - 0,677,0,0,564,0 # Holly bushes
    objects:
      track:
        - person
        - dog
    zones:  
      BBQ:
        coordinates: 1596,1080,1131,1080,0,1080,41,928,547,154,1107,0,1289,161,1618,641,1523,863
        detect:
          - person
          - dog
  front_walkway: # Front Walkway
    ui:
      order: 2
    birdseye:
      order: 2
    ffmpeg:
      inputs:
        - path: rtsp://127.0.0.1:8554/frontwalkway # <--- the name here must match the name of the camera in restream
          roles:
            - record
            - detect
        #- path: rtsp://127.0.0.1:8554/frontwalkway_sub # <--- the name here must match the name of the camera_sub in restream
          #roles:
            #- detect
    detect:
      width: 640
      height: 360
      enabled: True
      fps: 5
    motion:
      mask:
        - 346,0,581,0,578,31,350,28 # Timestamp from Camera
        - 83,192,238,30,228,0,0,0,0,360.xx.,360 # Roof line
    objects:
      track:
        - person
        - package
        - face
      filters:
        person:
          #mask: 640,43,640,150,553,149,548,44
          min_area: 7000
    live:
      stream_name: frontwalkway
  mudroom: # Mudrom
    ui:
      order: 6
    birdseye:
      order: 6
    ffmpeg:
      output_args:
        record: preset-record-generic-audio-copy
      inputs:
        - path: rtsp://127.0.0.1:8554/mudroom # <--- the name here must match the name of the camera in restream
          input_args: preset-rtsp-restream
          roles:
            - record
        - path: rtsp://127.0.0.1:8554/mudroom_sub # <--- the name here must match the name of the camera_sub in restream
          input_args: preset-rtsp-restream
          roles:
            - detect
    detect:
      width: 1920
      height: 1080
      enabled: True
      fps: 5
    motion:
      mask:
        - 1351,93,1346,21,1880,28,1872,90 # Timestamp from Camera
    objects:
      track:
        - person
      filters:
        person:
          min_area: 30000
          min_score: .80
          threshold: .95
  backyard: # Backyard
    ui:
      order: 7
    birdseye:
      order: 7
    ffmpeg:
      output_args:
        record: preset-record-generic-audio-copy
      inputs:
        - path: rtsp://127.0.0.1:8554/backyard # <--- the name here must match the name of the camera in restream
          input_args: preset-rtsp-restream
          roles:
            - record
        - path: rtsp://127.0.0.1:8554/backyard_sub # <--- the name here must match the name of the camera_sub in restream
          input_args: preset-rtsp-restream
          roles:
            - detect
    detect:
      width: 1920
      height: 1080
      enabled: True
      fps: 5
    motion:
      mask:
        - 1343,97,1875,103,1866,21,1342,21 # Timestamp from Camera
        - 483.xx.,742,119,.xx.,151,1474,271,1920,515,1920,0,754,0,0,0,0,423 # Backyard fence line
    objects:
      track:
        - person
        - dog
      filters:
        person:
          min_area: 15000
  charlotte: # Kiddo's room
    ui:
      order: 8
    birdseye:
      enabled: False
    ffmpeg:
      output_args:
        record: preset-record-generic-audio-copy
      inputs:
        - path: rtsp://127.0.0.1:8554/charlotte # <--- the name here must match the name of the camera in restream
          input_args: preset-rtsp-restream
          roles:
            - record
    detect:
      enabled: False
    motion:
      mask:
        - .xx.,153,2984,149,2974,53,.xx.,59 # Timestamp from Camera
        - 0,0,236,0,222,149,0,163 # Alexa device

Relevant log output

2023-11-20 18:56:24.417794060  [mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fe2741b1f40] moov atom not found
2023-11-20 18:56:24.417897146  [ERROR:0@78.796] global cap.cpp:164 open VIDEOIO(CV_IMAGES): raised OpenCV exception:
2023-11-20 18:56:24.417899939
2023-11-20 18:56:24.417903286  OpenCV(4.7.0) /io/opencv/modules/videoio/src/cap_images.cpp:267: error: (-215:Assertion failed) number < max_number in function 'icvExtractPattern'
2023-11-20 18:56:24.417905120
2023-11-20 18:56:24.417906720
2023-11-20 18:56:24.882556566  [2023-11-20 18:56:24] frigate.record.maintainer      WARNING : Failed to probe corrupt segment /tmp/cache/playroom@20231120185621-0500.mp4
2023-11-20 18:56:24.882581450  [2023-11-20 18:56:24] frigate.record.maintainer      WARNING : Discarding a corrupt recording segment: /tmp/cache/playroom@20231120185621-0500.mp4
2023-11-20 18:56:29.594567656  [2023-11-20 18:56:29] watchdog.playroom              ERROR   : Ffmpeg process crashed unexpectedly for playroom.
2023-11-20 18:56:29.594675315  [2023-11-20 18:56:29] watchdog.playroom              ERROR   : The following ffmpeg logs include the last 100 lines prior to exit.
2023-11-20 18:56:29.594764122  [2023-11-20 18:56:29] ffmpeg.playroom.detect         ERROR   : [segment @ 0x557e52d52fc0] 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
2023-11-20 18:56:29.594838553  [2023-11-20 18:56:29] ffmpeg.playroom.detect         ERROR   : [h264 @ 0x557e52b4f580] Hardware does not support image size 5120x1440 (constraints: width 0-4096 height 0-4096).
2023-11-20 18:56:29.594913423  [2023-11-20 18:56:29] ffmpeg.playroom.detect         ERROR   : [h264 @ 0x557e52b4f580] Failed setup for format vaapi: hwaccel initialisation returned error.
2023-11-20 18:56:29.594978344  [2023-11-20 18:56:29] ffmpeg.playroom.detect         ERROR   : Impossible to convert between the formats supported by the filter 'Parsed_fps_0' and the filter 'auto_scale_0'
2023-11-20 18:56:29.595057762  [2023-11-20 18:56:29] ffmpeg.playroom.detect         ERROR   : Error reinitializing filters!
2023-11-20 18:56:29.595107092  [2023-11-20 18:56:29] ffmpeg.playroom.detect         ERROR   : Failed to inject frame into filter network: Function not implemented
2023-11-20 18:56:29.595178197  [2023-11-20 18:56:29] ffmpeg.playroom.detect         ERROR   : Error while processing the decoded data for stream #0:0
2023-11-20 18:56:31.285190618  [2023-11-20 18:56:31] frigate.video                  ERROR   : playroom: Unable to read frames from ffmpeg process.
2023-11-20 18:56:31.285225875  [2023-11-20 18:56:31] frigate.video                  ERROR   : playroom: ffmpeg process is not running. exiting capture thread...

FFprobe output from your camera

ffprobe version 5.1.4-0+deb12u1 Copyright (c) 2007-2023 the FFmpeg developers
  built with gcc 12 (Debian 12.2.0-14)
  configuration: --prefix=/usr --extra-version=0+deb12u1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --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-libglslang --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librist --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --disable-sndio --enable-libjxl --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-libplacebo --enable-librav1e --enable-shared
  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 @ 0x56322406c700] max delay reached. need to consume packet
[rtsp @ 0x56322406c700] RTP: missed 255 packets
[h264 @ 0x563224071480] error while decoding MB 310 42, bytestream -7
[h264 @ 0x563224071480] concealing 15099 DC, 15099 AC, 15099 MV errors in I frame
[h264 @ 0x563224071480] Increasing reorder buffer to 1
Input #0, rtsp, from 'rtsp://user:password@192.168.xx.99:554/Streaming/Channels/101':
  Metadata:
    title           : Media Presentation
  Duration: N/A, start: 0.000000, bitrate: N/A
  Stream #0:0: Video: h264 (Main), yuvj420p(pc, progressive), 5120x1440 [SAR 1:1 DAR 32:9], 20 fps, 20 tbr, 90k tbn
  Stream #0:1: Audio: aac (LC), 16000 Hz, mono, fltp

Frigate stats

No response

Operating system

Debian

Install method

Docker Compose

Coral version

M.2

Network connection

Wired

Camera make and model

Hikvision DS-2CD2387G2P-LSU/SL

Any other information that may be helpful

First time setting up one of these cameras, I have another OLDER Hikvision and it works fine.

pyrodex commented 1 year ago

Looks like this H265 for this to work, on the main stream.

NickM-27 commented 1 year ago

Yes, the resolution is too large to be decided as h264 by hardware. This is expected.

NickM-27 commented 1 year ago

Feel free to create a new issue if something else comes up

e-hollebone commented 8 months ago

@pyrodex Did you get this camera model to work with Frigate? It is unclear for the above thread. If so with what settings? h265. I am thinking about buying a few and would appreciate any advice.

pyrodex commented 8 months ago

@pyrodex Did you get this camera model to work with Frigate? It is unclear for the above thread. If so with what settings? h265. I am thinking about buying a few and would appreciate any advice.

Yes I did!

Here are the Hikvision settings:

Screenshot 2024-03-25 at 6 52 24 PM

I DO NOT use it for detection so I don't have a sub-stream configured but here is my Frigate configuration stanzas:

go2rtc:

    playroom: 
      - rtsp://{FRIGATE_RTSP_USER}:{FRIGATE_RTSP_PASSWORD}@playroom.camera:554/Streaming/Channels/101
      - "ffmpeg:playroom#audio=opus"

Camera config:

  Playroom: # Kiddo's room
    ffmpeg:
      output_args:
        record: preset-record-generic-audio-copy
      inputs:
        - path: rtsp://127.0.0.1:8554/playroom 
          input_args: preset-rtsp-restream
          roles:
            - record

Good luck!