IpCamera: New IP Camera Binding

Yeah my NVR doesn’t do mjpeg. It only does h264 or h265. I guess Dahua removed that option on their newer NVRs.
I don’t mind higher CPU usage (right now my server isn’t breaking a sweat doing this) so I prefer having high quality/high FPS stream on all the time.

Speaking of Habpanel though. I am using the image widget for displaying the mjpegs (like I did before in OH2 with ffserver) and I am noticing that while using the binding some streams will just disappear after a few minutes (I get a blank background) or the whole habpanel will crash. Not sure if this is related to the binding or OH3. Just asking if you’ve noticed this before.

EDIT: Hmmm this is fun. This has somehow managed to crash my NVR. No RTSP streams were working and I couldn’t login into the web admin without rebooting the NVR.

EDIT2: I switched to the “generic RTSP” thing instead of using the Dahua specific thing and this seems to help in the stability of the NVR. It’s now running fine and the streams seem to be stable. However… habpanel is still crashing on two different android tablets every few hours. And it’s definitely connected to the mjpeg streams generated by this binding.

Fantastic! Thanks for the info. I installed the fixed version dated 2020-11-15 but initially I couldn’t get the rule that contained the call to getActions to work. Every time that line of code was executed I’d see this error in the log:

Rule 'Create front door camera GIF when front door motion detected': Instance is not a IpCamera class.

I searched the forum and found a few threads with similar issues (for other bindings) that suggested that the rule file containing the affected rule needed to be changed/touched to force it to be reloaded. That didn’t work for me but a restart of the openhab service resolved it.

How long should it take to generate a 6 second GIF on a Raspberry PI 4 with 4GB of RAM running OH 3.0.0? On mine it takes 30-60 seconds, but on my Windows box running 2.5M10 it takes about 10 seconds. I’m new to openHABian, but 60 seconds seems way too long to generate a 6 second GIF. Has anyone else noticed this? I can post the logs, but before I go there I want to make sure this isn’t normal behavior.

Marty

The camera list at the beginning ist old. Please add working cameras!

Hi,
I have an issue with Foscam FI9926P and PTZ functionalities.
I use OpenHab 3.0.0 with a docker image.
I try to configure it manually with the user interface and with the following config files, but without any success to PTZ:

ipcamera.things
Thing ipcamera:foscam:cam “Foscam Camera” @ “Living Room” [ipAddress=“192.168.0.28”, serverPort=38000, port=88, onvifPort=888, username=“…”, password=“…”]

and

ipcamera.items
Group Camera
Group Foscam “IP Camera (Living Room)” (LivingRoom) [“Camera”]
Switch Foscam_LED_Auto “Auto LED” (Camera,Foscam) [“Switch”] { channel=“ipcamera:foscam:cam:autoLED” }
Switch Foscam_LED_Enable “LED” (Camera,Foscam) [“Switch”] { channel=“ipcamera:foscam:cam:enableLED” }
Dimmer Foscam_Pan “Pan” (Camera,Foscam) [“Control”] { channel=“ipcamera:foscam:cam:pan” }
Dimmer Foscam_Tilt “Tilt” (Camera,Foscam) [“Control”] { channel=“ipcamera:foscam:cam:tilt” }
Dimmer Foscam_Zoom “Zoom” (Camera,Foscam) [“Control”] { channel=“ipcamera:foscam:cam:zoom” }

The AutoLED and LED are functionnal, but the PTZ items are not. I tried everything without any success.
PTZ functionnalities are ok using the ONVIF device Manager (and using the same username and password).

Some help will be appreciated.

What ONVIF modes did you try and confirm that work in ODM? continuous, relative and absolute as well as using presets, this adds up to 4 different ways and it is common for cameras to not support all 4 ways. I have posted screen shots on how to change between them on this forum if you do not know how.

In OH3 this widget is the easiest to get going IF you use the UI to auto find and add the thing as equipment.

OH3 Widget: Move and see your PTZ camera feed on a page - Add-ons / UIs - openHAB Community

Thanks for your reply. So I made some more tests with ONVIF Device Manager. In fact, only the Continous move mode seems to be supported on this camera (the others generate: nothing for absolute mode, and a SOAP Server error on the Relative mode). So the Continuous mode is OK for pan and tilt (still have some issue with zoom) and presets with ONVIF Device Manager.
So, with the OpenHab UI:

  • I added a new Thing for this Foscam camera, adding the right parameters (IP, ports, credentials, …)
  • I switched ON the “Use Continuous PTZ” property
  • I attached items for IR LEDs, pan, til,t and zoom.

