blakeblackshear / frigate

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

Green screen for rtsp stream for Hikvision #1095

Closed ferbulous closed 3 years ago

ferbulous commented 3 years ago

Hi, so I've gone through some of the proposed solution based on past issues raised but they're still not working for me:

1) Changed rtps security to basic/disabled, my password didn't have any special characters but it still wasn't working 2) Using input args for reolink 3) Removed rtmp line under roles: 3) Disabled protection mode for frigate addon

My device: Mac mini late 2012 running on hass supervised My camera: hikvision DS-2CD2145F-I

(stream is working fine when viewed with vlc) There are stream links tested - rtsp://192.168.2.224/Streaming/Channels/101/httppreview rtps://192.168.2.224//Streaming/Channels/101/?transportmode=multicast

Any suggestions for this issue?

frigate.yml

mqtt:
  host: 192.168.2.120
  user: mqtt-user
  password: password

ffmpeg:
  input_args:
    - -avoid_negative_ts
    - make_zero
    - -fflags
    - nobuffer
    - -flags
    - low_delay
    - -strict
    - experimental
    - -fflags
    - +genpts+discardcorrupt
    - -use_wallclock_as_timestamps
    - '1'

cameras:
  backyard:
    ffmpeg:
      inputs:
        - path: rtsp://192.168.2.224/Streaming/Channels/101/httppreview
          roles:
            - detect
    width: 1920
    height: 1080
    fps: 5

detectors:
  cpu1:
   type: cpu
  cpu2:
   type: cpu

frigate addon logs


* Starting nginx nginx
   ...done.
frigate.app                    INFO    : Creating directory: /tmp/cache
frigate.app                    WARNING : Camera backyard has rtmp enabled, but rtmp is not assigned to an input.
Starting migrations
peewee_migrate                 INFO    : Starting migrations
There is nothing to migrate
peewee_migrate                 INFO    : There is nothing to migrate
detector.cpu1                  INFO    : Starting detection process: 37
frigate.app                    INFO    : Camera processor started for backyard: 42
detector.cpu2                  INFO    : Starting detection process: 39
frigate.app                    INFO    : Capture process started for backyard: 43
frigate.mqtt                   INFO    : MQTT connected
frigate.video                  INFO    : backyard: ffmpeg sent a broken frame. memoryview assignment: lvalue and rvalue have different structures
frigate.video                  INFO    : backyard: ffmpeg process is not running. exiting capture thread...
ffmpeg.backyard.detect         ERROR   : rtsp://192.168.2.224/Streaming/Channels/101/httppreview: Invalid data found when processing input
frigate.video                  INFO    : backyard: ffmpeg sent a broken frame. memoryview assignment: lvalue and rvalue have different structures
frigate.video                  INFO    : backyard: ffmpeg process is not running. exiting capture thread...
ffmpeg.backyard.detect         ERROR   : rtsp://192.168.2.224/Streaming/Channels/101/httppreview: Invalid data found when processing input`

frigate debug

{
  "cameras": {
    "backyard": {
      "best_image_timeout": 60,
      "clips": {
        "enabled": false,
        "objects": null,
        "post_capture": 5,
        "pre_capture": 5,
        "required_zones": [],
        "retain": {
          "default": 10,
          "objects": {}
        }
      },
      "detect": {
        "enabled": true,
        "max_disappeared": 25
      },
      "ffmpeg_cmds": [
        {
          "cmd": "ffmpeg -hide_banner -loglevel warning -avoid_negative_ts make_zero -fflags nobuffer -flags low_delay -strict experimental -fflags +genpts+discardcorrupt -use_wallclock_as_timestamps 1 -i rtsp://192.168.2.224/Streaming/Channels/101/httppreview -r 5 -f rawvideo -pix_fmt yuv420p pipe:",
          "roles": [
            "detect"
          ]
        }
      ],
      "fps": 5,
      "frame_shape": [
        1080,
        1920
      ],
      "height": 1080,
      "motion": {
        "contour_area": 100,
        "delta_alpha": 0.2,
        "frame_alpha": 0.2,
        "frame_height": 180,
        "mask": null,
        "threshold": 25
      },
      "mqtt": {
        "bounding_box": true,
        "crop": true,
        "enabled": true,
        "height": 270,
        "required_zones": [],
        "timestamp": true
      },
      "name": "backyard",
      "objects": {
        "filters": {
          "person": {
            "mask": [],
            "max_area": 24000000,
            "min_area": 0,
            "min_score": 0.5,
            "threshold": 0.7
          }
        },
        "mask": null,
        "track": [
          "person"
        ]
      },
      "record": {
        "enabled": false,
        "retain_days": 30
      },
      "rtmp": {
        "enabled": true
      },
      "snapshots": {
        "bounding_box": false,
        "crop": false,
        "enabled": false,
        "height": null,
        "required_zones": [],
        "retain": {
          "default": 10,
          "objects": {}
        },
        "timestamp": false
      },
      "width": 1920,
      "zones": {}
    }
  },
  "clips": {
    "max_seconds": 300,
    "retain": {
      "default": 10,
      "objects": {}
    },
    "tmpfs_cache_size": ""
  },
  "database": {
    "path": "/media/frigate/clips/frigate.db"
  },
  "detectors": {
    "cpu1": {
      "device": "usb",
      "num_threads": 3,
      "type": "cpu"
    },
    "cpu2": {
      "device": "usb",
      "num_threads": 3,
      "type": "cpu"
    }
  },
  "environment_vars": {},
  "logger": {
    "default": "INFO",
    "logs": {}
  },
  "model": {
    "height": 320,
    "width": 320
  },
  "mqtt": {
    "client_id": "frigate",
    "host": "192.168.2.120",
    "port": 1883,
    "stats_interval": 60,
    "topic_prefix": "frigate",
    "user": "mqtt-user"
  },
  "snapshots": {
    "retain": {
      "default": 10,
      "objects": {}
    }
  }
}

ffprobe

root@debian:/home/ferbulous# ffprobe rtsp://192.168.2.224/Streaming/Channels/101/httppreview
ffprobe version 4.1.6-1~deb10u1 Copyright (c) 2007-2020 the FFmpeg developers
  built with gcc 8 (Debian 8.3.0-6)
  configuration: --prefix=/usr --extra-version='1~deb10u1' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --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-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --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-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
rtsp://192.168.2.224/Streaming/Channels/101/httppreview: Invalid data found when processing input

Screenshot image

blakeblackshear commented 3 years ago

A quick google search shows the rtsp url should probably be rtsp://192.168.2.224/Streaming/Channels/101/ instead. Try running ffprobe on that to see if you get something other than Invalid data found when processing input

ferbulous commented 3 years ago

@blakeblackshear

That rtsp url was actually the first url i tested before I moved to the other 2 rtsp urls Here's the log, still the same error message though

ferbulous@debian:~$ ffprobe rtsp://192.168.2.224/Streaming/Channels/101/
ffprobe version 4.1.6-1~deb10u1 Copyright (c) 2007-2020 the FFmpeg developers
  built with gcc 8 (Debian 8.3.0-6)
  configuration: --prefix=/usr --extra-version='1~deb10u1' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --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-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --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-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
rtsp://192.168.2.224/Streaming/Channels/101/: Invalid data found when processing input
blakeblackshear commented 3 years ago

That's odd. You need to figure out the url that ffprobe doesn't complain about. If that works, so should frigate.

xbmcnut commented 3 years ago

Try embedding your username and password. This works for me. rtsp://username:password@10.0.xxx.xxx/Streaming/Channels/103

Channel '103' is the third stream which I've set to h.264 @ 1280 x 720 and it's working a treat.

CarpeDiemRo commented 3 years ago

Same problem here.

The stream is working perfectly in VLC and in HA, FFmpeg integration. But Green screen in Frigate.

watchdog.door                  INFO    : No frames received from door in 20 seconds. Exiting ffmpeg...
watchdog.door                  INFO    : Waiting for ffmpeg to exit gracefully...
watchdog.door                  INFO    : FFmpeg didnt exit. Force killing...
frigate.video                  INFO    : door: ffmpeg sent a broken frame. memoryview assignment: lvalue and rvalue have different structures
frigate.video                  INFO    : door: ffmpeg process is not running. exiting capture thread...
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x1f23ce0] moov atom not found
/tmp/cache/door-20210611185626.mp4: Invalid data found when processing input
frigate.events                 INFO    : bad file: door-20210611185626.mp4
watchdog.door                  INFO    : No frames received from door in 20 seconds. Exiting ffmpeg...
watchdog.door                  INFO    : Waiting for ffmpeg to exit gracefully...
watchdog.door                  INFO    : FFmpeg didnt exit. Force killing...
frigate.video                  INFO    : door: ffmpeg sent a broken frame. memoryview assignment: lvalue and rvalue have different structures
frigate.video                  INFO    : door: ffmpeg process is not running. exiting capture thread...
[mov,mp4,m4a,3gp,3g2,mj2 @ 0xbface0] moov atom not found

