- Notifications
You must be signed in to change notification settings - Fork215
Home Assistant custom component for real-time viewing of almost any camera stream using WebRTC and other technologies.
License
AlexxIT/WebRTC
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Home Assistant custom component for real-time viewing of almost any camera stream usingWebRTC and other technologies.
Starting with version 3 the streaming server has been changed fromRTSPtoWebRTC togo2rtc.
- go2rtc
- Installation
- Configuration
- Custom card
- Templates
- Two-way audio
- Snapshots to Telegram
- Cast or share stream
- Stream to camera
- FAQ
- Debug
- Known work cameras
This component uses thego2rtc application as a streaming server:
- lowest possible streaming latency for many supported protocols
- streaming from RTSP, RTMP, HTTP (FLV/MJPEG/JPEG), HomeKit cameras, USB cameras and other sources
- streaming to RTSP, WebRTC, MSE/MP4 or MJPEG
- support popular codec H264/H265, AAC, PCMU/PCMA, OPUS
- on-the-fly transcoding for unsupported codecs via FFmpeg
- autoselect streaming technology based on stream codecs, browser capabilities, network configuration
Read more in the go2rtcdocs!
You can install go2rtc in several ways:
- Basic users - this component will automatically download and run the latest version of go2rtc, you don't need to do anything yourself.
- Advanced users - install thego2rtc orFrigate 12+ add-on.
- Hakers - install go2rtc asbinary orDocker on any server in LAN.
You can change the go2rtc settings by adding thego2rtc.yaml file to your Hass configuration folder.
Important. go2rtc runs its own web interface on port1984 without a password. There you can see a list of active camera streams. Anyone on your LAN canaccess them without a password. You can disable this in the go2rtc config.
PS. There is also another nice card with go2rtc support -Frigate Lovelace Card.
Method 1.HACS > Integrations > Plus >WebRTC > Install
Method 2. Manually copywebrtc folder fromlatest release to/config/custom_components folder.
Additional steps if you are using the UI in YAML mode: add card to resources
Thecustom_card will be automatically registered with the Home Assistant UI, except when you are managing the UI in YAML mode.If you are managing the UI in YAML mode then add this to your UI resources for thecustom:webrtc-camera card to work:
url:/webrtc/webrtc-camera.jstype:module
- Refresh your browser
Settings > Devices & Services > Add Integration >WebRTC
If the integration is not in the list, you need to clear the browser cache.
Componentdoesn't create devices and entities. It creates only two services and lovelace custom card.
As aurl you can use:
- any protocol supported by go2rtc (
rtsp,rtmp,http,onvif,dvrip,homekit,roborock, etc.) - stream
namefrom the go2rtc config Jinja2template (should render supported protocol or streamname)
As aentity you can use almost any camera from Hass.
As aposter you can use:
http-link (should be publicly available link)- camera
entityfrom Hass - stream
namefrom the go2rtc config Jinja2template (should render cameraentityor streamname)
Minimal
type:'custom:webrtc-camera'url:'rtsp://rtsp:12345678@192.168.1.123:554/av_stream/ch0'
or
type:'custom:webrtc-camera'url:'camera1'# stream name from go2rtc.yaml
or
type:'custom:webrtc-camera'entity:camera.generic_stream# change to your camera entity_id
or
type:'custom:webrtc-camera'streams: -url:go2rtc_stream_hdname:HD# name is optionalmode:webrtc# mode is optionalmedia:video# media is optional -url:go2rtc_stream_sdname:SDmode:msemedia:audio
PS. You can change the active stream by clicking on themode label. Or by clicking on the streamname with enabledui: true.
Full
All settings are optional! Only required setting -url orentity orstreams.
type:'custom:webrtc-camera'url:'rtsp://rtsp:12345678@192.168.1.123:554/av_stream/ch0'entity:camera.generic_streammode:webrtc,webrtc/tcp,mse,hls,mjpeg# stream technology, default all of themmedia:video,audio# select only video or audio track, default bothserver:http://192.168.1.123:1984/# custom go2rtc server address, default emptyui:true# custom video controls, default falsedigital_ptz:# digital zoom and pan via mouse/touch, defaults:mouse_drag_pan:truemouse_wheel_zoom:truemouse_double_click_zoom:truetouch_drag_pan:truetouch_pinch_zoom:truetouch_tap_drag_zoom:truepersist:true# zoom factor and viewport position survive page reloads# digital_ptz: false # to disable all mouse/touch digital zoom and pantitle:My super camera# optional card titleposter:https://home-assistant.io/images/cast/splash.png# still image when stream is loadingmuted:true# initial mute toggle state, default is false (unmuted)intersection:0.75# auto stop stream when less than 75% of video element is in the screen, 50% by defaultbackground:true# run stream when not displayed (ex. for quick video loading), default falseshortcuts:# custom shortcuts, default none-name:Recordicon:mdi:record-circle-outlineservice:switch.toggleservice_data:entity_id:switch.camera_record
Pan, tilt, zoom controls:PTZ config examples.
Paused by default
type:custom:webrtc-cameraposter:dahua1-snap# stream name from go2rtc.yaml (http-snapshot)streams: -url:''# empty url, so only poster will be shown -url:dahua1# stream name from go2rtc.yaml (rtsp-stream)
Video aspect ratioissue
style:"video {aspect-ratio: 16/9; object-fit: fill;}"
Video rotation
- On client (free CPU):
style:'video {transform: rotate(90deg); aspect-ratio: 1}'
- On server -FFmpeg transcoding (high CPU cost)
Hide mode label
style:'.mode {display: none}'
Hide fullscreen button
style:'.fullscreen {display: none}'
Hide screenshot button
style:'.screenshot {display: none}'
Hide PIP button
style:'.pictureinpicture {display: none}'
Shortcuts position
style:".shortcuts {left: unset; top: 25px; right: 5px; display: flex; flex-direction: column}"
PTZ position
style:".ptz {right: unset; left: 10px}"
Mode label position
style:'.header {bottom: 6px} .mode {position: absolute; bottom: 0px}'
Header line position
style:'.header {top: unset; bottom: 6px}'
- Card options
shortcuts,styleandptzsupports JavaScript templates - In
shortcutsandstyleyou can usestatesrelated templates - In
ptzyou can usestreamName/streamIDrelated templates (useful for card with multiple templates)
shortcuts: -name:Barn Lighticon:${ states['light.yeelight_lamp'].state === 'on' ? 'mdi:outdoor-lamp':'mdi:lamp' }service:light.toggleservice_data:entity_id:light.yeelight_lamp
ptz:service:notify.persistent_notificationdata_left:message:Left for ${ this.streamName } clickeddata_right:message:Rigth for ${ this.streamID } clicked
- Only forsupported sources in go2rtc
- Only for Hass with HTTPS access, this limitation isfrom the browsers
- Only for WebRTC mode
- HTTPS is also important for Hass Mobile App!
You should addmicrophone tomedia param. You can use two streams: one with mic, second without:
type:'custom:webrtc-camera'streams: -url:go2rtc_stream -url:go2rtc_streammode:webrtcmedia:video,audio,microphone
PS. For HassMobile App ensure that you can use microphone with the built-inAssist.
Component support streaming toGoogle Cast Chromecast devices (including Android TV and Google Smart Screen). Read more inwiki.
Also component support creating a temporary or permanent link to a stream without sharing access to you Home Assistant. Read more inwiki.
go2rtc support play audio files (ex.music orTTS) and live streams (ex. radio) on cameras withtwo way audio support. You need to:
- Check if your camera has supportedtwo way audio source
- Setup camera stream ingo2rtc.yaml config
- Check audio codec, that yourcamera supports
- Create virtualMedia Players for your cameras in
configuration.yaml:
media_player: -platform:webrtcname:Dahua Camerastream:dahuaaudio:pcmu/48000 -platform:webrtcname:Tapo Camerastream:tapoaudio:pcma
Q. Exernal access with WebRTC doesn't work
A.Read more and don't create new issues.
Q. Audio doesn't work
A. Check what audio codec your camera outputs. And what technology do you use to watch videos. Different technologies support different codecs.
Add to yourconfiguration.yaml:
logger:default:warninglogs:custom_components.webrtc:debug
| Brand | Models | Comment |
|---|---|---|
| ActiveCam | AC-D2121IR3 | |
| ActiveCam | AC-D7121IR1W | support sound |
| Android | IP Webcam Pro | support sound,rtsp://192.168.1.123:8080/h264_ulaw.sdp |
| C-tronics | CTIPC-690C | support sound, main :rtsp://username:password@192.168.1.xx:554/11 oronvif://username:password@192.168.1.xx:8080?subtype=MainStreamProfileToken |
| Dahua | DH-IPC-HDPW1431FP-AS-0280B, VTO2211G-P | support sound |
| Dahua | VTO2202F-P-S2 | read more |
| EZVIZ | C3S | rtsp://admin:pass@192.168.1.123:554/h264/ch01/main/av_stream and/h264/ch01/sub/av_stream |
| EZVIZ | C3W, C3WN, C6CN, C6T | rtsp://admin:pass@192.168.1.123:554/h264_stream |
| EZVIZ | C8C | rtsp://admin:pass@192.168.1.123:554/channel80 |
| Foscam | C1 | rtsp://user:pass@192.168.1.123:554/videoMain |
| Foscam | C2M, R2M | rtsp://user:pass@192.168.1.123:88/videoMain |
| GW Security | GW5088IP | rtsp://192.168.1.123:554/mpeg4cif?username=admin&password=123456 |
| GW Security | GW5078IP | rtsp://192.168.1.123:554/stream0?username=admin&password=123456 |
| GW Security | GW5071IP | Not working yet, something similar tortsp://admin:123456@192.168.0.207:554/live/main orrtsp://192.168.0.207:554/live/main?username=admin&password=123456 |
| Hikvision | DS-2CD2T47G1-L, DS-2CD1321-I, DS-2CD2143G0-IS | rtsp://user:pass@192.168.1.123:554/ISAPI/Streaming/Channels/102 |
| Hikvision | IPC-HDW3849H-AS-PV, IPC-EW5531-AS | wired to nvr DHI-NVR2108HS-8P-I usingcustom component |
| Imou | IPC-F42-B2E3 (Bullet 2C 4MP) | rtsp://admin:password@192.168.1.123:554/cam/realmonitor?channel=1&subtype=0 |
| QNAP | QUSBCam2 | rtsp://username:password@192.168.1.123:554/channel1docs |
| Raspberry Pi | PiCam | read more |
| Reolink | RLC-410, RLC-410W, RLC-510WA, E1 Pro, E1 Zoom, 4505MP | RLC-510WA support sound, E1 Zoom support sound, PTZ and zoom |
| Reolink | E1 | rtsp://admin:password@192.168.1.123:554/h264Preview_01_main |
| Sonoff | GK-200MP2-B | support sound andPTZ,rtsp://rtsp:12345678@192.168.1.123:554/av_stream/ch0 and/av_stream/ch1 |
| SriHome | SH035 | rtsp://192.168.xxx.xxx:8554/profile0 and/profile1 and/profile2 |
| Topvico | rtsp://192.168.1.123:8554/stream0 orrtsp://192.168.1.123:554/ch0_0.264 | |
| TP-Link | Tapo C100/C200/C210/C220/C310 | rtsp://user:pass@192.168.1.123:554/stream1 and/stream2 |
| TVT/Secutech | NVR-0808B2-8P | rtsp://user:pass@192.168.1.123:554/chID=1&streamType=main andchID=2&streamType=main |
| TVT/Secutech | IPC5-DF28SN | rtsp://user:pass@192.168.1.123:554/profile1 and/profile2 |
| Unifi | G4 Dome, G4 doorbell, G3 Bullet, G3 Flex | Copy the rtsps link from the camera's settings in Unifi Protect, but change the link torstp:// (it defaults to rstps://), change the port to7447, and remove any query params |
| Wyze | Cam v2/v3, Cam Pan v1/v2 | support sound |
| Xiaomi | Dafang | with hack,rtsp://192.168.1.123:8554/unicastVideo: H264, size: 1920x1080, bitrate: 1000, format: VBR, frame rate: 10 Audio: PCMU, rate in: 8000, rate out: 44100 |
| Yale | SV-4CFDVR-2, SV-DAFX | rtsp://admin:password@192.168.1.123/cam/realmonitor?channel=1&subtype=0 |
| Yale | SV-DPFX | rtsp://admin:password@192.168.1.123/cam/realmonitor?channel=1&subtype=1 |
| Yi | Hi3518e Chipset | with hack |
| Yi | MStar Infinity Chipset | with hack |
About
Home Assistant custom component for real-time viewing of almost any camera stream using WebRTC and other technologies.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.