INSTAR go2rtc for Home Assistant
go2rtc
- Docker Hub
alexxit/go2rtc:latest
: Latest release based on alpine (amd64, 386, arm, arm64) with support hardware transcoding for Intel iGPU and Raspberryalexxit/go2rtc:master
: Latest unstable version based on alpinealexxit/go2rtc:master-hardware
: Latest unstable version based on debian 12 (amd64) with support hardware transcoding for Intel iGPU, AMD GPU and NVidia GPU
docker pull alexxit/go2rtc:master-hardware
docker-compose.yml
services:
go2rtc:
image: alexxit/go2rtc:master-hardware
network_mode: host # important for WebRTC, HomeKit, UDP cameras
privileged: true # only for FFmpeg hardware transcoding
restart: unless-stopped # autorestart on fail or config change from WebUI
environment:
- TZ=Asia/Hong_Kong # timezone in logs
volumes:
- "~/go2rtc:/config" # folder for go2rtc.yaml file (edit from WebUI)
Open web interface: http://localhost:1984/
:
go2rtc.yaml
streams:
8415:
- rtsp://admin:instar@192.168.2.125:554/livestream/11
- rtsp://admin:instar@192.168.2.125:554/livestream/12
- rtsp://admin:instar@192.168.2.125:554/livestream/13
8015:
- rtsp://admin:instar@192.168.2.15:554/11
- rtsp://admin:instar@192.168.2.15:554/12
- rtsp://admin:instar@192.168.2.15:554/13
9408:
- ffmpeg:rstp://admin:instar@192.168.2.115/livestream/11
- ffmpeg:rstp://admin:instar@192.168.2.115/livestream/12
- ffmpeg:rstp://admin:instar@192.168.2.115/livestream/13
9420:
- ffmpeg:rstp://admin:instar@192.168.2.56/livestream/11
- ffmpeg:rstp://admin:instar@192.168.2.56/livestream/12
- ffmpeg:rstp://admin:instar@192.168.2.56/livestream/13
Any codec in source
- stream.html with auto-select mode / browsers: all / codecs: H264, H265*, MJPEG, JPEG, AAC, PCMU, PCMA, OPUS
- rtsp rtsp with only one video and one audio / codecs: any
- rtsp for MP4 recording (Hass or Frigate) / codecs: H264, H265, AAC
- rtsp with all tracks / codecs: any ffplay -fflags nobuffer -flags low_delay -rtsp_transport tcp "rtsp://127.0.0.1:8554/8415"
H264/H265 source
- stream.html WebRTC stream / browsers: all / codecs: H264, PCMU, PCMA, OPUS / +H265 in Safari
- stream.html MSE stream / browsers: Chrome, Firefox, Safari Mac/iPad / codecs: H264, H265*, AAC, PCMA*, PCMU*, PCM* / +OPUS in Chrome and Firefox
- stream.mp4 legacy MP4 stream with AAC audio / browsers: Chrome, Firefox / codecs: H264, H265*, AAC
- stream.mp4 modern MP4 stream with common audio / browsers: Chrome, Firefox / codecs: H264, H265*, AAC, FLAC (PCMA, PCMU, PCM)
- stream.mp4 MP4 stream with any audio / browsers: Chrome / codecs: H264, H265*, AAC, OPUS, MP3, FLAC (PCMA, PCMU, PCM)
- frame.mp4 snapshot in MP4-format / browsers: all / codecs: H264, H265*
- stream.m3u8 legacy HLS/TS / browsers: Safari all, Chrome Android / codecs: H264
- stream.m3u8 legacy HLS/fMP4 / browsers: Safari all, Chrome Android / codecs: H264, H265*, AAC
- stream.m3u8 modern HLS/fMP4 / browsers: Safari all, Chrome Android / codecs: H264, H265*, AAC, FLAC (PCMA, PCMU, PCM)
MJPEG source
- stream.html with MJPEG mode / browsers: all / codecs: MJPEG, JPEG
- stream.mjpeg MJPEG stream / browsers: all / codecs: MJPEG, JPEG
- frame.jpeg snapshot in JPEG-format / browsers: all / codecs: MJPEG, JPEG
API
producers
0
url "rtsp://admin:instar@192.168.2.125:554/livestream/11"
1
url "rtsp://admin:instar@192.168.2.125:554/livestream/12"
2
url "rtsp://admin:instar@192.168.2.125:554/livestream/13"
consumers []
Home Assistant
Docker Setup
RTSPtoWebRTC: Home Assistant Integration (deprecated)
I was not able to get this to work. Use WebRTC Camera Integration instead.
Go to the Integrations page, select an instance of RTSPtoWebRTC and point it towards the API URL of the go2rtc
container, e.g http://localhost:1984
:
Now we can add our camera's live stream to Home Assistant through the RTSPtoWebRTC
integration. The RTSPtoWeb integration registers with camera integration to provide WebRTC live streams for any RTSP camera.
So make sure that you have your cameras already added, e.g. as Generic Cameras
:
The RTSPtoWebRTC integration will now use RTSPtoWeb to receive the WebRTC stream from your generic camera's RTSP Stream:
But switching to my dashboard I see an error message:
go2rtc_1 | 13:11:10.652 WRN github.com/AlexxIT/go2rtc/internal/webrtc/webrtc.go:241 > error="streams: codecs not matched: H264, AAC => VP8, RTX, VP9, OPUS, G722, PCMU, PCMA, TELEPHONE-EVENT, S16B, S16L"
go2rtc_1 | 13:11:10.657 WRN github.com/AlexxIT/go2rtc/internal/webrtc/webrtc.go:241 > error="streams: codecs not matched: H264, AAC => VP8, RTX, VP9, OPUS, G722, PCMU, PCMA, TELEPHONE-EVENT, S16B, S16L"
WebRTC Camera: Home Assistant Integration
Start by installing the WebRTC Camera Add-on:
Restart Home Assistant and you should now be able to add the WebRTC Camera Integration:
Here you can add the API URL from your go2rtc container:
Edit your dashboard and add a Custom: WebRTC Camera card with one of the following configurations:
type: 'custom:webrtc-camera'
url: 'rtsp://rtsp:12345678@192.168.1.123:554/av_stream/ch0'
---
type: 'custom:webrtc-camera'
url: 'camera1' # stream name from go2rtc.yaml
---
type: 'custom:webrtc-camera'
entity: camera.generic_stream # change to your camera entity_id
Since I already added cameras to go2RTC I will simply use the ID that I assigned to them there:
To verify that it is working you can check the go2RTC dashboard to check if the camera now list one online stream consumer:
And your cameras are now running via the MSE stream:
ioBroker
You can use the stream.html
(e.g. http://192.168.2.112:1984/stream.html?src=8415
) stream provided in the go2rtc
web interface:
Use an iFrame Widget to add the stream to your vis
dashboard:
Node-RED
And the same also works in Node-RED using iFrame UI Node: