IpCamera: New IP Camera Binding

@JimT and @msexton187
I created a github feature request here so if you want to do some testing and give feedback, it can be captured in one place to be looked at getting added.

[ipcamera] Day/Night profile switching features · Issue #11470 · openhab/openhab-addons (github.com)

Hi,

first of all, thank you for developing this binding.

I’m testing out a low budget camera Reolink RLC-410W. Some things work, some things don’t. But one step at a time.

First issue I’m trying to solve is HLS Stream. curling /ipcamera.m3u8 gives empty reply. The logs say:

2021-10-30 15:42:21.700 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - Starting ffmpeg with this command now:-hide_banner -loglevel warning -rtsp_transport tcp -i rtsp://admin:********@192.168.0.77:554/h264Preview_01_main -strict -2 -f lavfi -i aevalsrc=0 -acodec aac -vcodec copy -hls_flags delete_segments -hls_time 2 -hls_list_size 4 /var/lib/openhab/ipcamera/1ae736639a/ipcamera.m3u8
2021-10-30 15:42:22.591 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - Invalid loglevel "warning". Possible levels are numbers or:
2021-10-30 15:42:22.594 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - "q�iet"
2021-10-30 15:42:22.609 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - "panic"
2021-10-30 15:42:22.613 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - "&atal"
2021-10-30 15:42:22.617 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - "error"
2021-10-30 15:42:22.620 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - "warning?verbose"
2021-10-30 15:42:22.624 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - "info"
2021-10-30 15:42:22.626 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - "verbose"
2021-10-30 15:42:22.630 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - "debug"
2021-10-30 15:42:22.640 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - "trace"

So ffmpeg complains about wrong loglevel settings. This is my ffmpeg version: “ffmpeg version 4.1.8-0+deb10u1+rpt1”. Is this a known problem? Binding version is 3.1.0

hmm, seems I’ve fixed it by uninstalling and reinstalling ffmpeg again

Looks like it is as data corruption. Make sure your card is not a counterfeit and is a quality one. Also make sure you have a UPS to protect against power outages when you have not shutdown correctly. Bad power supplies can also cause it. Do backups in case the card is failing.

I found that my Imou camera is set to be restarted every day at midnight. This process takes about 30-40 seconds, and after that camera lost connection with the binding (because I can see no more ONVIF Renew/PullMessages request in the openhab.log since then).
So is there a way to re-establish the connection or reset it frequently? Thank you! :slight_smile:

I believe I fixed that in the latest build, you can either download it now or wait around a week for the next milestone (4?) to be released. The event streams and also if you have any open mjpeg streams will continue on after the camera reboots without needing any interaction.

IpCamera binding - Breaking changes and new features in 3.2 Milestone 3 and newer - Add-ons / Bindings - openHAB Community

1 Like

Hm yeah, maybe. Although I can’t observe other inconsistencies.

Next error is, I get a segfault when running this command

sudo -u openhab /usr/bin/ffmpeg -hide_banner -loglevel debug -rtsp_transport tcp -i rtsp://admin:abc@192.168.0.77:554/h264Preview_01_main -strict -2 -f lavfi -i aevalsrc=0 -acodec aac -vcodec copy -hls_flags delete_segments -hls_time 2 -hls_list_size 4 /mnt/openhabian/camera/ipcamera.m3u8

Just booted my backup card and fixed apt, now everything seems to work :slight_smile: Never had any data issues for the last 10 years but always cared for my backups. Now it finally payed off.

1 Like

I like to give feedback about my current tests and local setup.
Probably it will help other.

Camera I use (just bought few days ago):
Reolink 4MP Überwachungskamera Aussen, 2,4/5GHz WLAN CCTV IP Kamera Outdoor, Wetterfest, 30m Nachtsicht, Sicherheitskamera mit Bewegungserkennung, Audioaufzeichnung, Fernzugriff, RLC-410W Schwarz

The rstp-address to get the native stream of the camera in my network is:
rtsp://admin:YOUR_PASSWORD@192.168.178.53:554//h264Preview_01_main

In my openHAB-configuration I add a new binding of “IpCamera Binding”:

I decided to use “RTSP/HTTP IP Camera”:

