• Stars
    star
    1,481
  • Rank 31,741 (Top 0.7 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 3 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Home Assistant custom component for real-time viewing of almost any camera stream using WebRTC and other technologies.

WebRTC Camera

hacs_badge

Home Assistant custom component for viewing almost any camera stream in real time using WebRTC and other technologies.

Starting with version 3 the streaming server has been changed from RTSPtoWebRTC to go2rtc.


go2rtc

This component uses the go2rtc application as 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 go2rtc docs!

You can install go2rtc in several ways:

  1. Basic users - this component will automatically download and run the latest version of go2rtc, you don't need to do anything yourself.
  2. Advanced users - install the go2rtc or Frigate 12+ add-on.
  3. Hakers - install go2rtc as binary or Docker on any server in LAN.

You can change the go2rtc settings by adding the go2rtc.yaml file to your Hass configuration folder.

Important. go2rtc runs its own web interface on port 1984 without a password. There you can see a list of active streams from cameras. And anyone on your LAN can access them without password. You can disable this in the go2rtc config.

PS. There is also another nice card with go2rtc support - Frigate Lovelace Card.

Installation

Method 1. HACS > Integrations > Plus > WebRTC > Install

Method 2. Manually copy webrtc folder from latest release to /config/custom_components folder.

Additional steps if you are using the UI in YAML mode: add card to resources

The custom_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 the custom:webrtc-camera card to work:

url: /webrtc/webrtc-camera.js
type: module
  • Refresh your browser

Configuration

Settings > Devices & Services > Add Integration > WebRTC

If the integration is not in the list, you need to clear the browser cache.

Component doesn't create devices and entities. It creates only two services and lovelace custom card.

Custom card

As a url you can use any protocol supported in go2rtc or specify the stream name from the go2rtc config.
As a entity you can use almost any camera from Hass.

Minimal

type: 'custom:webrtc-camera'
url: 'rtsp://rtsp:[email protected]:554/av_stream/ch0'

or

type: 'custom:webrtc-camera'
entity: camera.generic_stream  # change to your camera entity_id

Full

type: 'custom:webrtc-camera'
url: 'rtsp://rtsp:[email protected]:554/av_stream/ch0'

ui: true  # custom video controls, default false

digital_ptz:  # digital zoom and pan via mouse/touch. Defaults to:
  mouse_drag_pan: true 
  mouse_wheel_zoom: true
  mouse_double_click_zoom: true
  touch_drag_pan: true 
  touch_pinch_zoom: true  
  touch_tap_drag_zoom: true 
  persist: true  # zoom factor and viewport position survive page reloads

# digital_ptz: false  # to disable all mouse/touch digital zoom and pan

title: My super camera  # optional card title
poster: https://home-assistant.io/images/cast/splash.png  # still image when stream is loading
muted: 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 default
background: true  # run stream when not displayed (ex. for quick video loading), default false

shortcuts:  # custom shortcuts, default none
- name: Record
  icon: mdi:record-circle-outline
  service: switch.toggle
  service_data:
    entity_id: switch.camera_record

mode: webrtc,mse,hls,mjpeg  # also available - webrtc/tcp

Pan, tilt, zoom controls: PTZ config examples.

Video aspect ratio issue

style: "video {aspect-ratio: 16/9; object-fit: fill;}"

Video rotation

  1. On client (free CPU):
    style: 'video {transform: rotate(90deg); aspect-ratio: 1}'
  2. On server - FFmpeg transcoding (high CPU cost)

Hide mode label

style: '.mode {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}'

Snapshots to Telegram

read more

Cast or share stream

Component support streaming to Google Cast Chromecast devices (including Android TV and Google Smart Screen). Read more in wiki.

Also component support creating a temporary or permanent link to a stream without sharing access to you Home Assistant. Read more in wiki.

Stream to camera

go2rtc support play audio files (ex. music or TTS) and live streams (ex. radio) on cameras with two way audio support. You need to:

  1. Check if your camera has supported two way audio source
  2. Setup camera stream in go2rtc.yaml config
  3. Check audio codec, that your camera supports
  4. Create virtual Media Players for your cameras in configuration.yaml:
media_player:
  - platform: webrtc
    name: Dahua Camera
    stream: dahua
    audio: pcmu/48000
  - platform: webrtc
    name: Tapo Camera
    stream: tapo
    audio: pcma

FAQ

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.

Q. External access on the iPhone not in real time
A. The iPhone browser does not support modern web technologies. It's hard to believe, but it's true. If you haven't setup external access for WebRTC - you will get a chopped stream of keyframes in MP4 format.

Q. Stream in macOS app not in real time
A. Support for modern web technologies is blocked in the macOS app. You will get a chopped stream of keyframes in MP4 format.

Debug

Add to your configuration.yaml:

logger:
  default: warning
  logs:
    custom_components.webrtc: debug

Known work cameras

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
Dahua DH-IPC-HDPW1431FP-AS-0280B, VTO2211G-P support sound
Dahua VTO2202F-P-S2 read more
EZVIZ C3S rtsp://admin:[email protected]:554/h264/ch01/main/av_stream and /h264/ch01/sub/av_stream
EZVIZ C3W, C3WN, C6CN, C6T rtsp://admin:[email protected]:554/h264_stream
EZVIZ C8C rtsp://admin:[email protected]:554/channel80
Foscam C1 rtsp://user:[email protected]:554/videoMain
Foscam C2M, R2M rtsp://user:[email protected]: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 to rtsp://admin:[email protected]:554/live/main or rtsp://192.168.0.207:554/live/main?username=admin&password=123456
Hikvision DS-2CD2T47G1-L, DS-2CD1321-I, DS-2CD2143G0-IS rtsp://user:[email protected]:554/ISAPI/Streaming/Channels/102
Hikvision IPC-HDW3849H-AS-PV, IPC-EW5531-AS wired to nvr DHI-NVR2108HS-8P-I using custom component
Imou IPC-F42-B2E3 (Bullet 2C 4MP) rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=0
QNAP QUSBCam2 rtsp://username:[email protected]:554/channel1 docs
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:[email protected]:554/h264Preview_01_main
Sonoff GK-200MP2-B support sound and PTZ, rtsp://rtsp:[email protected]:554/av_stream/ch0 and /av_stream/ch1
SriHome SH035 rtsp://192.168.xxx.xxx:8554/profile0 and /profile1 and /profile2
TP-Link Tapo C100/C200/C310 rtsp://user:[email protected]:554/stream1 and /stream2
Unifi G4 Dome, G3 Bullet, G3 Flex
Wyze Cam v2/v3, Cam Pan v1/v2 support sound
Xiaomi Dafang with hack, rtsp://192.168.1.123:8554/unicast
Video: H264, size: 1920x1080, bitrate: 1000, format: VBR, frame rate: 10
Audio: PCMU, rate in: 8000, rate out: 44100
Yi Hi3518e Chipset with hack
Yi MStar Infinity Chipset with hack

More Repositories

1

go2rtc

Ultimate camera streaming application with support RTSP, RTMP, HTTP-FLV, WebRTC, MSE, HLS, MP4, MJPEG, HomeKit, FFmpeg, etc.
Go
4,834
star
2

SonoffLAN

Control Sonoff Devices with eWeLink (original) firmware over LAN and/or Cloud from Home Assistant
Python
2,688
star
3

XiaomiGateway3

Home Assistant custom component for control Xiaomi Multimode Gateway (aka Gateway 3), Xiaomi Multimode Gateway 2, Aqara Hub E1 on default firmwares over LAN
Python
2,444
star
4

YandexStation

Π£ΠΏΡ€Π°Π²Π»Π΅Π½ΠΈΠ΅ ЯндСкс.Π‘Ρ‚Π°Π½Ρ†ΠΈΠ΅ΠΉ ΠΈ Π΄Ρ€ΡƒΠ³ΠΈΠΌΠΈ устройствами ΡƒΠΌΠ½ΠΎΠ³ΠΎ Π΄ΠΎΠΌΠ° с Алисой ΠΈΠ· Home Assistant
Python
1,354
star
5

HassWP

Portable version of Home Assistant for Windows (no need to install)
Python
642
star
6

StreamAssist

Home Assistant custom component that allows you to turn almost any camera and almost any speaker into a local voice assistant
Python
213
star
7

YandexDialogs

ΠšΠΎΠΌΠΏΠΎΠ½Π΅Π½Ρ‚ для управлСния Home Assistant Ρ‡Π΅Ρ€Π΅Π· ЯндСкс.Π”ΠΈΠ°Π»ΠΎΠ³ΠΈ
Python
141
star
8

DashCast

DashCast component for Home Assistant
Python
139
star
9

PythonScriptsPro

Advanced version of python scripts for Home Assistant without limits
Python
117
star
10

Dataplicity

Public HTTPS access to Home Assistant with Dataplicity service
Python
115
star
11

SSHCommand

Run any SSH command on remote server from Home Assistant service call
Python
91
star
12

MorphNumbers

ΠšΠΎΠΌΠΏΠΎΠ½Π΅Π½Ρ‚ Home Assistant для Ρ€Π°Π±ΠΎΡ‚Ρ‹ с Ρ‡ΠΈΡΠ»ΠΈΡ‚Π΅Π»ΡŒΠ½Ρ‹ΠΌΠΈ Π² Jinja2
Python
90
star
13

hassio-addons

Hass.io addons: go2rtc and SSH Tunnel
Shell
85
star
14

VacuumZones

Control zone cleaning for Xiaomi vacuum cleaners from voice assistants and Home Assistant
Python
73
star
15

GyverLamp

Home Assistant ΠΊΠΎΠΌΠΏΠΎΠ½Π΅Π½Ρ‚ для ΠΈΠ½Ρ‚Π΅Π³Ρ€Π°Ρ†ΠΈΠΈ Π»Π°ΠΌΠΏΡ‹ Π“Π°ΠΉΠ²Π΅Ρ€Π° Π½Π° ΠΎΡ€ΠΈΠ³ΠΈΠ½Π°Π»ΡŒΠ½ΠΎΠΉ ΠΏΡ€ΠΎΡˆΠΈΠ²ΠΊΠ΅
Python
71
star
16

FasterWhisper

Faster Whisper for Home Assistant - custom integration with a local Speech-to-Text engine
Python
60
star
17

yandex_smart_home_fix

Python
58
star
18

Jura

Home Assistant custom component for control Jura Coffee Machines via Bluetooth module
Python
54
star
19

StartTime

Start Time sensor for Home Assistant
Python
53
star
20

AlexxIT

42
star
21

Blog

AlexxIT's Blog
38
star
22

gw3

Xiaomi Gateway 3 (ZNDMWG03LM) companion application for integration with open source Smart Home platforms
Go
30
star
23

openmiio_agent

Go
29
star
24

YandexCOVID

Python
22
star
25

pnproxy

Plug and Proxy is a simple home proxy for managing Internet traffic
Go
21
star
26

MediaExtractorPro

Play playlists on Chromecast devices from Home Assistant
Python
16
star
27

Updater

Python
11
star
28

Ergomotion

Home Assistant custom component for control Ergomotion Smart Beds via Bluetooth module
Python
11
star
29

YandexRoute

Python
8
star
30

rtsplog

Batchfile
7
star
31

BypassAPI

Custom component for disable Home Assistant REST API authentication
Python
6
star
32

AlexxIT.github.io

6
star
33

hassio-rtsp2webrtc

Hass.io addon allows you to watch an RTSP stream in real time using WebRTC technology
JavaScript
6
star
34

HassDiagnostics

Diagnostics entities for Home Assistant
Python
6
star
35

SlowSensor

Python
4
star
36

elastichandler

Python
3
star
37

git-test

3
star
38

yamlconf

Python
3
star
39

arequests

Python
3
star
40

pyasyncweb-tests

Python
2
star
41

intlist

ΠšΠΎΠ΄ΠΈΡ€ΠΎΠ²Π°Π½ΠΈΠ΅ массива integer для ΠΏΠ΅Ρ€Π΅Π΄Π°Ρ‡ΠΈ Π² качСства GET-ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€Π°
Python
1
star
42

SwimFitFixer

Python
1
star