Generic IP Camera binding

Thanks for the reply @Bagumka,

there is one more query,
does all ip camera has same url format you provided??
i’ve sannce 720p ip camera, is there any other url format than this ??
(Sorry for the noob question but i’m just getting started with the cameras and don’t know much about it…)

As I know, brands have their own unified url format. I mean:

HikVision have:
http://login:password@your.ip.address.here/ISAPI/Streaming/channels/101/picture?snapShotImageType=JPEG

Dahua have:
something other…

Hello Vadym,

The url is working you are right!! Thanks… but there is one problem.
When i worked on the habpanel and i save and run i get an error.

java.lang.OutOfMemoryError: Java heap space

It isn’t directly but most of the time after 2 or 3 times save and run.
Do you know how i can fix this.

Caused by: java.lang.OutOfMemoryError: Java heap space

2018-03-09 09:39:16.493 [ERROR] [ops4j.pax.logging.pax-logging-log4j2] - FrameworkEvent ERROR - org.ops4j.pax.logging.pax-logging-log4j2

java.lang.OutOfMemoryError: Java heap space

2018-03-09 09:39:19.868 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method ‘ThingHandler.handleCommand()’ on ‘org.openhab.binding.camera.handler.CameraHandler@1250720’: Java heap space

java.lang.OutOfMemoryError: Java heap space

==> /var/log/openhab2/events.log <==

2018-03-09 09:46:07.637 [ome.event.ItemCommandEvent] - Item ‘CamTuin_Image’ received command REFRESH

==> /var/log/openhab2/openhab.log <==

2018-03-09 09:46:13.040 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method ‘ThingHandler.handleCommand()’ on ‘org.openhab.binding.camera.handler.CameraHandler@1250720’: Java heap space

java.lang.OutOfMemoryError: Java heap space

I don’t saw that problem, but I don’t have OpenHAB in production, just testing. I Try to run it for some time to test.

Is there any Onvif or RTSP protocol support in any bindings in Openhab2?

Because RTSP is not supported yet, I used ffmpeg (ffserver) to transform the only available feed of my old Kaicong camera from RTSP to HTML (MJPEG).

It works fine and I’m able to use that HTML feed with Habpanel. The feed look like this: http://xxx.xxx.x.xx:8090/camera1.mjpeg

Now, I’m trying to use the Camera binding to get an image feed on my sitemap. I probably do not understand yet what is supported and what is not supported but I’m unable to make it work.

I do understand that video URL is not supported yet, but only Snapshot URL. I tried to use the mjpeg feed into snapshot URL field but the Openhab Thing remain always OFFLINE.

What should I do to get the Thing Online? Thanks.

