IpCamera: New IP Camera Binding

When it stops working, does it still work if you use the URL in a web browser? The binding does not change the URL unless the thing is rebooted like you pausing or changing a setting, so this is puzzling and makes me think it may be persistence is loading the value. The string in that item means nothing so it may still work if you use the URL that it used to hold. Make sure you look at the trace level logs when this has occurred.

Edit: perhaps this occurs after the camera reboots or has gone offline?

Thanks for the reply no if I leave it long enough (how long that is I haven’t measured) all cameras go to this state and the cameras don’t go offline as far as I know
Do you means the mpegurl or the camera URL?

I just migrated to OH3 and wanted to include my cameras again.
Did something significant change fron 2.5.x to 3.0 on this binding?
Because my Preset call of the PTZ which used to work on 2.5 is not working anymore.

EDIT:
I found the root cause.
On 2.5 the PTZ preset item was a Number and working fine.
On 3.0 it’s only working if the preset item is a String.

@matt1 I could report that RLC-410W is also working as ONVIF device. Same procedure: enable UPNP in the camera settings, reboot cam, discover with OH, set ONIF port to 8000 in the thing config (why is that not discovered automatically?)

I see 2 messages in the log, which might be an indicator for adjustments

  • Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)
  • Timestamps are unset in a packet for stream 0.
2021-03-07 08:23:38.519 [vent.ItemStateChangedEvent] - BackCam1Sauna_StartStreamHLSM3u8 changed from OFF to ON. Use/pw has been verified.

==> /var/log/openhab2/openhab.log <==
2021-03-07 08:23:38.525 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - Starting ffmpeg with this command now:-hide_banner -loglevel warning -rtsp_transport tcp -i rtsp://xxx:xxxx@192.168.6.179: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 /etc/openhab2/html/camera1ipcamera.m3u8
2021-03-07 08:23:43.529 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - [rtsp @ 0x1f3f370] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)
2021-03-07 08:23:43.541 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - [hls @ 0x1f5ef20] 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-03-07 08:23:43.546 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - [hls @ 0x1f5ef20] pkt->duration = 0, maybe the hls segment duration will not precise
2021-03-07 08:23:43.576 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] -     Last message repeated 19 times
2021-03-07 08:23:43.578 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - [hls @ 0x1f5ef20] Cannot use rename on non file protocol, this may lead to races and temporary partial files
2021-03-07 08:23:43.586 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - [hls @ 0x1f5ef20] pkt->duration = 0, maybe the hls segment duration will not precise
...
2021-03-07 08:24:33.417 [DEBUG] [pcamera.internal.StreamServerHandler] - Stream Server recieved request 	GET:/ipcamera.m3u8
2021-03-07 08:24:33.420 [INFO ] [pcamera.internal.StreamServerHandler] - IpCameras file server could not find the requested file. This may happen if ffmpeg is still creating the file.
...
2021-03-07 08:24:50.138 [vent.ItemStateChangedEvent] - BackCam1SaunaImage changed from raw type (image/jpeg): 332124 bytes to raw type (image/jpeg): 332458 bytes

Anything to fine tune?

How to get the timestamp for the last alarm / motion events?

OH is 2.5.12 with latest ipcamera build from Jenkins, freshly installed ffmpeg

Settings:

The special URLs for each camera are a very cool thing.
But they do not work via the openHAB cloud. AFAIK all URLs must be relative (meaning also the same port as the main UI) for this to work.
The questions is: Could those special URLs be changed, so that they are relative? I think that bindings can react to relative URLs, for example the HomeConnect binding does.
Maybe something like /ipcamera/01/snapshots.mjpeg.

The Video element used in a sitemap can pass through the myopenhab cloud so it is possible. If you’re going to do this for extended periods, increasing the load on the cloud, please consider donating to the foundation here
Join | openHAB Foundation

example

Video url="http://192.168.3.2:54321/autofps.mjpeg" encoding="mjpeg"