I kept most of the default which work.
I changed only:

  • IP Address (to 192.168.178.53)
  • Server Port (to 9801, must be unused, will be occupied by the streaming, see later)
  • FFmpeg Input (the mentioned URL, i.e rtsp://admin:YOUR_PASSWORD@192.168.178.53:554//h264Preview_01_main)

Thats it.

In openHAB’s “Model” page I have added the camera with “Create Equipement from Thing” with the following channels:

I am more than suprised… It works very smoothly.
The stream address is provided in the “Model”:

It can be opened directly in the browser but as well in the habpanel:
image

With the use of the small html part:

<h2>Kamera #1</h2>
<img src="http://192.168.178.29:9801/ipcamera.mjpeg" 
     style="width: 100%; height: 100%;">

As you can see 9801 is the configured port at the beginning which is used to provide the stream. Any camera needs its own port.

In the background the stream is provided by ffmpeg as you can see in the process list:

This is all great!
I really appreciate this approach.

1 Like

Hi @matt1,

I’ve been using your binding for over 3 years now and I’m starting my migration from OH 2.5 to 3.1 using two different platforms.

Bindings used:
org.openhab.binding.ipcamera-2.5.4-SNAPSHOT.jar
org.openhab.binding.ipcamera-3.2.0-SNAPSHOT.jar

I have copied all the settings via the GUI between the platforms. OH 3.1 Things report to be online but NO images are being produced.

I really only use the IMAGE channel and that’s NOT working on any camera on OH 3.1 like it is on OH 2.5

I did install the FFMPEG on the new RaspberryPi for OH 3.1 but did not per se configure and test it. Not sure if the FFMPEG is really used for what I’m doing.

Here’s an example of one camera config.




Do you have any thoughts on this?

Best, Jay

Since you have a Hikvision, there was a bug that stopped them working in DIGEST mode recently and this was just fixed in the released 3.2m4 just released. So make sure your on the latest version, or you can switch to basic auth as a work around. Dropping the new jar into older cores can be done.

As for the image channel, what is the config set to that is called ‘updateImage’? also have you tried the channel called ‘updateImageNow’ and turning that on?

I really don’t recommend using the image channel for multiple reasons, one of which is it floods the event bus with the image data. With only a few cameras and longer poll times it is fine to do but it is a feature that I have not tested in a very long time so if you still can not get it working let me know so I can run a test here. You posted you have 9 cameras and poll times of 3 seconds, I really really don’t think it is a good idea to use the image channel in this case, I would be surprised if it worked without issues.

Why do you not want to use the other methods?

The version I got was off your site back in Oct, should I get it from here which is built today?

https://ci.openhab.org/job/openHAB-Addons/lastSuccessfulBuild/artifact/bundles/org.openhab.binding.ipcamera/target/

EDIT - If found M4 here

I really only want an image to be displayed (which the image gets updated between 3 - 5 seconds) on a panel I have 6 cameras showing. Really don’t need to stream video the the panel (tablets aren’t that powerful)

Here’s the ITEMS for a camera that is working with your OH 2.5 binding.

Image		HIKGarageImage										"Snapshot"									(Group_HabPanel_Dashboard)									{ channel="ipcamera:hikvision:10f6258d1a:image" }
Switch		HIKGarageMotion										"Motion [MAP(Motion.map):%s]" (IPCams, gHIKMotion, gLastMotion, Group_HabPanel_Dashboard, ResetExpire)	{ channel="ipcamera:hikvision:10f6258d1a:motionAlarm", expire="10m, command=OFF" }
String		HIKGarageImageURL									"[%s]"																									{ channel="ipcamera:hikvision:10f6258d1a:imageurl" }
Switch		HIKGaragelineCrossingAlarm 							"Line Crossing [MAP(Motion.map):%s]"		(IPCams, gHIKLineCrossingAlarm, ResetExpire)				{ channel="ipcamera:hikvision:10f6258d1a:lineCrossingAlarm", expire="10m, command=OFF" }
Switch		HIKGarageEnablelineCrossing							"Enable Line Crossing [MAP(Motion.map):%s]"	(IPCams)													{ channel="ipcamera:hikvision:10f6258d1a:enableLineCrossingAlarm" }
Switch		HIKGarageEnableMotionAlarm							"Enable Motion Alarm [MAP(Motion.map):%s]"	(IPCams, gHIKMotionAlarm)									{ channel="ipcamera:hikvision:10f6258d1a:enableMotionAlarm" }
Switch		HIKGarageUpdateImage								"Update Image Now [MAP(Motion.map):%s]"		(IPCams, gHIKUpdateImage)									{ channel="ipcamera:hikvision:10f6258d1a:updateImageNow" }

Best, Jay

Hey @matt1,

I remember having to install some extra JAR’s around the 2.5.x version.

Is the 3.2m4 just one JAR or is there some other support JARs I need to install also?

Best, Jay

It still needs the extra Netty library, but now different openHAB versions use different Netty lib versions it is far easier to just install the telstick binding which will take care of the Netty libs so the single jar works. You can download the jars from the mvn/maven website, or install them with the console using the info from this post making sure you only use a single version of Netty on your system. The mqtt binding also uses different parts of the Netty libs.

That link will be the fixed version and should work on all 3.x versions of the core.

IpCamera binding - Breaking changes and new features in 3.2 Milestone 3 and newer - Add-ons / Bindings - openHAB Community

Try using the autofps.mjpeg stream as it updates every 8 seconds when there is no movement, then will change to every second when motion is detected. Tablets will handle it fine and there are widgets for OH3 that can make setting it up easy.

Another way would be to use snapshots.mjpeg and set the pollTime to 3 seconds and the stream will be a picture change every 3 seconds.

Yet another way is to use an Image item or oh-image card that gets fed the ipcamera.jpg url and set to update every 3 seconds.

All three of these ways will stop the image data going through the event bus and result in less load.

1 Like

Hey @matt1,

Thank you for all the detail to follow. I’m struggling to get TellStick to work. I’ve tried using the GUI to install it and dropping in the JAR. Here’s the state of it which it shows its missing a Netty object.

Also, I do have MQTT and zWave bindings both 3.1 versions installed if this is causing the issue.

344 │ Installed │  80 │ 3.2.0                 │ org.openhab.binding.tellstick


2021-11-09 08:23:46.618 [WARN ] [org.apache.felix.fileinstall        ] - Error while starting bundle: file:/usr/share/openhab/addons/org.openhab.binding.tellstick-3.2.0.jar
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.tellstick [344]
  Unresolved requirement: Import-Package: io.netty.channel.kqueue; version="[4.1.0,5.0.0)"

	at org.eclipse.osgi.container.Module.start(Module.java:463) ~[org.eclipse.osgi-3.16.200.jar:?]
	at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:440) ~[org.eclipse.osgi-3.16.200.jar:?]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1260) [bundleFile:3.6.8]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1233) [bundleFile:3.6.8]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:520) [bundleFile:3.6.8]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:365) [bundleFile:3.6.8]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:316) [bundleFile:3.6.8]

