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
4.06k stars 323 forks source link

No audio on Webrtc card and HomeKit despite being present on go2rtc interface and Frigate #1244

Open IliasEagle opened 1 month ago

IliasEagle commented 1 month ago

Hello!

with the following go2rtc configuration for a RLC-520A Reolink camera

  Living Room: 
    - rtsp://user:pass@192.168.1.114:554/h264Preview_01_main 
    - ffmpeg:Living Room#audio=opus

when I open the camera stream via the go2rtc dashboard

image

I can hear the audio which is also seen below image

When use the webrtc card though there is no audio as can be seen below

image

Below is the webrtc card config

type: custom:webrtc-camera
ui: true
style: '.screenshot {display: none}'
shortcuts:
  - name: Central
    icon: mdi:light-switch
    service: light.toggle
    service_data:
      entity_id: light.lounge_central
streams:
  - url: Living Room
    name: Lounge
    mode: webrtc
    media: video,audio
  - url: ''
    name: Poster

The same applies when trying to view the camera via HomeKit image


This issue is not unique to the aforementioned Reolink camera. The same applies to the Eufy Solo IndoorCam C24, 2K Also, if a camera is recorded by Frigate audio is passed to it as expected. So the issue seems to appear only on webrtc card

dagleaves commented 1 month ago

Check your logs, it seems like the ffmpeg producer fails to start or dies. With MSE/FMP4, it is using the AAC audio. The OPUS audio is never sent.

AlexxIT commented 1 month ago

I have this camera. It has awful unusable RTSP. Maybe it related to camera firmware. I don't know how you can use it as rtsp source.

I'll check your config with transcoding.

IliasEagle commented 1 month ago

@dagleaves

this is what I got in logs when opening the stream using the webrtc card:

image

forcing the webrtc card to mode:mse solved the issue for the webrtc card image

but the problem still exists when streaming to homekit: image

IliasEagle commented 1 month ago

@AlexxIT funny you should say it. I did see in the go2rtc documentation where you said Reolink cameras are temperamental (paraphrasing), but my experience first with the Reolink Doorbell was so good that I tired Reolink E1 Pro which has also been very stable and only recently I got the RLC-520A. They are all running the latest firmware.

When I say I had good experience that has to do primarily with the image. You can let the stream for hours and it won't break, unlike all Eufy cameras which I am in the process of decommissioning.

I have no issues with using the Reolink cameras with Frigate and it seems now with the webrtc card(forcing mode to MSE) in terms of both image and sound. It seems that the only problematic case to be streaming to HomeKit.

Below you can see the RLC-520A steam being consumed by the WebRTC card (top) and HomeKit (below). It makes no difference in which order I start the consumers. The result is always the same.

image

AlexxIT commented 1 month ago

Your issue with space in stream name.

PS. What firmware is on your RLC-520A camera?

IliasEagle commented 1 month ago

@AlexxIT I thought the space was the issue but I doubt it is as the same problem appear on the "Bedroom-1" (reolink) and "Bedroom-2" (Eufy) cameras

  Bedroom1: #reolink e1pro
    - rtsp://user:password@192.168.1.210:554/h264Preview_01_main 
    - ffmpeg:Bedroom1#audio=opus
  Bedroom2: #Eufy Solo IndoorCam C24, 2K
    - rtsp://user:password@192.168.1.77/live0
    - ffmpeg:Bedroom2#audio=opus
  Living Room:  #RLC-520A
    - rtsp://user:password@192.168.1.114:554/h264Preview_01_main 
    - ffmpeg:Living Room#audio=opus

homekit:
  Living Room:
    pin: xxxxx
    name: Living Room
    pairings:
       .....
  Bedroom1:
    pin: xxxxx
    name: Bedroom-1
    pairings:
       .....
  Bedroom2:
    pin: xxxxx
    name: Bedroom-2
    pairings:

My RLC-520A is on v3.0.0.2839_23102301 firmware (HW IPC_MS1NA45MP)

AlexxIT commented 1 month ago

You should collect logs again. Because I can see space problems in your previous message.

IliasEagle commented 1 month ago

Hello @AlexxIT

