IpCamera: New IP Camera Binding

Hi,

I have received a Hikam A7 from the 2nd Generation for a very cheap price. This supports ONVIF but I am not completely able to add it to my OpenHab.

I have installed your binding. I used the information from the camera vendor itself: http://supportus.hi-kam.com/en/support/solutions/articles/16000072606-how-to-watch-live-streams-with-onvif-clients-for-s6-a7-2018-version-

I took the generic ONVIF setting in your binding. It seems to work so the Video URL was recognized automatically:
video_url

But where can I get the live stream or a picture from the camera?

Edit: Maybe is it possible to run FFMPEG directly on the Openhabian for the convertion of the RTSP to HTTP?

This shows that you are not using the latest build which has the first of a number of streaming features. I have updated the readme and documentation so they are now only accurate with the latest build due to the breaking changes I listed in my post above…

The binding will handle snapshots very well but if the camera does not report a url via ONVIF then you will need to manually enter the snapshot url until rtsp features are added. The same goes for the mjpeg http based stream, it will need to be manually entered for cameras that are not HIK, Dahua or Amcrest until further features are added to give rtsp.

Create your own thread and include in it your items and things file contents (remove passwords).

I suspect the conflict errors are from you trying to modify with PaperUI after you have already setup items and things files, the readme warns you against this, so please take the time to read the readme file at the github project, link found in first post of this thread.

Thank you for your reply, but I tried both ways (PaperUI & Files) But I could not get it to work. Out of pure frustration (other things didn’t work either) I deleted the whole stuff and started from scratch again… hahah. But thank you for your reply.

You mean the beta?

Yes the beta is only marked that way as the new features are not running very well on slower hardware for me, under a fast machine it works fine. If you run it with the newer features disabled I would not call it beta and it will work as good as any previous build.

Because of the breaking changes I would only use the beta so you do not need to deal with them as I have updated all examples and readme for the new changes.

New Build 2019-03-16 has following changes.

  • Removed a bottleneck that was slowing down the video streams on older/slower CPUs. This has also lowered CPU usage over all previous builds even if only doing snapshots. Possible that one change may cause issues on non english setups, so please report if the previous BETA works and this build does not work for snapshots. The two builds can be swapped easily as no new channels or config items were changed.

  • Security improvements made for streaming. Will only return a stream if the request is GET:ipcamera.mjpeg , the port is correct and the IP is in the whitelist, it also only listens to local IP’s and wont work for external IP requests. DISCLAIMER: The new feature provides access to the video stream without authentication, If you do not know how to keep your internal network secure and care about the camera feeds, please do not enable the new streaming features. The feature is disabled by default.

  • Multiple streams can now be used around multiple tablets and the camera only sees a single stream. It is common for cameras to have a limit of 4 streams or even less. This binding will now remove that limitation. This is one reason why with a Foscam camera that can work streaming directly you may wish to use the binding as some are limited to 4 streams only.

  • Foscam now has streaming url hardcoded in, see readme for special setup info…

For any discussion on the new streaming features please use this thread:

Hi,

This shows that you are not using the latest build which has the first of a number of streaming features. I have updated the readme and documentation so they are now only accurate with the latest build due to the breaking changes I listed in my post above…

The binding will handle snapshots very well but if the camera does not report a url via ONVIF then you will need to manually enter the snapshot url until rtsp features are added. The same goes for the mjpeg http based stream, it will need to be manually entered for cameras that are not HIK, Dahua or Amcrest until further features are added to give rtsp.

tried again with the last version but it looks that my camera isn’t supported is it?
1

Or is there anything else I can do? Is there a way to transform the streams? For now images would be enough for me.

Thanks

No idea, I would need DEBUG log output when the binding tries to connect to see what is going on.
I would recommend you install ONVIF device manager and see if it detects and reports a snapshot url.
I believe for a camera to call itself ONVIF compatible it is required to support a snapshot.

Since the binding was reporting a RTSP link, you should look at the other thread you already posted in and I replied in, currently the binding does not support RTSP as it is still being worked on as I find spare time.

I would recommend you install ONVIF device manager and see if it detects and reports a snapshot url.

I already installed it. I can check my live stream but where I can see an Image link? Can you advise?

@matt1, I can personally confirm that the Fosbaby p1 is working. What I have tested so far is:

  • pan/tilt camera.
  • Image (2seconds interval).
  • Still Image which can be refreshed.
  • Livestream
  • Turn sound detection on/off
  • Sound detection

Other things are still being tested/configured. I will update my list when needed.
Great work on the binding! :clap: :+1:

1 Like