Screenshot 2021-06-11 at 19 04 42

The image from the left is a Hikvision integrated within a DVR and the image from the right is integrated directly. Is really odd.

@blakeblackshear Do you have any suggestions?

Config of the problematic camera

  door:
    ffmpeg:
      hwaccel_args:
        - -c:v
        - h264_v4l2m2m
      inputs:
        - path: rtsp://xxxx:yyyy@xx.yyy.zzz.qqq:9000/Streaming/channels/101/
          roles:
            - detect
            - rtmp
            - clips
    detect:
      max_disappeared: 15
    width: 2560
    height: 1440
    fps: 5
    objects:
      track:
        - person
      filters:
        person:
          min_score: 0.6
          threshold: 0.75
    snapshots:
      enabled: true
    clips:
      enabled: true
      pre_capture: 5
      post_capture: 5
      retain:
        default: 1
ferbulous commented 3 years ago

Almost forgot to update this The issues with my cameras was resolved I’m not really sure what fixed it Initially i had to portforward the nvr cameras and frigate was able to view them with no issues ‘http://myduckdns.org:544/Streaming/channels/101/‘ Oddly enough was still getting green screen even with the direct links ‘http://192.168.x.x:544/Streaming/channels/101/‘ and not even ffprobe detected the direct link stream A few weeks later I tried using direct link again and it was working normally and i didn’t even change any settings 😅

blakeblackshear commented 3 years ago

@CarpeDiemRo please open a new issue and provide the requested info in the template.

asemev commented 3 years ago

i have exactly the same issue. i restored a home assistant backup into a new home assistant setup and started to have this issue. my second camera shows full green screen and frigate debug screen shows 0 fps.

Eriobis commented 2 years ago

EDIT FOR FUTURE READER Problem has been solved by restarting the NVR. If anybody else is in the same situation, try to reset the NVR first to clean up the network stream.

end of edit

Is this still happening to you guys ? I am having the same issue, stream is perfectly working on VLC but it greenscreen in frigate. Tried to update the ffmpeg to ffmpeg 5.1 in the docker image but no luck.

I have a Lorex NVR and it outputs 8 streams, I currently have 2 cameras connected and the stream0 always green screen. I am getting 1 good frame once in a while ( once per hour ?! ).

I would gladly post the logs and the config but it's really similar to the one posted above.

I have tried to remove the input arguments of ffmpeg, bump the max_delay, stop the rtmp output feed ( even if the error seems to be in the input portion ). Note : The NVR only outputs its rtsp at 7 fps. Maybe ffmpeg needs to be forced somehow ?

Currently trying the 0.11.0-rc2 of fritage

[2022-09-04 20:29:08] ffmpeg.frontyard.detect        ERROR   : av_interleaved_write_frame(): Connection reset by peer
[2022-09-04 20:29:08] ffmpeg.frontyard.detect        ERROR   : Finishing stream 2:0 without any data written to it.
[2022-09-04 20:29:08] ffmpeg.frontyard.detect        ERROR   : [flv @ 0x55690df46680] Failed to update header with correct duration.
[2022-09-04 20:29:08] ffmpeg.frontyard.detect        ERROR   : [flv @ 0x55690df46680] Failed to update header with correct filesize.
[2022-09-04 20:29:08] ffmpeg.frontyard.detect        ERROR   : Error writing trailer of rtmp://127.0.0.1/live/frontyard: Connection reset by peer
[2022-09-04 20:29:08] ffmpeg.frontyard.detect        ERROR   : Error closing file rtmp://127.0.0.1/live/frontyard: Broken pipe
[2022-09-04 20:29:12] frigate.video                  ERROR   : frontyard: Unable to read frames from ffmpeg process.
[2022-09-04 20:29:12] frigate.video                  ERROR   : frontyard: ffmpeg process is not running. exiting capture thread...
[2022-09-04 20:29:18] watchdog.frontyard             ERROR   : Ffmpeg process crashed unexpectedly for frontyard.
[2022-09-04 20:29:18] watchdog.frontyard             ERROR   : The following ffmpeg logs include the last 100 lines prior to exit.
[2022-09-04 20:29:18] ffmpeg.frontyard.detect        ERROR   : [AVHWDeviceContext @ 0x562687bdec80] libva: /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so init failed
[2022-09-04 20:29:18] ffmpeg.frontyard.detect        ERROR   : [segment @ 0x562687bc6600] 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-09-04 20:29:18] ffmpeg.frontyard.detect        ERROR   : [flv @ 0x562687bc32c0] 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