Amcrest Camera Feed - How to Prevent Going Blank/White After a few Seconds If Clicked Into from HA?


#1

I have a few Amcrest IP cameras configured with HA. They provide a nice quick visual of what’s happening and work fairly consistently.

As soon as I click/tap into one of the camera feeds, I get a larger view of the “live stream” (really updates ever X number of seconds). After ~5 seconds, the screen goes blank/white and I am no longer shown the “live stream.” After clicking the X to go back to my Home UI, I still see the “live stream” via the smaller visual, so it’s still working.

Any ideas as to what’s happening? And if so, is there a configuration setting that would allow it to continue streaming the feed?


#2

There are several things you can do. I think the problem is the resolution is too high and frame rate is to much. I wasn’t happy with the performance when accessing my Amcrest IP Cam so I played around with various options until I found something that worked well.

One thing you my want to so is figure out the various URLs your camera supports. ispy is a good place for that: https://www.ispyconnect.com/man.aspx?n=Amcrest

If it has a substream, you can modify the settings to use something other than h.264. For instance, mine supports mjpeg. I can switch it to mjpeg and drop the frame rate down to 15 and access it through HA using the mjpeg camera type and its mjpeg url. The resolution will be smaller, probably 640x480 but even on my laptop, the quality is still excellent.

If it has rtsp support, you can use ffmpeg. For instance, I use ffmpeg with the substream set to h.264 and use the -r 15 argument to limit to 15 fps.

Another option is to use ffserver to transcode the rtsp stream into something else such as mjpeg. Then use the mjpeg camera type to view it. I find this to be the best way as the stream is always available and you don’t have to wait for ha to fire up an ffmpeg stream as the mjpeg stream is always running. Accessing an ffserver mjpeg stream from HA or HADashboard loads instantly.


#3

Are you using the Amcrest Hub component? And do you often see errors in the log? If so, I found that there is a bug in the code that makes it not thread-safe. I fixed the problem for myself, and added quite a few other features, but unfortunately given everything else going on I haven’t gotten around to feeding this back to the developer(s) of this component.

If you’re interested in what I’ve done, you can look here. Note this is not very well documented since so far I really haven’t shared this work. But you’re more than welcome to try what I did (if you’re comfortable with hand installing custom components.)

Regarding the thread-safety issue, basically the camera doesn’t like when multiple long commands are pending. (This applies to more than just the camera feeds, e.g., background motion detection monitoring, etc.) When you click on the image in the frontend, and you see the larger box open, what’s happening is now you have two views trying to show the same feed (which, by default, is using the camera’s snapshot API command.) The normal view only grabs a new image every 10 seconds, but the larger one tries to grab snapshots as fast as possible. When these two “collide”, the camera responds with errors.

Since there are many ways to configure HA to work with Amcrest cameras, and there are lots of Amcrest models, and lots of different firmware versions, the above discussion may or may not apply in your scenario.