blakeblackshear / frigate

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

[Support]: One out of 4 cameras does not record clips #2068

Closed kdjordjev closed 2 years ago

kdjordjev commented 2 years ago

Describe the problem you are having

I have 4 cameras , 3 Hikvision and one Amcrest AD110 doorbell All of the cameras work perfectly fine for object detection, birthview or live view the 3 Hikvision record video clips, while the Amcrest can not record clips. (wifi connected)

I can not see any errors in the Frigate NRV Log window , but i have no recordings form the Camera = front_door.

Please help on how to debug this? Any suggestion on resolving the issue?

Version

2.0 as Home Assistant Add On , haasio OS

Frigate config file

mqtt:
  host: 192.168.1.3
  user:     user
  password: pass

cameras:

  front_of_house:
    ffmpeg:
      inputs:
        - path: rtsp://user:pass@192.168.1.30:8554/Streaming/Unicast/channels/102
          roles:
            - detect
            - rtmp
            - record
    zones:
      entryway:
        coordinates:  640,360,640,226,178,69,0,93,0,360
    snapshots:
      required_zones:
        - entryway
    record:
      events:
        required_zones:
          - entryway

  front_yard:
    ffmpeg:
      inputs:
        - path: rtsp://user:pass@192.168.1.30:8554/Streaming/Unicast/channels/502
          roles:
            - detect
            - rtmp
            - record
    zones:
      frontlawn:
        coordinates:  0,133,313,101,640,207,640,360,0,360
    snapshots:
      required_zones:
        - frontlawn
    record:
      events:
        required_zones:
          - frontlawn

  back_yard:
    ffmpeg:
      inputs:
        - path: rtsp://user:pass@192.168.1.30:8554/Streaming/Unicast/channels/702
          roles:
            - detect
            - rtmp
            - record

  front_door:
    ffmpeg:
      inputs:
        - path: rtsp://user:pass@192.168.1.31:554/cam/realmonitor?channel=1&subtype=01
          roles:
            - detect
            - rtmp
            - record
    detect:
      width: 640
      height: 480
    zones:
      front_step:
        coordinates: 93,354,556,364,640,480,0,480
    snapshots:
      required_zones:
        - front_step
    record:
      events:
        required_zones:
          - front_step

ffmpeg:
  input_args: -avoid_negative_ts make_zero -flags low_delay -fflags +genpts+discardcorrupt -rtsp_transport tcp -stimeout 5000000 -use_wallclock_as_timestamps 1
  hwaccel_args:
    - -hwaccel
    - vaapi
    - -hwaccel_device
    - /dev/dri/renderD128
    - -hwaccel_output_format
    - yuv420p

birdseye: 
  enabled: True
  height: 360
  width: 640

live: 
  height: 360

rtmp:
  enabled: True

record:
  enabled: True
  retain_days: 0
  events:
    max_seconds: 300
    pre_capture: 10
    post_capture: 0
    retain:
      default: 7

snapshots: 
  enabled: True
  timestamp: True
  bounding_box: True
  retain:
    default: 7

detectors:
  cpu1:
    type: cpu
    num_threads: 2   
  cpu2:
    type: cpu
    num_threads: 2      
  cpu3:
    type: cpu
    num_threads: 2       
  cpu4:
    type: cpu
    num_threads: 2  

objects:
  track:
    - person
 #   - car
    - dog
    - bicycle

detect:
  width: 640
  height: 360
  fps: 6
  enabled: True
  max_disappeared: 25

