IpCamera: New IP Camera Binding

Either do I! Ignore me.

@dastrix80
It would be great if you could test your Doorbird with this new version of the binding as I had to guess at a number of things with the Alarm stream. If it does not work I just need some feedback on what the camera sends to this url in any browser:

http://ipofcamera/bha-api/monitor.cgi?ring=doorbell,motionsensor

Hi Matt

I dont use Motion on the doorbird, Iā€™ve got it turned off. I was able to pull a video stream from the doorbird just fine though. What did you want me to do, thrown that URL into a browser?

If you could and just tell me what appears on the screen when the doorbell is pushed down and what occurs when it is not pushed down. Same for motion if you could turn it on temporarily for testing. The binding may already react to doorbell and motion events. The binding wont mess with any of your settings as the alarm stream is handled differently in the binding to how I have seen people using the REST api.

OK, ill do my best

Hi,
Iā€™ve been not using your binding for a while since it somehow was breaking my openhab, twice.
It has to be connected somehow with out of heap space that appears always when I use this binding nevertheless I increased memory following some guidance in this community. I have had therefore to stop using the binding and use direct commands that Foscam FI9826W/P cameras supports. Donā€™t take me wrong, I very, very, very appreciate your work as this is an amazing and very important binding, however I havenā€™t time to deal with the issues I suffered.

Now Iā€™m back again since Iā€™ve installed 6th camera which is Hikvision DS-2CD2143G0-IS that unfortunately uses basic login credentials that are not supported by web browsers anymore.
So I hoped your binding can help with that and I will try this time to resolve issues with heap space and others.

Now I have a problem. I configured everything as in your description and Iā€™ve got video stream from the binding. However the video stream drops connection pretty often i.e. 15m, 0,5h, 1h etc. I solved the same problem with my foscam cameras by refreshing stream every 5m. However it doesnā€™t work with the stream from this binding. After refresh the camera does not reconnect. Only restarting webpage or browser helps.
I use tablets in my house with installed latest habpanelviewer on them and streams are put into Image widgets with embedded refresh feature. Also I use carousel widget with refresh. The issue is the same regardless of solution used.
Can you help me understand why this happens and how can I resolve it?

Hi Matt

If you used an Intel QuickSYNC GPU enabled system for OH2 (Say an Intel NUC with Intel Iris GFX), would your binding take advantage of the hardware decoding to reduce CPU usage? Even with 9 cameras at 350x230, 10FPS Substream MJPEG the CPU usage is high.

Cheers

If you ever used the Android app, see this thread. I suspect the leak you refer to having issues with in the past is in the displaying of images and is not part of my binding but the core of Openhab or the a app and the way it handles the image dataā€¦

I run only a single camera currently for weeks on end with no issues, however I donā€™t run the camera on a tablet non stop like you appear to be doing. I did do some testing where I ran the new stream non stop for over two hours watching the heap to see if it grew whilst monitoring memory/threads and objects, did not find any issues. The stream ran without stopping for over 2 hours when I got sick of watching and stopped it.

In regards to your stream stopping, does this happen only on Foscams or is it happening on the Hikvision as well? If on both it may be a network issue and worth fault finding if it may be a bad cable or something that is simple to replace.
The binding copies the stream and will not stop the stream from the camera to the binding if you are watching it on multiple tablets, this could be the reason why the same band aid fix of doing a refresh does not work. It only stops the stream if you stop or refresh when only 1 tablet is showing the stream. Having the camera going to two tablets would mean the original connection to the camera never stops and your work around fix would not work if the camera to the binding develops an issue.

Iā€™ll run some tests and look at what logging is in the binding to see if a trace would turn up more info.

@dastrix80
The binding does not give me high CPU so if you have that occurring it is an issue on your system which no one else has reported and I have not seen it happen here. So I suspect you would not see any difference by changing to a QuickSYNC system as currently the binding does not do any transcoding. In the future the binding may do transcoding and when that is the case QuickSYNC will help for sure.

Hi Matt

OK, something doesnt add up.

Without the binding, its fine, with it the CPU runs high when I display the cameras. The binding may not given you high CPU because youā€™re only running 1 camera right?

I agree, we have already discussed this, what is confusing you?

Fix the root cause of those errors and the CPU load will be nice and low like it is on my setup.

Why donā€™t you try only 1 camera and test it? You need to do some testing and fault finding as I will not do it for you, this is opensource where no one gets paid and I am not support. I use only 1 camera as the logs are a nightmare to read if multiple cameras are flooding detailed trace/debugging.