I have taken some logs on my different cameras using the


WebRTC

Here is the log shows two events where I launch the RLC-520A camera stream via the WebRTC card:

The undefined error happens when I close the stream

Time Level Message
12:58:28 trace [api] GET /api/log 172.30.32.2:33578
12:58:34 trace [api] GET /api/ws?src=Living+Room [::1]:49942
12:58:34 trace [api] ws msg type=mse
12:58:35 trace [api] GET /api/log 172.30.32.2:33578
12:58:40 trace [api] GET /api/log 172.30.32.2:33578
12:58:45 trace [api] GET /api/log 172.30.32.2:33578
12:58:48 trace undefined error=websocket: close 1000 (normal) caller=github.com/AlexxIT/go2rtc/internal/api/ws/ws.go:124
12:58:50 trace [api] GET /api/log 172.30.32.2:33578
12:58:55 trace [api] GET /api/ws?src=Living+Room [::1]:55612
12:58:55 trace [api] ws msg type=mse
12:58:55 trace [api] GET /api/log 172.30.32.2:33578
12:59:00 trace [api] GET /api/log 172.30.32.2:33578
12:59:05 trace [api] GET /api/log 172.30.32.2:33578
12:59:10 trace [api] GET /api/log 172.30.32.2:33578
12:59:11 trace undefined error=websocket: close 1000 (normal) caller=github.com/AlexxIT/go2rtc/internal/api/ws/ws.go:124
12:59:15 trace [api] GET /api/log 172.30.32.2:33578

Here is the log shows two events where I launch the Reolink E1 Pro camera stream via the WebRTC card:

Time Level Message
13:08:31 trace [api] GET /api/log 172.30.32.2:60030
13:08:34 trace [api] GET /api/ws?src=Bedroom1 [::1]:33786
13:08:34 trace [api] ws msg type=mse
13:08:34 trace [api] ws msg type=webrtc/offer
13:08:34 trace [api] ws msg type=webrtc/candidate
13:08:34 trace [api] ws msg type=webrtc/candidate
13:08:34 trace [api] ws msg type=webrtc/candidate
13:08:34 trace [api] ws msg type=webrtc/candidate
13:08:34 trace [api] ws msg type=webrtc/candidate
13:08:35 debug [exec] run rtsp args=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/Bedroom1?audio,-c:a,libopus,-application:a,lowdelay,-min_comp,0,-vn,-user_agent,ffmpeg/go2rtc,-rtsp_transport,tcp,-f,rtsp,rtsp://127.0.0.1:8554/8cf49f0b1e63144d36269e9f27bc6c1f
13:08:35 debug [rtsp] new consumer stream=Bedroom1
13:08:35 trace [api] GET /api/log 172.30.32.2:60030
13:08:37 debug [exec] run rtsp launch=2.322664845s
13:08:37 trace undefined error=websocket: close 1000 (normal) caller=github.com/AlexxIT/go2rtc/internal/api/ws/ws.go:124
13:08:40 trace [api] GET /api/log 172.30.32.2:60030
13:08:45 trace [api] GET /api/log 172.30.32.2:60030
13:08:50 trace [api] GET /api/log 172.30.32.2:60030
13:08:55 trace [api] GET /api/log 172.30.32.2:60030
13:08:55 debug [rtsp] handle error=EOF
13:08:55 debug [rtsp] disconnect stream=Bedroom1
13:08:57 trace [api] GET /api/ws?src=Bedroom1 [::1]:45856
13:08:57 trace [api] ws msg type=mse
13:08:57 trace [api] ws msg type=webrtc/offer
13:08:57 trace [api] ws msg type=webrtc/candidate
13:08:57 trace [api] ws msg type=webrtc/candidate
13:08:57 trace [api] ws msg type=webrtc/candidate
13:08:57 trace [api] ws msg type=webrtc/candidate
13:08:57 trace [api] ws msg type=webrtc/candidate
13:08:57 debug [exec] run rtsp args=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/Bedroom1?audio,-c:a,libopus,-application:a,lowdelay,-min_comp,0,-vn,-user_agent,ffmpeg/go2rtc,-rtsp_transport,tcp,-f,rtsp,rtsp://127.0.0.1:8554/8cf49f0b1e63144d36269e9f27bc6c1f
13:08:57 debug [rtsp] new consumer stream=Bedroom1
13:08:59 debug [exec] run rtsp launch=1.593084174s
13:08:59 trace undefined error=websocket: close 1000 (normal) caller=github.com/AlexxIT/go2rtc/internal/api/ws/ws.go:124
13:09:00 trace [api] GET /api/log 172.30.32.2:60030
13:09:05 trace [api] GET /api/log 172.30.32.2:60030
13:09:10 trace [api] GET /api/log 172.30.32.2:60030

