Hik Camera Node

We have a HIK IP Camera at work, and I have found 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

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 they start listening to an event stream:

    var header = 'GET /ISAPI/Event/notification/alertStream HTTP/1.1\r\n' +
     		'Host: ' + options.host + ':' + options.port + '\r\n' +
     		authHeader + '\r\n' +
     		'Accept: multipart/x-mixed-replace\r\n\r\n';
    

    So in fact you do a single http request to your camera, to let it know that you want to want to be informed about any event. From then on it will (endless?) keep on sending you events as soon as they happen. This is called a multipart stream (i.e. single request but endless response parts). This is much better than polling, where you have to send a request every N seconds to your camera to ask whether an event has happened during the last N seconds ... Because you avoid useles requests (when nothing has happened meanwhile) and you now immediately when an event has happened (instead of N seconds afterwards)...

  • Here 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:

    • code
    • action
    • index
    • time (timestamp of current moment in time)

Remarks:

  1. As you can see in this issue 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 they send a http request to your camera to ask for a snapshot image:

 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

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

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

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.

1 Like