AlexxIT / WebRTC

Home Assistant custom component for real-time viewing of almost any camera stream using WebRTC and other technologies.
https://github.com/AlexxIT/Blog
MIT License
1.52k stars 180 forks source link

i have image but no sound #339

Closed warlordattack closed 2 years ago

warlordattack commented 2 years ago

hello,

i stream from OBS - RTSP Server plugin on a local PC, to HA generic camera then display via

cards setup :

type: custom:webrtc-camera
entity: camera.dn_l # generic camera
muted: false

or

type: custom:webrtc-camera
url: rtsp://plop:obs1234@192.168.1.54/live
muted: false

i have the image but no sound, the same rtsp stream to picture glance card works with sound :

camera_view: live
type: picture-glance
title: obs
entities:
  - entity: camera.dn_l
camera_image: camera.dn_l
aspect_ratio: '16:9'

my HA OS is a VM inside synology ds918+ nas, powered by synology virtual machine manager, i have latest version of HA OS

this sound problem is the same on all my devices PC (edge), iphone, ipad

help please :)

best regards

2022-08-11_221847 2022-08-11_222207 2022-08-11_222512

sometimes i have this error but after few seconds the stream appears : 2022-08-11_224353

my goal is to have low latency apple tv stream with controls in HA, i capture apple tv to pc via usb hdmi recorder, in OBS i capture the USB Video device, then sent the stream via OBS RTSP Plugin to HA

full card of what you see on the picture : buttons use HACS Apple TV Beta Component : https://github.com/postlund/hass-atv-beta

cards:
  - type: custom:webrtc-camera
    entity: camera.dn_l
    muted: false
  - type: horizontal-stack
    cards:
      - type: custom:button-card
        entity: remote.atv_bureau
        name: null
        icon: mdi:chevron-left-box-outline
        show_icon: true
        show_name: false
        tap_action:
          action: call-service
          haptic: heavy
          service: remote.send_command
          service_data:
            command: menu
            entity_id: remote.atv_bureau
        hold_action:
          action: none
        styles:
          card:
            - height: 50px
          icon:
            - color: white
          label:
            - color: white
      - type: custom:button-card
        entity: remote.atv_bureau
        hold_action:
          action: none
        icon: mdi:chevron-up
        name: Up arrow
        show_icon: true
        show_name: false
        tap_action:
          action: call-service
          service: remote.send_command
          service_data:
            command: up
            entity_id: remote.atv_bureau
        styles:
          card:
            - height: 80px
          icon:
            - color: white
          label:
            - color: white
      - type: custom:button-card
        entity: remote.atv_bureau
        name: Home
        icon: mdi:monitor
        show_icon: true
        show_name: false
        tap_action:
          action: call-service
          haptic: heavy
          service: remote.send_command
          service_data:
            command: home
            entity_id: remote.atv_bureau
        hold_action:
          action: call-service
          service: remote.send_command
          service_data:
            command: home_hold
            entity_id: remote.living_room
        styles:
          card:
            - height: 50px
          icon:
            - color: white
          label:
            - color: white
  - type: horizontal-stack
    cards:
      - type: custom:button-card
        entity: remote.atv_bureau
        hold_action:
          action: none
        icon: mdi:chevron-left
        name: Left arrow
        show_icon: true
        show_name: false
        tap_action:
          action: call-service
          service: remote.send_command
          service_data:
            command: left
            entity_id: remote.atv_bureau
        styles:
          card:
            - height: 80px
          icon:
            - color: white
          label:
            - color: white
      - type: custom:button-card
        entity: remote.atv_bureau
        hold_action:
          action: none
        icon: mdi:radiobox-blank
        name: Select
        show_icon: true
        show_name: false
        tap_action:
          action: call-service
          haptic: heavy
          service: remote.send_command
          service_data:
            command: select
            entity_id: remote.atv_bureau
        styles:
          card:
            - height: 80px
          icon:
            - color: white
          label:
            - color: white
            - text-size: 12px
      - type: custom:button-card
        entity: remote.atv_bureau
        hold_action:
          action: none
        icon: mdi:chevron-right
        name: Right arrow
        show_icon: true
        show_name: false
        tap_action:
          action: call-service
          service: remote.send_command
          service_data:
            command: right
            entity_id: remote.atv_bureau
        styles:
          card:
            - height: 80px
          icon:
            - color: white
          label:
            - color: white
  - type: horizontal-stack
    cards:
      - type: custom:button-card
        entity: remote.atv_bureau
        name: Play/Pause
        icon: mdi:play-pause
        show_icon: true
        show_name: false
        tap_action:
          action: call-service
          haptic: heavy
          service: remote.send_command
          service_data:
            command: play_pause
            entity_id: remote.atv_bureau
        hold_action:
          action: none
        styles:
          card:
            - height: 50px
          icon:
            - color: null
          label:
            - color: white
      - type: custom:button-card
        entity: remote.atv_bureau
        hold_action:
          action: none
        icon: mdi:chevron-down
        name: Down arrow
        show_icon: true
        show_name: false
        tap_action:
          action: call-service
          service: remote.send_command
          service_data:
            command: down
            entity_id: remote.atv_bureau
        styles:
          card:
            - height: 80px
          icon:
            - color: white
          label:
            - color: white
      - type: custom:button-card
        entity: remote.atv_bureau
        name: mute
        icon: mdi:volume-off
        show_icon: true
        show_name: false
        tap_action:
          action: call-service
          haptic: heavy
          service: remote.send_command
          service_data:
            command: volume_set
            volume_level: 0
            entity_id: remote.atv_bureau
        hold_action:
          action: none
        styles:
          card:
            - height: 50px
          icon:
            - color: null
          label:
            - color: white
  - type: horizontal-stack
    cards:
      - type: custom:button-card
        entity: remote.atv_bureau
        name: Volume up
        icon: mdi:plus
        show_icon: true
        show_name: false
        tap_action:
          action: call-service
          haptic: heavy
          service: remote.send_command
          service_data:
            command: volume_up
            entity_id: remote.atv_bureau
        hold_action:
          action: none
        styles:
          card:
            - height: 50px
          icon:
            - color: null
          label:
            - color: white
      - type: custom:button-card
        entity: remote.atv_bureau
        name: Volume down
        icon: mdi:minus
        show_icon: true
        show_name: false
        tap_action:
          action: call-service
          haptic: heavy
          service: remote.send_command
          service_data:
            command: volume_down
            entity_id: remote.atv_bureau
        hold_action:
          action: none
        styles:
          card:
            - height: 50px
          icon:
            - color: null
          label:
            - color: white
      - type: custom:button-card
        entity: remote.atv_bureau
        hold_action:
          action: none
        icon: mdi:rewind-10
        name: Skip Back
        show_icon: true
        show_name: false
        tap_action:
          action: call-service
          service: remote.send_command
          service_data:
            command: skip_backward
            entity_id: remote.atv_bureau
        styles:
          card:
            - height: 50px
          icon:
            - color: null
          label:
            - color: white
      - type: custom:button-card
        entity: remote.atv_bureau
        hold_action:
          action: none
        icon: mdi:fast-forward-10
        name: Skip forward
        show_icon: true
        show_name: false
        tap_action:
          action: call-service
          service: remote.send_command
          service_data:
            command: skip_forward
            entity_id: remote.atv_bureau
        styles:
          card:
            - height: 50px
          icon:
            - color: null
          label:
            - color: white
      - type: custom:button-card
        entity: remote.atv_bureau
        name: Sleep
        icon: mdi:power-standby
        show_icon: true
        show_name: false
        tap_action:
          action: call-service
          service: remote.send_command
          service_data:
            command: suspend
            entity_id: remote.atv_bureau
        hold_action:
          action: none
        styles:
          card:
            - height: 50px
          icon:
            - color: white
          label:
            - color: white
  - camera_view: live
    type: picture-glance
    title: obs
    entities:
      - entity: camera.dn_l
    camera_image: camera.dn_l
    aspect_ratio: '16:9'
