Hi there,
I’ve been trying to add a camera to Home Assistant running on an RPi Zero 2 W without using mjpeg to improve performance (resolution/framerate). Looking at the documentation on Rasperry PI it lists TCP, RTSP and UDP and for every protocol I’ve ran into issues with HA and get the following message: Timeout while loading URL
.
When using TCP and RTSP I’ve been able to see that Home Assistant is actually reaching the endpoint and using cvlc on the host machine I can see the stream.
In case of RTSP I can see the following first by Home Assistant and the host machine:
$ rpicam-vid -t 0 --nopreview --rotation 180 --width 1280 --height 720 --inline -o - | cvlc stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/stream1}' :demux=h264 -vv
[...]
[0000007f700011a0] main stream out debug: net: connecting to [192.168.175.235]:61890
[0000007f700011a0] main stream out debug: net: connecting to [192.168.175.235]:61891 from [192.168.175.168]:58202
[0000007f700011a0] main stream out debug: net: connecting to [192.168.178.78]:41014
[0000007f700011a0] main stream out debug: net: connecting to [192.168.178.78]:41015 from [192.168.175.168]:32969
Using TCP the server allows only one connection and stops after the client closes the connection. I can see that Home Assistant is connecting to it so it reaches it, but after a short time (while the spinner is visible in the HA UI) it disconnects and the server stops:
$ rpicam-vid -t 0 --rotation 180 --width 1280 --height 720 --inline --nopreview --listen -o tcp://0.0.0.0:8001
[...]
Received signal 13
terminate called after throwing an instance of 'std::runtime_error'
what(): failed to send data on socket
Aborted
Funnily the documentation uses tcp/h264
as a protocol which the integration does not allow, because it thinks it is a relative URL.
With UDP I had the most issues and wasn’t able to use VLC on my machine and I could only use ffplay
. As it is also unidirectional I cannot see anything on the RPi that it actually is getting any data.
The logs in Home Assistant are not really helpful as I’m not always sure which log line correspond to which test:
2024-11-13 13:15:36.242 ERROR (stream_worker) [homeassistant.components.stream.stream.test_stream] Error from stream worker: Stream ended; no additional packets
2024-11-13 13:42:01.223 ERROR (stream_worker) [homeassistant.components.stream.stream.test_stream] Error from stream worker: Stream ended; no additional packets
2024-11-13 13:56:58.551 ERROR (stream_worker) [homeassistant.components.stream.stream.test_stream] Error from stream worker: No dts in 7 consecutive packets
2024-11-13 13:57:13.708 ERROR (stream_worker) [homeassistant.components.stream.stream.test_stream] Error from stream worker: No dts in 7 consecutive packets
2024-11-13 13:58:17.969 ERROR (stream_worker) [homeassistant.components.stream.stream.test_stream] Error from stream worker: No dts in 7 consecutive packets
2024-11-13 13:58:28.102 ERROR (stream_worker) [homeassistant.components.stream.stream.test_stream] Error from stream worker: Error opening stream (ERRORTYPE_111, Connection refused, tcp://192.168.175.168:8001)
2024-11-13 14:03:05.591 ERROR (stream_worker) [homeassistant.components.stream.stream.test_stream] Error from stream worker: Error opening stream (EXIT, Immediate exit requested, udp://192.168.175.168:8001)