AlexxIT / go2rtc

Ultimate camera streaming application with support RTSP, RTMP, HTTP-FLV, WebRTC, MSE, HLS, MP4, MJPEG, HomeKit, FFmpeg, etc.
https://github.com/AlexxIT/Blog
MIT License
6.84k stars 486 forks source link

Adding RTSP to HomeKit #1140

Closed shadowgrapher closed 5 months ago

shadowgrapher commented 5 months ago

Running 1.8.5-4 as a package on Synology (latest build from SynoCommunity) go2rtc.yaml:

api:
  listen: ":1984"
  username: username
  password: password

log:
  format: "text"
  level: "debug"
  homekit: "debug"
  rtsp: "debug"
  streams: "debug"

rtsp:
  listen: ":8554"

srtp:
  # force use of ipv4
  listen: "0.0.0.0:18443"

#webrtc:
  listen: ":8555"

streams:
  orangery: rtsp://10.0.1.10:5544/live0.264

homekit:
  orangery:                   # same stream ID from streams list

image

camera and syno sharing same network 10.0.1.* Home.app discovers go2rtc-3f6D accessory but stuck on adding.

IMG_1994 IMG_1995 logs:

Time    Level   Message
26.05.2024, 16:24:07    info    go2rtc version 1.8.5 linux/arm
26.05.2024, 16:24:07    info    [api] listen addr=:1984
26.05.2024, 16:24:07    info    [rtsp] listen addr=:8554
26.05.2024, 16:24:07    info    [webrtc] listen addr=:8555
26.05.2024, 16:24:07    debug   [hass] can't import config: open .storage/core.config_entries: no such file or directory

Note I'm not using HomeAssistant

What I am missing in config, any thoughts?

AlexxIT commented 5 months ago

Your problem is username/password for api module. It's breaking HomeKit. It will be fixed someday.

shadowgrapher commented 5 months ago

Got it. As a temporary workaround removed credentials and successfully added to Home.app But there is no stream from camera, meanwhile rtsp://10.0.1.10:5544/live0.264 can be viewed in VLC and Syno Surveillance

26.05.2024, 17:03:38 debug [streams] can't stop none producer

UPDATE: added credentials to RTSP stream and fixed problem.

shadowgrapher commented 5 months ago

Can't get audio from camera to HomeKit. My camera used 711 codec (VLC says PCM 8000) But it seems transcoding to opus on the fly in config needs something more than this?

streams:
  orangery:
  - rtsp://user:pass@10.0.1.10:5544/live0.264
  - ffmpeg:orangery#audio=opus`
{
  "producers": [
    {
      "type": "RTSP active producer",
      "url": "rtsp://10.0.1.10:5544/live0.264/",
      "remote_addr": "10.0.1.10:5544",
      "user_agent": "go2rtc/1.8.5",
      "sdp": "v=0\r\no=- 1262591058 1 IN IP4 10.0.1.10\r\ns=Session Streamed by LIBZRTSP\r\ni=live0.264\r\nt=0 0\r\na=tool:LIBZRTSPD v1/0.3\r\nm=video 0 RTP/AVP 96\r\nc=IN IP4 10.0.1.10\r\nb=AS:2\r\na=rtpmap:96 H264/90000\r\na=fmtp:96 packetization-mode=1;profile-level-id=64002A;sprop-parameter-sets=Z2QAKq2EAQwgCGEAQwgCGEAQwgCEO1A8ARPyzcBAQARo,aO48sA==\r\na=control:track1\r\nm=audio 0 RTP/AVP 0\r\nc=IN IP4 0.0.0.0\r\nb=AS:64\r\na=rtpmap:0 PCMU/8000\r\na=control:track2\r\n",
      "medias": [
        "video, recvonly, H.264 High 4.2",
        "audio, recvonly, PCMU/8000"
      ],
      "receivers": [
        "96 H264, bytes=0, senders=1"
      ]
    },
    {
      "url": "ffmpeg:orangery#audio=opus"
    }
  ],
  "consumers": [
    {
      "type": "HomeKit passive consumer",
      "remote_addr": "10.0.1.3:50389",
      "sdp": "{CodecType:0 CodecParams:[{ProfileID:[1] Level:[2] PacketizationMode:0 CVOEnabled:[] CVOID:[]}] VideoAttrs:[{Width:1280 Height:720 Framerate:30}] RTPParams:[{PayloadType:99 SSRC:3619404824 MaxBitrate:299 RTCPInterval:0.5 MaxMTU:[1378] ComfortNoisePayloadType:[]}]}\n{CodecType:3 CodecParams:[{Channels:1 Bitrate:0 SampleRate:[1] RTPTime:[20]}] RTPParams:[{PayloadType:110 SSRC:4240356936 MaxBitrate:24 RTCPInterval:5 MaxMTU:[] ComfortNoisePayloadType:[13]}] ComfortNoise:[0]}",
      "medias": [
        "video, sendonly, H264",
        "audio, sendonly, OPUS"
      ],
      "senders": [
        "96 H264, bytes=329219, receivers=1"
      ],
      "send": 334912
    }
  ]
}

my ffmpeg version installed on Syno is 4.1.8: log

Time    Level   Message
26.05.2024, 18:14:18    info    go2rtc version 1.8.5 linux/arm
26.05.2024, 18:14:18    info    [rtsp] listen addr=:8554
26.05.2024, 18:14:18    info    [webrtc] listen addr=:8555
26.05.2024, 18:14:18    debug   [hass] can't import config: open .storage/core.config_entries: no such file or directory
26.05.2024, 18:14:18    info    [api] listen addr=:1984
26.05.2024, 18:14:29    debug   [streams] can't stop none producer
26.05.2024, 18:14:29    debug   [streams] start producer url=rtsp://user:pass@10.0.1.10:5544/live0.264
26.05.2024, 18:14:29    debug   [streams] stop producer url=rtsp://user:pass@10.0.1.10:5544/live0.264
26.05.2024, 18:14:29    debug   [streams] can't stop none producer
26.05.2024, 18:14:31    debug   [exec] run url=exec:ffmpeg -hide_banner -v error -fflags nobuffer -flags low_delay -timeout 5000000 -user_agent go2rtc/ffmpeg -rtsp_flags prefer_tcp -i rtsp://127.0.0.1:8554/orangery?audio -c:a libopus -application:a lowdelay -min_comp 0 -vn -user_agent ffmpeg/go2rtc -rtsp_transport tcp -f rtsp {output}
26.05.2024, 18:14:31    debug   [streams] can't stop none producer
26.05.2024, 18:14:31    debug   [streams] start producer url=rtsp://user:pass@10.0.1.10:5544/live0.264
26.05.2024, 18:14:32    warn    undefined error=EOF url=rtsp://user:pass@10.0.1.10:5544/live0.264 caller=github.com/AlexxIT/go2rtc/internal/streams/producer.go:171
26.05.2024, 18:14:32    debug   [streams] retry=0 to url=rtsp://user:pass@10.0.1.10:5544/live0.264
26.05.2024, 18:14:34    debug   [streams] stop producer url=rtsp://user:pass@10.0.1.10:5544/live0.264

with

streams:
  orangery: ffmpeg:rtsp://user:pass@10.0.1.10:5544/live0.264#video=copy#audio=opus 

camera stop streaming to HK

AlexxIT commented 5 months ago

FFmpeg 4 not supported

shadowgrapher commented 5 months ago

What version should I use? Downgrade or upgrade to ...?

UPDATE: done with ffmpeg 6.