Here’s the Netty’s I have on my 3.1 system.

243 │ Active │  80 │ 4.1.63.Final          │ io.netty.buffer
244 │ Active │  80 │ 4.1.63.Final          │ io.netty.codec
245 │ Active │  80 │ 4.1.63.Final          │ io.netty.codec-http
246 │ Active │  80 │ 4.1.63.Final          │ io.netty.common
247 │ Active │  80 │ 4.1.63.Final          │ io.netty.handler
248 │ Active │  80 │ 4.1.63.Final          │ io.netty.resolver
249 │ Active │  80 │ 4.1.63.Final          │ io.netty.transport
275 │ Active │  80 │ 4.1.63.Final          │ io.netty.codec-socks
276 │ Active │  80 │ 4.1.63.Final          │ io.netty.handler-proxy
277 │ Active │  80 │ 4.1.63.Final          │ io.netty.transport-native-epoll
278 │ Active │  80 │ 4.1.63.Final          │ io.netty.transport-native-unix-co

Maybe as a simplier option, can you zip up the Netty stuff and put it up on your server like you have in the past with the older versions?

Best, Jay

Hi @matt1,

I have upgraded OH from 3.1 to 3.2m4 and now I have more Netty objects and the install of TellStick worked.

openhab> list -s | grep netty
258 │ Active │  80 │ 4.1.68.Final          │ io.netty.buffer
259 │ Active │  80 │ 4.1.68.Final          │ io.netty.codec
260 │ Active │  80 │ 4.1.68.Final          │ io.netty.codec-http
261 │ Active │  80 │ 4.1.68.Final          │ io.netty.codec-socks
262 │ Active │  80 │ 4.1.68.Final          │ io.netty.common
263 │ Active │  80 │ 4.1.68.Final          │ io.netty.handler
264 │ Active │  80 │ 4.1.68.Final          │ io.netty.handler-proxy
265 │ Active │  80 │ 4.1.68.Final          │ io.netty.resolver
266 │ Active │  80 │ 4.1.68.Final          │ io.netty.transport
267 │ Active │  80 │ 4.1.68.Final          │ io.netty.transport-native-epoll
268 │ Active │  80 │ 4.1.68.Final          │ io.netty.transport-native-unix-common
331 │ Active │  80 │ 4.1.68.Final          │ io.netty.transport-native-kqueue

