IpCamera: New IP Camera Binding

The binding should work with both however if it has been using DIGEST the binding may refuse to switch to BASIC and this is a security feature as a common hacking technique is to use whats called a ''Downgrade attack". Possible you need to do a restart after having switched the camera to BASIC from DIGEST.

If you want this looked at in case it is a compatiblity issue, please start your own thread or PM me with some TRACE log output, I just need to see what the HTTP headers are for your camera and some lines to see how the binding is handling the headers.

I introduced some breaking changes, see here as one would have caused you problems. Also clean out tmp and cache.

Hi,

I tried to install the binding, and everything seems to be OK. But I cannot have the stream working…
Have a Hikvision camera (DS-2CD2085FWD-I)

I have a manual things file:


Thing ipcamera:HIKVISION:002 [IPADDRESS="192.168.1.45", PASSWORD="XXX", USERNAME="xxx", SERVER_PORT=1021, IP_WHITELIST="(192.168.1.2)(192.168.1.45)(192.168.1.71)(192.168.1.28)", IMAGE_UPDATE_EVENTS=0, POLL_CAMERA_MS=2000]

Log:

2019-03-23 22:55:16.984 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'IP_camera.things'
2019-03-23 22:55:17.101 [me.event.ThingUpdatedEvent] - Thing 'ipcamera:HIKVISION:002' has been updated.

2019-03-23 22:55:24.513 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - The 'ONVIF media profile 1' is using mjpeg and will allow you to use the new streaming features if reachable with HTTP.

2019-03-23 22:55:31.581 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - IP Camera at 192.168.1.45:80 is now online.

2019-03-23 22:55:31.593 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - IpCamera stream server has started on port:1021.

2019-03-23 22:55:33.581 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - The alarm checking stream was not running. Cleaning channels and then going to re-start it now.

In the sitemap:

Text label="XXX" icon="camera" {Video url="http://192.168.1.45:1021/ipcamera.mjpeg" encoding="mjpeg"}

Also when I’m trying to reach it from browser, nothing happens.

Any idea what the problem could be?

Br,
Levente

Everything looks right. When you try and open the stream watch the log in debug mode (see readme file for how to do this) also when the server starts look at the log. Does your openhab machine have more than 1 network card? It may be serving on the wrong network card if u have multiples.

Hi Matt,

Thank you for the answer. Now I see the problem. On the sitemap, the IP address belongs to the camera not to the server (which is an RPi). Now it works partially. I can see the the stream through browser, in Classic UI, but not in the OpenHAB app (iPhone/iOS). Any idea about this?

I tried the webview option: I have an image (not optimized for the mobile), and the app freezes, I need to close it manually.

Thanks, Levente

Yes that is what I found, the iOS app has issues. Image for snapshots does not work, video items do not work and webview shows a picture and then crashes. Android app works great.

Conclusion is the iOS app needs some work. Use habpanel or basic/classic ui in a browser and it works.

Not sure I follow your statement about using ip of camera in the sitemap, you use the link the binding gives in the streaming URL channel. If you think the readme needs changing to make something clearer just let me know.

Sad to hear it :disappointed_relieved:
I haven’t planned to change my mobile :smiley: May be I need to be patient and sometime it’ll work… (or not :frowning: )
I have another issue with it, as some of the icons sometimes are not shown but there is no regurality… I’ve been waiting to be solved this for about a year, but nothing happened :frowning:

The readme is OK, doesn’t need to be changed. I was too tired and careless yesterday.

Thanks for your quick answers, and you did a brilliant work with this binding. I will keep checking the updates :sunglasses:

Br,
Levente

Hi @matt1 ,
I am testing an Amcrest dvr And I’d love to get this all working, so far I’m able to get 1 camera connected and so far all the channels I have tested work, except… When I add a second camera from the same dvr all of the channels seem to return data from only the first camera connected to the dvr (Image,motion alarm,etc).
I have tried adding it as both an Amcrest and as a DAHUA within the paper ui (I read in the readme I should try that) with the same results.

the dvr in question is Amcrest AMDVTENL8-H5 I’m not really sure what I should try next

I have never had someone with a NVR contact me, so the binding will not do anything different until I have some urls confirmed…
Snapshot does this give you the snapshot from the second channel?
http://ipaddress/cgi-bin/snapshot.cgi?channel=2
You can use the snapshot url override feature to manually enter this in for each camera.

I will also need an example of the alarm stream and what comes up in a browser for this URL?

http://ipaddress/cgi-bin/eventManager.cgi?action=attach&codes=[All]

Some example output when you have movement alarms going off for channels other than 1.

The Amcrest API document is linked in the readme so you can read and look at the examples and test what works for you in any browser.