New Build 2019-03-21 has these changes:

  • Fixed issue with server port not changing unless rebooted, should now change and allow the streaming server to stop without needing a reboot.

  • Fixed logs to stop errors/warnings when a phone is displaying a stream and the phone locks and stops accepting the stream without a clean stop.

  • Improved the setup config names in PaperUI so they are consistent with what logs ask you to do.

  • Some performance improvements made

@onacvooe
Thanks for the kind words, be sure to check out the examples in the readme as I have put in what I use for a baby monitor in there…

@matt1, Thank you for your update, I will install it shortly,

At the moment I’m not able to get the live stream to work with my camera. Still trying but any help would be nice. I have read your readme but there are a few things which I don’t get. First off, the port… Where do I find that port? I cannot use an ONVIF Device manager because I don’t have a windows machine. And the stream URL contains of http://IPADRESS:PORT/ipcamera.mjpeg but where does the IPCAMERA.MJPEG come from? Especially the IPCAMERA name… These things might differ from my setup. Can you help me with that?

Could it be that it is not supported? / Not functioning on my device?

Never mind, I just found out where ipcamera and port came from.

Got the livestream working via the ffmpeg server option.(RTSP).

Yes that is the most compatible way to do it, but it will chew the most CPU power from your Openhab server.

First find out if your camera has the ability to do MJPEG aka Motion jpeg streams, Foscams should do it but it is up to you to do the research on if your model does and how to enable and setup the mjpeg stream.

http://foscam.us/forum/how-to-fetch-snapshots-and-mjpeg-stream-on-hd-cameras-t4328.html

  1. Try and get the camera to stream directly to sitemaps/habpanel as that is most efficient. Foscams should be able to do it directly.
  2. If 1 fails then use the IpCamera binding if you have http access to a mjpeg stream.
  3. Use the FFMPEG server as a last resort, or look at a separate video server running a dedicated software package.

The binding only works for a few seconds and then the stream stops. It also jumps in 2-3 second steps and not each second.

Item:

Image Livefeed_Haustuere “Livebild Haustür” <Camera>
{ channel=“ipcamera:AMCREST:001:image” }

Things:

Thing ipcamera:AMCREST:001 [IPADDRESS=“XXX.XXX.XXX.XX”, PASSWORD=“XXXXX”, USERNAME=“XXXXX”, POLL_CAMERA_MS=1000, SERVER_PORT=54321, IP_WHITELIST="(XXX.XXX.XXX.XX)(localhost)", IMAGE_UPDATE_EVENTS=1]

Logs item:

2019-03-20 07:02:28.311 [vent.ItemStateChangedEvent] - Livefeed_Haustuere changed from NULL to raw type (image/jpeg): 589330 bytes
2019-03-20 07:02:30.140 [vent.ItemStateChangedEvent] - Livefeed_Haustuere changed from raw type (image/jpeg): 589330 bytes to raw type (image/jpeg): 590068 bytes
2019-03-20 07:02:33.275 [vent.ItemStateChangedEvent] - Livefeed_Haustuere changed from raw type (image/jpeg): 590068 bytes to raw type (image/jpeg): 590373 bytes
2019-03-20 07:02:35.303 [vent.ItemStateChangedEvent] - Livefeed_Haustuere changed from raw type (image/jpeg): 590373 bytes to raw type (image/jpeg): 589295 bytes
2019-03-20 07:02:37.297 [vent.ItemStateChangedEvent] - Livefeed_Haustuere changed from raw type (image/jpeg): 589295 bytes to raw type (image/jpeg): 588955 bytes
2019-03-20 07:02:39.437 [vent.ItemStateChangedEvent] - Livefeed_Haustuere changed from raw type (image/jpeg): 588955 bytes to raw type (image/jpeg): 589907 bytes

Logs ipcamera:

2019-03-20 07:01:59.880 [.ItemChannelLinkAddedEvent] - Link ‘Livefeed_Haustuere-ipcamera:AMCREST:001:image’ has been added.
2019-03-20 07:02:00.432 [hingStatusInfoChangedEvent] - ‘ipcamera:AMCREST:001’ changed from UNINITIALIZED to INITIALIZING
2019-03-20 07:02:09.884 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Cameras selected ‘ONVIF media profile’ is using encoding of H_264 and needs to be MJPEG to work with the new streaming features.
2019-03-20 07:02:26.455 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - IP Camera at 192.168.188.67:80 is now online.
2019-03-20 07:02:26.460 [hingStatusInfoChangedEvent] - ‘ipcamera:AMCREST:001’ changed from INITIALIZING to ONLINE
2019-03-20 07:02:26.500 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - IpCamera stream server has started on port:54321.
2019-03-20 07:02:31.646 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - !!! Camera has closed the channel URL:/cgi-bin/eventManager.cgi?action=getEventIndexes&code=VideoMotion Cause reported is: {}
at io.netty.util.concurrent.DefaultPromise.checkDeadLock(DefaultPromise.java:395) ~[233:org.openhab.binding.ipcamera:2.5.0.201903190907]
at io.netty.channel.DefaultChannelPromise.checkDeadLock(DefaultChannelPromise.java:159) ~[233:org.openhab.binding.ipcamera:2.5.0.201903190907]
at io.netty.util.concurrent.DefaultPromise.awaitUninterruptibly(DefaultPromise.java:246) ~[233:org.openhab.binding.ipcamera:2.5.0.201903190907]
at io.netty.channel.DefaultChannelPromise.awaitUninterruptibly(DefaultChannelPromise.java:137) ~[233:org.openhab.binding.ipcamera:2.5.0.201903190907]
at io.netty.channel.DefaultChannelPromise.awaitUninterruptibly(DefaultChannelPromise.java:30) ~[233:org.openhab.binding.ipcamera:2.5.0.201903190907] at org.openhab.binding.ipcamera.handler.IpCameraHandler.sendHttpRequest(IpCameraHandler.java:634) ~[233:org.openhab.binding.ipcamera:2.5.0.201903190907] at org.openhab.binding.ipcamera.internal.MyNettyAuthHandler.processAuth(MyNettyAuthHandler.java:174) ~[233:org.openhab.binding.ipcamera:2.5.0.201903190907] at org.openhab.binding.ipcamera.internal.MyNettyAuthHandler.channelRead(MyNettyAuthHandler.java:223) ~[233:org.openhab.binding.ipcamera:2.5.0.201903190907] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [233:org.openhab.binding.ipcamera:2.5.0.201903190907] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [233:org.openhab.binding.ipcamera:2.5.0.201903190907] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [233:org.openhab.binding.ipcamera:2.5.0.201903190907] at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:438) [233:org.openhab.binding.ipcamera:2.5.0.201903190907] at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:323) [233:org.openhab.binding.ipcamera:2.5.0.201903190907] at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:297) [233:org.openhab.binding.ipcamera:2.5.0.201903190907] at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:253) [233:org.openhab.binding.ipcamera:2.5.0.201903190907] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [233:org.openhab.binding.ipcamera:2.5.0.201903190907] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [233:org.openhab.binding.ipcamera:2.5.0.201903190907] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [233:org.openhab.binding.ipcamera:2.5.0.201903190907] at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:286) [233:org.openhab.binding.ipcamera:2.5.0.201903190907] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [233:org.openhab.binding.ipcamera:2.5.0.201903190907] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [233:org.openhab.binding.ipcamera:2.5.0.201903190907] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [233:org.openhab.binding.ipcamera:2.5.0.201903190907] at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1408) [233:org.openhab.binding.ipcamera:2.5.0.201903190907] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [233:org.openhab.binding.ipcamera:2.5.0.201903190907] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [233:org.openhab.binding.ipcamera:2.5.0.201903190907] at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:930) [233:org.openhab.binding.ipcamera:2.5.0.201903190907] at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163) [233:org.openhab.binding.ipcamera:2.5.0.201903190907]
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:677) [233:org.openhab.binding.ipcamera:2.5.0.201903190907]
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:612) [233:org.openhab.binding.ipcamera:2.5.0.201903190907]
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:529) [233:org.openhab.binding.ipcamera:2.5.0.201903190907]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:491) [233:org.openhab.binding.ipcamera:2.5.0.201903190907]
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:905) [233:org.openhab.binding.ipcamera:2.5.0.201903190907]
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [233:org.openhab.binding.ipcamera:2.5.0.201903190907]
2019-03-20 07:02:39.241 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - !!! Camera has closed the channel URL:/cgi-bin/eventManager.cgi?action=getEventIndexes&code=VideoMotion Cause reported is: {}
at io.netty.util.concurrent.DefaultPromise.checkDeadLock(DefaultPromise.java:395) ~[233:org.openhab.binding.ipcamera:2.5.0.201903190907]
at io.netty.channel.DefaultChannelPromise.checkDeadLock(DefaultChannelPromise.java:159) ~[233:org.openhab.binding.ipcamera:2.5.0.201903190907]
at io.netty.util.concurrent.DefaultPromise.awaitUninterruptibly(DefaultPromise.java:246) ~[233:org.openhab.binding.ipcamera:2.5.0.201903190907]
at io.netty.channel.DefaultChannelPromise.awaitUninterruptibly(DefaultChannelPromise.java:137) ~[233:org.openhab.binding.ipcamera:2.5.0.201903190907]
at io.netty.channel.DefaultChannelPromise.awaitUninterruptibly(DefaultChannelPromise.java:30) ~[233:org.openhab.binding.ipcamera:2.5.0.201903190907]
at org.openhab.binding.ipcamera.handler.IpCameraHandler.sendHttpRequest(IpCameraHandler.java:634) ~[233:org.openhab.binding.ipcamera:2.5.0.201903190907]
at org.openhab.binding.ipcamera.internal.MyNettyAuthHandler.processAuth(MyNettyAuthHandler.java:174) ~[233:org.openhab.binding.ipcamera:2.5.0.201903190907]
at org.openhab.binding.ipcamera.internal.MyNettyAuthHandler.channelRead(MyNettyAuthHandler.java:223) ~[233:org.openhab.binding.ipcamera:2.5.0.201903190907]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [233:org.openhab.binding.ipcamera:2.5.0.201903190907]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [233:org.openhab.binding.ipcamera:2.5.0.201903190907]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [233:org.openhab.binding.ipcamera:2.5.0.201903190907]
at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:438) [233:org.openhab.binding.ipcamera:2.5.0.201903190907]
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:323) [233:org.openhab.binding.ipcamera:2.5.0.201903190907]
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:297) [233:org.openhab.binding.ipcamera:2.5.0.201903190907]
at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:253) [233:org.openhab.binding.ipcamera:2.5.0.201903190907]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [233:org.openhab.binding.ipcamera:2.5.0.201903190907]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [233:org.openhab.binding.ipcamera:2.5.0.201903190907]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [233:org.openhab.binding.ipcamera:2.5.0.201903190907]
at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:286) [233:org.openhab.binding.ipcamera:2.5.0.201903190907]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [233:org.openhab.binding.ipcamera:2.5.0.201903190907]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [233:org.openhab.binding.ipcamera:2.5.0.201903190907]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [233:org.openhab.binding.ipcamera:2.5.0.201903190907]
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1408) [233:org.openhab.binding.ipcamera:2.5.0.201903190907]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [233:org.openhab.binding.ipcamera:2.5.0.201903190907]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [233:org.openhab.binding.ipcamera:2.5.0.201903190907]
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:930) [233:org.openhab.binding.ipcamera:2.5.0.201903190907]
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163) [233:org.openhab.binding.ipcamera:2.5.0.201903190907]
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:677) [233:org.openhab.binding.ipcamera:2.5.0.201903190907]
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:612) [233:org.openhab.binding.ipcamera:2.5.0.201903190907]
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:529) [233:org.openhab.binding.ipcamera:2.5.0.201903190907]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:491) [233:org.openhab.binding.ipcamera:2.5.0.201903190907]
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:905) [233:org.openhab.binding.ipcamera:2.5.0.201903190907]
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [233:org.openhab.binding.ipcamera:2.5.0.201903190907]

