blakeblackshear / frigate

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

[Support]: go2RTC not able to use Scrypted rebroadcast stream #8878

Closed t0ny-peng closed 11 months ago

t0ny-peng commented 11 months ago

Describe the problem you are having

I'm using Scrypted as the main "Receiver" of the camera stream, and rebroadcast it to be used by Frigate go2rtc setup, to save bandwidth from the cameras. However, go2rtc is not able to use the rtsp stream provided by Scrypted.

The rebroadcast RTSP stream URL is rtsp://10.0.0.2:37379/b3aa516a03a5a8b9, which can be opened by VLC on my laptop.

Version

0.12.1-367d724

Frigate config file

detectors:
  coral:
    type: edgetpu
    device: pci

detect:
  fps: 5
  enabled: True
  stationary:
    interval: 128

objects:
  track:
    - person
    - cat

birdseye:
  mode: objects

rtmp:
  enabled: False

ffmpeg:
  hwaccel_args: preset-vaapi

record:
  enabled: True
  retain:
    days: 15
    mode: motion
  events:
    retain:
      default: 30
      mode: active_objects

snapshots:
  enabled: True
  timestamp: True
  bounding_box: True

go2rtc:
  streams:
    Living_Room:
      - rtsp://10.0.0.2:41191/70dfb386e3d5ddce
    Backyard_1:
      - rtsp://10.0.0.2:37379/b3aa516a03a5a8b9
    Backyard_2:
      - rtsp://10.0.0.2:46179/c87906b1b941a6bc
    Front_Door:
      - rtsp://10.0.0.2:39735/1cb7b361dabc365f
  webrtc:
    candidates:
      - 10.0.0.2:8555
      - stun:8555

Relevant log output

2023-12-07 00:34:16.019886824  [2023-12-07 00:34:16] frigate.app                    INFO    : Starting Frigate (0.12.1-367d724)
2023-12-07 00:34:16.070038056  [2023-12-07 00:34:16] peewee_migrate                 INFO    : Starting migrations
2023-12-07 00:34:16.088238133  [2023-12-07 00:34:16] peewee_migrate                 INFO    : There is nothing to migrate
2023-12-07 00:34:16.105680307  [2023-12-07 00:34:16] detector.coral                 INFO    : Starting detection process: 434
2023-12-07 00:34:16.113507296  [2023-12-07 00:34:16] frigate.app                    INFO    : Output process started: 436
2023-12-07 00:34:16.135218672  [2023-12-07 00:34:16] frigate.app                    INFO    : Camera processor started for Front_Door: 442
2023-12-07 00:34:16.136078152  [2023-12-07 00:34:16] frigate.app                    INFO    : Camera processor started for Living_Room: 443
2023-12-07 00:34:16.151386053  [2023-12-07 00:34:16] frigate.app                    INFO    : Camera processor started for Backyard_1: 444
2023-12-07 00:34:16.170543991  [2023-12-07 00:34:16] frigate.app                    INFO    : Camera processor started for Backyard_2: 445
2023-12-07 00:34:16.183035994  [2023-12-07 00:34:16] frigate.detectors.plugins.edgetpu_tfl INFO    : Attempting to load TPU as pci
2023-12-07 00:34:16.198254329  [2023-12-07 00:34:16] frigate.app                    INFO    : Capture process started for Front_Door: 447
2023-12-07 00:34:16.211307063  [2023-12-07 00:34:16] frigate.app                    INFO    : Capture process started for Living_Room: 461
2023-12-07 00:34:16.216213657  [2023-12-07 00:34:16] frigate.app                    INFO    : Capture process started for Backyard_1: 464
2023-12-07 00:34:16.234346493  [2023-12-07 00:34:16] frigate.app                    INFO    : Capture process started for Backyard_2: 467
2023-12-07 00:34:16.243899548  [2023-12-07 00:34:16] frigate.detectors.plugins.edgetpu_tfl INFO    : TPU found
2023-12-07 00:34:16.339877956  00:34:16.337 ERR github.com/AlexxIT/go2rtc/cmd/streams/producer.go:53 > error=EOF url=rtsp://10.0.0.2:39735/1cb7b361dabc365f
2023-12-07 00:34:16.350915395  00:34:16.350 ERR github.com/AlexxIT/go2rtc/cmd/streams/producer.go:53 > error=EOF url=rtsp://10.0.0.2:39735/1cb7b361dabc365f
2023-12-07 00:34:16.350924243  00:34:16.350 WRN [rtsp] error="source 0 error: EOF" stream=Front_Door
2023-12-07 00:34:16.430871186  00:34:16.428 ERR github.com/AlexxIT/go2rtc/cmd/streams/producer.go:53 > error=EOF url=rtsp://10.0.0.2:37379/b3aa516a03a5a8b9
2023-12-07 00:34:16.430883100  00:34:16.429 ERR github.com/AlexxIT/go2rtc/cmd/streams/producer.go:53 > error=EOF url=rtsp://10.0.0.2:41191/70dfb386e3d5ddce
2023-12-07 00:34:16.473290469  00:34:16.472 ERR github.com/AlexxIT/go2rtc/cmd/streams/producer.go:53 > error=EOF url=rtsp://10.0.0.2:37379/b3aa516a03a5a8b9

