IpCamera: New IP Camera Binding

Thanks for the answer.
log-filtering is already in place, i have setup a solution where i can change the logging on the fly via an openhab sitemap and respective rules.
I was more thinking about a solution to avoid events comming from the ipcamera (in my case an UPCAM camera) to openhab, may be a filter in CreatePullPointSubscription could be used. I am not an expert in ONVIF but this is what i found in the ONVIF documentation.



the new action call for creating a mp4 or gif file dont create a uniquie name for the file.
thats a problem, every new gif overrides the gif before.
is it possible to change it, or give it a uniquier name?

thx i found it.

now iam at another problem. the motion alarm channels dont trigger.
i had three channels, but no one trigger my motion.

Motion Alarm
Cell Motion Alarm
Line Crossing Alarm

i used the old binding on openhab2 and it works fine.

any ideas what i can do?


I went through this whole thread and documentation and got quite close to get my camera working, but now I finally got stuck. I used my Foscam FI9853EP V2 with openhab 2 just by adding the direct stream from the camera to a panel in HABpanel and it worked well. Setting up a new server for openhab 3 I would like to use the binding for more functionallity. I installed the binding, configured a new user in the camera, installed FFMPEG and finally get files in the FFMPEG Output directory like these:

-rw-rw-r-- 1 openhab openhab 494628 Jan 20 09:44 ipcamera18.ts
-rw-rw-r-- 1 openhab openhab 496884 Jan 20 09:44 ipcamera19.ts
-rw-rw-r-- 1 openhab openhab 495568 Jan 20 09:44 ipcamera20.ts
-rw-rw-r-- 1 openhab openhab 497636 Jan 20 09:44 ipcamera21.ts
-rw-rw-r-- 1 openhab openhab 495004 Jan 20 09:44 ipcamera22.ts
-rw-rw-r-- 1 openhab openhab 262144 Jan 20 09:44 ipcamera23.ts
-rw-rw-r-- 1 openhab openhab 493500 Jan 20 09:41 ipcamera318.ts
-rw-rw-r-- 1 openhab openhab 493876 Jan 20 09:41 ipcamera319.ts
-rw-rw-r-- 1 openhab openhab 494628 Jan 20 09:41 ipcamera320.ts
-rw-rw-r-- 1 openhab openhab 494064 Jan 20 09:41 ipcamera321.ts
-rw-rw-r-- 1 openhab openhab 494816 Jan 20 09:41 ipcamera322.ts
-rw-rw-r-- 1 openhab openhab 262144 Jan 20 09:41 ipcamera323.ts
-rw-rw-r-- 1 openhab openhab 498764 Jan 19 17:39 ipcamera430.ts
-rw-rw-r-- 1 openhab openhab 498012 Jan 19 17:40 ipcamera431.ts
-rw-rw-r-- 1 openhab openhab 499328 Jan 19 17:40 ipcamera432.ts
-rw-rw-r-- 1 openhab openhab 498764 Jan 19 17:40 ipcamera433.ts
-rw-rw-r-- 1 openhab openhab 497072 Jan 19 17:40 ipcamera434.ts
-rw-rw-r-- 1 openhab openhab 262144 Jan 19 17:40 ipcamera435.ts
-rw-rw-r-- 1 openhab openhab    202 Jan 20 09:44 ipcamera.m3u8

But the only thing I can use is the snapshot jpg. Starting the HLS Stream results in the following log entrys:

2021-01-20 15:57:42.419 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'EGWZfoscam_StartHLSStream' received command ON

2021-01-20 15:57:42.422 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'EGWZfoscam_StartHLSStream' predicted to become ON

2021-01-20 15:57:42.436 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'EGWZfoscam_StartHLSStream' changed from OFF to ON

==> /var/log/openhab/openhab.log <==

2021-01-20 15:57:45.191 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - Guessed Channel Layout for Input Stream #0.1 : mono

2021-01-20 15:57:45.207 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - [aac @ 0x14bea60] Too many bits 8832.000000 > 6144 per frame requested, clamping to max

2021-01-20 15:57:45.217 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - [rtsp @ 0x1381370] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)