I uninstalled the IPCam 3.2m4 and re-dropped it in and got this in the event log.

2021-11-09 14:07:45.710 [hingStatusInfoChangedEvent] - Thing 'ipcamera:hikvision:60179e611f' changed from UNINITIALIZED (HANDLER_MISSING_ERROR) to INITIALIZING
2021-11-09 14:07:45.896 [hingStatusInfoChangedEvent] - Thing 'ipcamera:hikvision:10f6258d1a' changed from UNINITIALIZED (HANDLER_MISSING_ERROR) to INITIALIZING
2021-11-09 14:07:45.919 [hingStatusInfoChangedEvent] - Thing 'ipcamera:hikvision:1e24e8460d' changed from UNINITIALIZED (HANDLER_MISSING_ERROR) to INITIALIZING
2021-11-09 14:07:45.946 [hingStatusInfoChangedEvent] - Thing 'ipcamera:hikvision:91b4b89a9d' changed from UNINITIALIZED (HANDLER_MISSING_ERROR) to INITIALIZING
2021-11-09 14:07:45.978 [hingStatusInfoChangedEvent] - Thing 'ipcamera:hikvision:0cf1f88e47' changed from UNINITIALIZED (HANDLER_MISSING_ERROR) to INITIALIZING
2021-11-09 14:07:45.998 [hingStatusInfoChangedEvent] - Thing 'ipcamera:hikvision:46e5506d6a' changed from UNINITIALIZED (HANDLER_MISSING_ERROR) to INITIALIZING
2021-11-09 14:07:46.005 [nelDescriptionChangedEvent] - Description for field 'STATE_OPTIONS' of channel 'ipcamera:hikvision:60179e611f:gotoPreset' changed from 'null' to '{"options":[]}' for linked items: []
2021-11-09 14:07:46.021 [hingStatusInfoChangedEvent] - Thing 'ipcamera:hikvision:87cb66e306' changed from UNINITIALIZED (HANDLER_MISSING_ERROR) to INITIALIZING
2021-11-09 14:07:46.053 [hingStatusInfoChangedEvent] - Thing 'ipcamera:hikvision:0b51a19946' changed from UNINITIALIZED (HANDLER_MISSING_ERROR) to INITIALIZING
2021-11-09 14:07:46.077 [hingStatusInfoChangedEvent] - Thing 'ipcamera:hikvision:2df5aa8a86' changed from UNINITIALIZED (HANDLER_MISSING_ERROR) to INITIALIZING
2021-11-09 14:07:46.081 [nelDescriptionChangedEvent] - Description for field 'STATE_OPTIONS' of channel 'ipcamera:hikvision:10f6258d1a:gotoPreset' changed from 'null' to '{"options":[]}' for linked items: []
2021-11-09 14:07:46.162 [nelDescriptionChangedEvent] - Description for field 'STATE_OPTIONS' of channel 'ipcamera:hikvision:1e24e8460d:gotoPreset' changed from 'null' to '{"options":[]}' for linked items: []
2021-11-09 14:07:46.287 [nelDescriptionChangedEvent] - Description for field 'STATE_OPTIONS' of channel 'ipcamera:hikvision:46e5506d6a:gotoPreset' changed from 'null' to '{"options":[]}' for linked items: []
2021-11-09 14:07:46.329 [nelDescriptionChangedEvent] - Description for field 'STATE_OPTIONS' of channel 'ipcamera:hikvision:91b4b89a9d:gotoPreset' changed from 'null' to '{"options":[]}' for linked items: []
2021-11-09 14:07:46.335 [nelDescriptionChangedEvent] - Description for field 'STATE_OPTIONS' of channel 'ipcamera:hikvision:0cf1f88e47:gotoPreset' changed from 'null' to '{"options":[]}' for linked items: []
2021-11-09 14:07:46.352 [nelDescriptionChangedEvent] - Description for field 'STATE_OPTIONS' of channel 'ipcamera:hikvision:87cb66e306:gotoPreset' changed from 'null' to '{"options":[]}' for linked items: []
2021-11-09 14:07:46.361 [nelDescriptionChangedEvent] - Description for field 'STATE_OPTIONS' of channel 'ipcamera:hikvision:0b51a19946:gotoPreset' changed from 'null' to '{"options":[]}' for linked items: []
2021-11-09 14:07:46.381 [nelDescriptionChangedEvent] - Description for field 'STATE_OPTIONS' of channel 'ipcamera:hikvision:2df5aa8a86:gotoPreset' changed from 'null' to '{"options":[]}' for linked items: []