FFprobe output from your camera

ffprobe version n5.1-2-g915ef932a3-20220731 Copyright (c) 2007-2022 the FFmpeg developers
  built with gcc 12.1.0 (crosstool-NG 1.25.0.55_3defb7b)
  configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-ffbuild-linux-gnu- --arch=x86_64 --target-os=linux --enable-gpl --enable-version3 --disable-debug --enable-iconv --enable-libxml2 --enable-zlib --enable-libfreetype --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-libvorbis --enable-opencl --enable-libpulse --enable-libvmaf --enable-libxcb --enable-xlib --enable-amf --enable-libaom --enable-libaribb24 --enable-avisynth --enable-libdav1d --enable-libdavs2 --disable-libfdk-aac --enable-ffnvcodec --enable-cuda-llvm --enable-frei0r --enable-libgme --enable-libass --enable-libbluray --enable-libjxl --enable-libmp3lame --enable-libopus --enable-mbedtls --enable-librist --enable-libtheora --enable-libvpx --enable-libwebp --enable-lv2 --enable-libmfx --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopenmpt --enable-librav1e --enable-librubberband --disable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libsvtav1 --enable-libtwolame --enable-libuavs3d --enable-libdrm --enable-vaapi --enable-libvidstab --enable-vulkan --enable-libshaderc --enable-libplacebo --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --enable-libzvbi --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-ldexeflags=-pie --extra-libs='-ldl -lgomp' --extra-version=20220731
  libavutil      57. 28.100 / 57. 28.100
  libavcodec     59. 37.100 / 59. 37.100
  libavformat    59. 27.100 / 59. 27.100
  libavdevice    59.  7.100 / 59.  7.100
  libavfilter     8. 44.100 /  8. 44.100
  libswscale      6.  7.100 /  6.  7.100
  libswresample   4.  7.100 /  4.  7.100
  libpostproc    56.  6.100 / 56.  6.100
[rtsp @ 0x562cd1ad1140] method SETUP failed: 461 Unsupported Transport.  ❌❌ This seems to be the actually reason
Input #0, rtsp, from 'rtsp://10.0.0.2:41191/70dfb386e3d5ddce':
  Metadata:
    title           : Session streamed by "TP-LINK RTSP Server"
    comment         : stream2
  Duration: N/A, start: 0.000000, bitrate: N/A
  Stream #0:0: Video: h264 (Main), yuv420p(progressive), 2304x1296, 15 fps, 19.92 tbr, 90k tbn
  Stream #0:1: Audio: pcm_alaw, 8000 Hz, mono, s16, 64 kb/s

Frigate stats

No response

Operating system

Proxmox

Install method

Docker Compose

Coral version

PCIe

Network connection

Wired

Camera make and model

Tplink C210

Any other information that may be helpful

No response

t0ny-peng commented 11 months ago

From this issue, it seems I should add -rtsp_transport tcp to ffprobe and that does give me the correct info:

$ ffprobe -rtsp_transport tcp rtsp://10.0.0.2:41191/70dfb386e3d5ddce
ffprobe version 6.0 Copyright (c) 2007-2023 the FFmpeg developers
  built with Apple clang version 14.0.3 (clang-1403.0.22.14.1)
  configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/6.0_1 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libaribb24 --enable-libbluray --enable-libdav1d --enable-libjxl --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libsvtav1 --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox --enable-audiotoolbox --enable-neon
  libavutil      58.  2.100 / 58.  2.100
  libavcodec     60.  3.100 / 60.  3.100
  libavformat    60.  3.100 / 60.  3.100
  libavdevice    60.  1.100 / 60.  1.100
  libavfilter     9.  3.100 /  9.  3.100
  libswscale      7.  1.100 /  7.  1.100
  libswresample   4. 10.100 /  4. 10.100
  libpostproc    57.  1.100 / 57.  1.100
Input #0, rtsp, from 'rtsp://10.0.0.2:41191/70dfb386e3d5ddce':
  Metadata:
    title           : Session streamed by "TP-LINK RTSP Server"
    comment         : stream2
  Duration: N/A, start: 0.000000, bitrate: N/A
  Stream #0:0: Video: h264 (Main), yuv420p(progressive), 2304x1296, 15 fps, 20 tbr, 90k tbn
  Stream #0:1: Audio: pcm_alaw, 8000 Hz, mono, s16, 64 kb/s

I'm not sure if this is the reason, since ffmpeg -i rtsp://10.0.0.2:41191/70dfb386e3d5ddce -y video.jpg can still get the stream into picture.

However, updating the go2rtc config like this doesn't help and generate similar error:

go2rtc:
  streams:
    Living_Room:
      - ffmpeg:rtsp://rtsp:10.0.0.2:41191/70dfb386e3d5ddce#rtsp_transport=tcp
    Backyard_1:
      - ffmpeg:rtsp://rtsp:10.0.0.2:37379/b3aa516a03a5a8b9#rtsp_transport=tcp
    Backyard_2:
      - ffmpeg:rtsp://rtsp:10.0.0.2:46179/c87906b1b941a6bc#rtsp_transport=tcp
    Front_Door:
      - ffmpeg:rtsp://rtsp:10.0.0.2:39735/1cb7b361dabc365f#rtsp_transport=tcp
  webrtc:
    candidates:
      - 10.0.0.2:8555
      - stun:8555
2023-12-07 00:55:26.894895208  00:55:26.894 ERR github.com/AlexxIT/go2rtc/cmd/streams/producer.go:53 > error="exec: exit status 1" url=ffmpeg:rtsp://rtsp:10.0.0.2:37379/b3aa516a03a5a8b9#rtsp_transport=tcp
2023-12-07 00:55:26.899330576  00:55:26.899 ERR github.com/AlexxIT/go2rtc/cmd/streams/producer.go:53 > error="exec: exit status 1" url=ffmpeg:rtsp://rtsp:10.0.0.2:39735/1cb7b361dabc365f#rtsp_transport=tcp
2023-12-07 00:55:26.899337483  00:55:26.899 ERR github.com/AlexxIT/go2rtc/cmd/streams/producer.go:53 > error="exec: exit status 1" url=ffmpeg:rtsp://rtsp:10.0.0.2:41191/70dfb386e3d5ddce#rtsp_transport=tcp
2023-12-07 00:55:26.915116143  00:55:26.915 ERR github.com/AlexxIT/go2rtc/cmd/streams/producer.go:53 > error="exec: exit status 1" url=ffmpeg:rtsp://rtsp:10.0.0.2:39735/1cb7b361dabc365f#rtsp_transport=tcp
NickM-27 commented 11 months ago

I believe this has already been fixed and go2rtc just needs to be updated https://docs.frigate.video/configuration/advanced#custom-go2rtc-version

t0ny-peng commented 11 months ago

Hi Nick. Thanks for the reply. I downloaded the new go2rtc 1.8.4 and made sure it's used by Frigate. However I'm still seeing the exec: exit status 1 error. IIUC, go2rtc is doing fork and exec ffmpeg to receive the stream data, and it does not work well with the Scrypted stream. Do you know if there a way to turn on verbose error message? Otherwise, the only error information is the return code 1. Thanks!

Btw, I can use rtsp://10.0.0.2:41191/70dfb386e3d5ddce in the inputs of the camera without any problem, but then I cannot use the Frigate lovelace card with go2rtc provider to get the lowest latency

go2rtc:
  streams:
    Living_Room:
      - rtsp://rtsp:10.0.0.2:41191/70dfb386e3d5ddce#rtsp_transport=tcp
    Backyard_1:
      - rtsp://rtsp:10.0.0.2:37379/b3aa516a03a5a8b9#rtsp_transport=tcp
    Backyard_2:
      - rtsp://rtsp:10.0.0.2:46179/c87906b1b941a6bc#rtsp_transport=tcp
    Front_Door:
      - rtsp://rtsp:10.0.0.2:39735/1cb7b361dabc365f#rtsp_transport=tcp
  webrtc:
    candidates:
      - 10.0.0.2:8555
      - stun:8555
NickM-27 commented 11 months ago

you can enable

go2rtc:
  log:
    exec: trace

to get more info

t0ny-peng commented 11 months ago

As I poke around, it seems that go2rtc does not play well with the rebroadcast Tapo camera streams, while it's perfectly fine with my old Amcrest PoE camera.

Related Frigate error that the go2rtc server returns 404 for Tapo cameras.

2023-12-08 10:54:38.007822881  [2023-12-08 10:54:38] ffmpeg.Front_Door.record       ERROR   : [rtsp @ 0x55f4d40ce0c0] method DESCRIBE failed: 404 Not Found
2023-12-08 10:54:38.007876693  [2023-12-08 10:54:38] ffmpeg.Front_Door.record       ERROR   : rtsp://127.0.0.1:8554/Front_Door: Server returned 404 Not Found
2023-12-08 10:54:38.007932189  [2023-12-08 10:54:38] watchdog.Front_Door            INFO    : Terminating the existing ffmpeg process...
2023-12-08 10:54:38.007976432  [2023-12-08 10:54:38] watchdog.Front_Door            INFO    : Waiting for ffmpeg to exit gracefully...
2023-12-08 10:54:38.024870985  10:54:38.024 WRN [rtsp] error="streams: EOF" stream=Front_Door
2023-12-08 10:54:38.051949321  [2023-12-08 10:54:38] ffmpeg.Backyard_1.record       ERROR   : [rtsp @ 0x55a73b6250c0] method DESCRIBE failed: 404 Not Found
2023-12-08 10:54:38.052036410  [2023-12-08 10:54:38] ffmpeg.Backyard_1.record       ERROR   : rtsp://127.0.0.1:8554/Backyard_1: Server returned 404 Not Found
2023-12-08 10:54:38.052094202  [2023-12-08 10:54:38] watchdog.Backyard_1            INFO    : Terminating the existing ffmpeg process...
2023-12-08 10:54:38.052147494  [2023-12-08 10:54:38] watchdog.Backyard_1            INFO    : Waiting for ffmpeg to exit gracefully...
2023-12-08 10:54:38.065552987  10:54:38.065 WRN [rtsp] error="streams: EOF" stream=Backyard_1
2023-12-08 10:54:38.067589785  [2023-12-08 10:54:38] ffmpeg.Living_Room.record      ERROR   : [rtsp @ 0x55b0a65a30c0] method DESCRIBE failed: 404 Not Found
2023-12-08 10:54:38.067678648  [2023-12-08 10:54:38] ffmpeg.Living_Room.record      ERROR   : rtsp://127.0.0.1:8554/Living_Room: Server returned 404 Not Found
2023-12-08 10:54:38.067754521  [2023-12-08 10:54:38] watchdog.Living_Room           INFO    : Terminating the existing ffmpeg process...
2023-12-08 10:54:38.067824259  [2023-12-08 10:54:38] watchdog.Living_Room           INFO    : Waiting for ffmpeg to exit gracefully...

Related go2rtc error:

10:55:05.947 ERR github.com/AlexxIT/go2rtc/internal/mjpeg/init.go:166 > error="streams: EOF"
10:55:08.048 WRN [rtsp] error="streams: EOF" stream=Front_Door
10:55:08.092 WRN [rtsp] error="streams: EOF" stream=Backyard_1

The solution I found, though seeming completely unrelated, is to set the RTSP Parser in the camera stream page to FFmpeg(UDP), albeit already said to be the default option.

Closing this ticket now as it's solved.