I checked what the logs will show and the line will need the logs set to DEBUG to be seen. If you disable image updates and set the polling time to be large then the log output should be minimal.
When you try to refresh do you see this in the logā€¦

[DEBUG] [.o.b.i.handler.IpCameraHandler:490  ] - All streams have stopped, so closing the source stream now.

Unless you see this the cameras source stream is still running. Other lines will/may appear in the log which may give clues.

Tonight I ran two cameras at the same time feeding two habpanels from each of the cameras, no problems and closed it down after an hour. One camera was Hikvision and the other an Amcrest.

It would also be helpful to know what/how you are displaying the video feed as you mention you are sending the feed to an IMAGE item ?!?!?! Have you tried the VIDEO item or using the habpanel ā€˜frame widgetā€™ it has the ability to do an auto refresh for you, but remember it will not stop the source stream from the camera unless all the feeds to target devices have been shutdown and that line I quoted earlier appears in your log.

If you ever used the Android app, see this thread. I suspect the leak you refer to having issues with in the past is in the displaying of images and is not part of my binding but the core of Openhab or the a app and the way it handles the image dataā€¦

Iā€™m sure this issue is connected with my case. From what I remeber, out of memory space happened much quicker in case I wanted view often refreshed snapshots from cameras, on the android app.

I run only a single camera currently for weeks on end with no issues, however I donā€™t run the camera on a tablet non stop like you appear to be doing. I did do some testing where I ran the new stream non stop for over two hours watching the heap to see if it grew whilst monitoring memory/threads and objects, did not find any issues. The stream ran without stopping for over 2 hours when I got sick of watching and stopped it.

So I have 6 cameras running. 5 cameras are Foscam FI9826W/P and 1 camera is Hikvision DS-2CD2143G0-IS. I also have tablets of Lenovo Tab2 A10-70 (Andorid 6.0) running habpanelviewer for 24h. In terms of network I have Asus RT-AC87U working together with 2 TP-Link switches TL-SG3424. The Asus router is not very reliable and Iā€™m going to exchange it to something else, however even though there can be network issues, openhab and its bindings should be resistant for such things in my opinion.

In regards to your stream stopping, does this happen only on Foscams or is it happening on the Hikvision as well?

I think it is difficult to compare, because the stream from foscam cameras are taken directly from the camera and last much longer than for Hikvision camera. But anyway any camera will lost connection eventually and such situation should have its solution in my opinion.

The binding copies the stream and will not stop the stream from the camera to the binding if you are watching it on multiple tablets, this could be the reason why the same band aid fix of doing a refresh does not work. It only stops the stream if you stop or refresh when only 1 tablet is showing the stream.

So certainly i watch streams from cameras on every tablet in various combinations at the same time.

Having the camera going to two tablets would mean the original connection to the camera never stops and your work around fix would not work if the camera to the binding develops an issue.

Iā€™m not sure if I understood it correctly.
I suppose the connection between the binding and camera itself works fine and donā€™t stop?
The stream that stops in my opinion is between the binding and the tablets, and it looks like it canā€™t be just refreshed. Reloading page does not work in case of habpanelviewer. I need to restart habpanelviewer app to get refreshed stream. In case of Chrome running on my PC nrestarting Chrome or reloading page doesnā€™t work at allā€¦

I checked what the logs will show and the line will need the logs set to DEBUG to be seen. If you disable image updates and set the polling time to be large then the log output should be minimal.
When you try to refresh do you see this in the logā€¦

Ok I will set up DEBUG and let you know what results are

It would also be helpful to know what/how you are displaying the video feed as you mention you are sending the feed to an IMAGE item ?!?!?! Have you tried the VIDEO item or using the habpanel ā€˜frame widgetā€™ it has the ability to do an auto refresh for you, but remember it will not stop the source stream from the camera unless all the feeds to target devices have been shutdown and that line I quoted earlier appears in your log.

I didnā€™t set up Sitemap at all. Right now I only use habpanel with Image widget (with refresh) and Carousel template (also with refresh) as below;

<uib-carousel ng-init="
                         images=[
                           { url: 'http://192.168.1.181:54320/ipcamera.mjpeg', name: 'Cam0', refresh: 3000 },
                           { url: 'http://192.168.1.111:9988/cgi-bin/CGIStream.cgi?cmd=GetMJStream&usr=openhab&pwd=xxx', name: 'Cam1', refresh: 3000 },
                           { url: 'http://192.168.1.112:9988/cgi-bin/CGIStream.cgi?cmd=GetMJStream&usr=openhab&pwd=xxx', name: 'Cam2', refresh: 3000 },
                           { url: 'http://192.168.1.113:9988/cgi-bin/CGIStream.cgi?cmd=GetMJStream&usr=openhab&pwd=xxx', name: 'Cam3', refresh: 3000 },
                           { url: 'http://192.168.1.114:9988/cgi-bin/CGIStream.cgi?cmd=GetMJStream&usr=openhab&pwd=xxx', name: 'Cam4', refresh: 3000 },
                           { url: 'http://192.168.1.115:9988/cgi-bin/CGIStream.cgi?cmd=GetMJStream&usr=openhab&pwd=xxx', name: 'Cam5', refresh: 3004 }
                         ]" 
                interval='7000'>
   <uib-slide index="$index" ng-repeat="image in images">
     <span style="color: white; font-size: 10pt">
     <p ng-if="image.name">{{ image.name }}</p>
    </span>     
     <widget-image ng-model="image"></widget-image>
    </uib-slide>
  </uib-carousel>

Yes that is to be expected the more memory you push through leaky code the faster it would have an issue and this binding certainly moves lots of data through memory. I use the Andriod app and donā€™t have an issue, but I close it and only watch the cameras for 15 minute long looks when my baby is going to sleep. Works great with no restarts for 2 weeks so it will be leaving it open that causes an issue and closing the app allows the Java garbage collection to clean up.

You could try the ā€˜merlinā€™ firmware which looks the same as the stock firmware, or loading ddwrt/tomato onto it, the Asus routers are popular as you can load Opensource firmwares onto them. It could be something like a router or switch over heating, but lets diagnose the issue and narrow down where it is.

Does this happen when using Chrome/Safari and watching the camera directly without using Openhab? If it works fine outside of Openhab it would rule out the router as a cause.

I can confirm that I can reproduce this here using the habpanel frame widget which used to work when I was coding, Iā€™ll take a look at the refresh not working shortly. We should still work out why the stream is stopping which will not be related to the refresh not working. If the stream from the camera to the binding is not breaking then this should be fixable with the same work around of using refresh, but it is always best to find and fix the root cause.

OK Iā€™ll do some tests using that and work out why the refresh is not working.

New build 2019-04-13 has following change:

  • Fixed bug for refresh on video streams. Caused by binding refusing to respond to requests that had a query even though the file path was correct eg
    Stream request GET/ipcamera.mjpeg?_t=2019-04-13T00:12:57.306Z
    Binding does not work the same as a proxy, it only works for a single request and can not be used for anything other than this single file.

@zacofunny
This should allow the picture to refresh, since the stream from the camera never stops I would be interested to hear if this behaves differently to refreshing the foscams directly, ie does the image flicker or drop off for a moment when done directly? None of my cameras work directly and require the binding to work so I cannot compare.

Hi Matt, Iā€™m having trouble with error messages on my camera. I thought the thing was configured correctly, but apparently not. Any clues where I went wrong would be appreciated.

Thing Entry:

Thing ipcamera:ONVIF:ipcam1     "IP Camera 1" @ "Cameras"       [USERNAME="XXXX", PASSWORD="XXXX", POLL_CAMERA_MS=1000, IPADDRESS="192.168.0.100", SNAPSHOT_URL_OVERRIDE="http://192.168.10.100/tmpfs/auto.jpg", PORT=80, ONVIF_PORT=8080, SERVER_PORT=54321]

Error Msg:

[WARN ] [ing.ipcamera.handler.IpCameraHandler] - The Streaming Setup for this camera is not valid, check the SERVER_PORT and STREAM_URL_OVERRIDE settings are correct.

Either do one of two things. Delete the server port part or provide a streaming URL for a mjpeg stream. That line is a warning which means you can ignore it.

Thanks Matt, I hoped itā€™d be something simple. I have trouble getting rtsp streams from this cam, so Iā€™ll delete the server port, though I only just added that because of the log message, I was getting the same msg without the server port parameter.

Just ignore the message for now as I am hoping to have a big new feature soon if I can work out how to code it in the little time I can give it each week.

1 Like

Hi Kim,
I also have reolink camera but model RLC 411s, does binding with openhab have any better motion detection capability?

Hi Matt!

Iā€™m using Doorbird at home, so I would test the new binding, but havent found any description how to implement it. Has the readme file been refreshed already?

Br, Levente