IpCamera: New IP Camera Binding

It is possible you have the wrong onvif PORT setup in the thing file, for hikvision it defaults to what their brand uses as the port so hence it may work because the default matches your cameras settings. you can check the onvif by using a free program called ‘onvif device manager’.

@oppo1967p
@HDaniel

The FI9902P appears to be in the HD range of Foscam and ‘Should’ support the api and work fine, never tried it and it is up to you to research if it supports the Foscam api. Just a heads up on the bullet style cameras, they tend to attract spiders webs as the shape allows the web to be built right in front of lens and the IR leds attract bugs that attract the spiders.

Hi @matt1, Thanks for your reply.
I use the right port (80). Http and Onvif services in my camera uses the same port.
When I use an Onvif Device Manager, I see that Onvif dialog really use the port 80.

I feel that the problem is when the ip camera binding use the onvif-java-lib.
It seems that all branded type (DAHUHA, HIKVISION, etc) only use HTTP direct, not Onvif protocol.
Am I right ?
If yes, that can explain that there is no NPE exception, when i setup HIKVISION instead of ONVIF on my ipcamera.things files.

Hi @matt1,
I tryied both Eclipse and VSCode to analyze what happen.
When you setup a wrong port, the onvif-lib-java throw a ConnectException.
When you setup a wrong IP adresse, it throw a SOAPException (after a while).

Throw Eclispe, when I wrote a little program using the onvif-java-lib, I can navigate through its source file in debug mode as Eclipse has a function “attach source file” while debugging.

However I haven’t precise that the Onvif camera I want to plug to openhab is implemented the 18.12 version of Onvif.

But I did not find the way to debug an openhab add-on through Eclipse (the step by step guide to debug trough Eclipse not work for me see my post here).

I would be able to understand what happen, as soon as I will be able to debug through Eclipse or find the way to associated source code of onvif-java-lib in VScode IDE.

It is about one week I tried to move forward :sweat: on making this camera work with openhab with your great ipcamera binding.

Have a great day.

Hi Community,

I’m using several Amcrest IP4M-1026EW for surveillance and motion detection. Everything is working great with this IP Camera Binding. The camera supports up to four motion detection regions per camera.

The question is whether there is a way in the binding to see which region has been triggered? This would allow to control different lights depending on the region triggered.

Thanks!

1 Like

The binding handles those brands the EXACT same way with 1 exception. Since it knows the snapshot url it will skip using the onvif library to discover the snapshot url. The line of code that is skipped is…
snapshotUri = onvifCamera.getMedia().getSnapshotUri(profileToken);
The exact same thing can be done by setting up as ONVIF and using the override to provide a url for the snapshot. The camera will connect faster the less the binding uses the slow ONVIF library, and if your camera does not have PTZ features you should not even bother with ONVIF and just set it up as a httponly type. The binding really only uses the onvif library for PTZ and also auto discovery of some urls.

Out of interest what brand and model camera is it that you are using? If you work out the cause then please let me know.

@HoLiuS

I am not sure if there is a way, have a read of the API and see if it details this at all, you can also see the alarm stream in realtime by using the edge browser under windows as some other browsers refuse to show the stream of text. Or you can tail the ipcamera log with it in trace mode.

The url to look at is…

/cgi-bin/eventManager.cgi?action=attach&codes=[All]

I do a similar thing to what you want with Hikvision cameras with using multiple alarm types. Having support for ‘line crossing’ and other smart alarms like intrusion or loitering alarms gives more feedback to Openhab and I am able to determine if someone is walking towards my house or away and some degree of where they are. Sadly camera manufacturers do not program with automation in mind, they simply see it as a way to turn a recording on and off so which area has movement is usually not important to them.

Rain and bugs moving at night make using cameras ‘fun’ so it can take some tweaking to get things working well so you really want a full featured camera that can be tuned to ignore/filter what it is you are after.

thanks

Hi, i installed a new Dahua DH-IPC-HDW4631C-A. I bought it from Aliexpress for about 45 $/€. It is a “china cam”, no supported cam from Dahua.