type: vertical-stack
AlexxIT commented 2 years ago

If you have sound in glance card means audio in AAC codec. This codec don't supported by WebRTC: https://developer.mozilla.org/en-US/docs/Web/Media/Formats/WebRTC_codecs

raven-2014 commented 1 year ago

@AlexxIT Hi, I am new to HomeAssistant and started playing with the Webrtc Camera Intergration (using built-in go2rtc). Before brining up the question again, I searched for my problem, but could not figure out how to solve my problem. Thus my question here:

HomeAssistant is running in Docker, in Host-Mode. I have a Reolink E1 Zoom. Reolink Integration is installed and provides the camera entity. Displaying the life-stream in Picture-Glance has video and audio, but terrible latency and stability.

This is what I added into the go2rtc.yaml file:

api:
  listen: 127.0.0.1:1984
rtsp:
  listen: 127.0.0.1:8554

streams:
  cam_01_sub: 
    - rtsp://<user>:<password>@<cameraIP>:554/h264Preview_01_sub&audio=opus 
    - ffmpeg:rtsp://<user>:<password>@<cameraIP>:554/h264Preview_01_sub&audio=opus

webrtc:
  candidates:
    - 127.0.0.1:8555
    - stun:8555

This is the config in my frigate-card:

type: custom:frigate-card
cameras:
  - camera_entity: camera.cam_01_sub
    live_provider: webrtc-card
    webrtc_card:
      entity: camera.cam_01_sub
      mse: false
      mode: webrtc
menu:
  style: hover
  buttons:
    image:
      enabled: true
view:
  default: image
image:
  mode: camera
  refresh_seconds: 2

The Video is playing super smooth using the frigate card, I do not have audio though. Looks like it is not picking up the opus codec. What am I missing?

AlexxIT commented 1 year ago

You have a lot of mistakes in config

raven-2014 commented 1 year ago

@AlexxIT thank you for your very quick response. I corrected mistakes 2 & 3 but I guess I have not yet figured out how link the camera entity in the card with the entry in g2rtc.yaml.

This is what I tried ... without success .. i.e. webrtc video displaying, but still no audio available:


api:
  listen: <server IP>:1984
rtsp:
  listen: <server IP>:8554

webrtc:
  candidates:
    - <server IP>:8555
    - stun:8555

streams:
  cam_01_sub:
    - rtsp://<user>:<password>@<camera IP>:554/cam_01_sub
    - ffmpeg:rtsp://<user>:<password>@<camera IP>:554/cam_01_sub#audio=opus

log:
  level: info  # default level
  api: trace
  exec: debug
  rtsp: debug
  streams: debug
  webrtc: debug

When looking into the g2rtc web-ui, I see the camera.cam_01_sub and can view the stream in RTC, but also only without audio.

Can you pleeease enlighten me :) thanks a lot.

UPDATE: It looks like this Integration is somewhat in conflict with the FRIGATE Integration in its usage of go2rtc. I played around with a FRIGATE webrtc stream in the FRIGATE card, using go2rtc as the live-provider .... and guess what ... it worked with audio right away.