Realtime camera streaming without any delay - WebRTC

You can run it via SSH Addon. Anyway I already bought Dahua IPC-K42. And it has RTSP backchannel support.

So would I just copy the linux version of the logger to the HA config directory and then run the command in Terminal? I was hoping to test my Hikvision camera or are you saying that this should work on any camera with ONVIF Profile T?

Thank you Alexx, it is working very well, the only thing is the sound icon is enabled while connecting to WiFi only, if remotely it became disabled, do you have solution for that please?

and what about the Mic, is there a way to integrate it ?

Solution for reliable WebRTC in any network setup will be in next big release. Microphone support is also planned there, but only for ONVIF Profile T cameras.

6 Likes

waawā€¦ we will wait for the coming release with many thanksss.

@fuatakgun Iā€™m trying to do the same thing. Any chance you could share conditional card logic? How do you know when camera is streaming?

I read the docs you shared and it was suggesting to key off a binary sensor for the camera, but I donā€™t seem to have one. Iā€™m using MQTT with Ring.

Would appreciate any tips.

@anon63427907 Update: I noticed there was a switch I could key off of (I missed it in the docs).

Unfortunately, Iā€™m noticing a quirk: When I turn the switch off (to stop streaming), it flips back to the static image, but then a few seconds later resumes streaming. Iā€™m assuming there is some delay between the MTQQ/Ring switch and the WebRTC card still trying to stream, which has it bouncing back and forth. Did you run into similar issues?

type: grid
square: false
cards:
  - type: conditional
    conditions:
      - entity: switch.my_camera_name_stream
        state: 'off'
    card:
      type: picture-entity
      entity: camera.my_camera_name_snapshot
      tap_action:
        action: call-service
        service: switch.turn_on
        target:
          entity_id: switch.my_camera_name_stream
  - type: conditional
    conditions:
      - entity: switch.my_camera_name_stream
        state: 'on'
    card:
      type: vertical-stack
      cards:
        - type: custom:webrtc-camera
          entity: camera.my_camera_name_video_feed
        - type: button
          name: Stop Streaming
          show_state: false
          show_icon: false
          tap_action:
            action: call-service
            service: switch.turn_off
            target:
              entity_id: switch.my_camera_name_stream
columns: 1

@AlexxIT - any thoughts on using your card/component in this way? Any better solution you can think of? My hope is to avoid streaming my cameras by default, and require a click/tap on the image to trigger the live feed. [BTW: This WebRTC implementation is soooo fast. Thanks for your contributions!]

This is amazing, thanks all for everyone whoā€™s contributed. It works wonderfullyā€¦ however, Fully (android) crashes after a couple hours. Anyone else experienced this?

hey all - what what a thread - apologies if ive missed a post above on this. Im trying to get this to work through a nginx and docker setup thats NOT in network_mode: host.

Yes i know the docs say not to do thisā€¦ but hey im a network dude and i like the pain.

The first step in getting any protocol to work is to understand the packet flowā€¦ and its here i noticed some crazy-weird behaviour. First i had a lot of trouble even finding my source / test host trying to load the streamā€¦ i think i figured it out thoughā€¦ i think the hass webrtc-camera card code seems to be instructing clients to try connect to ALL addresses that it can pick up on the hass host.

In my case, its a docker container, with

  • A forward facing NIC (172.20.1.x which points upto NGINX) and
  • A downward facing nic (172.20.3.x which points down to the DB layer)

ā€¦ both of which are useless to tell say an iPhone to connect to - they are internal docker addresses - non routable.

But then curiously it seems to ALSO want to try and connect to my ISP public IP address (no idea how it knows that).

so @AlexxIT - heres the question - whats your code doing here? Seems it might be a bit inefficient to spray prospective clients - telling them to connect in to many IPs addresses to bring up the streams. Is there a chance you could have your code tell clients to connect to just the base FQDN, not all the IP addresses (and let the client resolve what that means). In my case (and i suspect a lot of peoples) that would work on the LAN and remote

I can raise an issue, but i did notice there was 117 open so hopeful for the good people in here to comment before i head there.