UPDATE:
I tried something else without success, so I still need help. I installed Zoneminder. RTSP feed is easy to configure. Zoneminder use ffmpeg to generate a new feed who can be used in an embeded URL link. This link (http://xxx.xxx.x.xx/zm/cgi-bin/nph-zms?mode=jpeg&monitor=1&scale=50&maxfps=15) is working in any browser. I copied it into the binding Snapshot URL field but Thing still offline.

Any help would be welcome.

@_Thomas
What is the current status of this binding? Is anyone actively coding as I am interested in making a binding with many more features but don’t wish to make huge changes if they are not going to get accepted.

@cailleute,

look at the zoneminder binding from @mr_eskildsen - I implemented the zm jpeg/mjpeg feed there. One thing with mjpeg (or any other stream) is that the default settings of the proxy in openhab will kill the feed after 1 minute. You’ll need the patch in this bug report: https://github.com/eclipse/smarthome/issues/4873 to make it work longer than one minute. JPEG images work ok.

Cheers,
-Th

Be sure to grab the marketplace binding. Sine it is only implementering there

Thanks @captndelta and @mr_eskildsen! I didn’t know about your work Martin. Great binding! It will fit perfectly my need… if I succeed to make it work.

I do not want to use an hardware NVR so I’m doing test with zoneminder on an hold PC running Linux. I will buy better hardware later to build an home made NAS based on FreeNas. So, I hope my current problem is not related to the poor hardware performance. So, maybe one of you could help me to figure it out what is my problem:

I didn’t change a lot of thing in the basic zoneminder configuration.

  • add a new admin user
  • check both option OPT_USE_API and OPT_TRIGGER to allow binding to make connection.

On the binding itself:

  • entered IP address of my zoneminder server
  • credentials of the new admin user I created. (I’m using this user too to reach zoneminder console.)

From the zoneminder console, I see my camera feed. On Openhab side, Things are switching from online to offline to online etc. I have the following error in my log:

2018-04-05 16:05:33.737 [ERROR] [andler.ZoneMinderThingMonitorHandler] - [MONITOR-1]: context='fetchMonitorDaemonStatus' error in call to 'getMonitorData' Exception='name.eskildsen.zoneminder.exception.ZoneMinderAuthenticationException' Message='Unable to authenticate in ZoneMinder'

name.eskildsen.zoneminder.exception.ZoneMinderResponseException:  - HttpStatus='401', HttpMessage='Unauthorized', Request='http://192.168.x.xx/zm/api/monitors/1.json', ExceptionMessage='Not Authenticated'	

It looks like my credentials are not valid, but I’m using exactly the same to reach console. Same credential is used if I call manually the JPEG feed at this address:

http://192.168.x.xx/zm/cgi-bin/nph-zms?mode=jpeg&monitor=1&scale=100&maxfps=25&user=myuser&pass=mypassword

Is there something I could try? Thanks.

That might be a little tricky to say so… The problem is that the process of determining that isn’t straight forward. So there might be a wrong conclusion in the code.
Since you are using the admin user, I guess that it shouldn’t be missing access rights.Since you can logon to ZoneMinder console it should be fine.
What happens if you logon to ZM console and the afterwards tries to access the api from the browser:
http://192.168.x.xx/zm/api/monitors/1.json”?
That should return a JSON with data for monitor 1.

If that doesn’t work, the problem would be something in your ZoneMinder setup. If it does work, you should try to disable authentication in ZoneMinder. If you use any special characters in your password, try to change it to a more simple password (off course you should be able to use special characters, but for test purposes).

Thanks @mr_eskildsen, you show me the right direction. Accessing the api from the browser is the fastest way to see if there is access error. You were right, currently I’m just able to make it work without authentication. I will make more test later on my zoneminder configuration.

So for the moment, just some more general questions. I probably miss something in the Openhab documentation but I don’t understand how to handle item related to video and image into sitemap.

I have two items:

Image Cam_monitor1_image  "Cam_1 image"	 {channel="zoneminder:monitor:aec1aeed:monitor-1:image"}
String Cam_monitor1_video  "Cam_1 video" {channel="zoneminder:monitor:aec1aeed:monitor-1:videourl"}
  1. With the image item, I cannot use: Image item= Cam_monitor1_image. SmartHome designer give an error. I can just use: Default item=Cam_monitor1_image. By this way, I get a static image.

2a) For the String item related to video. I just don’t understand how to use the String value returned by the binding. I can hardcode the url of this string in a Webview (Webview url=‘http://192.168.x.xx/zm/cgi-bin/nph-zms?monitor=1&scale=20&buffer=1000’ height=5) but nothing else directly by the way of the item name itself

2b) If I use a Webview, I get a static image, not a camera feed. However I’m sure the url is good because if I use it directly into a browser, I get the real time camera feed.

  1. I’m not able to use Video in sitemap. Just by the way of hardcoding an URL. Am I right to think this is useless for a real time camera signal?

  2. Finally, if I finish by getting something (static or real time feed) in BasicUi sitemap on my PC, should I get the same result from the IOS OpenHab app? If yes, should I get the same result if the IOS Openhab connection is remote (outside of my network)?

@cailleute,
for (1.): I’ve only tried it in the ‘regular’ sitemap files, things were working for me there. You have to use the image item as the ‘item’ in the sitemaps ‘Image’ element (don’t use the url at the same time). There is a setting for images how often they are updated in the settings of the binding.
for (2.a): If you look at the “video” element in https://docs.openhab.org/configuration/sitemaps.html#element-type-video , it says that “item can refer to a String Item whose state is a URL to a video”. Don’t set the URL in that case. You still have to set the encoding (only mjpeg supported). I have not tried that in Webview, it’ll probably not work (unless the ‘item’ there has the same behavior, but can’t find anything documented to that effect)
for (3): see 2a
EDIT (forgot to answer 4.): As long as you can access your openhab site outside of your network, you should also see the video/image feed. Those are proxied thru your openhab server. (the internal URL’s are no longer used)

Cheers,
-Th

Strange, but if it doesn’t work from the browser, it won’t work in the binding :slight_smile:

Default item=Cam_monitor1 should be fine. The Binding will update the image.

For the moment openHAB doesn’t support a video item type, this means that the binding has no way of returning the video stream. I am not using the video url myself, and it is also considered experimental. I think what you describe is just the way it is right now. :frowning:

You should get the same stream both in your PC, IOS app internal as well as external. But that is all core openHAB. If things works on your PC, everything should be fine.

Thanks Martin for your time. I now have a better understanding of image/video related to camera.

For everyone, in conclusion, we have two good options to manage camera in sitemap: camera binding and zoneminder binding (from the marketplace). The choice is based following your needs to get NVR functionnalities and/or the feed type your camera provide.

1 Like

There is a camera binding? Tell me more.

This whole thread is about Camera binding… See first post for a link to the JAR file.

There is now a different IP Camera binding found here:

i cant find anyone who says how to install this binding… can anyone help me?

1 Like

Hello Thomas,
did you have the latest version in a compiled (or so on) .jar file to easy install it with putting this in the addons folder?
Thanks, I’m a totally beginner and have done some things with OH2 on my QNAP and it works, but I want also integrate my cameras.
Thanks a lot and best regards
Stefan