reolink_dev icon indicating copy to clipboard operation
reolink_dev copied to clipboard

Camera stream errors in HomeKit

Open muxa opened this issue 3 years ago • 4 comments

Describe the bug Camera streaming works in HA but does not work via HomeKit (waiting for the stream times out). I have tried different permutations of the integration configuration parameters for protocol, stream and codec without any luck.

To Reproduce Every time I open the camera from the Apple Home app it does not work. HA logs shows:

Logger: homeassistant.components.homekit.type_cameras
Source: components/homekit/type_cameras.py:461
Integration: HomeKit (documentation, issues)
First occurred: 08:36:01 (7 occurrences)
Last logged: 18:56:54

[b69eded9-d7c2-4c8a-83ac-772ce2fd5ba5] Failed to close stream
[b4aba904-b9bc-40f5-b66a-26ab83999a42] Failed to close stream
[8ec0fbb2-ec95-4c9c-94d6-32bce1577c39] Failed to close stream
[95d7a5e1-a921-4faf-ae5f-14429f7dccf7] Failed to close stream
[00bafa0e-7586-49cc-bfbb-ad9c3d1b0e0a] Failed to close stream
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/homekit/type_cameras.py", line 461, in stop_stream
    await getattr(stream, shutdown_method)()
  File "/usr/local/lib/python3.9/site-packages/haffmpeg/core.py", line 158, in close
    await self._loop.run_in_executor(None, _close)
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.9/site-packages/haffmpeg/core.py", line 153, in _close
    self._proc.stdin.write(b"q")
BrokenPipeError: [Errno 32] Broken pipe

Expected behavior I'm expecting the camera stream to work via HomeKit, as it works for generic cameras.

Screenshots n/a

Environment: Please provide useful information about your environment, like:

  • Home Assistant 2021.12.4
  • Reolink camera model RLC-410 & RLC-410W
  • Camera firmware number v3.0.0.136_20121100

Additional context The above mentioned problem happens with 2 cameras setup via Reolink integration, however it does not happen with another camera configured using generic camera:

  - platform: generic
    name: Carport
    stream_source: "-re -rtsp_transport tcp -i rtsp://admin:[email protected]:554/h264Preview_01_sub"

muxa avatar Dec 22 '21 06:12 muxa

I have been trying to figure this out as well. The best I can figure out so far is that I think HomeKit wants MJPEG video (though apple was the biggest proponent of H264.) and currently the integration passes the video through as-is, in whatever format the camera provides. The "Generic" camera forces MJPEG via FFMPEG which is why it works. I think if there is a way to know what video format the camera provides, and what format HomeKit is requesting HA can automatically convert via FFMPEG when necessary.

xannor avatar Feb 12 '22 13:02 xannor

I had the same issue, I was able to fix it by setting the stream type as RTSP and 264 in the config options for the integration. See if that helps

skynet01 avatar Mar 17 '22 18:03 skynet01

I have also adjusted it as follows, with me unfortunately no camera comes even after restart HassIO. image

flame4ever avatar Jul 31 '22 19:07 flame4ever

I actually ended up installing Scrypted it handles all of the HomeKit for me and all videos show up instantly (I also use it to rebroadcast streams to HA and they work more stable). There is a Home Assistant addon of Scrypted as well if you want to run it on the same platform as HA.

skynet01 avatar Nov 09 '22 19:11 skynet01