blakeblackshear / frigate

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

[Support]: Snapshot shows event trigger but recorded video clip doesn't include those frames #3043

Closed spikeygg closed 1 week ago

spikeygg commented 2 years ago

Describe the problem you are having

I've been using Frigate for almost a year now. I really like that Nvidia CUDA is supported via docker container (I use that one). However, I've noticed that occasionally an event will be caught and the snapshot shows the trigger (like a person, cat or dog) but when I view the recorded video clip it doesn't contain those frames. Often, the event was completely missed! This happens pretty regularly on my setup. Here's an example.

Snapshot shows "16:44:51": image

First frame of video shows "16:44:58": image

Last frame of video shows "16:45:05": image

Version

0.10.1-83481AF

Frigate config file

detectors:
  coral:
    type: edgetpu
    device: usb

ffmpeg:
  hwaccel_args:
    - -hwaccel
    - cuda
    - -c:v
    - h264_cuvid
  output_args:
    record: -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c:a copy -c:v h264_nvenc -vf hwupload_cuda,scale_npp=w='if(gt(a\,1280/960)\,1280\,oh*a)':h='if(gt(a\,1280/960)\,ow/a\,960)'
    rtmp: -c:a copy -f flv -c:v h264_nvenc -vf hwupload_cuda,scale_npp=w='if(gt(a\,1280/960)\,1280\,oh*a)':h='if(gt(a\,1280/960)\,ow/a\,960)'
  input_args:
    - -avoid_negative_ts
    - make_zero
    - -fflags
    - nobuffer
    - -flags
    - low_delay
    - -strict
    - experimental
    - -fflags
    - +genpts+discardcorrupt
    - -use_wallclock_as_timestamps
    - "1"

record:
  enabled: True
  retain:
    days: 2
    mode: motion
  events:
    retain:
      default: 10
      mode: active_objects

snapshots:
  enabled: True
  timestamp: False
  bounding_box: True
  height: 400

objects:
  track:
    - person
    - dog
    - cat