Does this look right?

Best, Jay

Then just use the merged binding as it has the fix in it. Remove all extra jars and just install it as per normal.

Done.

  • Stopped IPCam 3.2m4 addon, uninstalled it then deleted it
  • Uninstalled TellStick from the GUI
  • Installed IPCam 3.2m4 from the GUI
  • Stopped OH
  • Cleared /Cache & /Tmp
  • Rebooted

Same issue, Things are online but no item channels are working with it.

This is pretty much a clean install on a new Pi4. I don’t even have rules running yet, just trying to get the Things and Items to work as first step.

What can I provide you to figure this out? Debugs, remote connection to my system, etc.?

Thanks again!

Best, Jay

Debug or trace log output would be the first step. The ipcamera binding documentation has at the very first section titled ‘how to get help’ which gives the command to enable the log output, then please start a new thread and feel free to mention my name in it or post a link to it from here.

Hikvision cameras have an illegal login lock that once tripped will mean you have to reboot the camera, worth doing in case that is the cause but the logs should be picking that up when you enable debug/trace.

Also you should try and open the stream by just typing the URL into any web browser, the binding should log that it got the request and then the following info may yield a clue as to what is wrong.

Hi @matt1,

I found out the issues with my HikVision NVR model DS-7208HUI-K2 configuration with migrating the binding versions from 2.5 to 3.x.

Here’s a summary of them.

v2.5 has two channels that are NOT named the same on v3.x

  • updateImageNow is now pollImage
  • videourl is now mjpegUrl (at least I think it is)

v2.5 does NOT need the updateImageNow turned ON to update the IMAGE channel but v3.x pullImage channel does.

v2.5 has a “Poll Time” value which is defaulted to 1000. The v2.5 binding has an option called “Update the JPG and Image when: Always update JPG” which is 1. v3.x has an option called “Update Image Channel When” which is defaulted to None but if you put it to follow pullImage which is option 1 to mirror v2.5 setting, this isn’t the same thing. You must have v3.x pullImage switch ON for this to work.

I did get these to work: [EDITED]

http://openhab:8080/ipcamera/cameraUID/ipcamera.jpg
http://openhab:8080/ipcamera/cameraUID/ipcamera.mjpeg
http://openhab:8080/ipcamera/cameraUID/snapshots.mjpeg

These did NOT get these working but I didn’t spend much time trying to debug why: [EDITED]

http://openhab:8080/ipcamera/cameraUID/ipcamera.m3u8
http://openhab:8080/ipcamera/cameraUID/autofps.mjpeg

I’m interested in how to push the ipcamera.jpg url into a native IMAGE item in the item file. Is it simply this format or something else?

Image HIKFrontDoorImage { http://openhab:8080/ipcamera/cameraUID/ipcamera.jpg }

Best, Jay