Other better ways can be a reverse proxy or a VPN like wireguard which remove the need to even use the cloud.

I have not used a binding that does and hence I am not aware it is possible to both send data to and fetch from a binding. The only answer I can give is that it is not possible to serve on the same port without massive changes to the binding… It is a complex topic which I don’t want to go into due to no time, but the best way is to send data directly from a camera to your viewing device and NOT through the OH server so really the openHAB framework should be written to handle for doing that and this binding fits into a niche for those that find the ‘best way’ does not work perhaps because the binding gives mjpeg when the camera itself does not.

Thanks for the hint. I forgot that sitemaps can do that.
But, in the end, the Main UI is the future and I want to use that also on mobile. But I guess, Main UI cannot proxy URLs, yet.

It should be, if you do a TRACE log when it is discovered it should give more info. The xAddress is what you need to find.

Google any of the lines from FFmpeg and you will find plenty of info from people with more of a clue then me.

There is a channel called last motion and you can create a rule to create a timestamp when ever this channel changes state.

What is the procedure to upload newest snaphot of the binding in OH3?

In OH2 I was uploading all jars to /usr/share/openhab2/addons.
But I am not sure if it is still actual in OH3 since this is built-in (native) addon now.

Are you having issues? Best not to change things unless there is a reason to. A new milestone release is made usually 4 weeks apart so just update to the latest milestone build. You can get Jenkins builds and place it into your addons folder which is probably now /usr/share/openhab/addons note the 2 is removed from now on.

No, I don’t have any issues. Just wanted to try new features regarding foscam cameras in lastest version (“OpenHAB 3.1M2 got a fix that helped foscam to get auto detected correctly”)
If it will be in next stable release so I can wait then.

I have added my 4 Hikvision DS-2CD2346G2-ISU/SL cameras and it looks like it is working ok, I haven´t done that much in Openhab yet. But I am turning some lights on based on motion detection etc. I will start adding it to a panel as the next step.

But I have a question as well, in the bindings I can see that there is a Human Alarm channel, but after I have added the cameras using the GUI that channel is not listed. The cameras has both human and car detection. I have tested to add the cameras as Hikvision and as ONVIF but none of the camera things have human or car alarm in the list.

Is there anything specific you would like me to test?

Grab the build from 2 days ago from this link

Index of /openhab/IpCameraBinding/ (pcmus.com)

This has some changes in it for Hikvision which are currently getting reviewed to be merged. This build will put this into the DEBUG level log output…

Unrecognised Hikvision eventType=xxxxxxx

This will be for any alarms and events that are not added to the binding yet.

In TRACE level you will also see the actual reply back from the camera.

The command to change the log level is in the bindings documentation under how to get help.

@kristofejro this build has the changes in it that you are after if you don’t want to change your core to the milestones.

Ok, I will do that, I just need to figure out how to add the binding manually, can you point me to any instructions on how to do that please?

do not edit any cfg files, just drop unzipped files into the addons folder. The docs also cover logging and also using the console, if anything in there is not correct or confusing then please ask and then raise any needed changes on github for the next person that uses them.

Added the new build that you liked to and it seems to be running, what log will it use for the Unrecognised Hikvision event? I want to debug the correct log…

I started DEBUG logging for org.openhab.binding.ipcamera and so far all I have seen is an 401 error:

09:54:39.435 [DEBUG] [ng.ipcamera.internal.HikvisionHandler] - Unhandled reply-

Document Error: Unauthorized

Access Error: 401 -- Unauthorized

Authentication Error

I guess that´s the digest 401 message?

Your looking at the right log. It seems some hikvision models do not provide a separate smart event alert, whilst others do. See second post here

Thanks for your reply Matt, you are doing all kind of support it seems, sorry about that… I just assumed that the camera would generate a specific human detection event but apparently not. That´s ok for me though, I´m happy as long as it uses the algorithm to lessen the amount of false alerts. It actually works very well, I have only had a couple of false alarms so far, but after lowering the sensitivity those went away as well.