But it is working very good. It has 3 streams.
Stream 1 is up to 6MP in H.246H and H.256 up to 6 MP.
Stream 2 (Substream 1) is in H.246H, H.256 or MJPEG - but only at a maximum resolution of 704*576
Stream 3 (Substream 2) is like Substream 1, but with resolution up to Full HD (1920x1080 (1080P)

But the ip camera binding is only using Substream 1 with the poor resolution. Is there a way to use Substream 2 with Full HD?

Yes see the readme file on how to override the urls to what you wish to use. The API has the urls in it.

I use this in my sitemap:

Image url="http://192.168.102.23:50001/ipcamera.mjpeg" refresh=1000

This is my items-file:

String CamEingang_imageUrl                 { channel="ipcamera:DAHUA:CamEingang:imageUrl" }
String CamEingang_StreamUrl "Mjpeg Stream" { channel="ipcamera:DAHUA:CamEingang:streamUrl" }

This i get in my logfile, (i made some rules for testing):

CamEingang_imageUrl  --> http://192.168.102.46/cgi-bin/snapshot.cgi?channel=1
CamEingang_StreamUrl --> http://0.0.0.0:50001/ipcamera.mjpeg

How can i see, which url is used for the mjpeg stream? I only can see my local url from the binding, but not the url from the cam.

See the readme file which shows you how to enable TRACE on the log file. I’ll look at making both of those consistent. For the mjpeg to work you need to replace the 0.0.0.0 with the IP of your openhab server and not the ip of the camera. The 0.0.0.0 means it could not autodetect the network as having a sitelocal connection and it is serving on all connections which I am looking at this shortly over Christmas break.

TRACE didn´t help me much… I only could see the already known adress for snapshots from the cam directly. But there was no adress for the mjpeg-stream from my cam.

Also i saw a lot of wired things, java out of heap space errors, and much more…

Snapshots and mjpeg is not working like it should, most time i can get the stream visible in my sitemap for a few seconds/minutes and then it stops playing, sometimes a browser refresh helps, sometimes not…

Will wait for the new version after x-mas holiday.

Could this error:

[WARN ] [org.eclipse.jetty.server.HttpChannel] - /basicui/app

java.lang.OutOfMemoryError: Java heap space

	at org.apache.commons.lang.text.StrBuilder.<init>(StrBuilder.java:115) ~[?:?]

	at org.apache.commons.lang.StringUtils.replace(StringUtils.java:3815) ~[?:?]

	at org.apache.commons.lang.StringUtils.replace(StringUtils.java:3771) ~[?:?]
...

be because of too big snapshots? I use 6MP-Snapshots at the moment, mjpeg is limited to 700x350 (round about) at the moment.

Will this be gone, if i reduce the size of the snapshots? Maybe only 2MP (Full HD)?

search this forum/thread for OOME you will find what to do easily. Turning off the image channel from updating will solve it.

Turning off the image of a cam… Why should i buy a cam, when i have to switch off the image???

Will there be stored more then one jpeg inside the binding or will the last snapshot be erased there is a newer one?

Will try that solution with the extened memory configuration. Is there a memory leak inside the binding and this solution is just cosmetics or will this fix the error completely?

Sometimes it works for some time and after some minutes the error occures.

Here is the link to the solution:

This is the output of my console before any editing:

openhab> shell:info
Karaf
  Karaf version               4.2.6
  Karaf home                  /usr/share/openhab2/runtime
  Karaf base                  /var/lib/openhab2
  OSGi Framework              org.eclipse.osgi-3.12.100.v20180210-1608

JVM
  Java Virtual Machine        Java HotSpot(TM) 64-Bit Server VM version 25.201-b09
  Version                     1.8.0_201
  Vendor                      Oracle Corporation
  Pid                         14138
  Uptime                      55 minutes
  Process CPU time            6 minutes
  Process CPU load            0.00
  System CPU load             0.07
  Open file descriptors       309
  Max file descriptors        102,642
  Total compile time          1 minute
Threads
  Live threads                219
  Daemon threads              121
  Peak                        270
  Total started               3322
Memory
  Current heap size           294,721 kbytes
  Maximum heap size           1,269,760 kbytes
  Committed heap size         1,265,664 kbytes
  Pending objects             0
  Garbage collector           Name = 'G1 Young Generation', Collections = 243, Time = 16.777 seconds
  Garbage collector           Name = 'G1 Old Generation', Collections = 0, Time = 0.000 seconds
Classes
  Current classes loaded      21,341
  Total classes loaded        23,902
  Total classes unloaded      2,561
Operating system
  Name                        Linux version 4.19.0-6-amd64
  Architecture                amd64
  Processors                  2

After switching on the update-image-channel, current heap size increases to 1.050.000 kb and jumps between 400.000 and 1.000.000. My snapshot is fullHD (2MP), it is way better then with 6MP-Snapshots.
My heap space is already 1,2 GB? Should i increase it?

Hello,

I have my DVR/NVR which is OEM from hykvision. I have 16 TVI HD cameras and 2 IP camera.
http://www.ltsecurityinc.com/platinum-hdtvi-digital-video-recorder-dvr-ltd8516t-st.html

my things config file looks like this:
Thing ipcamera:HIKVISION:009 “CAM9” @ “Cameras”
[
IPADDRESS=“192.168.10.10”,
PORT=8080,
USERNAME=“admin”,
SERVER_PORT=50009,
NVR_CHANNEL=9,
FFMPEG_OUTPUT="/tmp/CAM9"
]
Thing ipcamera:HIKVISION:003 “CAM3” @ “Cameras”
[
IPADDRESS=“192.168.10.10”,
PORT=8080,
USERNAME=“admin”,
SERVER_PORT=50003,
NVR_CHANNEL=3,
FFMPEG_OUTPUT="/tmp/CAM3"
]

I can see photo only from camera3, camera 9 do not have any picture. if I leave in config only camera9, then I can see camera9…
Debug log details show me, that only request for CAM3, nothing about CAM9 :frowning:
2019-12-06 11:01:54.055 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://192.168.10.10/ISAPI/Streaming/channels/301/picture
2019-12-06 11:01:54.057 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Have re-opened the closed channel:0 GET:/ISAPI/Streaming/channels/301/picture
2019-12-06 11:01:54.241 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Snapshot recieved: Binding will now close the channel.
2019-12-06 11:01:54.242 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - commonCameraHandler closed channel:0 URL:/ISAPI/Streaming/channels/301/picture
2019-12-06 11:01:56.055 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://192.168.10.10/ISAPI/Streaming/channels/301/picture
2019-12-06 11:01:56.057 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Have re-opened the closed channel:0 GET:/ISAPI/Streaming/channels/301/picture
2019-12-06 11:01:56.271 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Snapshot recieved: Binding will now close the channel.
2019-12-06 11:01:56.272 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - commonCameraHandler closed channel:0 URL:/ISAPI/Streaming/channels/301/picture
2019-12-06 11:01:58.055 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://192.168.10.10/ISAPI/Streaming/channels/301/picture
2019-12-06 11:01:58.057 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Have re-opened the closed channel:0 GET:/ISAPI/Streaming/channels/301/picture
2019-12-06 11:01:58.211 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Snapshot recieved: Binding will now close the channel.
2019-12-06 11:01:58.212 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - commonCameraHandler closed channel:0 URL:/ISAPI/Streaming/channels/301/picture

Also I do not understand how to receive motion alarms, I enable in DVR motion detection, and Notify Surveillance Center, see picture
image

I also configure my Alarm host IP (it’s IP of my openhab)
image

But I do not receive any alarms (alarms works, because I receive emails, but not to openhab).
Also my log report:
[WARN ] [ing.ipcamera.handler.IpCameraHandler] - The alarm stream was not running for camera 192.168.10.10, re-starting it now

Also it’s not clear to me, how I can receive alarms from DVR, where I have 15 cameras…

My assumption you should implement something like a bridge interface in openhab.

Thanx for answer in advance,
Ed

@halloween
There are multiple ways to get a picture from the binding, they are covered in the readme. Also see this post

@Bl00d_b0b
The hik nvr’s can be setup in two ways, the better way I am told by others is to setup each camera to be exposed on its own port which needs an option turned on in the nvr to do this. Then each camera is able to be talked to directly at the NVR IP and on its own port. Sorry don’t own one and don’t work for hik.

Hello,

I have DVR/NVR in one box. 13 TVI Analog camedas + 2 IP cameras. and it’s no way to separate ports. It’s a DVR with analog cameras.

Any comment on my next questions regarding Alarms?

Ed

I now only use the mjpeg stream provided from the binding.

It works, but after some time, the stream stops playing. Most of the time it helps, to reload the browser and the stream is working again.

Any idea? This is on all my devices. I tried IMAGE and VIDEO inside the openhab-sitemap. It is the same with both and it is the same on my android phone (openhab andoid app beta and chrome) and on my windows-computer (chrome, firefox, ie11 and edge).

Hello,

My DVR return this support:

<?xml version="1.0" encoding="UTF-8" ?>
<SdkCap version="1.0" xmlns="http://www.isapi.org/ver20/XMLSchema">
<isSupportHttpPlay>false</isSupportHttpPlay>
<isSupportHttpPlayback>true</isSupportHttpPlayback>
<isSupportHttpTransCodePlay>true</isSupportHttpTransCodePlay>
<isSupportHttpTransCodePlayback>true</isSupportHttpTransCodePlayback>
<isSupportHttpsPlay>false</isSupportHttpsPlay>
<isSupportHttpsPlayback>false</isSupportHttpsPlayback>
<isSupportHttpsTransCodePlay>false</isSupportHttpsTransCodePlay>
<isSupportHttpsTransCodePlayback>false</isSupportHttpsTransCodePlayback>
<ipChanBase>33</ipChanBase>
</SdkCap>