blakeblackshear / frigate

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

[Config Support]: Recordings never moved from cache for one camera #5632

Closed dsanner closed 1 year ago

dsanner commented 1 year ago

Describe the problem you are having

Amcrest IP4M-1041B camera's not recording. I have a few tapo's, reolink, and wyze with rtsp. Detection and record works fine on all those. I was using go2rtc with everything at first. The other cameras will record clips and record snapshots. The two amcrest cameras, however, will work fine with detect, and snapshot but I can't get them to record anything.

There doesn't seem to be any errors in logs related to it. I tried using go2rtc, and then tried using just a single camera in frigate config, and both ways it doesn't store a recording for the event... just a snapshot picture.

I am running the bleeding edge so might be that... or maybe something wrong with my config.

I tried running ffmpeg -hide_banner -loglevel debug -i 'rtsp://admin:pass@10.0.0.44/cam/realmonitor?channel=1&subtype=0&authbasic=64 ' -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c copy -an test.mp4

and ffmpeg is able to connect and record the mp4 with no issues.

Version

0.12.0-318240C

Frigate config file

mqtt:
  host: 10.0.0.181
  port: 1883
  client_id: frigate
  user: frigate
  password: pass
  stats_interval: 60
logger:
  default: debug
  logs: 
    frigate.record: debug

ffmpeg:
  # Optional: global ffmpeg args (default: shown below)
  global_args: -hide_banner -loglevel warning -threads 1
  # Optional: global hwaccel args (default: shown below)
  # NOTE: See hardware acceleration docs for your specific device
  hwaccel_args: preset-nvidia-h264
  # Optional: global input args (default: shown below)
  input_args: preset-rtsp-generic
  # Optional: global output args
  output_args:
    # Optional: output args for detect streams (default: shown below)
    detect: -threads 1 -f rawvideo -pix_fmt yuv420p
    # Optional: output args for record streams (default: shown below)
    record: preset-record-generic
    # Optional: output args for rtmp streams (default: shown below)
    rtmp: preset-rtmp-generic

detectors:
  coral:
    type: edgetpu
    device: usb  
snapshots:
  enabled: True
  clean_copy: True
  timestamp: True
  retain:
    default: 100
cameras:
  livingroomtokitchen:
    ffmpeg:
      inputs:
        - path: rtsp://admin:pass@10.0.0.44/cam/realmonitor?channel=1&subtype=0&authbasic=64
          input_args: preset-rtsp-generic
          roles:
            - record
            - detect
    record:
      enabled: True
      retain:
        days: 14
        mode: all
detect:
  stationary:
    interval: 0
    threshold: 50
record:
  enabled: True
  retain:
    days: 14
    mode: all
  events:
    retain:
      default: 31
      mode: active_objects

# Optional: birdseye configuration
birdseye:
  # Optional: Enable birdseye view (default: shown below)
  enabled: True
  mode: motion
  # Optional: Width of the output resolution (default: shown below)
  width: 1400
  height: 800
  quality: 15

Relevant log output

2023-03-03 06:34:12.370609503  [2023-03-03 06:34:12] frigate.events                 DEBUG   : Event received: update livingroomtokitchen 1677825121.185688-da4ok6
2023-03-03 06:34:33.949130837  [2023-03-03 06:34:33] frigate.http                   ERROR   : No recordings found for the requested time range

Frigate stats

No response

Operating system

Proxmox

Install method

Docker Compose

Coral version

USB

Any other information that may be helpful

No response

NickM-27 commented 1 year ago

If you check /tmp/cache do you see recordings files for that camera?

dsanner commented 1 year ago

in docker bash ls -all -h shows:

-rw-r--r-- 1 root root 420M Mar 3 16:28 livingroomtokitchen-20230303155605.mp4

NickM-27 commented 1 year ago

Okay, so that means something is wrong with the Timestamps so the recording never closes.

Maybe try preset-rtsp-restream for that camera and see what happens.

dsanner commented 1 year ago

Okay I tried that with and without go2rtc... it still just grows in the tmp/cache and doesn't ever get transferred. For go2rtc I tried using go2rtc with a few different input args.

 ffmpeg: 
    hwaccel_args: preset-nvidia-h264
    rtsp: " -fflags nobuffer -flags low_delay -timeout 5000000 -user_agent go2rtc/ffmpeg -rtsp_transport tcp -i {input}"
    testrtsp: "-timeout 5000000 -analyzeduration 1000M -probesize 1000M -strict experimental -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt low_delay -correct_ts_overflow 0 -use_wallclock_as_timestam
    test2rtsp: " -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -rtsp_transport tcp -timeout 5000000 -use_wallclock_as_timestamps 1 -rtsp_transport tcp -i {input}"
ps 1 -rtsp_transport tcp -i {input}"
 livingroomtokitchen: 
      #amcrest
      - rtsp://admin:pass@10.0.0.47/cam/realmonitorchannel=1&subtype=0&authbasic=64
      - "ffmpeg:livingroomtokitchen#input=rtsp#video=copy#audio=copy#audio=opus"

 livingroomtokitchen:
    ffmpeg:
      inputs:
        - path: rtsp://127.0.0.1:8554/livingroomtokitchen?video=h264&audio=aac
          input_args: preset-rtsp-restream
          roles:
            - record
            - detect
NickM-27 commented 1 year ago

If you left the original go2rtc config there then the ffmpeg one would never be used so I don't believe any of those tests would have gone through. You would need to merge the two in order for that to work

- "ffmpeg:rtsp://admin:pass@10.0.0.47/cam/realmonitorchannel=1&subtype=0&authbasic=64#input=rtsp#video=copy#audio=copy#audio=opus"

I would suggest trying those again

dsanner commented 1 year ago

I removed all go2rtc, and tried again using pure Frigate config. It works if i change input args to: input_args:

Thank you for the hint about timestamps, even if can't get working with go2rtc i can at least use frigate and per-camera input_args.

dsanner commented 1 year ago

Excellent. Thanks for the hint about timestamps. Adding "-correct_ts_overflow 0" was needed for go2rtc to work. Now works all going through go2rtc

NickM-27 commented 1 year ago

Interesting, thanks, that may be very helpful to know for other users who have the same issue

dsanner commented 1 year ago

just as update. Works as long as audio=copy and video=copy in go2rtc. If I add audio=opus then it throwing the following error:

[rtsp @ 0x55fdf1c36080] Non-monotonous DTS in output stream 0:2; previous: 117627, current: 116475; changing to 117628. This may result in incorrect timestamps in the output file.

and frigate fails to move it out of /tmp/cache again and it sits there and grows. For now I'm just using aac, but will have to investigate later.

gromero2305 commented 1 year ago

preset-rtsp-generic

just as update. Works as long as audio=copy and video=copy in go2rtc. If I add audio=opus then it throwing the following error:

[rtsp @ 0x55fdf1c36080] Non-monotonous DTS in output stream 0:2; previous: 117627, current: 116475; changing to 117628. This may result in incorrect timestamps in the output file.

and frigate fails to move it out of /tmp/cache again and it sits there and grows. For now I'm just using aac, but will have to investigate later.

Can you please share a copy of your final config? I'm having the same issue not moving files from cache when updating to beta9, I am assuming because of changes is go2rtc 1.2. Timestamp problem makes sense.

dsanner commented 1 year ago

I never really got it working well. Removing #audio=opus helped for my amcrest and reolink on previous beta.

In beta9 it went back to having the growing problem in /tmp/cache for those two cameras.

github-actions[bot] commented 1 year 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.