Relevant log output

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[2021-10-20 19:18:45] frigate.app                    INFO    : Starting Frigate (0.9.1-800f33e)
[2021-10-20 19:18:45] frigate.app                    INFO    : Creating directory: /tmp/cache
Starting migrations
[2021-10-20 19:18:45] peewee_migrate                 INFO    : Starting migrations
There is nothing to migrate
[2021-10-20 19:18:45] peewee_migrate                 INFO    : There is nothing to migrate
[2021-10-20 19:18:45] frigate.mqtt                   INFO    : MQTT connected
[2021-10-20 19:18:45] detector.cpu1                  INFO    : Starting detection process: 225
[2021-10-20 19:18:45] frigate.edgetpu                WARNING : CPU detectors are not recommended and should only be used for testing or for trial purposes.
[2021-10-20 19:18:45] detector.cpu2                  INFO    : Starting detection process: 227
[2021-10-20 19:18:45] frigate.edgetpu                WARNING : CPU detectors are not recommended and should only be used for testing or for trial purposes.
[2021-10-20 19:18:45] detector.cpu3                  INFO    : Starting detection process: 229
[2021-10-20 19:18:45] frigate.edgetpu                WARNING : CPU detectors are not recommended and should only be used for testing or for trial purposes.
[2021-10-20 19:18:45] detector.cpu4                  INFO    : Starting detection process: 231
[2021-10-20 19:18:45] frigate.app                    INFO    : Output process started: 233
[2021-10-20 19:18:45] frigate.edgetpu                WARNING : CPU detectors are not recommended and should only be used for testing or for trial purposes.
[2021-10-20 19:18:45] ws4py                          INFO    : Using epoll
[2021-10-20 19:18:45] frigate.app                    INFO    : Camera processor started for front_of_house: 237
[2021-10-20 19:18:45] frigate.app                    INFO    : Camera processor started for front_yard: 240
[2021-10-20 19:18:45] frigate.app                    INFO    : Camera processor started for back_yard: 241
[2021-10-20 19:18:45] frigate.app                    INFO    : Camera processor started for front_door: 243
[2021-10-20 19:18:45] frigate.app                    INFO    : Capture process started for front_of_house: 244
[2021-10-20 19:18:45] frigate.app                    INFO    : Capture process started for front_yard: 248
[2021-10-20 19:18:45] frigate.app                    INFO    : Capture process started for back_yard: 253
[2021-10-20 19:18:45] frigate.app                    INFO    : Capture process started for front_door: 260
[2021-10-20 19:18:45] ws4py                          INFO    : Using epoll

FFprobe output from your camera

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

OUTPUT FROM THE Amcrest CAMERA WHICH DOES NOT RECORD CLIPS - THE ISSUE

Input #0, rtsp, from 'rtsp://user:pass@192.168.1.31:554/cam/realmonitor?channel=1&subtype=01':
  Metadata:
    title           : Media Server
  Duration: N/A, start: 0.082000, bitrate: N/A
    Stream #0:0: Video: h264, yuvj420p(pc, bt709, progressive), 640x480, 100 tbr, 90k tbn, 180k tbc
    Stream #0:1: Audio: aac, 16000 Hz, mono, fltp

OUTPUT FROM THE HIKVISIONCAMERA WHICH RECORDS CLIPS

    title           : Media Server V3.4.6
    comment         : Media Server Session Description : standard
  Duration: N/A, start: 1.183333, bitrate: N/A
    Stream #0:0: Video: h264, yuvj420p(pc, bt709, progressive), 640x360, 6 fps, 20 tbr, 90k tbn, 12 tbc

Frigate stats

No response

Operating system

HassOS

Install method

HassOS Addon

Coral version

CPU (no coral)

Network connection

Mixed

Camera make and model

Amcrest AD110

Any other information that may be helpful

I tested with the baseline ffmpg flags and with an additional "-flags low_delay" with no difference in behaviour

jaytea33 commented 2 years ago

I have the AD110 as well and recording works for me. I think you're missing the output args. Here's the relevant part of my config for reference, hope it helps:

cameras: doorbell_cam: ffmpeg: input_args: -hide_banner -loglevel warning -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -rtsp_transport tcp -stimeout 5000000 -use_wallclock_as_timestamps 1 output_args: detect: -f rawvideo -pix_fmt yuv420p record: -f segment -segment_time 3 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c copy -an -vsync 0 -enc_time_base -1 inputs:

EDIT: Sorry, not sure how to preserve formatting here

kdjordjev commented 2 years ago

Hi Blakeblackshear Thank you for the response. I used the default output arguments.

Regardless. i changed to what you provided, but still have the same issue. Camera can be viewed, detection works, but i can not record clips. Below is the detailed debug configuration for this camera

Is there any way to debug it? Any limitation on number of cameras? Anything else The only difference i see between the hickvision and AD110 is the frame rate (Hick is 6fps / AD is more)

I disabled one of the other cameras, but no effect as well (in case there was a limitation of the number of cameras) K

full command:

ffmpeg -hide_banner -loglevel warning -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format yuv420p -avoid_negative_ts make_zero -flags low_delay -fflags +genpts+discardcorrupt -rtsp_transport tcp -stimeout 5000000 -use_wallclock_as_timestamps 1 -i @.***:554/cam/realmonitor?channel=1&subtype=01 -f segment -segment_time 3 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c copy -an -vsync 0 -enc_time_base -1 /tmp/cache/front_door-%Y%m%d%H%M%S.mp4 -c copy -f flv rtmp://127.0.0.1/live/front_door -r 6 -s 640x480 -f rawvideo -pix_fmt yuv420p pipe:",

"front_door": {
  "best_image_timeout": 60,
  "detect": {
    "enabled": true,
    "fps": 6,
    "height": 480,
    "max_disappeared": 25,
    "width": 640
  },
  "ffmpeg": {
    "global_args": [
      "-hide_banner",
      "-loglevel",
      "warning"
    ],
    "hwaccel_args": [
      "-hwaccel",
      "vaapi",
      "-hwaccel_device",
      "/dev/dri/renderD128",
      "-hwaccel_output_format",
      "yuv420p"
    ],
    "input_args": "-avoid_negative_ts make_zero -flags low_delay

-fflags +genpts+discardcorrupt -rtsp_transport tcp -stimeout 5000000 -use_wallclock_as_timestamps 1", "inputs": [ { "global_args": [], "hwaccel_args": [], "input_args": [], "path": @.:554/cam/realmonitor?channel=1&subtype=01", "roles": [ "detect", "rtmp", "record" ] } ], "output_args": { "detect": [ "-f", "rawvideo", "-pix_fmt", "yuv420p" ], "record": "-f segment -segment_time 3 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c copy -an -vsync 0 -enc_time_base -1", "rtmp": [ "-c", "copy", "-f", "flv" ] } }, "ffmpeg_cmds": [ { "cmd": "ffmpeg -hide_banner -loglevel warning -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format yuv420p -avoid_negative_ts make_zero -flags low_delay -fflags +genpts+discardcorrupt -rtsp_transport tcp -stimeout 5000000 -use_wallclock_as_timestamps 1 -i @.:554/cam/realmonitor?channel=1&subtype=01 -f segment -segment_time 3 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c copy -an -vsync 0 -enc_time_base -1 /tmp/cache/front_door-%Y%m%d%H%M%S.mp4 -c copy -f flv rtmp://127.0.0.1/live/front_door -r 6 -s 640x480 -f rawvideo -pix_fmt yuv420p pipe:", "roles": [ "detect", "rtmp", "record" ] } ], "live": { "height": 360, "quality": 8 }, "motion": { "contour_area": 74, "delta_alpha": 0.2, "frame_alpha": 0.2, "frame_height": 180, "mask": "", "threshold": 25 }, "mqtt": { "bounding_box": true, "crop": true, "enabled": true, "height": 270, "quality": 70, "required_zones": [], "timestamp": true }, "name": "front_door", "objects": { "filters": { "bicycle": { "mask": null, "max_area": 24000000, "min_area": 0, "min_score": 0.5, "threshold": 0.7 }, "dog": { "mask": null, "max_area": 24000000, "min_area": 0, "min_score": 0.5, "threshold": 0.7 }, "person": { "mask": null, "max_area": 24000000, "min_area": 0, "min_score": 0.5, "threshold": 0.7 } }, "mask": "", "track": [ "person", "dog", "bicycle" ] }, "record": { "enabled": true, "events": { "max_seconds": 300, "objects": null, "post_capture": 0, "pre_capture": 10, "required_zones": [ "front_step" ], "retain": { "default": 7, "objects": {} } }, "retain_days": 0 }, "rtmp": { "enabled": true }, "snapshots": { "bounding_box": true, "clean_copy": true, "crop": false, "enabled": true, "height": null, "quality": 70, "required_zones": [ "front_step" ], "retain": { "default": 7, "objects": {} }, "timestamp": true }, "timestamp_style": { "color": { "blue": 255, "green": 255, "red": 255 }, "effect": null, "format": "%m/%d/%Y %H:%M:%S", "position": "tl", "thickness": 2 }, "zones": { "front_step": { "coordinates": "93,354,556,364,640,480,0,480", "filters": {}, "objects": [] } } },

