Ipcamera streams not automatically updating / cached


i use ipCamera binding for my Unifi Protect Doorbell G4. Mjpeg und HLS Streams work, but are not updating if i go to my camera page in openhab again.

so i have a constantly open and running openhab on my tablets at home and when going to the camera page where i include the mjpg / hls streams, it loads. e.g. a 4h old stream when i watched last time. page reloads makes reload the videos and show the live streams. it seems its cached or something like that.

any idea how i can fix this?

also i notice that after some time my binding seems to stop working. disabling and enabling the Thing fixes this. but this happens regularly. in the same time i can open the streams from the native apps of the cameras, so they are online.

happy to hear you thoughts.

The binding does not cache any video streams, however it does hold the last snapshot in ram to help start mjpeg streams created from snapshots faster. If you’re seeing the clock tick over or the picture is not fully static then it will be your camera giving an old stream.

The binding can be operating in either a proxy mode where it passes the cameras stream on, or it can also create the mjpeg streams from snapshots, knowing which URL you’re trying to open and where the camera is sourcing it from will be helpful. The logs will show this as especially when the camera is ONVIF, the camera can auto find urls to use and does not need them given in the setup.

In the bindings documentation at the very start it tells you how to get debug and trace level logs for asking help with. That will be helpful to see what is happening.

thanks for the insights. i just figured out that i have very low wifi singal stregth (around -75dbm) so i guess i have packet losses etc. i first try to fix this and retest. if the problem persists i will try to get trace logs etc. thanks.

also thanks for last snapshot info. the time is static so its the last shot i see and somehow the binding doesnt get the new mjpeg stream (via proxy)…

hi @matt1

first of all thanks you help all the time with this great binding.
I was able to fix some things. it was not because of bad wifi, but my mjpeg stream was constantly running on 2 tablets and i guess used all ressources and basically openhab crashed but didnt show it immediately.

however, i lowered the resolution of the rtsp stream and also changed my code so the stream is only showed on demand for my doorbell. this works and is not showing old snapshots any more.

so i am fine with mjpeg.

on another page i still have a problem that i was not able to solve.
its a openhab main ui page whre i have 3 HLS Streams included. they are not running all the time. so no problem with ressources etc. but i can always reproduce the following:

1 of the streams is always “old” and shows an ealrlier date/time. it runs some second and then stops loading. the other 2 streams load the live stream. this was random with the 3 videos. than i changed to “manual” start of the videos and i can reproduce the following: the first video i start is old, the next 2 ones get the fresh stream.

here the logs

openhab> log:tail camera.internal
08:30:35.487 [DEBUG] [camera.internal.servlet.CameraServlet] - GET:/ipcamera.m3u8, received from
08:30:35.489 [DEBUG] [nhab.binding.ipcamera.internal.Ffmpeg] - Starting ffmpeg with this command now:-hide_banner -loglevel warning                            -rtsp_transport tcp -i rtsps:// -strict -2 -f lavfi -i aevalsrc=0 -acodec aac -vcode                           c copy -hls_flags delete_segments -hls_time 2 -hls_list_size 4 /var/lib/openhab/ipcamera/f0dc14d199/ipcamera.m3u8
08:30:35.576 [DEBUG] [camera.internal.servlet.CameraServlet] - GET:/ipcamera.m3u8, received from
08:30:35.576 [DEBUG] [nhab.binding.ipcamera.internal.Ffmpeg] - Starting ffmpeg with this command now:-hide_banner -loglevel warning                            -rtsp_transport tcp -i rtsps:// -strict -2 -f lavfi -i aevalsrc=0 -acodec aac -vcode                           c copy -hls_flags delete_segments -hls_time 2 -hls_list_size 4 /var/lib/openhab/ipcamera/165b42c7f9/ipcamera.m3u8
08:30:35.586 [DEBUG] [camera.internal.servlet.CameraServlet] - GET:/ipcamera.m3u8, received from
08:30:35.587 [DEBUG] [nhab.binding.ipcamera.internal.Ffmpeg] - Starting ffmpeg with this command now:-hide_banner -loglevel warning                            -rtsp_transport tcp -i rtsps:// -strict -2 -f lavfi -i aevalsrc=0 -acodec aac -vcode                           c copy -hls_flags delete_segments -hls_time 2 -hls_list_size 4 /var/lib/openhab/ipcamera/aa63b2a7ff/ipcamera.m3u8
08:30:37.830 [DEBUG] [nhab.binding.ipcamera.internal.Ffmpeg] - [rtsp @ 0x56315b8d9a40] Thread message queue blocking; consider rais                           ing the thread_queue_size option (current value: 8)
08:30:37.973 [DEBUG] [nhab.binding.ipcamera.internal.Ffmpeg] - [rtsp @ 0x55768dc53a40] Thread message queue blocking; consider rais                           ing the thread_queue_size option (current value: 8)
08:30:38.088 [DEBUG] [nhab.binding.ipcamera.internal.Ffmpeg] - [rtsp @ 0x557235e52a40] Thread message queue blocking; consider rais                           ing the thread_queue_size option (current value: 8)
08:30:41.007 [DEBUG] [camera.internal.servlet.CameraServlet] - GET:/ipcamera.m3u8, received from
08:30:41.374 [DEBUG] [camera.internal.servlet.CameraServlet] - GET:/ipcamera19.ts, received from
08:30:42.495 [DEBUG] [camera.internal.servlet.CameraServlet] - GET:/ipcamera20.ts, received from
08:30:42.916 [DEBUG] [camera.internal.servlet.CameraServlet] - GET:/ipcamera21.ts, received from
08:30:43.275 [DEBUG] [camera.internal.servlet.CameraServlet] - GET:/ipcamera22.ts, received from
08:30:45.013 [DEBUG] [camera.internal.servlet.CameraServlet] - GET:/ipcamera.m3u8, received from

Can you help me with this? the only problem i see is thread_queue_size option which i guess has to do again wieth resources - but there should be enough free resources as before nothing was running from ipcamera.

what i also noticed is that log entries already apear when the page loads, and not only when i hit play. so i guess auto-play or manual play is not really a difference. its just easier to reproduce the problem for me.

regarding my setup: I use a unifi nvr. so all rtsp streams come from 1 server and not different cams/ips. dont know if this may be problematic for the binding? (so ip is always same, but stream urls are different of course).

for the hls streams i also lowered the resolution of the incoming rtsp stream

hope you can help with this. however my major problem was with mjpeg which i could solce.

or what logs /data etc. could i look into more? regarding the thread_queue_size option i didnt find anything useful except ressource issues but as said, before starting the video streams - no other video is running and other stuff in my server consume like nothing … server is also a real virtual server with enough resources an not raspberry.

also i was wondering why the logs mention the ip as i dont use it. my nvr is and cameras also have other ips. so what is this ip in the log?


That IP should be the machine that your asking to watch the HLS stream from. It should be one of your tablets if that is what your using to open the stream with. Your able to use the whitelist if you want to limit only certain IP’s from getting access to the streams.

Yes I can reproduce this so I do not need logs from your sysrem. It takes time for FFmpeg to start creating the HLS stream and some times the ipcamera.m3u8 file is sent back old if it has not fully started creating the stream. I may be able to improve this as I was using delays in replying to the requesting browser to give it time to open the camera and produce the stream, there are limitations on what can be done as a web browser expects a reply within a certain time frame…

As for a work around, you can create the HLS stream non stop so it is always being created, or you can just press refresh on the browser to get the updated stream after a few seconds has passed to give it some time to fully create the stream.

thanks, all clear!