@matt1, thank you for pointing me to the foscam forum! I could not get it to work directly so thats why I used ffserver. But with the help of you and the pointers on the foscam forum I managed to get a direct mjpeg stream from my camera!

Again Matt: THANK YOU! :smiley:

@Johannes_Bauerstatte

I recommend setting up all Amcrest cameras as DAHUA as they work better that way, see readme.

My guess is you are looking at the image which is not a stream, The fact you have called the snapshot/image ‘Livefeed’ gives me this indication. The image channel only displays a snapshot. For the stream you need to test opening up the link in a browser/habpanel/sitemap from a machine with its IP in the whitelist…
http://xxx.xxx.xxx.xxx:54321/ipcamera.mjpg

This probably is also going to be a problem. You need to setup the camera for mjpeg, see your cameras manual or support.

I tried to recreate the other errors and could not, if you work out the cause of the deadlock please let me know but possibly they are from a bottleneck if they only happen when the stream starts. Let me know what kind of device you are running this on, is it a Raspberry Pi 1?

Sorry I forgot. Yes I use image and not a stream. I set update interval to 1 second. I will have a look at the manual to find if mjpeg works. This image solution was just easy to implement. :slight_smile:

It is running on a NUC Intel® Celeron® CPU 847E @ 1.10GHz with SSD and 8GB Ram. So I think Hardware should be OK.

Update: With the DAHUA settings it is working. Thank you.

@matt1

Sorry Matt to bother you again but, I just received an update on my FOSCAM software on my android device and it now has an option to be put to sleep/Standby mode. (See attached screenshot) But the slider doesn’t work with my camera at the moment. If I enable it, it immediately gets disabled again. (This might be a firmware issue with my camera or something, not important).

It might be interesting for you to look at this new function and implement it in the IPCAMERA Binding? This should put a lot less strain on OPENHAB and the camera itself if you would put this in a time schedule.

Just my 2 cents as a heads up.

Thank you for all your great work!