heres the TCPDUMPā€™ing i was doing proving what im saying if anyone is interested (i ended up finding the flows by grepā€™ing for 528 (which i configured the port range to be 52800 ā†’ 52850)

Hi. I am glad to introduce to you my new project:

Itā€™s in very early stage and can be super unstable. But it already can:

  • be a Home Assistant Add-on or be a standalone application
  • has integration with Hass built-in lovelace camera card
  • has a stable solution for external access to webrtc
  • has integration with FFmpeg for transcoding, MJPEG, HLS and other nice things
  • has 2-way audio support for cameras with ONVIF Profile T

There are more very cool features coming in the near futureā€¦

7 Likes

So, if i understand correct, this addon supports h265 codec? All my cameras are lately h265 so iā€™ve had problems showing picture in HAā€¦

H265 supported almost nowhere in the web.

Theoretically it may be supported on Safari, but with additional development from my side.

But H265 can be transcoded to H264 on the fly with ffmpeg integration. Check examples in the docs. This should still work in near real time delay.

Yeah, i feared soā€¦
thanks, iā€™ll try to play with ffmpeg then.

@keiran.harris I can try to limit listeners on docker interfaces in new go2rtc project.

2 Likes

Hello guys. I am wondering if it possible to combine webrtc-camera card with the picture glance. In other words i would like to have a live feed from sd sream but when i click inside the picture i would like to see the hd stream at bigger window. Thanks.

PS, i am using the tapo integration. My card is looking like this at the moment:

type: custom:stack-in-card
cards:
  - type: custom:webrtc-camera
    url: rtsp://lXXXXX:[email protected]:554/stream2
    camera_view: live
    entities:
      - entity: camera.tapo_camera_sd
        icon: mdi:arrow-left-drop-circle-outline
        tap_action:
          action: call-service
          service: tapo_control.ptz
          service_data:
            entity_id: camera.tapo_camera_sd
            pan: LEFT
      - entity: camera.tapo_camera_sd
        icon: mdi:arrow-up-drop-circle-outline
        tap_action:
          action: call-service
          service: tapo_control.ptz
          service_data:
            entity_id: camera.tapo_camera_sd
            tilt: UP
      - entity: camera.tapo_camera_sd
        icon: mdi:arrow-down-drop-circle-outline
        tap_action:
          action: call-service
          service: tapo_control.ptz
          service_data:
            entity_id: camera.tapo_camera_sd
            tilt: DOWN
      - entity: camera.tapo_camera_sd
        icon: mdi:arrow-right-drop-circle-outline
        tap_action:
          action: call-service
          service: tapo_control.ptz
          service_data:
            entity_id: camera.tapo_camera_sd
            pan: RIGHT
  - type: glance
    show_icon: true
    show_name: false
    show_state: false
    style: |
      ha-card.type-glance .entities, 
      ha-card.type-glance .entity {
        padding: 0px;
        margin: 0px;
      }
      ha-card.type-glance {
        margin-bottom: 0px;
      }
    entities:
      - entity: camera.tapo_camera_hd
        icon: mdi:cctv
        tap_action:
          action: call-service
          service: tapo_control.set_motion_detection_mode
          service_data:
            entity_id: camera.tapo_camera_hd
            motion_detection_mode: low
      - entity: camera.tapo_camera_sd
        icon: mdi:cctv-off
        tap_action:
          action: call-service
          service: tapo_control.set_motion_detection_mode
          service_data:
            entity_id: camera.tapo_camera_hd
            motion_detection_mode: 'off'
      - entity: camera.tapo_camera_sd
        icon: mdi:weather-sunny
        tap_action:
          action: call-service
          service: tapo_control.set_day_night_mode
          service_data:
            entity_id: camera.tapo_camera_sd
            day_night_mode: 'off'
      - entity: camera.tapo_camera_sd
        icon: mdi:weather-night
        tap_action:
          action: call-service
          service: tapo_control.set_day_night_mode
          service_data:
            entity_id: camera.tapo_camera_sd
            day_night_mode: 'on'
  - type: entities
    entities:
      - entity: binary_sensor.tapo_motion_detection
        name: Motion Sensor
    style: |
      ha-card.type-entities {
        margin-right: 14px;
      }
      ha-card.type-entities #states {
        padding-top: 10px;
      }
1 Like

go2rtc compatible with default picture glance card

Thanks @AlexxIT - wow go2rtc looks really promising! Thanks for all you dev!!

Thinking about my issue more (and anyone with their setup using docker and non-host-mode networking) ā€¦ i think the feature request may simply be - allow the user to configure what IP address HASS is known on the local network (not the inside docker network). For instance inside my hass docker instance is 172.x.x.xā€¦ā€¦ but on my real LAN, its 10.1.3.50 (which then of course maps out to an external IP on the internet thru NAT for access outside the house).

So an ability to hard code the IP that the hass streaming source is on - not auto discovery of it - which in this case doesnt work.

go2rtc support hardcode IP list. Check docs.

Iā€™m trying to decide which networks to ignore. Maybe all networks 172.xxx.xxx.xxx

Nice @AlexxIT ! I plan to look deeper at your new project on the weekend so will read the docs fully then. I suspect you will need to allow the user to configure what ranges they should ignore - as docker people may like to fiddle with non standard ranges. Did you want me to move this chat to a new github issue (how do you find the time mate?!!! Very appreciative of your dev. Ill buy you a coffee when im up and running).

Range of networks is very complicated for middle user. I donā€™t like having options like this.

Unfortunately, you canā€™t send me a coffee after february 2022ā€¦