2021-01-20 15:57:45.243 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - [hls @ 0x139c600] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly

2021-01-20 15:57:54.170 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - [hls @ 0x139c600] pkt->duration = 0, maybe the hls segment duration will not precise

2021-01-20 15:57:56.109 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] -     Last message repeated 49 times

2021-01-20 15:57:56.110 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - [hls @ 0x139c600] Cannot use rename on non file protocol, this may lead to races and temporary partial files

2021-01-20 15:57:56.187 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - [hls @ 0x139c600] pkt->duration = 0, maybe the hls segment duration will not precise

2021-01-20 15:57:56.502 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] -     Last message repeated 8 times

2021-01-20 15:57:56.503 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - [aac @ 0x14bea60] Queue input is backward in time

2021-01-20 15:57:56.548 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - [hls @ 0x139c600] pkt->duration = 0, maybe the hls segment duration will not precise

2021-01-20 15:58:49.931 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] -     Last message repeated 1335 times

2021-01-20 15:58:49.932 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - [aac @ 0x14bea60] Queue input is backward in time

2021-01-20 15:58:49.957 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - [hls @ 0x139c600] pkt->duration = 0, maybe the hls segment duration will not precise

2021-01-20 15:58:50.140 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] -     Last message repeated 5 times

2021-01-20 15:58:50.143 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - [hls @ 0x139c600] Non-monotonous DTS in output stream 0:1; previous: 5977958, current: 5977564; changing to 5977959. This may result in incorrect timestamps in the output file.

2021-01-20 15:58:50.211 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - [hls @ 0x139c600] pkt->duration = 0, maybe the hls segment duration will not precise

2021-01-20 15:59:18.717 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] -     Last message repeated 713 times

2021-01-20 15:59:18.718 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - [aac @ 0x14bea60] Queue input is backward in time

2021-01-20 15:59:18.753 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - [hls @ 0x139c600] pkt->duration = 0, maybe the hls segment duration will not precise

2021-01-20 15:59:18.959 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] -     Last message repeated 5 times

2021-01-20 15:59:18.960 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - [hls @ 0x139c600] Non-monotonous DTS in output stream 0:1; previous: 8570655, current: 8568810; changing to 8570656. This may result in incorrect timestamps in the output file.

2021-01-20 15:59:18.989 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - [hls @ 0x139c600] pkt->duration = 0, maybe the hls segment duration will not precise

The m3u8 file has always just some bytes and trying to open it via VLC blocks VLC because of continuous “jump backs”
Any idea?

I’m struggle with this binding under OH3 and a doorbird node. It took me a while before I understood that I had to use a normal user, and not the admin user of doorbird. :blush:

Log admin:

2021-01-27 14:41:12.681 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - Starting ffmpeg with this command now:-hide_banner -loglevel warning -rtsp_transport tcp -i rtsp://USER:PWD@ -strict -2 -f lavfi -i aevalsrc=0 -acodec aac -vcodec copy -hls_flags delete_segments -hls_time 2 -hls_list_size 4 /etc/openhab/html/62226/ipcamera.m3u8
2021-01-27 14:41:12.868 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - [rtsp @ 0x55c4accf58c0] method DESCRIBE failed: 401 Unauthorized
2021-01-27 14:41:12.868 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - rtsp://USER:PWD@ Server returned 401 Unauthorized (authorization failed)

Once I changed it to a ‘normal’ user, it started to work, and creating the m3u8 files.

2021-01-27 14:44:17.281 [DEBUG] [amera.internal.onvif.OnvifConnection] - GetStreamUri:rtsp://
2021-01-27 14:44:30.177 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - Starting ffmpeg with this command now:-hide_banner -loglevel warning -rtsp_transport tcp -i rtsp://USER:********@ -strict -2 -f lavfi -i aevalsrc=0 -acodec aac -vcodec copy -hls_flags delete_segments -hls_time 2 -hls_list_size 4 /etc/openhab/html/62226/ipcamera.m3u8
2021-01-27 14:44:33.502 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - [rtsp @ 0x5610d538f8c0] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)