On Thu, Oct 21, 2021 at 2:51 AM jaytea33 @.***> wrote:

I have the AD110 as well and recording works for me. I think you're missing the output args. Here's the relevant part of my config for reference, hope it helps:

cameras: doorbell_cam: ffmpeg: input_args: -hide_banner -loglevel warning -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -rtsp_transport tcp -stimeout 5000000 -use_wallclock_as_timestamps 1 output_args: detect: -f rawvideo -pix_fmt yuv420p record: -f segment -segment_time 3 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c copy -an -vsync 0 -enc_time_base -1 inputs:

  • path: rtsp:// @.***:554/cam/realmonitor?channel=1&subtype=1

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/blakeblackshear/frigate/issues/2068#issuecomment-948444635, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGLINQCOSL6MLV66I5IIMOLUH7PDHANCNFSM5GNA3W3A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

blakeblackshear commented 2 years ago

The comment above wasn't from me. I wouldn't use those output args suggested by another user. Do you see the live stream for the camera without recordings in the UI? If so, can you check to see if there are files being created in /tmp/cache or /media/frigate/recordings for that camera?

kdjordjev commented 2 years ago

Sorry.. my mistake ..

Attaching screenshots

tmp media

blakeblackshear commented 2 years ago

Are you still using the configuration from the original post? Something is preventing ffmpeg from properly splitting the segments for the cache file. Typically I have seen this happen when users have custom args defined.

kdjordjev commented 2 years ago

Thanks for the quick reply.

Originally i used the Default settings, now is below . Both cases the same behavior

record": "-f segment -segment_time 3 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c copy -an -vsync 0 -enc_time_base -1",

record": "-f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c copy -an ",

ffmpeg -hide_banner -loglevel warning -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format yuv420p -avoid_negative_ts make_zero -flags low_delay -fflags +genpts+discardcorrupt -rtsp_transport tcp -stimeout 5000000 -use_wallclock_as_timestamps 1 -i @.***:554/cam/realmonitor?channel=1&subtype=01 -f segment -segment_time 3 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c copy -an -vsync 0 -enc_time_base -1 /tmp/cache/front_door-%Y%m%d%H%M%S.mp4 -c copy -f flv rtmp://127.0.0.1/live/front_door -r 6 -s 640x480 -f rawvideo -pix_fmt yuv420p pipe:",

blakeblackshear commented 2 years ago

Can you try again without the custom args? The vsync parameter in particular has a known issue with segments and causes the behavior you see in the cache where the file grows forever.

kdjordjev commented 2 years ago

Thank you ... ! Found the issue It was in the input arguments "-flags low_delay" which causes somehow the file not to split .

input_args: ... -flags low_delay ....

