IpCamera: New IP Camera Binding

Hi,
Can anyone that has the NVR “DS-7616NI-K2” help me understand how to configure the things for the different cameras/channels. I currently have two HIK vision and one HiLook camera connected to the NVR.
I can add things for the HIK vision cameras directly connected to the cameras, everything works fine.

However, I would prefer to access the cameras via the NVR instead.

If I add three things, all pointing to the NVR and set the option “NVR input channel” to the (camera speficic) numbers per the NVR, I can only access/view each camera “one at a time”. That is, the Item “Snapshot from Camera” will show the stream for the one camera with the Item “Update the Image” set to ON.

(I do not know if what I am trying to describe makes any sense, but somehow I cannot have three concurrent streams (one for each camera) streaming to the Things “Update the Image” item. I get the same stream on all three Things.)

Any feedback on how I should do a correct configuration when adding the cameras via the NVR would be highly appreciated.

Hi @matt1,

Sorry for the long silence but I have lost my Father and was busy with the funerals. :cry:

I am trying to integrate an Acromedia Camera RX-CH242H3CG-8MP which implement ONVIF v18.12 with profils S and G.

Sorry to hear of your loss.

1 Like

Hello,

I’m trying to get my Dahua camera online without succes.
It says the thing is online but, i can’t get any image.
Where should i begin?
If i check in the camera webinterface i can see that opehanb is connected.

When installing IP Camera binding in a clean openhab installation

2019-12-14 19:54:13.572 [WARN ] [org.apache.felix.fileinstall        ] - Error while starting bundle: file:/usr/share/openhab2/addons/org.openhab.binding.ipcamera-2.5.0-SNAPSHOT.jar
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.ipcamera [226]
  Unresolved requirement: Import-Package: org.apache.commons.collections.buffer; version="[3.2.0,4.0.0)"

/Mike

I installes the newest version [ipcamera2019-08-03.zip] with openhab 2.4. My ip camera is turned off when the 3d printer is off, so most times it is offline.
It seems that this is the reason for the logging messaging coming up all the time:

2019-12-15 09:23:33.028 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - ipCamera restarting.

Is there a workaround for this use case or should there be an update to turn of the polling of the online status of different cameras?

This will be fixed in next version that I am working on at the moment. Not an issue as it is only a log entry but it is annoying me too.

Thanks for your work Skinah. Appreciate.

What I think about would it make sense to allow the binding to not to poll the update status of a camera because of cpu activity?
I mean - if the log entry disappears it will still go on polling the status in the background. Right?

From memory it trys after 10 seconds to reconnect and if it fails it then trys once per minute to see if the camera is back online. That’s why u get the message once per minute. Its low on cpu.

@matt1 How do i solve my missed dependence?

/Mike

Just as a follow up. I found the mistake I made that caused the odd behaviour streaming from the NVR.
The config field “SNAPSHOT_URL_OVERRIDE” had a reference. When deleting that, i.e. leaving the field blank - it works as expected.

I can confirm the binding has this as an import, never complained to me so my guess is 2.4 stable uses this and has it already imported and a newer (you don’t post which clean version you have) build may not use it anymore. You can most likely fix it by dropping the jar file directly into the addons folder. Try version 4.0.0 first and if that works move to 4.4 which is the latest…

Download the precompiled jar files from here…

https://mvnrepository.com/artifact/org.apache.commons/commons-collections4

Let me know how you go as it may require it to be added into the source files, still getting my head around the new bnd build system.

EDIT: Yes appears removed only 18 days ago…

https://github.com/openhab/openhab2-addons/pull/6467

Yes if you over ride the url, you need to give it the url that works, be sure to test any urls in a browser of your choice before giving it to the binding. The NVR channel field is used to build up a hard coded url which is not used if you over ride it. Thanks for posting to say it is fixed and it may help someone else.

Unfortunately dropping the collections jar file (https://repo1.maven.org/maven2/org/apache/commons/commons-collections4/4.0/commons-collections4-4.0.jar) into the addons folder didn’t work for me. I moved to OpenHAB 2.5.0 (stable) today and use the jars from ipcamera2019-08-03.zip.

If I list my bundles I can see that the jars are loaded but the IpCamera bundle is not working:

239 | Installed |  80 | 2.5.0.201908030247    | openHAB Add-ons :: Bundles :: IpCamera Binding
240 | Active    |  80 | 4.1.34.Final          | Netty/Buffer
241 | Active    |  80 | 4.1.34.Final          | Netty/Handler
242 | Active    |  80 | 4.1.34.Final          | Netty/Codec
243 | Active    |  80 | 1.4.0                 | javax.xml.soap API
244 | Active    |  80 | 4.1.34.Final          | Netty/Common
245 | Active    |  80 | 4.1.34.Final          | Netty/Resolver
246 | Active    |  80 | 4.1.34.Final          | Netty/Transport
247 | Active    |  80 | 4.1.34.Final          | Netty/Codec/HTTP
249 | Active    |  80 | 4.0.0                 | Apache Commons Collections

The following message is found in openhab.log:

2019-12-16 14:50:14.168 [WARN ] [org.apache.felix.fileinstall        ] - Error while starting bundle: file:/usr/share/openhab2/addons/org.openhab.binding.ipcamera-2.5.0-SNAPSHOT.jar
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.ipcamera [239]
  Unresolved requirement: Import-Package: org.apache.commons.collections.buffer; version="[3.2.0,4.0.0)"

        at org.eclipse.osgi.container.Module.start(Module.java:444) ~[org.eclipse.osgi-3.12.100.jar:?]
        at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:383) ~[org.eclipse.osgi-3.12.100.jar:?]
        at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1260) [bundleFile:3.6.4]
        at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1233) [bundleFile:3.6.4]
        at org.apache.felix.fileinstall.internal.DirectoryWatcher.startAllBundles(DirectoryWatcher.java:1221) [bundleFile:3.6.4]
        at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:515) [bundleFile:3.6.4]
        at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:365) [bundleFile:3.6.4]
        at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:316) [bundleFile:3.6.4]