But thanks for clearing this up, then I don´t need to look for a human alert and can use the motion detection instead!

Hi … I am having the same problem to get my Yoosee running … reached the point of “An error occured trying to process the messages from FFmpeg.” how did you make it run finally …
Any help appreciated …

Hi, I am continuing to have unreliable events generated with my Hikvision cameras under OH3 (OH2.5.9 was fine). The XML appears in the logs, but events are not allways created. Noting Rich Koshak’s recent debug suggestion about using the GUI for config (I have used config files previously), I stood up a brand new 3.0.1 on a Windows PC with only the IPCamera binding, and configured 3 cameras - all the same models running all the same firmware. The one thing I noticed is that for the alarm that worked, the log shows “<EventNotificationAlert” on its own line. All others in the log are like the one that failed to generate. At the moment, despite reboots and camera resets, I am getting no events. Camera details:
DS-2CD2646G1-IZS Firmware V5.6.0 build 190507 Encoding V7.3 build 190423 Web Version V4.0.1 build 190506 Plugin Version V3.0.7.16

Words of wisdom welcome!

Here is the complete event log and and logs for an event that is generated, and one that is not.

2021-03-25 08:56:00.034 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'ipcamera:hikvision:1921681133' changed from INITIALIZING to ONLINE
2021-03-25 09:19:52.330 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'hikvisioncamera1921681131_MotionAlarm' changed from NULL to OFF
2021-03-25 09:21:54.014 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'hikvisioncamera1921681132_MotionAlarm' changed from NULL to OFF
2021-03-25 09:23:58.398 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'hikvisioncamera1921681133_MotionAlarm' changed from NULL to OFF
2021-03-25 09:28:40.153 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'hikvisioncamera1921681132_LineCrossingAlarm' changed from NULL to ON
2021-03-25 09:28:49.713 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'hikvisioncamera1921681132_LineCrossingAlarm' changed from ON to OFF
2021-03-25 09:39:30.408 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'hikvisioncamera1921681131_LineCrossingAlarm' changed from NULL to ON
2021-03-25 09:39:42.478 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'hikvisioncamera1921681131_LineCrossingAlarm' changed from ON to OFF
2021-03-25 13:13:43.451 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'hikvisioncamera1921681131_LineCrossingAlarm' changed from OFF to ON
2021-03-25 13:13:53.376 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'hikvisioncamera1921681131_LineCrossingAlarm' changed from ON to OFF

Event generated:


2021-03-25 13:13:42.500 [TRACE] [era.internal.handler.IpCameraHandler] - Sending camera: GET: http://192.168.1.132:80/ISAPI/Streaming/channels/101/picture
2021-03-25 13:13:42.500 [TRACE] [era.internal.handler.IpCameraHandler] - Sending camera: GET: http://192.168.1.132:80/ISAPI/System/IO/inputs/1/status
2021-03-25 13:13:42.632 [TRACE] [g.ipcamera.internal.HikvisionHandler] - HTTP Result back from camera is 	:<?xml version="1.0" encoding="UTF-8"?>
<IOPortStatus version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<ioPortID>1</ioPortID>
<ioPortType>input</ioPortType>
<ioState>inactive</ioState>
</IOPortStatus>
:
2021-03-25 13:13:43.410 [TRACE] [g.ipcamera.internal.HikvisionHandler] - HTTP Result back from camera is 	:--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 1248