cameras:
  front_door:
    ffmpeg:
      inputs:
        - path: rtmp://rlc-520-1/bcs/channel0_main.bcs?channel=0&stream=0&user={FRIGATE_RTSP_USERNAME}&password={FRIGATE_RTSP_PASSWORD}
          roles:
            - detect
            - record
            - rtmp
    detect:
      width: 2048
      height: 1536
    mqtt:
      crop: False

  west_yard:
    ffmpeg:
      inputs:
        - path: rtmp://rlc-410-4/bcs/channel0_main.bcs?channel=0&stream=0&user={FRIGATE_RTSP_USERNAME}&password={FRIGATE_RTSP_PASSWORD}
          roles:
            - detect
            - record
            - rtmp
    detect:
      width: 2048
      height: 1536
    mqtt:
      crop: False
    motion:
      mask:
        - 2048,1536,2048,842,1819,800,1778,901,1447,779,1263,971,1150,1349,1550,1536
    zones:
      west_yard_zone_close:
        coordinates: 2048,1536,2048,137,1760,266,1237,64,1215,575,610,888,0,1277,0,1536
      west_yard_zone_far:
        coordinates: 0,0,2048,0,2048,137,1760,266,1237,64,1215,575,610,888,0,1277

  east_yard:
    ffmpeg:
      inputs:
        - path: rtmp://rlc-410-3/bcs/channel0_main.bcs?channel=0&stream=0&user={FRIGATE_RTSP_USERNAME}&password={FRIGATE_RTSP_PASSWORD}
          roles:
            - detect
            - record
            - rtmp
    detect:
      width: 2048
      height: 1536
    motion:
      mask:
        - 0,0,0,857,1487,180,1506,0
    zones:
      east_yard_zone_close:
        coordinates: 2048,1536,2048,364,1563,257,1189,215,460,167,460,0,0,0,0,1192,0,1536
      east_yard_zone_far:
        coordinates: 2048,0,460,0,460,167,1189,215,1563,257,2048,364

  back_yard:
    ffmpeg:
      inputs:
        - path: rtmp://rlc-410-1/bcs/channel0_main.bcs?channel=0&stream=0&user={FRIGATE_RTSP_USERNAME}&password={FRIGATE_RTSP_PASSWORD}
          roles:
            - detect
            - record
            - rtmp
    detect:
      width: 2304
      height: 1296
    motion:
      mask:
        - 2304,1296,2304,420,2039,390,2051,236,1872,124,1628,285,1611,655,1300,785,1970,1296
    zones:
      back_yard_zone_canal:
        coordinates: 2304,0,2304,427,2100,380,1030,0
      back_yard_zone_grass:
        coordinates: 2100,380,1300,785,1970,1296,1123,1296,873,984,839,685,486,282,705,213,693,0,1030,0
      back_yard_zone_garden:
        coordinates: 2304,1296,2304,427,2100,380,1300,785,1970,1296
      back_yard_zone_deck_and_patio:
        coordinates: 0,966,839,685,625,431,486,282,705,213,693,0,0,0

  out_the_back:
    ffmpeg:
      inputs:
        - path: rtmp://rlc-410-2/bcs/channel0_main.bcs?channel=0&stream=0&user={FRIGATE_RTSP_USERNAME}&password={FRIGATE_RTSP_PASSWORD}
          roles:
            - detect
            - record
            - rtmp
    detect:
      width: 2304
      height: 1296
    objects:
      track:
        - person
        - dog
        - cat
        - car
    zones:
      out_the_back_zone_far:
        coordinates: 2304,0,2304,521,0,524,0,0
      out_the_back_zone_near:
        coordinates: 0,1296,2304,1296,2304,522,0,522

  garage:
    ffmpeg:
      inputs:
        - path: rtmp://rlc-511-1/bcs/channel0_main.bcs?channel=0&stream=0&user={FRIGATE_RTSP_USERNAME}&password={FRIGATE_RTSP_PASSWORD}
          roles:
            - detect
            - record
            - rtmp
    detect:
      width: 2048
      height: 1536
    objects:
      track:
        - person

  storage_room:
    ffmpeg:
      inputs:
        - path: rtmp://rlc-e1-zoom-1/bcs/channel0_main.bcs?channel=0&stream=0&user={FRIGATE_RTSP_USERNAME}&password={FRIGATE_RTSP_PASSWORD}
          roles:
            - detect
            - record
            - rtmp
    detect:
      width: 2048
      height: 1536
    objects:
      track:
        - person

Relevant log output


Surprisingly, there are no log entries from 3-31-2022:

{"log":"[2022-03-30 08:19:17] frigate.mqtt                   INFO    : Turning off detection for back_yard via mqtt\n","stream":"stderr","time":"2022-03-30T14:19:17.840702009Z"}
{"log":"[2022-03-30 08:19:17] frigate.mqtt                   INFO    : Turning off detection for east_yard via mqtt\n","stream":"stderr","time":"2022-03-30T14:19:17.841131169Z"}
{"log":"[2022-03-30 08:19:17] frigate.mqtt                   INFO    : Turning off detection for front_door via mqtt\n","stream":"stderr","time":"2022-03-30T14:19:17.885932354Z"}
{"log":"[2022-03-30 08:19:17] frigate.mqtt                   INFO    : Turning off detection for out_the_back via mqtt\n","stream":"stderr","time":"2022-03-30T14:19:17.886365833Z"}
{"log":"[2022-03-30 08:19:17] frigate.mqtt                   INFO    : Turning off detection for west_yard via mqtt\n","stream":"stderr","time":"2022-03-30T14:19:17.887149665Z"}
{"log":"[2022-03-30 10:19:17] frigate.mqtt                   INFO    : Turning on detection for back_yard via mqtt\n","stream":"stderr","time":"2022-03-30T16:19:17.051743774Z"}
{"log":"[2022-03-30 10:19:17] frigate.mqtt                   INFO    : Turning on detection for east_yard via mqtt\n","stream":"stderr","time":"2022-03-30T16:19:17.053558165Z"}
{"log":"[2022-03-30 10:19:17] frigate.mqtt                   INFO    : Turning on detection for front_door via mqtt\n","stream":"stderr","time":"2022-03-30T16:19:17.097473388Z"}
{"log":"[2022-03-30 10:19:17] frigate.mqtt                   INFO    : Turning on detection for out_the_back via mqtt\n","stream":"stderr","time":"2022-03-30T16:19:17.098299657Z"}
{"log":"[2022-03-30 10:19:17] frigate.mqtt                   INFO    : Turning on detection for west_yard via mqtt\n","stream":"stderr","time":"2022-03-30T16:19:17.099251758Z"}
{"log":"[2022-03-30 10:34:37] frigate.mqtt                   INFO    : Turning off detection for back_yard via mqtt\n","stream":"stderr","time":"2022-03-30T16:34:37.257154934Z"}
{"log":"[2022-03-30 10:34:37] frigate.mqtt                   INFO    : Turning off detection for east_yard via mqtt\n","stream":"stderr","time":"2022-03-30T16:34:37.257863285Z"}
{"log":"[2022-03-30 10:34:37] frigate.mqtt                   INFO    : Turning off detection for front_door via mqtt\n","stream":"stderr","time":"2022-03-30T16:34:37.258570228Z"}
{"log":"[2022-03-30 10:34:37] frigate.mqtt                   INFO    : Turning off detection for out_the_back via mqtt\n","stream":"stderr","time":"2022-03-30T16:34:37.259244919Z"}
{"log":"[2022-03-30 10:34:37] frigate.mqtt                   INFO    : Turning off detection for west_yard via mqtt\n","stream":"stderr","time":"2022-03-30T16:34:37.259989084Z"}
{"log":"[2022-03-30 11:34:37] frigate.mqtt                   INFO    : Turning on detection for back_yard via mqtt\n","stream":"stderr","time":"2022-03-30T17:34:37.040617225Z"}
{"log":"[2022-03-30 11:34:37] frigate.mqtt                   INFO    : Turning on detection for east_yard via mqtt\n","stream":"stderr","time":"2022-03-30T17:34:37.085334772Z"}
{"log":"[2022-03-30 11:34:37] frigate.mqtt                   INFO    : Turning on detection for front_door via mqtt\n","stream":"stderr","time":"2022-03-30T17:34:37.087544776Z"}
{"log":"[2022-03-30 11:34:37] frigate.mqtt                   INFO    : Turning on detection for out_the_back via mqtt\n","stream":"stderr","time":"2022-03-30T17:34:37.08807026Z"}
{"log":"[2022-03-30 11:34:37] frigate.mqtt                   INFO    : Turning on detection for west_yard via mqtt\n","stream":"stderr","time":"2022-03-30T17:34:37.088709136Z"}
{"log":"[2022-04-01 10:04:00] ws4py                          INFO    : Managing websocket [Local =\u003e 127.0.0.1:5002 | Remote =\u003e 127.0.0.1:42174]\n","stream":"stderr","time":"2022-04-01T16:04:00.641621847Z"}
{"log":"[2022-04-01 10:05:28] frigate.http                   ERROR   : No recordings found for the requested time range\n","stream":"stderr","time":"2022-04-01T16:05:28.663134352Z"}
{"log":"[2022-04-01 10:05:57] ws4py                          INFO    : Terminating websocket [Local =\u003e 127.0.0.1:5002 | Remote =\u003e 127.0.0.1:42174]\n","stream":"stderr","time":"2022-04-01T16:05:57.500025201Z"}

FFprobe output from your camera

> ffprobe "rtmp://rlc-410-3/bcs/channel0_main.bcs?channel=0&stream=0&user=******&password=******"

ffprobe version 4.3.1 Copyright (c) 2007-2020 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.3.0-17ubuntu1~20.04)
  configuration: --disable-debug --disable-doc --disable-ffplay --enable-shared --enable-avresample --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-gpl --enable-libfreetype --enable-libvidstab --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libxcb --enable-libx265 --enable-libxvid --enable-libx264 --enable-nonfree --enable-openssl --enable-libfdk_aac --enable-postproc --enable-small --enable-version3 --enable-libzmq --extra-libs=-ldl --prefix=/opt/ffmpeg --enable-libopenjpeg --enable-libkvazaar --enable-libaom --extra-libs=-lpthread --enable-libsrt --enable-libaribb24 --enable-nvenc --enable-cuda --enable-cuvid --enable-libnpp --extra-cflags='-I/opt/ffmpeg/include -I/opt/ffmpeg/include/ffnvcodec -I/usr/local/cuda/include/' --extra-ldflags='-L/opt/ffmpeg/lib -L/usr/local/cuda/lib64 -L/usr/local/cuda/lib32/'
  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
