Realtime camera streaming without any delay - WebRTC

Save the video then send it to user. You can send complete file or send web accessible link to video

Integration is working using MP4 or MSE modes. If i choose WEBRTC, it’s stuck on loading.
My cameras (Reolink E1 Zoom) are in a IOT, no WAN (internet) zone but have lan access both ways.
Does GO2RTC need internet to work.

Thank you for your work

Strangely, i just find out that MSE mode work great using Chrome browser but not Firefox.
Since my cameras are in a IOT without inernet, i’m using a WireGuard VPN tunnel to access my LAN instead of using NGINX as before. Now RTC work with Chrome using my PC on my local network but it’s laging and freezing on my cell phone. If I disable my wifi connection and use my tunnel over cellular, all is ok.

Ok working with Firefox if i turn to true the media.peerconnection.enabled setting but it’s lagging big time.

I’m talking about automation that sends video to telegram, and what are you talking about

Hello @AlexxIT

i have a problem with the “custom:webrtc-camera” card, i have rtsp streams from my eufy cameras, but on my iphone the sound doesnt work, on the android phone from my wife the sound works well.

have you any ideas?

this is the output of go2rtc with my iphone

{
  "producers": [
    {
      "type": "RTSP active producer",
      "url": "rtsp://192.168.0.43:554/live0",
      "remote_addr": "192.168.0.43:554",
      "user_agent": "go2rtc/1.5.0",
      "medias": [
        "video, recvonly, H.264 High 4.2",
        "audio, recvonly, MPEG4-GENERIC/16000"
      ],
      "receivers": [
        "96 H264, bytes=214547, senders=1"
      ],
      "recv": 217139
    }
  ],
  "consumers": [
    {
      "type": "WebRTC/WebSocket async passive consumer",
      "remote_addr": "udp4 prflx 192.168.0.128:60213 related :0",
      "user_agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 16_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Home Assistant/2023.4 (io.robbie.HomeAssistant; build:2023.460; iOS 16.5.1) Mobile/HomeAssistant, like Safari",
      "medias": [
        "video, sendonly, H264, RTX, VP8, VP9, RED, ULPFEC, FLEXFEC-03",
        "audio, sendonly, OPUS/48000/2, RED/48000/2, ISAC/16000, G722/8000, PCMU/8000, PCMA/8000, CN/16000, CN/8000, TELEPHONE-EVENT/48000, TELEPHONE-EVENT/16000, TELEPHONE-EVENT/8000, L16"
      ],
      "senders": [
        "96 H264, bytes=214547, receivers=1"
      ],
      "send": 210026
    }
  ]
}

and here with the android phone

{
  "producers": [
    {
      "type": "RTSP active producer",
      "url": "rtsp://192.168.0.43:554/live0",
      "remote_addr": "192.168.0.43:554",
      "user_agent": "go2rtc/1.5.0",
      "medias": [
        "video, recvonly, H.264 High 4.2",
        "audio, recvonly, MPEG4-GENERIC/16000"
      ],
      "receivers": [
        "96 H264, bytes=846233, senders=2",
        "97 MPEG4-GENERIC/16000, bytes=35162, senders=1"
      ],
      "recv": 892303
    }
  ],
  "consumers": [
    {
      "type": "MP4 passive consumer",
      "remote_addr": "127.0.0.1, [::1]:42188",
      "user_agent": "Mozilla/5.0 (Linux; Android 13; SM-G991B Build/TP1A.220624.014; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/114.0.5735.130 Mobile Safari/537.36 Home Assistant/2023.6.0-10170 (Android 13; SM-G991B)",
      "medias": [
        "video, sendonly, H264, H265",
        "audio, sendonly, MPEG4-GENERIC, PCMA, PCMU, L16, OPUS"
      ],
      "senders": [
        "96 H264, bytes=39084, receivers=1",
        "97 MPEG4-GENERIC/16000, bytes=4504, receivers=1"
      ]
    },
    {
      "type": "WebRTC/WebSocket async passive consumer",
      "remote_addr": "udp4 host 192.168.0.70:39485",
      "user_agent": "Mozilla/5.0 (Linux; Android 13; SM-G991B Build/TP1A.220624.014; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/114.0.5735.130 Mobile Safari/537.36 Home Assistant/2023.6.0-10170 (Android 13; SM-G991B)",
      "medias": [
        "video, sendonly, VP8, RTX, VP9, AV1, H264, RED, ULPFEC, FLEXFEC-03",
        "audio, sendonly, OPUS/48000/2, RED/48000/2, G722/8000, PCMU/8000, PCMA/8000, CN/8000, TELEPHONE-EVENT/48000, TELEPHONE-EVENT/8000, L16"
      ],
      "senders": [
        "102 H264, bytes=38052, receivers=1"
      ],
      "send": 38604
    }
  ]
}

Thank you

Your camera uses AAC codec

ok, what can i do now? I have already activated the setting in the developer settings on the iphone.

