home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
69.71k stars 28.87k forks source link

Choppy audio for HomeKit cameras / similar issue has been solved elsewhere #118135

Open Kugelfang666 opened 1 month ago

Kugelfang666 commented 1 month ago

The problem

A camera exposed to HomeKit via HA exhibits choppy audio. A similar issue has been discussed, identified and fixed elsewhere.

https://github.com/AlexxIT/go2rtc/issues/667

https://github.com/AlexxIT/go2rtc/pull/843

I could verify that If I expose my camera using the HomeKit server of go2rtc everything is working as expected.

If I use the HomeAssitant HomeKit server with the go2rtc stream as source the audio is choppy.

What version of Home Assistant Core has the issue?

2024.5.5

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

homekit

Link to integration documentation on our website

https://www.home-assistant.io/integrations/homekit/

Diagnostics information

No response

Example YAML snippet

homekit:  
  - name: CAM Haustuer 2
    port: 21068
    entity_config:
      camera.my_cam:
        name: my_cam
        linked_doorbell_sensor: binary_sensor.my_cam_bell
        linked_motion_sensor: binary_sensor.my_cam_motion
        video_codec: copy
        support_audio: false
        stream_source: "rtsp://GO2RTC-IP:8554/my_cam#audio=opus"

Anything in the logs that might be useful for us?

Details can be found here https://github.com/AlexxIT/go2rtc/pull/843#issue-2055099121

Additional information

No response

myevit commented 1 month ago

It has been always choppy due to not fully compatible audio codec. Apple use proprietary audio codec in homekit, that's why it's not a part of HA. Something like this I believe.

Kugelfang666 commented 1 month ago

Thanks for looking into this.

From the linked solution months go2rtc repro it seemed to be a mismatch in pakage sizes depending on connection type (WiFi / cellular)

For the go2rtc HomeKit server this issues was successfully resolved. Hence I hope that this can server as a template for the solution in HA too

home-assistant[bot] commented 3 weeks ago

Hey there @bdraco, mind taking a look at this issue as it has been labeled with an integration (homekit) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `homekit` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign homekit` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


homekit documentation homekit source (message by IssueLinks)

bdraco commented 3 weeks ago

HomeKit calls ffmpeg directly and there is no reprocessing of the audio stream where the timestamps could be rewritten. Something would need to be written to reprocess the audio stream to be able to implement something similar.