The IR leds are OK (I can switch them on and off, so no credential issues), but I still have the same issue with the PTZ functionalities.

I also confirm that I have the lastest firmware (V-2.x.1.79_p1) for this camera.

Thanks in advance for any help.

Good, just check that in the UI it is showing as turned on it you are using textual to rule to typo/syntax issues.

Can you send me the TRACE level logs of when the camera is connecting? Just do a find and replace on your password first. I am after the ONVIF xml chatter that occurs when the camera first connects. If the handshake is working then I will move onto looking at wireshark logs of what is different when comparing what ODM sends vs the bindings messages.

If presets work, they will be better to use.

10:56:20.464 [DEBUG] [mera.internal.handler.IpCameraHandler] - About to connect to the IP Camera using the ONVIF PORT at IP:192.168.0.28:888
10:56:20.476 [TRACE] [camera.internal.onvif.OnvifConnection] - Sending ONVIF request:GetSystemDateAndTime
10:56:20.526 [TRACE] [mera.internal.handler.IpCameraHandler] - Sending camera: GET: http://192.168.0.28:88/cgi-bin/CGIProxy.fcgi?usr=...&pwd=...&cmd=snapPicture2
10:56:20.527 [INFO ] [hab.event.ThingStatusInfoChangedEvent] - Thing 'ipcamera:foscam:7058551098' changed from OFFLINE (COMMUNICATION_ERROR): Connection Timeout: Check your IP and PORT are correct and the camera can be reached. to ONLINE
10:56:20.571 [TRACE] [camera.internal.onvif.OnvifConnection] - Onvif reply is:<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsdd="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:chan="http://schemas.microsoft.com/ws/2005/02/duplex" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:c14n="http://www.w3.org/2001/10/xml-exc-c14n#" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" xmlns:wsc="http://schemas.xmlsoap.org/ws/2005/02/sc" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:xmime="http://tempuri.org/xmime.xsd" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:tdn="http://www.onvif.org/ver10/network/wsdl" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl"><SOAP-ENV:Body><tds:GetSystemDateAndTimeResponse><tds:SystemDateAndTime xsi:type="tt:SystemDateTime"><tt:DateTimeType>NTP</tt:DateTimeType><tt:DaylightSavings>false</tt:DaylightSavings><tt:TimeZone xsi:type="tt:TimeZone"><tt:TZ>CST-1:00:00</tt:TZ></tt:TimeZone><tt:UTCDateTime xsi:type="tt:DateTime"><tt:Time xsi:type="tt:Time"><tt:Hour>10</tt:Hour><tt:Minute>16</tt:Minute><tt:Second>49</tt:Second></tt:Time><tt:Date xsi:type="tt:Date"><tt:Year>2021</tt:Year><tt:Month>1</tt:Month><tt:Day>10</tt:Day></tt:Date></tt:UTCDateTime><tt:LocalDateTime xsi:type="tt:DateTime"><tt:Time xsi:type="tt:Time"><tt:Hour>11</tt:Hour><tt:Minute>16</tt:Minute><tt:Second>49</tt:Second></tt:Time><tt:Date xsi:type="tt:Date"><tt:Year>2021</tt:Year><tt:Month>1</tt:Month><tt:Day>10</tt:Day></tt:Date></tt:LocalDateTime></tds:SystemDateAndTime></tds:GetSystemDateAndTimeResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
10:56:20.583 [TRACE] [camera.internal.onvif.OnvifConnection] - Sending ONVIF request:GetCapabilities
10:56:20.610 [DEBUG] [camera.internal.onvif.OnvifConnection] - Cameras  UTC dateTime is:2021-1-10T10:16:49
10: 56:20.614 [DEBUG] [camera.internal.onvif.OnvifConnection] - Openhabs UTC dateTime is:2021-01-10T10:56:20.614Z
10:56:20.647 [TRACE] [camera.internal.onvif.OnvifConnection] - Onvif reply is:<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsdd="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:chan="http://schemas.microsoft.com/ws/2005/02/duplex" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:c14n="http://www.w3.org/2001/10/xml-exc-c14n#" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" xmlns:wsc="http://schemas.xmlsoap.org/ws/2005/02/sc" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:xmime="http://tempuri.org/xmime.xsd" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:tdn="http://www.onvif.org/ver10/network/wsdl" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl"><SOAP-ENV:Header></SOAP-ENV:Header><SOAP-ENV:Body><SOAP-ENV:Fault SOAP-ENV:encodingStyle="http://www.w3.org/2003/05/soap-encoding"><SOAP-ENV:Code><SOAP-ENV:Value>SOAP-ENV:Sender</SOAP-ENV:Value></SOAP-ENV:Code><SOAP-ENV:Reason><SOAP-ENV:Text xml:lang="en">HTTP Error: 401 Unauthorized</SOAP-ENV:Text></SOAP-ENV:Reason></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
10:56:21.545 [TRACE] [mera.internal.handler.IpCameraHandler] - Sending camera: GET: http://192.168.0.28:88/cgi-bin/CGIProxy.fcgi?usr=...&pwd=...&cmd=snapPicture2
10:56:21.552 [TRACE] [mera.internal.handler.IpCameraHandler] - Sending camera: GET: http://192.168.0.28:88/cgi-bin/CGIProxy.fcgi?cmd=getDevState&usr=...&pwd=...
10:56:21.745 [TRACE] [mera.internal.handler.IpCameraHandler] - HTTP Result back from camera is  :<CGI_Result>
    <result>0</result>
    <IOAlarm>0</IOAlarm>
    <motionDetectAlarm>1</motionDetectAlarm>
    <soundAlarm>0</soundAlarm>
    <record>0</record>
    <sdState>0</sdState>
    <sdFreeSpace>0k</sdFreeSpace>
    <sdTotalSpace>0k</sdTotalSpace>
    <ntpState>2</ntpState>
    <ddnsState>0</ddnsState>
    <url></url>
    <upnpState>0</upnpState>
    <isWifiConnected>0</isWifiConnected>
    <wifiConnectedAP></wifiConnectedAP>
    <infraLedState>0</infraLedState>
    <humanDetectAlarmState>1</humanDetectAlarmState>
    </CGI_Result>