ls -l /etc/openhab/html/62226/
total 228
-rw-r--r-- 1 openhab openhab   202 Jan 27 14:45 ipcamera.m3u8
-rw-r--r-- 1 openhab openhab 44744 Jan 27 14:45 ipcamera24.ts
-rw-r--r-- 1 openhab openhab 44180 Jan 27 14:45 ipcamera25.ts
-rw-r--r-- 1 openhab openhab 43616 Jan 27 14:45 ipcamera26.ts
-rw-r--r-- 1 openhab openhab 44556 Jan 27 14:45 ipcamera27.ts
-rw-r--r-- 1 openhab openhab 45308 Jan 27 14:45 ipcamera28.ts

But I’m getting a lot of errors that are saying that I’m not authorized?

==> log/openhab.log <==
2021-01-27 14:47:58.074 [TRACE] [era.internal.handler.IpCameraHandler] - Sending camera: GET:
2021-01-27 14:47:58.079 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <title>401 Unauthorized</title>
  <h1>401 Unauthorized</h1>
2021-01-27 14:47:58.079 [TRACE] [era.internal.handler.IpCameraHandler] - Sending camera: GET:
2021-01-27 14:47:58.094 [DEBUG] [ipcamera.internal.MyNettyAuthHandler] - Camera at IP: gave a reply with a response code of :404
2021-01-27 14:47:58.095 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:<HTML><HEAD><TITLE>404 Not Found, The request path could not be found on the server.</TITLE></HEAD>
<BODY><H1>404 Not Found</H1>
The request path could not be found on the server.

Should I disable something, or is there something I need to do in the settings of the doorbird app?

ps I’ve noticed also that when I change the username/password, it stays somewhere in the memory. After restarting the binding, it uses the correct username.

Is that a requirement that should be added to the readme/docs? I dont have any Doorbird cameras and as most users are using the other binding for their brand I do not get any people giving feedback.

No idea other than the API was clear that you can not have multiple programs talking to the camera at the same time and only 1 stream open. The app will stop everything else from working so it needs to be closed. If you have the doorbird binding installed and the ipcamera binding then this may cause issues due to 1 connection only works at a time. The ipcamera binding will allow you to display the streams across multiple tablets at the same time as it can internally copy the stream.

That should not happen, I’ll have a look to see if that is a bug.

I would love to use your binding, because I want to push the image to some google chrome casts for showing the visit.

I’ve just did some additional tests:

  1. I created a seperate user on doorbird for this (so not used for anything else)
    Error remains…

  2. I’ve stopped all other tools that were linked with the doorbird node (=openhab doorbird binding, zoneminder server, openhab network binding).
    Errors remains…

  3. When I enter the url direclty in a browser, I’m getting a authentication popup. After entering the normal user/pwd of doorbird, it shows me nicely the picture.

Maybe the way of sending login credentials is differently? I’ve tested it, and for my doorbird (d101s), it works with:".

Its not just per user, but I believe it is camera wide. You can only have 1 connection in total regardless of the user. Disclaimer I could be wrong as I dont work for them and it could be outdated info, you need to test.

Great that means the camera supports either basic or digest methods which the binding supports both of these automatically. The other way you outline is not very good if your internal network ever gets compromised but you always have the option of using that URL in sitemaps and widgets.

Interesting that even FFmpeg is having issues which this is another clue as this is independant of the binding. Can you try creating a very basic password with no special characters or symbols or non ACSI in it? Does it work with a simple english password?

Also don’t worry if you see 401 messages as they can be normal when the camera uses DIGEST method, what matters is if the binding works when you ask for the ipcamera.jpg and other methods.

Lastly it is worth rebooting the camera as well as openhab in case the camera has locked out the openhab IP from having the wrong user / pass combo.

Sadly you can give them yourself, it’s the app who generates them.
But they aren’t that complex (fe fiKazptKJ).

Tried this, but no luck. Errors remain.

I'm getting a lot few errors when I add following link to the Snapshot url:

Just this one seems to remain:

2021-01-28 13:15:21.651 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is        :--ioboundary
Content-Type: text/plain