G’day @matt1, I’m currently using “ipcamera2019-03-19.zip” and it wouldn’t work without adding user/pswd info to the “SNAPSHOT_URL_OVERIDE” parameter. Wondering if this is now the default behaviour? And why doesn’t it use the values in the “USERNAME” and " PASSWORD" parameters?

this is the old (commented) version and new (working) version:

//Thing ipcamera:ONVIF:ipcam1 "IP Camera 1" @ "Cameras" [ USERNAME="user", PASSWORD="pswd", POLL_CAMERA_MS=1000, IPADDRESS="192.168.0.100", SNAPSHOT_URL_OVERIDE="http://192.168.0.100/tmpfs/auto.jpg", PORT=80, ONVIF_PORT=8080 ]
Thing ipcamera:ONVIF:ipcam1 "IP Camera 1" @ "Cameras" [ USERNAME="user", PASSWORD="pswd", POLL_CAMERA_MS=1000, IPADDRESS="192.168.0.100", SNAPSHOT_URL_OVERIDE="http://user:pswd@192.168.0.100/tmpfs/auto.jpg", PORT=80, ONVIF_PORT=8080 ]

Any info greatly appreciated.

See braking changes in a previous post
SNAPSHOT_URL_OVERIDE Is now
SNAPSHOT_URL_OVERRIDE

I did read that, but missed this difference.

Still it’s odd that the old version with the single ‘R’ still works if you supply the user/pswd to the URL.

That will be the onvif finding the URL for you as you do not need to supply the URL if onvif works on your camera. My guess is a reboot and onvif made it work.

1 Like

Hello @matt1 I just wanted to say thank you for this binding. I played a few days with it and my foscam camera and it works well. You work is very much appreciated

1 Like

I got it working but it in chrome there is a pop up for user and password which comes as soon as I refresh the page. How can I get rid of this.

This is the entry in my Sitemap:

Video url=“http://XXX:XXX@192.168.188.77/cgi-bin/mjpg/video.cgi?subtype=1” encoding=“mjpeg”

That sitemap you posted shows you are not using the binding but are trying to get the camera to send directly. For cameras like foscam that place the user and pass into the URL query string it works, but for other cameras it will not work. The issue is most if not all browsers are discontinuing the embedded user and pass that you are trying to do. This is because of security concerns and the standards specify it should not be done hence why browsers are removing support for something that used to work.

See the readme file for this binding as it guides you through what to do. You will need to remove the xxx:xxx@ from your URL with the binding.

Hi Matt

I have set the ONVIF encoder profile to 1, which should be the DAHUA substream profile.

CPU is very very high though, with a Quad core Xeon. How can I verify its definitely using the substream profile? Cheers

My thing:

Thing ipcamera:DAHUA:FrontYard [IPADDRESS="192.168.0.249", PASSWORD="camuser2018", USERNAME="camuser", POLL_CAMERA_MS=2000, SERVER_PORT=54321, IP_WHITELIST="(192.168.0.10)(192.168.0.3)", IMAGE_UPDATE_EVENTS=0, ONVIF_MEDIA_PROFILE=1]

Further, lots of these errors:

[io.netty.channel.nio.NioEventLoop    ] - Selector.select() returned prematurely 512 times in a row; rebuilding Selector io.netty.channel.nio.SelectedSelectionKeySetSelector@52f424a3

It will be as this is the line that is hardcoded into the binding for Dahua. It would not work if it was not using a substream that is setup for mjpeg.

videoUri = "/cgi-bin/mjpg/video.cgi?channel=" + nvrChannel + "&subtype=" + selectedMediaProfile;

Ok that probably explains the high CPU usage, there is an open issue for a similar report at the Netty github and they are not able to reproduce it, but the error is the same as yours and reports of high CPU. I can not reproduce it as it has been working fine here for weeks but I have not tested with multiple cameras at the same time. You will need to strip it back to a single camera and try changing different things until you find the cause. There is a newer version of Netty that I can upgrade to next time I am building a jar to see if it fixes. Also try cleaning the cache and tmp folders and turning your server off and back on again.

HI Matt

Ok, then im using the right substream and its a netty issue thats causing the CPU.

Ill clear the folders and restart. Stopping the binding fixes the issue with CPU

Cool, ill look forward to your next binding update

Hi Matt
sorry another question. Does the frame rate in the ‘thing’ need to match the actual camera? I have the cameras defined at 25FPS, but I’m happy to have them set to 10 in the thing configuration.

Or, should both match?

Thanks

New build 2019-04-07 has these changes:

  • Doorbird API has now begun to be added, needs testing as probably got some stuff wrong.
  • Dahua/Amcrest changes for NVR pictures.
  • New Netty 4.1.34 is now used. I have noticed my CPU usage has dropped since making this change.

@dastrix80
Have no idea what you are asking, there is no video frame rate options in the thing definition.