Input #0, flv, from 'rtmp://rlc-410-3/bcs/channel0_main.bcs?channel=0&stream=0&user=******&password=******':
  Metadata:
    displayWidth    : 2048
    displayHeight   : 1536
  Duration: 00:00:00.00, start: 463005.222000, bitrate: N/A
    Stream #0:0: Data: none
    Stream #0:1: Audio: aac, 16000 Hz, mono, fltp
    Stream #0:2: Video: h264, yuv420p(progressive), 2048x1536, 10 fps, 10 tbr, 1k tbn
Unsupported codec with id 0 for input stream 0
>

Frigate stats

{
"back_yard": {
"camera_fps": 5.1,
"capture_pid": 265,
"detection_fps": 0,
"pid": 245,
"process_fps": 5.1,
"skipped_fps": 0
},
"detection_fps": 4.4,
"detectors": {
"coral": {
"detection_start": 0,
"inference_speed": 11.17,
"pid": 725959
}
},
"east_yard": {
"camera_fps": 5,
"capture_pid": 259,
"detection_fps": 4.3,
"pid": 243,
"process_fps": 5,
"skipped_fps": 0
},
"front_door": {
"camera_fps": 5.1,
"capture_pid": 251,
"detection_fps": 0,
"pid": 238,
"process_fps": 5.1,
"skipped_fps": 0
},
"garage": {
"camera_fps": 5.1,
"capture_pid": 276,
"detection_fps": 0,
"pid": 248,
"process_fps": 5.1,
"skipped_fps": 0
},
"out_the_back": {
"camera_fps": 5.1,
"capture_pid": 270,
"detection_fps": 0.1,
"pid": 247,
"process_fps": 5.1,
"skipped_fps": 0
},
"service": {
"storage": {
"/dev/shm": {
"free": 2079.2,
"mount_type": "tmpfs",
"total": 2147.5,
"used": 68.3
},
"/media/frigate/clips": {
"free": 1759233.9,
"mount_type": "ext4",
"total": 1967928.4,
"used": 108658.1
},
"/media/frigate/recordings": {
"free": 1759233.9,
"mount_type": "ext4",
"total": 1967928.4,
"used": 108658.1
},
"/tmp/cache": {
"free": 1980.3,
"mount_type": "tmpfs",
"total": 2000,
"used": 19.7
}
},
"temperatures": {},
"uptime": 1737130,
"version": "0.10.1-83481af"
},
"storage_room": {
"camera_fps": 5,
"capture_pid": 279,
"detection_fps": 0,
"pid": 249,
"process_fps": 5,
"skipped_fps": 0
},
"west_yard": {
"camera_fps": 5.1,
"capture_pid": 255,
"detection_fps": 0,
"pid": 241,
"process_fps": 5.1,
"skipped_fps": 0
}
}

Operating system

Other Linux

Install method

Docker Compose

Coral version

USB

Network connection

Wired

Camera make and model

reolink

Any other information that may be helpful

No response

NickM-27 commented 2 years ago

Hi, few things:

  1. Please provide logs
  2. Stats is accessed by using http:frigate.ip.add.ress:5000/api/stats

As far as the actual issue, you are using the same feed for both detect and record roles which makes this more interesting. In the screenshot it seems to show the video as having 6 (or maybe 8?) seconds which is even less than 1 segment (10 seconds). This seems to tell me that something is going wrong, as I don't believe frigate does any trimming of the 10 second segments. Logs from an occurence of this should definitely add some context.

spikeygg commented 2 years ago

Hi, few things:

  1. Please provide logs
  2. Stats is accessed by using http:frigate.ip.add.ress:5000/api/stats

As far as the actual issue, you are using the same feed for both detect and record roles which makes this more interesting. In the screenshot it seems to show the video as having 6 (or maybe 8?) seconds which is even less than 1 segment (10 seconds). This seems to tell me that something is going wrong, as I don't believe frigate does any trimming of the 10 second segments. Logs from an occurence of this should definitely add some context.

