IpCamera: New IP Camera Binding

@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

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