blakeblackshear / frigate

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

Camera not recording clips? #1880

Closed eblohm closed 2 years ago

eblohm commented 2 years ago

I've had this issue since I set the camera up but I was sure I'd be able to figure it out myself but I can't. It's a Wyze Cam v2 with the official RTSP firmware flashed. I can view the stream and RTMP of the camera and events are created, but it doesn't record anything. The snapshot of the event shows, but there's no option to play anything, and if I try to download the clip, my browser just says "Failed - No File". Using 0.9.0RC5

Config:

  living_room:
    ffmpeg:
      inputs:
        - path: rtsp://USERNAME:PASSWORD@192.168.1.222/live
          roles:
            - rtmp
            - detect
            - record
    detect:
      width: 1920
      height: 1080
      fps: 5
    objects:
      filters:
        person:
          mask:
            - 685,0,608,489,0,449,0,54,0,0
        cat:
          mask:
            - 685,0,608,489,0,449,0,54,0,0
        dog:
          mask:
            - 685,0,608,489,0,449,0,54,0,0
    record:
      enabled: true
      retain_days: 0
      events:
        pre_capture: 5
        post_capture: 5
        objects:
          - dog
          - cat
        retain:
          default: 3
    snapshots:
      enabled: true
      timestamp: false
      bounding_box: true
      crop: False
      retain:
        default: 3

Debug related to the camera:

"living_room": {
  "best_image_timeout": 60,
  "detect": {
    "enabled": true,
    "fps": 5,
    "height": 1080,
    "max_disappeared": 25,
    "width": 1920
  },
  "ffmpeg": {
    "global_args": [
      "-hide_banner",
      "-loglevel",
      "warning"
    ],
    "hwaccel_args": [],
    "input_args": [
      "-avoid_negative_ts",
      "make_zero",
      "-fflags",
      "+genpts+discardcorrupt",
      "-rtsp_transport",
      "tcp",
      "-stimeout",
      "5000000",
      "-use_wallclock_as_timestamps",
      "1"
    ],
    "inputs": [
      {
        "global_args": [],
        "hwaccel_args": [],
        "input_args": [],
        "path": "rtsp://USERNAME:PASSWORD@192.168.1.222/live",
        "roles": [
          "rtmp",
          "detect",
          "record"
        ]
      }
    ],
    "output_args": {
      "detect": [
        "-f",
        "rawvideo",
        "-pix_fmt",
        "yuv420p"
      ],
      "record": [
        "-f",
        "segment",
        "-segment_time",
        "10",
        "-segment_format",
        "mp4",
        "-reset_timestamps",
        "1",
        "-strftime",
        "1",
        "-c",
        "copy",
        "-an"
      ],
      "rtmp": [
        "-c",
        "copy",
        "-f",
        "flv"
      ]
    }
  },
  "ffmpeg_cmds": [
    {
      "cmd": "ffmpeg -hide_banner -loglevel warning -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -rtsp_transport tcp -stimeout 5000000 -use_wallclock_as_timestamps 1 -i rtsp://USERNAME:PASSWORD@192.168.1.222/live -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c copy -an /tmp/cache/living_room-%Y%m%d%H%M%S.mp4 -c copy -f flv rtmp://127.0.0.1/live/living_room -r 5 -s 1920x1080 -f rawvideo -pix_fmt yuv420p pipe:",
      "roles": [
        "rtmp",
        "detect",
        "record"
      ]
    }
  ],
  "live": {
    "height": 720,
    "quality": 8
  },
  "motion": {
    "contour_area": 99,
    "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": "living_room",
  "objects": {
    "filters": {
      "cat": {
        "mask": [
          "685,0,608,489,0,449,0,54,0,0"
        ],
        "max_area": 24000000,
        "min_area": 0,
        "min_score": 0.5,
        "threshold": 0.7
      },
      "dog": {
        "mask": [
          "685,0,608,489,0,449,0,54,0,0"
        ],
        "max_area": 24000000,
        "min_area": 0,
        "min_score": 0.5,
        "threshold": 0.7
      },
      "person": {
        "mask": [
          "685,0,608,489,0,449,0,54,0,0"
        ],
        "max_area": 24000000,
        "min_area": 0,
        "min_score": 0.5,
        "threshold": 0.7
      }
    },
    "mask": "",
    "track": [
      "person"
    ]
  },
  "record": {
    "enabled": true,
    "events": {
      "max_seconds": 300,
      "objects": [
        "dog",
        "cat"
      ],
      "post_capture": 5,
      "pre_capture": 5,
      "required_zones": [],
      "retain": {
        "default": 3,
        "objects": {}
      }
    },
    "retain_days": 0
  },
  "rtmp": {
    "enabled": true
  },
  "snapshots": {
    "bounding_box": true,
    "clean_copy": true,
    "crop": false,
    "enabled": true,
    "height": null,
    "quality": 70,
    "required_zones": [],
    "retain": {
      "default": 3,
      "objects": {}
    },
    "timestamp": false
  },
  "timestamp_style": {
    "color": {
      "blue": 255,
      "green": 255,
      "red": 255
    },
    "effect": null,
    "format": "%m/%d/%Y %H:%M:%S",
    "position": "tl",
    "thickness": 2
  },
  "zones": {}
},
blakeblackshear commented 2 years ago

You should have something in the logs related to this.

eblohm commented 2 years ago

I restarted Frigate, opened moved in front of the camera to trigger an event, checked the events page to see if one was created (it was, same thing as usual though for this camera, just a snapshot, no play button and attempting to download it fails) :(

This is what my log file looks like since Frigate was restarted.

[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.
[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-09-30 10:53:34] frigate.app INFO : Starting Frigate (0.9.0-aa807d2)
Starting migrations
[2021-09-30 10:53:34] peewee_migrate INFO : Starting migrations
There is nothing to migrate
[2021-09-30 10:53:34] peewee_migrate INFO : There is nothing to migrate
[2021-09-30 10:53:34] frigate.mqtt INFO : MQTT connected
[2021-09-30 10:53:34] detector.coral_pci INFO : Starting detection process: 233
[2021-09-30 10:53:34] frigate.app INFO : Output process started: 235
[2021-09-30 10:53:34] ws4py INFO : Using epoll
[2021-09-30 10:53:34] frigate.edgetpu INFO : Attempting to load TPU as pci
[2021-09-30 10:53:34] frigate.app INFO : Camera processor started for bun_room_1: 240
[2021-09-30 10:53:35] frigate.edgetpu INFO : TPU found
[2021-09-30 10:53:34] frigate.app INFO : Camera processor started for bun_room_2: 243
[2021-09-30 10:53:34] frigate.app INFO : Camera processor started for garage: 244
[2021-09-30 10:53:34] frigate.app INFO : Camera processor started for doorbell: 246
[2021-09-30 10:53:34] frigate.app INFO : Camera processor started for living_room: 249
[2021-09-30 10:53:34] frigate.app INFO : Capture process started for bun_room_1: 250
[2021-09-30 10:53:34] frigate.app INFO : Capture process started for bun_room_2: 254
[2021-09-30 10:53:34] frigate.app INFO : Capture process started for garage: 258
[2021-09-30 10:53:34] frigate.app INFO : Capture process started for doorbell: 267
[2021-09-30 10:53:34] frigate.app INFO : Capture process started for living_room: 273
[2021-09-30 10:53:34] ws4py INFO : Using epoll
[2021-09-30 10:59:22] ws4py INFO : Managing websocket [Local => 127.0.0.1:5002 | Remote => 127.0.0.1:51870]
[2021-09-30 10:59:27] ws4py INFO : Managing websocket [Local => 127.0.0.1:8082 | Remote => 127.0.0.1:43810]
[2021-09-30 10:59:32] ws4py INFO : Terminating websocket [Local => 127.0.0.1:8082 | Remote => 127.0.0.1:43810]

Event happened at 11:00:16

blakeblackshear commented 2 years ago

Can you try setting retain_days to 0.1 to see if it still happens for events within the last 2.4 hours?

eblohm commented 2 years ago

Set it to 1 day, and now it's even weirder:

I can watch the full recording, use the timeline to jump to an event and it plays the event. However if I go through the event log for that camera, the issue is still there (no play button, can't download the clip, but it has a screenshot of the event)

blakeblackshear commented 2 years ago

And the event you are referring occurred after you changed the setting to 1 day right?

eblohm commented 2 years ago

Yep, that's correct. In fact, I just had an event occur. (retain_days is still set to 1 instead of 0). I can go through the recording timeline and watch the event that way still, but checking the events page for it just gives me the screenshot. All of my other cameras work perfectly - but they're Amcrest IP cameras and this one is my only Wyze (though I doubt that has anything to do with it, haha)

blakeblackshear commented 2 years ago

So this only happens on one of your cameras? Somehow I missed that detail.

eblohm commented 2 years ago

Yep, just the Wyze. All of my Amcrest's work fine (sorry, I don't think I mentioned that in my original post)

blakeblackshear commented 2 years ago

I think I see your issue. You have specified that only dog and cat events should be recorded in your config, but you don't have dog and cat listed as objects to track for that camera.

Looking at your config, I would expect person events to have a snapshot, but no recording. That's why you don't have a play button even though you have the recordings.

eblohm commented 2 years ago

...oh man. I had compared my configurations between cameras so many times but somehow missed that every single time. Thank you!

blakeblackshear commented 2 years ago

With so much flexibility in the config, this is one of those edge cases where it's possible to create an invalid config. I will see if I can detect this and add a warning in the logs.