It is interesting, since the live view of the camera was working. Perhaps the low delay combined with some of the output arguments referring to the timestamp. "-reset_timestamps 1 -strftime 1" .. sorry i do not understand them..

In any case works without the "low_delay"

thanks alot .. awesome product !!!

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

aforch commented 2 years ago

Thank you ... ! Found the issue It was in the input arguments "-flags low_delay" which causes somehow the file not to split .

input_args: ... -flags low_delay ....

It is interesting, since the live view of the camera was working. Perhaps the low delay combined with some of the output arguments referring to the timestamp. "-reset_timestamps 1 -strftime 1" .. sorry i do not understand them..

In any case works without the "low_delay"

thanks alot .. awesome product !!!

Is this still working for you? I'm having the exact same problem, issue 2359

kdjordjev commented 2 years ago

Yes. It has been working flawlessly since thenSent from my Galaxy -------- Original message --------From: aforch @.> Date: 12/3/21 12:00 AM (GMT-08:00) To: blakeblackshear/frigate @.> Cc: kdjordjev @.>, Author @.> Subject: Re: [blakeblackshear/frigate] [Support]: One out of 4 cameras does not record clips (Issue #2068)

Thank you ... ! Found the issue It was in the input arguments "-flags low_delay" which causes somehow the file not to split . input_args: ... -flags low_delay .... It is interesting, since the live view of the camera was working. Perhaps the low delay combined with some of the output arguments referring to the timestamp. "-reset_timestamps 1 -strftime 1" .. sorry i do not understand them.. In any case works without the "low_delay" thanks alot .. awesome product !!!

Is this still working for you? I'm having the exact same problem, issue 2359

—You are receiving this because you authored the thread.Reply to this email directly, view it on GitHub, or unsubscribe.Triage notifications on the go with GitHub Mobile for iOS or Android.

aforch commented 2 years ago

Yes. It has been working flawlessly since thenSent from my Galaxy

Could you share your current config and frigate version please?

kdjordjev commented 2 years ago

Nothing special. Just using the baseline settings. (below) Since the issue happened on only one one camera, my speculation is something to do with the time synchronization (i.e. the camera time stamp compared to the ffmpeg time) The camera which failed had the lowest latency. When i used the "-flags low_delay" flag the camera time was faster compared to ffmpeg and ffmpeg failed to split for snapshots. My other 5 cameras had different timestamp, were slower and they worked without issue. I removed the "-flags low_delay" flag for that specific camera , it added some more latency to it (~1s) and the splitting was fine I assume the same could be achieved with some other way to adjust camera timestamp

Starting Frigate (0.9.4-26ae608) Hassio add on: Frigate NVR 2.3

cameras:

front_door: ffmpeg: input_args: -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -rtsp_transport tcp -stimeout 5000000 -use_wallclock_as_timestamps 1 inputs:

ffmpeg: input_args: -avoid_negative_ts make_zero -flags low_delay -fflags +genpts+discardcorrupt -rtsp_transport tcp -stimeout 5000000 -use_wallclock_as_timestamps 1 hwaccel_args:

birdseye: enabled: True height: 360 width: 640

rtmp: enabled: True

live: height: 360

rtmp: enabled: True

record: enabled: True retain_days: 0 events: max_seconds: 300 pre_capture: 10 post_capture: 0 retain: default: 7

snapshots: enabled: True timestamp: True bounding_box: True retain: default: 7

detectors: coral: type: edgetpu device: usb

objects: track:

detect: width: 640 height: 360 fps: 6 enabled: True max_disappeared: 30 `

aforch commented 2 years ago

Thanks for the reply. I tried your config but I still don't get any recording when using it. My camera timestamp runs approximately 1-2 seconds behind the ffmpeg timestamp, so I'm not sure where the problem is coming from

srvoets commented 2 years ago

Im having a similar issue with my ad-110, 3 other cameras record clips no problem