# Hik Camera Node

**URL:** <https://discourse.nodered.org/t/hik-camera-node/15989>\
**Category:** General\
**Created:** [27 September 2019 10:38 UTC](https://discourse.nodered.org/t/hik-camera-node/15989 "2019-09-27T10:38:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ChrisO](https://avatars.discourse-cdn.com/v4/letter/c/dec6dc/32.png) [@ChrisO](https://discourse.nodered.org/u/ChrisO)\
**Post date:** [27 September 2019 10:38 UTC](https://discourse.nodered.org/t/hik-camera-node/15989/1 "2019-09-27T10:38:29Z")

</div>

We have a HIK IP Camera at work, and I have found [https://flows.nodered.org/node/node-red-contrib-hikcamera](https://flows.nodered.org/node/node-red-contrib-hikcamera).  
But there isn't a great deal of info with it.  
Would anyone have any examples of how to use it.  
I have supplied it with the IP address of our camera, and it's floating between connected and disconnected.  
The debug is showing an empty string in the hikcamera alarm node.

Thank you

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [27 September 2019 11:04 UTC](https://discourse.nodered.org/t/hik-camera-node/15989/2 "2019-09-27T11:04:31Z")

</div>

Hey Chris,

I haven't used this node myself, but by having a quick look at the code it seems to work like below.  
There are two nodes available:

## HikcameraAlarmInNode

- [Here](https://github.com/dbowerman/node-red-contrib-hikcamera/blob/master/hikvision-api.js#L29) they start listening to an event stream:

- [Here](https://github.com/dbowerman/node-red-contrib-hikcamera/blob/master/hikcamera.js#L101) you can see that - as soon as an event has been received - an output message will be generated, containing following fields in the `msg.payload`:

Remarks:

1. As you can see in this [issue](https://github.com/bartbutenaers/node-red-contrib-multipart-stream-decoder/issues/6) some users use my node-red-contrib-multipart-stream-decoder node to receive such an event stream from their Hikvision camera. For some it works, for others not. I haven't had time yet to investigate this...
2. The users in the previous issue also had to add extra logic in their flows to restart the stream. Suppose the stream stops (for whatever reason), you will have to restart it ...
3. Could it be that you don't receive any events, because there aren't any? Or perhaps you haven't setup any events? Haven't used it myself, but I can image that you explicit have to configure your camera to send event (e.g. when motion is detected, when the embedded pir sensor detects heat movement, ....).

## HikcameraImageInNode

[Here](https://github.com/dbowerman/node-red-contrib-hikcamera/blob/master/hikcamera.js#L146) they send a http request to your camera to ask for a snapshot image:

```auto
 this.http_options = {
            host: this.hikcamera.options.host,
            port: this.hikcamera.options.port,
            path: '/Streaming/Channels/101/Picture',
            headers: {
                'Authorization': "Basic " + new Buffer(this.hikcamera.options.user + ":" + this.hikcamera.options.pass).toString('base64')
            }
};

```

As soon as all data chunks of the image has arrived, you will get the snapshot image in the `msg.payload` as a Buffer.

I think that is what it does ...  
Bart

---

<div class="post-metadata">

**Author:** ![ChrisO](https://avatars.discourse-cdn.com/v4/letter/c/dec6dc/32.png) [@ChrisO](https://discourse.nodered.org/u/ChrisO)\
**Post date:** [27 September 2019 11:31 UTC](https://discourse.nodered.org/t/hik-camera-node/15989/3 "2019-09-27T11:31:47Z")

</div>

Thank You  
That looks quite involved.  
For the HikCameraAlarm Node  
Point 3 in your remarks is definitely a small issue. The camera is pointed at the wall most of the time.  
Limited data from the camera, so would explain the empty payload for the majority of the time.

For the HikCameraImage Node, it looks like they ,may, have hardcoded the path to retrieve the any images '/Streaming/Channels/101/Picture'

doesn't match the path that our camera provides at all.  
I'll have a look at changing that see if anything changes

Thanks for the response

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [27 September 2019 12:32 UTC](https://discourse.nodered.org/t/hik-camera-node/15989/4 "2019-09-27T12:32:03Z")

</div>

> [@ChrisO](#):
>
> Limited data from the camera, so would explain the empty payload for the majority of the time.

Are those empty messages at regular intervals? Perhaps the camera sends an empty event periodically to keep the stream alive?

---

<div class="post-metadata">

**Author:** ![ChrisO](https://avatars.discourse-cdn.com/v4/letter/c/dec6dc/32.png) [@ChrisO](https://discourse.nodered.org/u/ChrisO)\
**Post date:** [27 September 2019 12:46 UTC](https://discourse.nodered.org/t/hik-camera-node/15989/5 "2019-09-27T12:46:31Z")

</div>

They're approx every 75s, so seems feasible, that there's a keep alive process ongoing  
Shows disconnected for a few seconds after we get one of these messages too.