Thanks for your support, looking forward hearing from you.

Update: I don’t know why but after uninstalling another binding suddenly the ip camera binding got loaded and I have a connection to the camera. I see another jar that got loaded now:
Commons Collections 3.2.1

Updated to version 2.5.0 today.
The camera works like before, only now in the logs of the console there was such a mistake.

I am installing 2.5 Stable now to do some testing so I should have a newer version after it passes minimal tests here. My guess is one of the other bindings you installed also uses it and has installed a now outdated version which the ipcamera binding is using. It is possible if I fix this it may conflict with the other binding as the newer bnd system seems to not handle multiple versions of jars like the old system did, but I really know very little on this topic… Should know more shortly and I will try to remove the need for the lib if possible due to mentioned possible issue…

New build just uploaded 2019-12-17 has these changes:

  • Removed the need for org.apache.commons.collections.buffer to fix the issue people were having on 2.5 Stable.
  • Updated to use newer Netty 4.1.42 to match the version used by the IO addons mqttembeddedbroker
  • Removed log output when camera is trying to check if camera that is offline is reachable.

I have not tested it much and the main change was to how snapshots were stored for creating a animated Gif, so check for bugs with this feature as that was the area I rewrote to remove the needed lib.

I have 90% of my server on a clean 2.5 Stable install of Openhab, so once I am fully up and I then look at making some more changes to this binding. So if you don’t need to upgrade, perhaps wait until I make another release.

To upgrade:
Remove all the old netty jar files and drop the new ones to the addons folder. Then clean your tmp and cache and restart to rid the system of the older files that may conflict.

1 Like

@matt1 The new drop works great for me. My cameras (Instar IN-9008 and IN-8015) are working fine with this software version. Thanks a lot for updating the code.

I often get this warning:

2019-12-18 09:35:20.850 [WARN ] [io.netty.channel.nio.NioEventLoop   ] - Selector.select() returned prematurely 512 times in a row; rebuilding Selector io.netty.channel.nio.SelectedSelectionKeySetSelector@b307b62.

I´m still on 2.5 snapsot and the old ipcam-binding-version. Will update to a newer version during the holidays.


And a strange thing: I can view the mjpeg stream provided by the binding inside my sitemap, but after some time (a few minutes) it stops playing (i can see this because the time code in the corner is paused). When i do a browser refresh the video starts again.

But when i open the mjpeg stream from the binding inside VLC, the stream works for hours without any error…

I can not get HLS Streaming to work
PI3
OH 2.5
Latest binding
ffmpeg installed
Hikvision DS-2CD2442FWD-IW

Thing ipcamera:HIKVISION:Front "Front Camera" @ "Cameras"
[
    IPADDRESS="192.168.192.82",
    PASSWORD="password",
    USERNAME="admin",
    POLL_CAMERA_MS=2000,
    SERVER_PORT=50002,
    IP_WHITELIST="DISABLE",
    IMAGE_UPDATE_EVENTS=1,
    UPDATE_IMAGE=false,
    FFMPEG_OUTPUT="/tmpfs/Front/",
    FFMPEG_HLS_OUT_ARGUMENTS="-acodec copy -vcodec copy -hls_flags delete_segments"
]

http://192.168.192.63:50002/ipcamera.m3u8
192.168.192.63 sending no data.

2019-12-18 16:21:55.773 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - IpCamera file server for camera 192.168.192.82 has started on port 50002
2019-12-18 16:21:55.799 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - IP Camera at 192.168.192.82 is now online.
2019-12-18 16:22:02.724 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - The alarm stream was not running for camera 192.168.192.82, re-starting it now
2019-12-18 16:23:15.940 [WARN ] [pcamera.internal.StreamServerHandler] - Exception caught from stream server:{}
java.lang.NullPointerException: null
        at org.openhab.binding.ipcamera.handler.IpCameraHandler.setupFfmpegFormat(IpCameraHandler.java:1005) ~[?:?]
        at org.openhab.binding.ipcamera.internal.StreamServerHandler.channelRead(StreamServerHandler.java:79) ~[?:?]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) [bundleFile:4.1.42.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) [bundleFile:4.1.42.Final]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) [bundleFile:4.1.42.Final]
        at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:438) [bundleFile:4.1.42.Final]
        at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:328) [bundleFile:4.1.42.Final]
        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:302) [bundleFile:4.1.42.Final]
        at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:253) [bundleFile:4.1.42.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) [bundleFile:4.1.42.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) [bundleFile:4.1.42.Final]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) [bundleFile:4.1.42.Final]
        at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:287) [bundleFile:4.1.42.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) [bundleFile:4.1.42.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) [bundleFile:4.1.42.Final]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) [bundleFile:4.1.42.Final]
        at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1422) [bundleFile:4.1.42.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) [bundleFile:4.1.42.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) [bundleFile:4.1.42.Final]
        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:931) [bundleFile:4.1.42.Final]
        at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163) [bundleFile:4.1.42.Final]
        at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:700) [bundleFile:4.1.42.Final]
        at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:635) [bundleFile:4.1.42.Final]
        at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:552) [bundleFile:4.1.42.Final]
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:514) [bundleFile:4.1.42.Final]
        at io.netty.util.concurrent.SingleThreadEventExecutor$6.run(SingleThreadEventExecutor.java:1044) [bundleFile:4.1.42.Final]
        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) [bundleFile:4.1.42.Final]
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [bundleFile:4.1.42.Final]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_231]

What am i doing wrong.

/Mike