<EventNotificationAlert version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<ipAddress>192.168.1.131</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>bc:ba:c2:e3:db:fe</macAddress>
<channelID>1</channelID>
<dateTime>2021-03-25T13:13:42+00:00</dateTime>
<activePostCount>32</activePostCount>
<eventType>linedetection</eventType>
<eventState>active</eventState>
<eventDescription>linedetection alarm</eventDescription>
<DetectionRegionList>
<DetectionRegionEntry>
<regionID>1</regionID>
<sensitivityLevel>50</sensitivityLevel>
<RegionCoordinatesList>
<RegionCoordinates>
<positionX>602</positionX>
<positionY>380</positionY>
</RegionCoordinates>
<RegionCoordinates>
<positionX>425</positionX>
<positionY>337</positionY>
</RegionCoordinates>
</RegionCoordinatesList>
</DetectionRegionEntry>
</DetectionRegionList>
<channelName></channelName>
<Extensions version="1.0" xmlns="urn:psi:
2021-03-25 13:13:43.416 [TRACE] [g.ipcamera.internal.HikvisionHandler] - HTTP Result back from camera is 	:alliance-org">
<serialNumber xmlns="urn:selfextension:psiaext-ver10-xsd">DS-2CD2646G1-IZS20190911AAWRD60961158</serialNumber>
<eventPush xmlns="urn:selfextension:psiaext-ver10-xsd">DS-2CD2646G1-IZS20190911AAWRD60961158,2021-03-25T13:13:42+00:00,0,1.0</eventPush>
</Extensions>
</EventNotificationAlert>
:
2021-03-25 13:13:43.418 [DEBUG] [g.ipcamera.internal.HikvisionHandler] - Unhandled reply-alliance-org">
<serialNumber xmlns="urn:selfextension:psiaext-ver10-xsd">DS-2CD2646G1-IZS20190911AAWRD60961158</serialNumber>
<eventPush xmlns="urn:selfextension:psiaext-ver10-xsd">DS-2CD2646G1-IZS20190911AAWRD60961158,2021-03-25T13:13:42+00:00,0,1.0</eventPush>
</Extensions>
</EventNotificationAlert>
.
2021-03-25 13:13:48.078 [TRACE] [era.internal.handler.IpCameraHandler] - Sending camera: GET: http://192.168.1.131:80/ISAPI/System/IO/inputs/1/status
2021-03-25 13:13:48.078 [TRACE] [era.internal.handler.IpCameraHandler] - Sending camera: GET: http://192.168.1.131:80/ISAPI/Streaming/channels/101/picture

No event generated:

2021-03-25 12:53:47.254 [TRACE] [g.ipcamera.internal.HikvisionHandler] - HTTP Result back from camera is 	:--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 1248

:
2021-03-25 12:53:47.255 [TRACE] [g.ipcamera.internal.HikvisionHandler] - HTTP Result back from camera is 	:<EventNotificationAlert version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<ipAddress>192.168.1.131</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>bc:ba:c2:e3:db:fe</macAddress>
<channelID>1</channelID>
<dateTime>2021-03-25T12:53:46+00:00</dateTime>
<activePostCount>25</activePostCount>
<eventType>linedetection</eventType>
<eventState>active</eventState>
<eventDescription>linedetection alarm</eventDescription>
<DetectionRegionList>
<DetectionRegionEntry>
<regionID>1</regionID>
<sensitivityLevel>50</sensitivityLevel>
<RegionCoordinatesList>
<RegionCoordinates>
<positionX>602</positionX>
<positionY>380</positionY>
</RegionCoordinates>
<RegionCoordinates>
<positionX>425</positionX>
<positionY>337</positionY>
</RegionCoordinates>
</RegionCoordinatesList>
</DetectionRegionEntry>
</DetectionRegionList>
<channelName></channelName>
<Extensions version="1.0" xmlns="urn:psialliance-org">
<serialNumber xmlns="urn:selfextension:psiaext-ver10-xsd">DS-2CD2646G1-IZS20190911AAWRD60961158</serialNumber>
<eventPush xmlns="urn:selfextension:psiaext-ver10-xsd">DS-2CD2646G1-IZS20190911AAWRD60961158,2021-03-25T12:53:46+00:00,0,1.0</eventPush>
</Extensions>
</EventNotificationAlert>
:
2021-03-25 12:53:49.087 [TRACE] [g.ipcamera.internal.HikvisionHandler] - HTTP Result back from camera is 	:--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 1448