IpCamera: New IP Camera Binding

This is covered in the documentation here
IP Camera - Bindings | openHAB

With 20 cameras yes I am not surprised that M3 is still an issue, I have not tested that many before but you do not need to wait for M4 as I have uploaded the jar if you wish to try it out.

That is difficult to answer as it depends on the browser and the widget. You can easily check yourself by using DEBUG log output. Sometimes it is needed to press refresh on a browser after you leave the page to stop some streams.

Your streams not starting whilst others do, are any of them hikvision with digest? if so see hereā€¦

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

@matt1 I read that part - but I assumed that given I am talking to all cams through an NVR - same ip of NVR for all 20 cams/RTSP/different channels it isnt relevant to me? Should either work or not.

will try the new jar and revert after I read the debug info also.
thanks

Newer jar just uploaded for the hik digest bug. I have fixed a lot of bugs since M3 so you may find it now works with the newer jar. A NVR can be setup to allow each camera to be accessed via its own port, in that case it would depend on the cameras settings.

my NVR is a hybrid one - some analogue and some ip cameras. - it doesnt offer the option of port specific access. this is why i access via rtsp / channel by channel :slight_smile:

@matt1 uploaded the jar from here - http://www.pcmus.com/openhab/IpCameraBinding/
added it into the folder - usr/share/openhab/addons.
rebooted the rpi for good measure.

how do i know if it updated? does the below make sense? (it says the old Bundle is waiting)

Just updated and enabled CGI on the cameras. Everything seem ok now. No more repeating INFO messages.

Still canā€™t SCAN though, but adding manually works fine.

Thanks.

I use curl within Rules.

val logName = "Update Camera Schedule"
  
    val String DawnHour = astro_NauticDawnEnd_dt.state.format("%1$tH")  //%1$td.%1$tm.%1$ty %1$tH:%1$tM"
    val String DawnMinute = astro_NauticDawnEnd_dt.state.format("%1$tM")  
    val String DuskHour = astro_NauticDuskStart_dt.state.format("%1$tH")  
    val String DuskMinute = astro_NauticDuskStart_dt.state.format("%1$tM")  

    logInfo(logName, "Updating Camera Schedules: " + DawnHour + ":" + DawnMinute + " " + DuskHour + ":" + DuskMinute)

    //Amcrest
    // curl --anyauth --globoff -u username:yourpassowrd "http://10.1.1.201/cgi-bin/configManager.cgi?action=setConfig&VideoInOptions[0].NightOptions.SunriseHour=23"
    
    val strA = "http://10.1.1.208/cgi-bin/configManager.cgi?action=setConfig&VideoInOptions[0].NightOptions.SunriseHour=" + DawnHour
    createTimer(now.plusSeconds(1), [| executeCommandLine("curl", "--anyauth", "--globoff", "-u", "username:yourpassowrd", strA) ])
  
    val strB = "http://10.1.1.208/cgi-bin/configManager.cgi?action=setConfig&VideoInOptions[0].NightOptions.SunriseMinute=" + DawnMinute
    createTimer(now.plusSeconds(2), [| executeCommandLine("curl", "--anyauth", "--globoff", "-u", "username:yourpassowrd", strB) ])

    val strC = "http://10.1.1.208/cgi-bin/configManager.cgi?action=setConfig&VideoInOptions[0].NightOptions.SunsetHour=" + DuskHour
    createTimer(now.plusSeconds(3), [| executeCommandLine("curl", "--anyauth", "--globoff", "-u", "username:yourpassowrd", strC) ])

    val strD = "http://10.1.1.208/cgi-bin/configManager.cgi?action=setConfig&VideoInOptions[0].NightOptions.SunsetMinute=" + DuskMinute
    createTimer(now.plusSeconds(4), [| executeCommandLine("curl", "--anyauth", "--globoff", "-u", "username:yourpassowrd", strD) ])

Thanks @msexton187! This is much better than relying on openhab to perform the actual switching. I wasnā€™t aware of the sunrise / sunset hours being available. Indeed I could just set the time from astro and even add/subtract as I see fit.

@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