A similar behaviour to Reolink E1 Pro can be observed on theEufy Solo IndoorCam C24, 2K

Time Level Message
13:13:30 trace [api] GET /api/log 172.30.32.2:36412
13:13:38 trace [api] GET /api/ws?src=Bedroom2 [::1]:36576
13:13:38 trace [api] ws msg type=mse
13:13:38 trace [api] ws msg type=webrtc/offer
13:13:38 trace [api] ws msg type=webrtc/candidate
13:13:38 trace [api] ws msg type=webrtc/candidate
13:13:38 trace [api] ws msg type=webrtc/candidate
13:13:38 trace [api] ws msg type=webrtc/candidate
13:13:38 trace [api] ws msg type=webrtc/candidate
13:13:38 debug [exec] run rtsp args=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/Bedroom2?audio,-c:a,libopus,-application:a,lowdelay,-min_comp,0,-vn,-user_agent,ffmpeg/go2rtc,-rtsp_transport,tcp,-f,rtsp,rtsp://127.0.0.1:8554/8ed41b6754a1e3a34406f8b03e5921f3
13:13:38 debug [rtsp] new consumer stream=Bedroom2
13:13:38 debug [exec] run rtsp launch=474.851548ms
13:13:39 trace undefined error=websocket: close 1000 (normal) caller=github.com/AlexxIT/go2rtc/internal/api/ws/ws.go:124
13:13:40 trace [api] GET /api/log 172.30.32.2:36412
13:13:45 trace [api] GET /api/log 172.30.32.2:36412
13:13:50 trace [api] GET /api/log 172.30.32.2:36412
13:13:55 trace [api] GET /api/log 172.30.32.2:36412
13:13:57 trace [api] GET /api/ws?src=Bedroom2 [::1]:55986
13:13:57 trace [api] ws msg type=mse
13:13:57 trace [api] ws msg type=webrtc/offer
13:13:57 trace [api] ws msg type=webrtc/candidate
13:13:57 trace [api] ws msg type=webrtc/candidate
13:13:57 trace [api] ws msg type=webrtc/candidate
13:13:57 trace [api] ws msg type=webrtc/candidate
13:13:57 trace [api] ws msg type=webrtc/candidate
13:13:58 trace undefined error=websocket: close 1000 (normal) caller=github.com/AlexxIT/go2rtc/internal/api/ws/ws.go:124
13:14:00 trace [api] GET /api/log 172.30.32.2:36412
13:14:05 trace [api] GET /api/log 172.30.32.2:36412
13:14:10 trace [api] GET /api/log 172.30.32.2:36412
13:14:15 trace [api] GET /api/log 172.30.32.2:36412
13:14:20 trace [api] GET /api/log 172.30.32.2:36412

HomeKit

Here is the log shows two events where I launch the RLC-520A camera stream via HomeKit:

The error happens when I close the stream