:
10:56:21.772 [DEBUG] [mera.internal.handler.IpCameraHandler] - End of FOSCAM handler reached, so closing the channel to the camera now
10:56:29.584 [TRACE] [mera.internal.handler.IpCameraHandler] - Sending camera: GET: http://192.168.0.28:88/cgi-bin/CGIProxy.fcgi?usr=...&pwd=...&cmd=snapPicture2
10:56:29.586 [TRACE] [mera.internal.handler.IpCameraHandler] - Sending camera: GET: http://192.168.0.28:88/cgi-bin/CGIProxy.fcgi?cmd=getDevState&usr=...&pwd=...
10:56:29.772 [TRACE] [mera.internal.handler.IpCameraHandler] - HTTP Result back from camera is  :<CGI_Result>
    <result>0</result>
    <IOAlarm>0</IOAlarm>
    <motionDetectAlarm>1</motionDetectAlarm>
    <soundAlarm>0</soundAlarm>
    <record>0</record>
    <sdState>0</sdState>
    <sdFreeSpace>0k</sdFreeSpace>
    <sdTotalSpace>0k</sdTotalSpace>
    <ntpState>2</ntpState>
    <ddnsState>0</ddnsState>
    <url></url>
    <upnpState>0</upnpState>
    <isWifiConnected>0</isWifiConnected>
    <wifiConnectedAP></wifiConnectedAP>
    <infraLedState>0</infraLedState>
    <humanDetectAlarmState>1</humanDetectAlarmState>
</CGI_Result>
:
10:56:29.786 [DEBUG] [mera.internal.handler.IpCameraHandler] - End of FOSCAM handler reached, so closing the channel to the camera now

And moreover, I tried the preset and when I try to at a channel (with link an Item), I’ve got the following error message in the openhab console:

11:07:44.562 [WARN ] [se.internal.SseItemStatesEventBuilder] - Attempting to send a state update of an item which doesn't exist: FoscamCamerawithAPI_GoToPreset
11:07:55.344 [ERROR] [core.common.registry.AbstractRegistry] - Cannot inform the listener "org.openhab.core.thing.internal.ChannelLinkNotifier@6d512" about the "ADDED" event: Index: 0, Size: 0
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
    at java.util.LinkedList.checkElementIndex(LinkedList.java:559) ~[?:?]
    at java.util.LinkedList.get(LinkedList.java:480) ~[?:?]
    at org.openhab.binding.ipcamera.internal.onvif.OnvifConnection.getXml(OnvifConnection.java:288) ~[?:?]
    at org.openhab.binding.ipcamera.internal.onvif.OnvifConnection.requestBuilder(OnvifConnection.java:366) ~[?:?]
    at org.openhab.binding.ipcamera.internal.onvif.OnvifConnection.sendPTZRequest(OnvifConnection.java:809) ~[?:?]
    at org.openhab.binding.ipcamera.internal.handler.IpCameraHandler.handleCommand(IpCameraHandler.java:1178) ~[?:?]
    at org.openhab.core.thing.binding.BaseThingHandler.channelLinked(BaseThingHandler.java:177) ~[?:?]
    at org.openhab.core.thing.internal.ChannelLinkNotifier.lambda$3(ChannelLinkNotifier.java:72) ~[?:?]
    at org.openhab.core.thing.internal.ChannelLinkNotifier.call(ChannelLinkNotifier.java:96) ~[?:?]
    at org.openhab.core.thing.internal.ChannelLinkNotifier.added(ChannelLinkNotifier.java:72) ~[?:?]
    at org.openhab.core.thing.internal.ChannelLinkNotifier.added(ChannelLinkNotifier.java:1) ~[?:?]
    ...

Do you know how to use wireshark? It is failing to work for this request so if you can provide what odm is sending as a request for the above?

Yes I know. I just captured all the traffic and save it into a wireshark log file.
As I can’t modify the log to remove some potential credential information, I would like to send this log to you directly (and not on this forum). Could you tell me how to proceed.

I’ll PM you my email if that is what you prefer.
Some other things are:

  1. Change your password before taking the log and then change it back afterwards.
  2. I only need the REQUEST and not the RESPONSE, with only half of the traffic the digest method can not be reversed from what I understand. I have seen some cameras do a really stupid things so it is best to do 1. if it concerns you.

I’m on OH3 now so who to kill to get my UDP camera to work?

I’m currently trying to record a 30 seconds GIF from my Foscam via the recordGIF action.

While in the logs it first tell me that the recording should be 30 seconds, the passed parameter -t is only 5:

10:54:40.079 [DEBUG] [ing.ipcamera.internal.IpCameraActions] - Recording ipcamera.gif for 30 seconds.
10:54:40.085 [DEBUG] [nhab.binding.ipcamera.internal.Ffmpeg] - Starting ffmpeg with this command now:-y -t 5 -hide_banner -loglevel warning -rtsp_transport tcp -i rtsp://user:pass@192.168.1.62:88/videoMain -r 2 -filter_complex scale=-2:360:flags=lanczos,setpts=0.5*PTS,split[o1][o2];[o1]palettegen[p];[o2]fifo[o3];[o3][p]paletteuse c:\openhab\conf\html\carport\ipcamera.gif

Does anyone have an idea how this can be solved or is GIF recording somehow limited to max 5 seconds?

That is a bug in the 2.5.x merged binding which was fixed in V3.0 and newer. I built a fixed version and uploaded it here for 2.5.x
http://www.pcmus.com/openhab/IpCameraBinding/ipcamera-2020-11-15.zip

Thanks, do I need to recreate the thing or something like that? Because removing the bundle and installing that addon plus restarting OH didn’t change the behavior.

Matt
I have fresh installed OH3, installed IP Camera Binding and tried to add ONVIF UDP camera.
When I play the stream:

rtsp://user:pass@192.168.1.16/onvif1

in VLC all works!
When I add ONVIF camera as a thing with parameters:

IP - 192.168.1.15
ONVIF PORT: 5000
PORT: 2015
MJPEG: rtsp://user:pass@192.168.1.16:554/onvif1
Options before -i: -rtsp_transport udp

OH Log Viewer gives error:

2021-01-12 15:40:12.204 [WARN ] [hab.binding.ipcamera.internal.Ffmpeg] - An error occured trying to process the messages from FFmpeg.

any thoughts?

UPDATE: I have managed kinda make it working, but that is DEAD slow!!! DEAD and unstable!!! and on fresh install did not work at all for some reason…And that is the same with TCP stream by the way - very slow (RPI3B+)

So does this mean you are supplying a H264 stream to the config that is meant for a mjpeg format stream? if so that would explain your issues. If your camera does not do mjpeg, then leave that feild blank. It would be more helpful if you posted the CODE that shows how the thing is configured. Also no need to do user:pass@ in the urls the binding will handle the password correctly for you.

Same problem as Tobias…

Steps:

  1. Uninstalled the binding in PaperUI
  2. Stopped OH
  3. Placed org.openhab.binding.ipcamera-2.5.10-SNAPSHOT.jar in the addon-folder
  4. Restarted OH

Result:
Binding was loaded / Camera-Thing works ok but still only 5 seconds recorded