Thanks for the quick response. I've updated the API data in the original ticket from the address you supplied. I also tracked down the frigate log file and looked through it; I reported all the logfile detail from 3-30-22 at 8:00 until now. To my surprise there were no entries on 3-31-22 when the example event I reported was triggered by the system. I wonder if I need to increase the logging verbosity to see that? Should I add:

logger:
  default: debug

to my config to see it? Any other suggestions?

blakeblackshear commented 2 years ago

I wouldn't turn on debug logging like that. There will be so much noise that you will never find the important messages.

Are the video segments always after the event when this happens? Does your RTMP feed get out of sync too?

spikeygg commented 2 years ago

I wouldn't turn on debug logging like that. There will be so much noise that you will never find the important messages.

Do you recommend I increase the debugging to try to capture more detail when this occurs? If so, please suggest the yaml loggers I should increase and I'll keep an eye on it for instances. I'm looking at the docs (https://docs.frigate.video/configuration/advanced) and there are quite a few options but I don't know which one we should focus on for this.

Are the video segments always after the event when this happens? Does your RTMP feed get out of sync too?

So far, I think all the times it has happened the video has been after the event -- I usually miss the action if the trigger was quick and gone.

I don't know how to tell if the RTMP feed gets out of sync (need more detail on what that means). However, I also have issues where one event trigger may show up multiple times. I was thinking it was an unrelated issue but it may stem from the same problem. I also have quite a few instances where a snapshot is captured but the recorded video clip reports as The media could not be loaded, either because the server or network failed or because the format is not supported.

When the event has duplicates usually the second snapshot is a slightly different frame (just 2-4 seconds later). In the duplicate case, sometimes the video is exactly the same as the dupe and sometimes only one of the dupes plays and the other gives me the media could not be loaded error. Occasionally, neither duplicate will play their video.

blakeblackshear commented 2 years ago

I don't know if there is any debug logging that will tell you more. The default logging settings will show warnings when segments are discarded as corrupt. If there were errors, they would already be showing up.

When viewing the live view in frigate, is there a significant delay or is that close to real time?

The time of the recordings is determined based on the timestamp in the filenames written to cache by ffmpeg. There isn't any other way for frigate to know what time it was in the video other than when it received it. In your case, ffmpeg is reading a single stream, decoding it, sending it to frigate as raw frames and encoding it as h264 so it can be written to disk at the same time. Something must be getting delayed in one of those two places and the file writes are getting out of sync with when frame are sent for processing.

spikeygg commented 2 years ago

When viewing the live view in frigate, is there a significant delay or is that close to real time?

I just checked and all the cameras are between 0-4 seconds behind realtime. All cameras are wired via gigabit PoE except for one which is WiFi and surprisingly that WiFi camera was only 1 second behind realtime. They all sync their times via NTP nightly so they should all be very close to accurate.

The time of the recordings is determined based on the timestamp in the filenames written to cache by ffmpeg. There isn't any other way for frigate to know what time it was in the video other than when it received it. In your case, ffmpeg is reading a single stream, decoding it, sending it to frigate as raw frames and encoding it as h264 so it can be written to disk at the same time. Something must be getting delayed in one of those two places and the file writes are getting out of sync with when frame are sent for processing.

Wow, that sounds complex but if there are two places at least it narrows it down. Is there a way I can manually test one or both of those to see if I can determine how/why?

blakeblackshear commented 2 years ago

Can you change your record config to retain all segments for the first 2 days to see if this still happens? I don't know if it's because the timing is off or if the segments are not being retained when they should.

record:
  enabled: True
  retain:
    days: 2
    mode: all
  events:
    retain:
      default: 10
      mode: active_objects
spikeygg commented 2 years ago

Can you change your record config to retain all segments for the first 2 days to see if this still happens?

I'm on it! Just updated the config.yml and restarted.

spikeygg commented 2 years ago

Looks like it's still occurring. :(

Here's a capture from 10:37:59 to 10:38:19 and the snapshot shows 10:38:06: image

However, when I click play the first frame starts at 10:38:12: image

blakeblackshear commented 2 years ago

The timeline for the video only shows 5 seconds for a 30s event which suggests that it's missing segments altogether. Can you look in the recordings directory for this event and see what files are in there? Also, do you have warning messages in the logs about segments being discarded?

spikeygg commented 2 years ago

The timeline for the video only shows 5 seconds for a 30s event which suggests that it's missing segments altogether. Can you look in the recordings directory for this event and see what files are in there? Also, do you have warning messages in the logs about segments being discarded?

I see a few recordings that appear to have landed at 10:38AM on that camera feed, they are all about 27 seconds: image

The only log entries I see are like this:

{"log":"[2022-04-01 21:58:20] ws4py                          INFO    : Managing websocket [Local =\u003e 127.0.0.1:5002 | Remote =\u003e 127.0.0.1:36990]\n","stream":"stderr","time":"2022-04-02T03:58:20.412520347Z"}
{"log":"[2022-04-01 21:58:54] ws4py                          INFO    : Terminating websocket [Local =\u003e 127.0.0.1:5002 | Remote =\u003e 127.0.0.1:36990]\n","stream":"stderr","time":"2022-04-02T03:58:54.980982969Z"}
{"log":"[2022-04-02 11:16:11] ws4py                          INFO    : Managing websocket [Local =\u003e 127.0.0.1:5002 | Remote =\u003e 127.0.0.1:42834]\n","stream":"stderr","time":"2022-04-02T17:16:11.971450362Z"}
{"log":"[2022-04-02 11:17:48] ws4py                          INFO    : Terminating websocket [Local =\u003e 127.0.0.1:5002 | Remote =\u003e 127.0.0.1:42834]\n","stream":"stderr","time":"2022-04-02T17:17:48.387128227Z"}
{"log":"[2022-04-02 13:20:03] ws4py                          INFO    : Managing websocket [Local =\u003e 127.0.0.1:5002 | Remote =\u003e 127.0.0.1:56028]\n","stream":"stderr","time":"2022-04-02T19:20:03.308793164Z"}
{"log":"[2022-04-02 13:21:49] ws4py                          INFO    : Terminating websocket [Local =\u003e 127.0.0.1:5002 | Remote =\u003e 127.0.0.1:56028]\n","stream":"stderr","time":"2022-04-02T19:21:49.50565259Z"}
blakeblackshear commented 2 years ago

When you playback those files, how do the filenames line up with the timestamp from the camera? Are some parts missing? With retain mode set to all, you shouldn't have any missing video.

spikeygg commented 2 years ago

When you playback those files, how do the filenames line up with the timestamp from the camera? Are some parts missing? With retain mode set to all, you shouldn't have any missing video.

Okay, when I play back the recordings I see this:

2022-04/02/10/out_the_back/37.46.mp4 - camera's timestamp range is 37:44-38:12 2022-04/02/10/out_the_back/38.14.mp4 - camera's timestamp range is 38:12-38:39 2022-04/02/10/out_the_back/38.41.mp4 - camera's timestamp range is 38:40-39:07

there might be some split-seconds dropped between recordings but overall it looks pretty seamless and complete, at least from the recordings directory standpoint.

blakeblackshear commented 2 years ago

That seems like a reasonable difference, so I think the problem must be elsewhere. I wonder if there is some kind of error when reading the duration of these files. Do you mind uploading to google drive and sharing with blake@frigate.video?

spikeygg commented 2 years ago

That seems like a reasonable difference, so I think the problem must be elsewhere. I wonder if there is some kind of error when reading the duration of these files. Do you mind uploading to google drive and sharing with blake@frigate.video?

Done, you should have gotten a notification email or something. Thanks for taking a look! Lemme know if I can help with anything else.

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.

gszigethy commented 1 year ago

@spikeygg Have you found any solution for this? I seem to have the same issue, snapshots and clips are way out of sync.

Calimerorulez commented 1 year ago

Same here after moving to a less beefy server, but CPU isn't an issue.

jncanches commented 1 year ago

Same here but it is linked to the output_args to re-encode mjpeg stream to H.264. output_args: record: -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c:v libx264 -an rtmp: -c:v libx264 -an -f flv

Without that, clips are ok (but not playable in UI). With it, clips are "after" the motion event :(

blakeblackshear commented 1 year ago

Try these args to tell ffmpeg to prioritize realtime encoding:

  output_args: 
    record: -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c:v libx264 -tune zerolatency -preset ultrafast -an 
    rtmp: -c:v libx264 -tune zerolatency -preset ultrafast -an -f flv