Time Level Message
13:17:16.344 trace [api] GET /api/log 172.30.32.2:33646
13:17:20.235 trace [api] GET /api/log 172.30.32.2:33646
13:17:25.243 trace [api] GET /api/log 172.30.32.2:33646
13:17:26.821 trace [api] POST /pair-verify 192.168.1.201:61517
13:17:29.255 debug [exec] run rtsp args=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/Living,Room?audio,-c:a,libopus,-application:a,lowdelay,-min_comp,0,-vn,-user_agent,ffmpeg/go2rtc,-rtsp_transport,tcp,-f,rtsp,rtsp://127.0.0.1:8554/b9074a770f91c18e3032aad8480cb1ad
13:17:29.308 debug [exec] [rtsp @ 0x7ff1b4ab2600] method DESCRIBE failed: 404 Not Found
13:17:29.308 debug [exec] [in#0 @ 0x7ff1b4be5a80] Error opening input: Server returned 404 Not FoundError opening input file rtsp://127.0.0.1:8554/Living.Error opening input files: Server returned 404 Not Found
13:17:30.234 trace [api] GET /api/log 172.30.32.2:33646
13:17:35.236 trace [api] GET /api/log 172.30.32.2:33646
13:17:40.290 trace [api] GET /api/log 172.30.32.2:33646
13:17:42.774 error undefined error=write tcp 192.168.1.217:1984->192.168.1.201:61517: use of closed network connection caller=github.com/AlexxIT/go2rtc/internal/homekit/homekit.go:185
13:17:45.256 trace [api] GET /api/log 172.30.32.2:33646
13:17:50.312 trace [api] GET /api/log 172.30.32.2:33646
13:17:50.473 trace [api] POST /pair-verify 192.168.1.201:61520
13:17:51.066 debug [exec] run rtsp args=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/Living,Room?audio,-c:a,libopus,-application:a,lowdelay,-min_comp,0,-vn,-user_agent,ffmpeg/go2rtc,-rtsp_transport,tcp,-f,rtsp,rtsp://127.0.0.1:8554/b9074a770f91c18e3032aad8480cb1ad
13:17:51.120 debug [exec] [rtsp @ 0x7ff542c7c600] method DESCRIBE failed: 404 Not Found
13:17:51.120 debug [exec] [in#0 @ 0x7ff542dafa80] Error opening input: Server returned 404 Not FoundError opening input file rtsp://127.0.0.1:8554/Living.Error opening input files: Server returned 404 Not Found
13:17:55.248 trace [api] GET /api/log 172.30.32.2:33646
13:18:00.238 trace [api] GET /api/log 172.30.32.2:33646
13:18:05.246 trace [api] GET /api/log 172.30.32.2:33646
13:18:08.262 trace [api] POST /pair-verify 192.168.1.201:61524
13:18:08.262 trace [api] POST /pair-verify 192.168.1.201:61523
13:18:08.725 error undefined error=write tcp 192.168.1.217:1984->192.168.1.201:61520: use of closed network connection caller=github.com/AlexxIT/go2rtc/internal/homekit/homekit.go:185
13:18:10.250 trace [api] GET /api/log 172.30.32.2:33646

Here is the log shows two events where I launch the Reolink E1 Pro camera stream via HomeKit:

Time Level Message
13:22:06.100 trace [api] GET /api/log 172.30.32.2:58414
13:22:10.248 trace [api] GET /api/log 172.30.32.2:58414
13:22:12.665 trace [api] POST /pair-verify 192.168.1.201:61525
13:22:13.275 trace [api] POST /pair-verify 192.168.1.201:61526
13:22:13.275 trace [api] POST /pair-verify 192.168.1.201:61527
13:22:15.237 trace [api] GET /api/log 172.30.32.2:58414
13:22:17.267 trace [api] POST /pair-verify 192.168.1.201:61528
13:22:17.788 debug [exec] run rtsp args=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/Bedroom1?audio,-c:a,libopus,-application:a,lowdelay,-min_comp,0,-vn,-user_agent,ffmpeg/go2rtc,-rtsp_transport,tcp,-f,rtsp,rtsp://127.0.0.1:8554/8cf49f0b1e63144d36269e9f27bc6c1f
13:22:17.840 debug [rtsp] new consumer stream=Bedroom1
13:22:18.944 debug [exec] run rtsp launch=1.155630299s
13:22:20.247 trace [api] GET /api/log 172.30.32.2:58414
13:22:25.254 trace [api] GET /api/log 172.30.32.2:58414
13:22:28.617 error undefined error=write tcp 192.168.1.217:1984->192.168.1.201:61528: use of closed network connection caller=github.com/AlexxIT/go2rtc/internal/homekit/homekit.go:185
13:22:28.620 debug [rtsp] handle error=EOF
13:22:28.620 debug [rtsp] disconnect stream=Bedroom1
13:22:30.242 trace [api] GET /api/log 172.30.32.2:58414
13:22:34.795 trace [api] POST /pair-verify 192.168.1.201:61531
13:22:35.118 debug [exec] run rtsp args=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/Bedroom1?audio,-c:a,libopus,-application:a,lowdelay,-min_comp,0,-vn,-user_agent,ffmpeg/go2rtc,-rtsp_transport,tcp,-f,rtsp,rtsp://127.0.0.1:8554/8cf49f0b1e63144d36269e9f27bc6c1f
13:22:35.194 debug [rtsp] new consumer stream=Bedroom1
13:22:35.234 trace [api] GET /api/log 172.30.32.2:58414
13:22:36.944 debug [exec] run rtsp launch=1.825544009s
13:22:40.243 trace [api] GET /api/log 172.30.32.2:58414
13:22:44.928 error undefined error=write tcp 192.168.1.217:1984->192.168.1.201:61531: use of closed network connection caller=github.com/AlexxIT/go2rtc/internal/homekit/homekit.go:185
13:22:45.254 trace [api] GET /api/log 172.30.32.2:58414

Lastly this is the case of the Eufy Solo IndoorCam C24, 2K where I launched the steam at 13:24:32.146 successfully and again the error occurred when closing the stream. Then I tried to reopen the stream at: 13:24:43.347 which showed as loading the stream for a while. About 5 sec later the stream started and failed. Usually I need to restart go2rtc to get the stream working again.

Time Level Message
13:24:17.525 trace [api] GET /api/log 172.30.32.2:49158
13:24:30.252 trace [api] GET /api/log 172.30.32.2:49158
13:24:32.146 debug [exec] run rtsp args=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/Bedroom2?audio,-c:a,libopus,-application:a,lowdelay,-min_comp,0,-vn,-user_agent,ffmpeg/go2rtc,-rtsp_transport,tcp,-f,rtsp,rtsp://127.0.0.1:8554/8ed41b6754a1e3a34406f8b03e5921f3
13:24:32.200 debug [rtsp] new consumer stream=Bedroom2
13:24:32.604 debug [exec] run rtsp launch=456.8966ms
13:24:35.273 trace [api] GET /api/log 172.30.32.2:49158
13:24:40.250 trace [api] GET /api/log 172.30.32.2:49158
13:24:42.844 trace [api] POST /pair-verify 192.168.1.201:61536
13:24:43.342 error undefined error=write tcp 192.168.1.217:1984->192.168.1.201:61527: use of closed network connection caller=github.com/AlexxIT/go2rtc/internal/homekit/homekit.go:185
13:24:43.347 debug [rtsp] handle error=EOF
13:24:45.242 trace [api] GET /api/log 172.30.32.2:49158
13:24:50.257 trace [api] GET /api/log 172.30.32.2:49158
13:24:55.241 trace [api] GET /api/log 172.30.32.2:49158
13:25:00.239 trace [api] GET /api/log 172.30.32.2:49158
13:25:05.236 trace [api] GET /api/log 172.30.32.2:49158
13:25:09.681 trace [api] POST /pair-verify 192.168.1.201:61543
13:25:09.681 trace [api] POST /pair-verify 192.168.1.201:61544
13:25:09.681 trace [api] POST /pair-verify 192.168.1.201:61545
13:25:10.292 trace [api] GET /api/log 172.30.32.2:49158
13:25:15.255 trace [api] GET /api/log 172.30.32.2:49158
13:25:15.697 trace [api] POST /pair-verify 192.168.1.201:61547
13:25:20.252 trace [api] GET /api/log 172.30.32.2:49158
13:25:25.240 trace [api] GET /api/log 172.30.32.2:49158
13:25:26.335 trace [api] POST /pair-verify 192.168.1.201:61548
13:25:30.240 trace [api] GET /api/log 172.30.32.2:49158
13:25:35.243 trace [api] GET /api/log 172.30.32.2:49158
13:25:40.245 trace [api] GET /api/log 172.30.32.2:49158