blakeblackshear / frigate

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

[Config Support]: I would like to integrate my UDP camera into go2rtc #9652

Closed Khangry closed 7 months ago

Khangry commented 7 months ago

Describe the problem you are having

My camera connected normal with frigate, but i want it to connect with go2rtc for low latency restream.

Version

0.13.1-34fb1c2

Frigate config file

mqtt:
  enabled: False
record:
  enabled: True
  retain:
    days: 7
    mode: all
  sync_recordings: True
go2rtc:
  webrtc:
    candidates:
      - stun:8555
      - 192.168.1.1xx:8555
  streams:
    Backyard:
      - rtsp://xxxxxx@192.168.1.1xx:554/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif 
      - "ffmpeg:Backyard#video=h264#audio=opus"
    Backyard-record:
      - rtsp://xxxxxx@192.168.1.1xx:554/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif 
      - "ffmpeg:Backyard-record#video=h265#audio=opus"
cameras:
  Backyard:
    enabled: True
    detect: 
      enabled: False 
    birdseye:
      order: 1
    ffmpeg:
      hwaccel_args: preset-vaapi
      inputs:
        - path: rtsp://127.0.0.1:8554/Backyard
          input_args: preset-rtsp-restream-low-latency
          roles:
            - detect
        - path: rtsp://127.0.0.1:8554/Backyard-record
          input_args: preset-rtsp-restream-low-latency
          roles:
            - record
  Fronyard:
    enabled: True
    detect: 
      enabled: False 
    birdseye:
      order: 2
    ffmpeg:
      hwaccel_args: preset-vaapi
      inputs:
        - path: rtsp://xxxx@192.168.1.101:554/onvif1 #<- I want to make this camera work with go2rtc
          input_args: preset-rtsp-udp
          roles:
            - detect
            - record
birdseye:
  enabled: True
  width: 1280
  height: 720
  mode: continuous
  quality: 8

logger:
  default: info
  logs:
    frigate.event: debug

timestamp_style:
  position: "tl"
  format: "%H:%M:%S %d/%m/%Y"
  color:
    red: 255
    green: 255
    blue: 255
  thickness: 2
  effect: solid
ui:
  live_mode: webrtc
  use_experimental: False
  time_format: browser
  date_style: short
  time_style: short
  strftime_fmt: "%H:%M %d/%m/%Y"

Relevant log output

2024-02-04 22:30:04.936013489  [2024-02-04 22:30:04] watchdog.Fronyard              ERROR   : Ffmpeg process crashed unexpectedly for Fronyard.
2024-02-04 22:30:04.936024624  [2024-02-04 22:30:04] watchdog.Fronyard              ERROR   : The following ffmpeg logs include the last 100 lines prior to exit.
2024-02-04 22:30:04.936030411  [2024-02-04 22:30:04] ffmpeg.Fronyard.detect         ERROR   : [rtsp @ 0x561c68d68100] method DESCRIBE failed: 404 Not Found
2024-02-04 22:30:04.936036593  [2024-02-04 22:30:04] ffmpeg.Fronyard.detect         ERROR   : rtsp://127.0.0.1:8554/Frontyard: Server returned 404 Not Found
2024-02-04 22:30:04.980445762  [2024-02-04 22:30:04] frigate.video                  ERROR   : Fronyard: Unable to read frames from ffmpeg process.
2024-02-04 22:30:04.981185641  [2024-02-04 22:30:04] frigate.video                  ERROR   : Fronyard: ffmpeg process is not running. exiting capture thread...
2024-02-04 22:30:14.964977487  [2024-02-04 22:30:14] watchdog.Fronyard              ERROR   : Ffmpeg process crashed unexpectedly for Fronyard.
2024-02-04 22:30:14.966120556  [2024-02-04 22:30:14] watchdog.Fronyard              ERROR   : The following ffmpeg logs include the last 100 lines prior to exit.
2024-02-04 22:30:14.966129974  [2024-02-04 22:30:14] ffmpeg.Fronyard.detect         ERROR   : [rtsp @ 0x55e58e4da100] method DESCRIBE failed: 404 Not Found
2024-02-04 22:30:14.966136200  [2024-02-04 22:30:14] ffmpeg.Fronyard.detect         ERROR   : rtsp://127.0.0.1:8554/Frontyard: Server returned 404 Not Found
2024-02-04 22:30:15.009987204  [2024-02-04 22:30:15] frigate.video                  ERROR   : Fronyard: Unable to read frames from ffmpeg process.
2024-02-04 22:30:15.010564694  [2024-02-04 22:30:15] frigate.video                  ERROR   : Fronyard: ffmpeg process is not running. exiting capture thread...

Frigate stats

{
    "cameras": {
        "Backyard": {
            "audio_dBFS": 0,
            "audio_rms": 0,
            "camera_fps": 5.1,
            "capture_pid": 247,
            "detection_enabled": 0,
            "detection_fps": 0,
            "ffmpeg_pid": 264,
            "pid": 243,
            "process_fps": 5.1,
            "skipped_fps": 0
        },
        "Fronyard": {
            "audio_dBFS": 0,
            "audio_rms": 0,
            "camera_fps": 5,
            "capture_pid": 251,
            "detection_enabled": 0,
            "detection_fps": 0,
            "ffmpeg_pid": 305,
            "pid": 244,
            "process_fps": 5,
            "skipped_fps": 0
        }
    },
    "cpu_usages": {
        "1": {
            "cmdline": "/package/admin/s6/command/s6-svscan -d4 -- /run/service",
            "cpu": "0.0",
            "cpu_average": "0",
            "mem": "0.0"
        },
        "16": {
            "cmdline": "s6-supervise s6-linux-init-shutdownd",
            "cpu": "0.0",
            "cpu_average": "0",
            "mem": "0.0"
        },
        "17": {
            "cmdline": "/package/admin/s6-linux-init/command/s6-linux-init-shutdownd -c /run/s6/basedir -g 3000 -C -B",
            "cpu": "0.0",
            "cpu_average": "0",
            "mem": "0.0"
        },
        "25": {
            "cmdline": "s6-supervise s6rc-fdholder",
            "cpu": "0.0",
            "cpu_average": "0",
            "mem": "0.0"
        },
        "26": {
            "cmdline": "s6-supervise go2rtc-log",
            "cpu": "0.0",
            "cpu_average": "0",
            "mem": "0.0"
        },
        "27": {
            "cmdline": "s6-supervise frigate-log",
            "cpu": "0.0",
            "cpu_average": "0",
            "mem": "0.0"
        },
        "28": {
            "cmdline": "s6-supervise frigate",
            "cpu": "0.0",
            "cpu_average": "0",
            "mem": "0.0"
        },
        "29": {
            "cmdline": "s6-supervise s6rc-oneshot-runner",
            "cpu": "0.0",
            "cpu_average": "0",
            "mem": "0.0"
        },
        "30": {
            "cmdline": "s6-supervise nginx-log",
            "cpu": "0.0",
            "cpu_average": "0",
            "mem": "0.0"
        },
        "31": {
            "cmdline": "s6-supervise nginx",
            "cpu": "0.0",
            "cpu_average": "0",
            "mem": "0.0"
        },
        "32": {
            "cmdline": "s6-supervise go2rtc-healthcheck",
            "cpu": "0.0",
            "cpu_average": "0",
            "mem": "0.0"
        },
        "33": {
            "cmdline": "s6-supervise go2rtc",
            "cpu": "0.0",
            "cpu_average": "0",
            "mem": "0.0"
        },
        "42": {
            "cmdline": "/package/admin/s6-2.11.3.2/command/s6-fdholderd -1 -i data/rules",
            "cpu": "0.0",
            "cpu_average": "0",
            "mem": "0.0"
        },
        "43": {
            "cmdline": "/package/admin/s6/command/s6-ipcserverd -1 -- /package/admin/s6/command/s6-ipcserver-access -v0 -E -l0 -i data/rules -- /package/admin/s6/command/s6-sudod -t 30000 -- /package/admin/s6-rc/command/s6-rc-oneshot-run -l ../.. --",
            "cpu": "0.0",
            "cpu_average": "0",
            "mem": "0.0"
        },
        "79": {
            "cmdline": "s6-log -b -- T 1 n0 s10000000 T /dev/shm/logs/nginx",
            "cpu": "0.0",
            "cpu_average": "0",
            "mem": "0.0"
        },
        "82": {
            "cmdline": "s6-log -b -- T 1 n0 s10000000 T /dev/shm/logs/go2rtc",
            "cpu": "0.0",
            "cpu_average": "0",
            "mem": "0.0"
        },
        "83": {
            "cmdline": "s6-log -b -- T 1 n0 s10000000 T /dev/shm/logs/frigate",
            "cpu": "0.0",
            "cpu_average": "0",
            "mem": "0.0"
        },
        "94": {
            "cmdline": "/usr/local/go2rtc/bin/go2rtc -config=/dev/shm/go2rtc.yaml",
            "cpu": "1.6",
            "cpu_average": "1",
            "mem": "0.3"
        },
        "112": {
            "cmdline": "bash ./run.user go2rtc-healthcheck",
            "cpu": "0.0",
            "cpu_average": "0",
            "mem": "0.0"
        },
        "114": {
            "cmdline": "python3 -u -m frigate",
            "cpu": "1.5",
            "cpu_average": "1",
            "mem": "2.8"
        },
        "123": {
            "cmdline": "nginx: master process nginx",
            "cpu": "0.0",
            "cpu_average": "0",
            "mem": "0.2"
        },
        "138": {
            "cmdline": "nginx: worker process",
            "cpu": "0.0",
            "cpu_average": "0",
            "mem": "0.1"
        },
        "139": {
            "cmdline": "nginx: worker process",
            "cpu": "0.0",
            "cpu_average": "0",
            "mem": "0.1"
        },
        "140": {
            "cmdline": "nginx: cache manager process",
            "cpu": "0.0",
            "cpu_average": "0",
            "mem": "0.1"
        },
        "223": {
            "cmdline": "frigate.logger       ",
            "cpu": "0.0",
            "cpu_average": "0",
            "mem": "1.3"
        },
        "227": {
            "cmdline": "frigate.recording_manager",
            "cpu": "0.5",
            "cpu_average": "0",
            "mem": "1.6"
        },
        "235": {
            "cmdline": "/usr/bin/python3 -c from multiprocessing.resource_tracker import main;main(42)",
            "cpu": "0.2",
            "cpu_average": "0",
            "mem": "0.1"
        },
        "236": {
            "cmdline": "frigate.detector.cpu ",
            "cpu": "0.0",
            "cpu_average": "0",
            "mem": "1.5"
        },
        "237": {
            "cmdline": "frigate.output       ",
            "cpu": "1.5",
            "cpu_average": "1",
            "mem": "1.6"
        },
        "241": {
            "cmdline": "ffmpeg -f rawvideo -pix_fmt yuv420p -video_size 1920x1080 -i pipe: -f mpegts -s 1280x720 -codec:v mpeg1video -q 8 -bf 0 pipe:",
            "cpu": "0.0",
            "cpu_average": "0",
            "mem": "0.3"
        },
        "243": {
            "cmdline": "frigate.process:Backyard",
            "cpu": "2.5",
            "cpu_average": "2",
            "mem": "1.5"
        },
        "244": {
            "cmdline": "frigate.process:Fronyard",
            "cpu": "2.2",
            "cpu_average": "1",
            "mem": "1.5"
        },
        "246": {
            "cmdline": "ffmpeg -f rawvideo -pix_fmt yuv420p -video_size 1280x720 -i pipe: -f mpegts -s 1280x720 -codec:v mpeg1video -q 8 -bf 0 pipe:",
            "cpu": "0.0",
            "cpu_average": "0",
            "mem": "0.6"
        },
        "247": {
            "cmdline": "frigate.capture:Backyard",
            "cpu": "6.9",
            "cpu_average": "6",
            "mem": "1.5"
        },
        "249": {
            "cmdline": "ffmpeg -f rawvideo -pix_fmt yuv420p -video_size 1280x720 -i pipe: -f mpegts -s 1280x720 -codec:v mpeg1video -q 8 -bf 0 pipe:",
            "cpu": "0.0",
            "cpu_average": "0",
            "mem": "0.2"
        },
        "251": {
            "cmdline": "frigate.capture:Fronyard",
            "cpu": "2.9",
            "cpu_average": "2",
            "mem": "1.5"
        },
        "264": {
            "cmdline": "ffmpeg -hide_banner -loglevel warning -threads 2 -hwaccel_flags allow_profile_mismatch -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format vaapi -user_agent FFmpeg Frigate/0.13.1-34fb1c2 -rtsp_transport tcp -timeout 5000000 -fflags nobuffer -flags low_delay -i rtsp://127.0.0.1:8554/Backyard -r 5 -vf fps=5,scale_vaapi=w=1920:h=1080:format=nv12,hwdownload,format=nv12,format=yuv420p -threads 2 -f rawvideo -pix_fmt yuv420p pipe:",
            "cpu": "11.3",
            "cpu_average": "10",
            "mem": "1.0"
        },
        "268": {
            "cmdline": "ffmpeg -hide_banner -loglevel warning -threads 2 -hwaccel_flags allow_profile_mismatch -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format vaapi -user_agent FFmpeg Frigate/0.13.1-34fb1c2 -rtsp_transport tcp -timeout 5000000 -fflags nobuffer -flags low_delay -i rtsp://127.0.0.1:8554/Backyard-record -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c copy -an /tmp/cache/Backyard@%Y%m%d%H%M%S%z.mp4",
            "cpu": "0.5",
            "cpu_average": "0",
            "mem": "0.3"
        },
        "305": {
            "cmdline": "ffmpeg -hide_banner -loglevel warning -threads 2 -hwaccel_flags allow_profile_mismatch -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format vaapi -user_agent FFmpeg Frigate/0.13.1-34fb1c2 -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -rtsp_transport udp -timeout 5000000 -use_wallclock_as_timestamps 1 -i rtsp://*:*@192.168.1.101:554/onvif1 -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c copy -an /tmp/cache/Fronyard@%Y%m%d%H%M%S%z.mp4 -r 5 -vf fps=5,scale_vaapi=w=1280:h=720:format=nv12,hwdownload,format=nv12,format=yuv420p -threads 2 -f rawvideo -pix_fmt yuv420p pipe:",
            "cpu": "4.2",
            "cpu_average": "4",
            "mem": "1.1"
        },
        "1069": {
            "cmdline": "sleep 30s",
            "cpu": "0.0",
            "cpu_average": "0",
            "mem": "0.0"
        }
    },
    "detection_fps": 0,
    "detectors": {
        "cpu": {
            "detection_start": 0,
            "inference_speed": 10,
            "pid": 236
        }
    },
    "gpu_usages": {
        "intel-vaapi": {
            "gpu": "2.49%",
            "mem": "-%"
        }
    },
    "processes": {
        "go2rtc": {
            "pid": 94
        },
        "logger": {
            "pid": 223
        },
        "recording": {
            "pid": 227
        }
    },
    "service": {
        "last_updated": 1707061208,
        "latest_version": "0.13.1",
        "storage": {
            "/dev/shm": {
                "free": 94.9,
                "mount_type": "tmpfs",
                "total": 100,
                "used": 5.1
            },
            "/media/frigate/clips": {
                "free": 533052,
                "mount_type": "fuse.mergerfs",
                "total": 1371354.1,
                "used": 815497.6
            },
            "/media/frigate/recordings": {
                "free": 533052,
                "mount_type": "fuse.mergerfs",
                "total": 1371354.1,
                "used": 815497.6
            },
            "/tmp/cache": {
                "free": 953.1,
                "mount_type": "tmpfs",
                "total": 953.7,
                "used": 0.6
            }
        },
        "temperatures": {},
        "uptime": 539,
        "version": "0.13.1-34fb1c2"
    }
}

