RTSP Stream (Solved)

Hello,
I am trying to get my cameras streaming to Home Assistant. In the past I setup a Zoneminder server, and then used the Zoneminder integration to get my cameras into Home Assistant. I have Zoneminder streaming my cameras via an RTSP TCP stream, it works great, and the Home Assistant Integration also works really well.

The Zoneminder server is a hog, and I want to eliminate it. I have heard and seen people be successful with getting RTSP streams working with Home Assistant.

This is what my configuration.yaml file looks like:

camera:
 - platform: ffmpeg
   name: "Indside Garage Doors"
   input: -f rtsp -rtsp_transport tcp -i rtsp://user:[email protected]:554/cam/realmonitor?channel=1&subtype=0

I do get a static image on the HA dashboard:
image


But when I click the image to bring up the stream I get this:

Error with media stream contents (bufferAppendError)

image

I tried running ffmpeg from the CLI in my HA Docker and this is the output that I get:

root@ha:/# ffmpeg version 4.4.1 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 10.3.1 (Alpine 10.3.1_git20210424) 20210424
configuration: --prefix=/usr --enable-avresample --enable-avfilter --enable-gnutls --enable-gpl --enable-libass --enable-libmp3lame --enable-libvorbis --enable-libvpx --enable-libxvid --enable-libx264 --enable-libx265 --enable-libtheora --enable-libv4l2 --enable-libdav1d --enable-postproc --enable-pic --enable-pthreads --enable-shared --enable-libxcb --enable-libsrt --enable-libssh --enable-libvidstab --disable-stripping --disable-static --disable-librtmp --enable-vaapi --enable-vdpau --enable-libopus --enable-vulkan --enable-libsoxr --enable-libwebp --enable-libaom --disable-debug
libavutil      56. 70.100 / 56. 70.100
libavcodec     58.134.100 / 58.134.100
libavformat    58. 76.100 / 58. 76.100
libavdevice    58. 13.100 / 58. 13.100
libavfilter     7.110.100 /  7.110.100
libavresample   4.  0.  0 /  4.  0.  0
libswscale      5.  9.100 /  5.  9.100
libswresample   3.  9.100 /  3.  9.100
libpostproc    55.  9.100 / 55.  9.100

I have become somewhat familiar with these pieces of documentation:

I have read through numerous threads trying various configurations:

My Home Assistant log is empty, not a single entry…

Any thoughts would be very much appreciated.

Ok, I have found a CLI command that is getting good output from ffmpeg:

ffmpeg -rtsp_transport tcp -i "rtsp://user:[email protected]:554/cam/realmonitor?channel=1&subtype=0" out.mp4

The big change here is quotes around the rtsp address. Apparently ffmpeg does not like the ampersand (&) and interprets everything after it as more parameters.

The MP4 that it outputs works, but unfortunately the same string does not work in my configuration.yaml file, the camera appears as “Unavailable”…

Edge and Firefox throw this error:
Error with media stream contents (bufferIncompatibleCodecsError)

While Chrome throws this error:
Error with media stream contents (bufferAppendError)

Turns out these errors are because Chromium based browsers cannot decode h265 streams. Switching my DVR box to h264 has solved the issue in Chrome and now I can rid myself of the Zoneminder VM that was consuming large amounts of processing power.

1 Like

Did you ever get this working? I have an Amcrest AD410 exposed to HA using the custom Dahua integration, but I am trying to get it working to homekit via HA and it doesn’t work. I am trying to do a packet capture but I am getting nowhere. I have added an rtsp stream_source kit to the homekit.yaml file but no dice.

Have you tried homekit with your setup or so far just trying to get it to work on the browser? I feel using the Dahua integration the browser seems fine. I am on the latest firefox.

Yes, I got it working by changing to h264. Both with web browsers and HomeKit.

2 Likes

Hi James, could you please share your automation setup code for future reference?

1 Like