Can I do something with ffmpeg now or am I misunderstanding the documentation?
sry for the question but I don’t see it all that way, any help would be greatly appreciated

Hello!
I can not put in my head the relationship of all components. What connects to what and what I need to install.
I have HiWatch IPC-C082-G2 and two probems: only h265 steam and no internal video rotating.
I installed WebRTC Camera addon and make /opt/ha/config/go2rtc.yaml config like:

api:
  password: 777
  username: homeassistant
rtsp:
  password: 777
  username: homeassistant
webrtc:
  candidates:
    - myrealip:8555 # forwarded this port to my Raspberry


streams:
  hikvision1:
#    - rtsp://homeassistant:[email protected]:554/Streaming/Channels/101
    - "ffmpeg:rtsp://go2rtc:[email protected]:554/ISAPI/Streaming/Channels/101#video=h264#rotate=90"
#    - rtsp://admin:[email protected]:554/Streaming/Channels/101
#    - isapi://go2rtc:[email protected]:80
#    - "ffmpeg:hikvision1#video=h264#rotate=90"

Added lovelace card:

type: custom:webrtc-camera
url: rtsp://homeassistant:[email protected]:8554/hikvision1 #My HA in docker, so I'm not sure that I should use 127.0.0.1 or interface IP...

As you see, I tried different ways, but always, if I trying to see camera in HA, I recieve in logs:

2023-07-03 22:37:16.459 DEBUG (webrtc) [custom_components.webrtc.utils] 22:37:16.459 DBG [exec] run url="exec:ffmpeg -hide_banner -v error -allowed_media_types video -fflags nobuffer -flags low_delay -timeout 5000000 -user_agent go2rtc/ffmpeg -rtsp_transport tcp -i rtsp://go2rtc:[email protected]:554/ISAPI/Streaming/Channels/101 -c:v libx264 -g 50 -profile:v high -level:v 4.1 -preset:v superfast -tune:v zerolatency -pix_fmt:v yuvj420p -an -vf transpose=1 -user_agent ffmpeg/go2rtc -rtsp_transport tcp -f rtsp {output}"
2023-07-03 22:37:16.858 DEBUG (webrtc) [custom_components.webrtc.utils] [rtsp @ 0xf2b98200] method DESCRIBE failed: 401 Unauthorized
2023-07-03 22:37:16.858 DEBUG (webrtc) [custom_components.webrtc.utils] rtsp://go2rtc:[email protected]:554/ISAPI/Streaming/Channels/101: Server returned 401 Unauthorized (authorization failed)

As you see, I created few users with the same result. I can authorize in my webcam with this credentials (go2rtc:777 or homeassistant:777) and can see the stream. What I’m doing wrong?

Here are my go2rtc.yaml settings for the Hikvision 2 camera
image

And this is the map settings

Thank you!
Picked up a working set of settings. However, quite a heavy load on the processor. What is the best video type?
In the camera on the sub-stream, the MJPEG type is set. But I see black screen with sound only if I not set the video= type…

Still in search for optimal transcode settings. This is my camera second stream setiings.

image

Lovelace card (thank you TokarevSergey!):

type: custom:webrtc-camera
url: hikvision1
muted: true
ui: true
title: Коридор

I found only one way to get my video working. go2rtc.yaml:

    - rtsp://go2rtc:[email protected]:554/ISAPI/Streaming/Channels/102
    - isapi://go2rtc:[email protected]:80
    - "ffmpeg:hikvision1#video=h264#rotate=90"

All working except small freezes (especially on moving detection). My Raspberry Pi4 when I looking video in HA:

As far as I understand, I can choose not to encode the video because my browser will play MJPEG as is. I need only rotating. But if I set
"ffmpeg:hikvision1#rotate=90"
or
"ffmpeg:hikvision1#video=mjpeg#rotate=90" or remove ffmpeg option at all, I see only black screen with audio.
What is the best option to get video stream for me?

Here are my stream settings.


Tell me, why do you need ffmpeg? Do you have h264 or h265 codec not working? ffmpeg is loading the cpu.

1 Like

why do you need ffmpeg?

  1. My camera (HiWatch IPC-C082-G2) have only H.265 on main stream. On second stream I can choose MJPEG. If I use any stream without FFMPEG, as I said, I see only black screen with sound. No picture. In my Chrome browser and the same in Android app.
  2. My camera can’t rotate image. I need to rotate it outside. If I rotate it with “style” the image does not take up the entire area of the card. Even in fullscreen.

I understand about CPU loading and trying to find the best option to make this load less.
Now I have only one option when I can see the video, but the CPU load is to high.
ffmpeg:hikvision1#video=h264#rotate=90

Update make me an error : webrtc / offer : stream not found with 1 android webcam and a real ip webcam

Same. Rolled back to previous and all OK

this new release is ok :

1 Like

Same issue on new version. 3.1.1 works fine though

How to roll back???

Just update the webrtc card (frontend), and you’ll be sweet. Otherwise, if you want to roll back, use a backup.

Updated on my head and does not work now.