Operating system

Debian

Install method

Docker Compose

Coral version

CPU (no coral)

Any other information that may be helpful

No response

NickM-27 commented 7 months ago

if you are going to use UDP then you must use ffmpeg in the go2rtc config

Khangry commented 7 months ago

if you are going to use UDP then you must use ffmpeg in the go2rtc config

Any examples for that, I'm stuck with this for an hour. =(

NickM-27 commented 7 months ago

"ffmpeg:rtsp://xxxxxx@192.168.1.1xx:554/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif#input=rtsp/udp"

Khangry commented 7 months ago

"ffmpeg:rtsp://xxxxxx@192.168.1.1xx:554/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif#input=rtsp/udp"

go2rtc:
  webrtc:
    candidates:
      - stun:8555
      - 192.168.1.1xx:8555
  streams:
    Frontyard:
      - "ffmpeg:rtsp://xxx:xxx@192.168.1.101:554/onvif1#input=rtsp/udp#video=h264#audio=opus"
cameras:
  Fronyard:
    enabled: True
    detect: 
      enabled: False 
    birdseye:
      order: 2
    ffmpeg:
      hwaccel_args: preset-vaapi
      inputs:
        - path: rtsp://127.0.0.1:8554/Frontyard
          input_args: preset-rtsp-restream-low-latency
          roles:
            - detect
            - record

I changed my config like above and seem like go2rtc worked, but i can't see webrtc or mse option on web ui. NVM, it worked now.

Khangry commented 7 months ago

Nvm, it suddenly worked now, thanks for help me