Content-Type: text/plain



That last message is not an error, it is the alarm stream from the camera and how the binding detects if the bell is pressed or if there is motion.

It sounds like there may be a compatibility issue that needs looking into in more depth and hopefully you are willing to help get it sorted?

Since ffmpeg is also flagging issues I think it would be worth checking for a firmware update for the camera in case it was known and a fix is available.

Whilst the work around seems to be helping, it would be better to use a more secure method of handling the password.

Let me know how I can help.
ps I’ve got also access to a Doorbird D21DKV. These are bigger models, but guess they should act the same… My model (tested here) is a Doorbird D101S

Just validate, and it’s running the latest firmware (000128).

Can I do anything to change this?

If you have Linux, enter this command into the terminal and post the output…

curl -sSL -D - -o /dev/null

This will tell me what the camera is saying it supports for authentication and then I can compare what the binding is doing with that info. This is what pops up the prompt for a user/pass in a browser.

The return:

HTTP/1.1 401 Unauthorized
WWW-Authenticate: Digest realm=“DoorBird Station”, charset=“UTF-8”, algorithm=MD5, nonce=“6013ddac:4617e971d126d71ed35de535a0c62d65”, qop=“auth”
Content-Type: text/html
Content-Length: 347
Date: Fri, 29 Jan 2021 10:04:28 GMT
Server: lighttpd

OK my guess is the missing “opaque” is causing the issue. I can create a build for you to try in a few days when I get some spare time as I have another request of github to look at… Line 129 in the file MyNettyAuthHandler needs adjusting. I wont know for sure until we try it.

Digest access authentication - Wikipedia

1 Like

One question:
Is it possible to add the channel “SetPreset”? (like: “GotoPreset”)? This would be very nice, because the channel is necessary for changing settings.

I have exactly the same camera, continuous movements are working, but absolute PTZ is not working.
I get the following error message:

2021-01-31 11:47:32.638 [TRACE] [amera.internal.onvif.OnvifConnection] - Sending ONVIF request:AbsoluteMove
2021-01-31 11:47:32.655 [TRACE] [amera.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:Code><SOAP-ENV:Value>SOAP-ENV:Sender</SOAP-ENV:Value><SOAP-ENV:Subcode><SOAP-ENV:Value>ter:InvalidPosition</SOAP-ENV:Value><SOAP-ENV:Subcode></SOAP-ENV:Subcode></SOAP-ENV:Subcode></SOAP-ENV:Code><SOAP-ENV:Reason><SOAP-ENV:Text xml:lang="en">Invalid Position</SOAP-ENV:Text></SOAP-ENV:Reason><SOAP-ENV:Node>http://www.w3.org/2003/05/soap-envelope/node/ultimateReceiver</SOAP-ENV:Node><SOAP-ENV:Role>http://www.w3.org/2003/05/soap-envelope/node/ultimateReceiver</SOAP-ENV:Role><SOAP-ENV:Detail>The requested position is out of bounds or not exist.</SOAP-ENV:Detail></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>

@matt1 Have you implemented @Lukas_1st fix for this issue? I’m currently using openHAB 3.0.1. Or maybe have you another idea why this does not work?


I have a problem that already occurred with openhab version 2 and now that I have upgraded to version 3, the problem persists.
My system is based on openhabian mounted on an RPI 4, and as video surveillance I have 6 cameras connected to a Dahua NVR.
I have installed Ipcamera binding and ffmpeg. Correctly configured the binding via ex paperui, I cannot correctly view the url on the web.
I am attaching a photo of the screenshot of my pc with the image captured correctly

and screenshot with videostream not working

Can someone help me?

It is pretty common for cameras to not support all of the methods, for this reason you should test the camera with ‘Onvif device manager’ software to see if it works with that program. Presets are another way to move the camera to a repeatable location and are easier to use, and for this you need to set them up and test with the same program.
The binding has that fix in it and if it was not you would not get continuous movements working without it.

It is possible and anyone is welcome to do a PR for that. I do not wish to do it myself due to not needing the feature and I don’t see the benefits for the effort when it can simply be done in another program.