Onvif camera control

Good afternoon

I know it was some work in progress from someone about this, managing a onvif camera...

Does someone did already some on managing PTZ etc...?

Thanks in advance

Hi David,

Indeed someone was last year working on it: https://github.com/bartbutenaers/node-red-contrib-onvif. But someone stopped since he had troubles with the underlying unvif library. However just before Christmas someone got finally response, so someone nows that the library is still maintained. Therefore someone has planned to continue with it soon :wink:

BTW someone already got the PTZ working: see example flow on the readme page above...

2 Likes

Thanks for the reply mate, if some day you have some working flow for PTZ and/or Zoom will be great if you can share.

Regards

Hey David,

I have lot's of other Node-RED stuff ongoing at the moment, but otherwise it would be a waste if I wouldn't publish all the things that I have already developed for Onvif. So if I can have some help here (for testing, discussions, ...), then I can try to have a look at it again this week. Would like to discuss whether my setup is correct, before i can continue my developments.

First of all, I need a NEW NAME for my contribution because meanwhile unfortunately somebody has already used the same name (see node-red-contrib-onvif). So all suggestions are welcome!

And if somebody should be wondering: NO I'm not going to drop my node and contribute to that other node. I have already spend to much time on mine, and moreover the other node is build on top of the node-onvif library.
I used in the beginning also that library, however that one cannot handle streaming events (see my issue here). And I want in the future to be able to have a live stream from my camera events (e.g.event when the embedded PIR detector senses movement). So I'm not going to revert back to that library ...

Bart

Some naming suggestions to get the discussion started:

  • node-red-contrib-onvif-nodes
  • node-red-contrib-onvif-suite
  • node-red-contrib-onvif-bundle
  • node-red-contrib-onvif-pack

I have choosen this kind of names, since my repository contains a series of multiple Onvif nodes: discovery, snapshot, events, ptz, media, ...

The PTZ example flow (in my readme file) worked fine for me at the time being. Only problem I had: my Pansonic cameras only support Panning and Tilting, but no Zoom. And the library (that I use underneath) expects that the camera supports all 3 options, otherwise it gets into problems. So I need to create a pull request to have that fixed...

Hello Boss

In my case I'm using motioneye which works really great, it has triggers that you can easily use to interact with node red via websocket for instance.

Actually what I do is that motion eye can handle all events, upload video or pictures to a specific folder or gdrive and publish the video to HTTP what makes It easy for me to integrate some how the video screen with a simple template.

Works really great, I'm my case I will be interested into be able to handle PTZ and zoom from nodered somehow but have no idea how to handle it.

from windows I have some app that I make it work already so means should be some easy way to implement it as onvif is an standard and as per my test it works.

If you have something on this direction and you can share privately I will appreciate, as you can imagine mine is for personal use, this is just a hobby I'm not working on nothing related and nothing to do with creation of other nodes... this is too far away for me... hahahah.

Regards

David,

I think you can do it in two ways:

  1. Control you cameras from an external tool (e.g. MotionEye) and connect MotionEye to Node-RED. So in fact than you can send triggers like this: Node-RED --> MotionEye --> Camera. If that is what you mean, then someone else will have to assist you. This kind of setups is not really my cup of tea ...

  2. Control you cameras directly from Node-RED like this: Node-RED --> Camera. If that is what you want, then you could use my Onvif nodes (once they are ready!). As you can see in this example I can PTZ control the camera by pushing buttons (of the Inject) nodes from within the flow editor. But you could also add some buttons to your Node-RED dashboard, and link those dashboard buttons to my PTZ node (to control your camera from your dashboard).

Hello Bart

I'm actually using motioneye as makes all easier.

I would like to integrate PTZ controls on node red and tried to install the node you suggested me from https://github.com/bartbutenaers/node-red-contrib-onvif#ptz-node doing as indicated:
npm install node-red-contrib-onvif

However once installed and system restarted I can not see the expected nodes on the paled and instead I see only this one.

image

Any idea?

Thanks in advance

@davidcgu,

I mentioned above that somebody else has meanwhile used the same node name, and published his node on npm. So when you do npm install node-red-contrib-onvif you are in fact installing his node (which can only take snapshots).

We first need to choose a new name for my suite of onvif nodes, before I can publish an alfa version of my own nodes on NPM. I have listed some possible new names above, but nobody has responded yet ...

fk!!!!!!!!! change the name of your node asap mate!!!!!!! hahahahah

set onvif-control or something similar

While waitting you make it available I found some npm packages like https://hawkeye64.github.io/onvif-nvt/ however I don't know how to make use of it on node red, do you know any tutorial I can learn how to handle it?

Thanks in advance

on a good day you should be able to install directly from github... you have to do it manually

cd ~/.node-red
npm i bartbutenaers/node-red-contrib-onvif

But sadly that fails for me also.

I currently use this npm library. The one you are mentioning might indeed be a good alternative. But it will be easier that you just wait a couple of days until I have an alfa version available for you on NPM. It is quite a bit of work to integrate such a library in Node-RED. Believe me ... I will try to start with it in a couple of days, but first I have another Node-RED contribution that I want to finish first.

So if you can do some first tests next week, I think this could become a nice set of nodes for the community ...

I 'think' I have somewhere (at one of my Raspberries) a more recent version of my Onvif nodes. But it is some months ago already, so I have forgotten where I have stored it :thinking:

But now I'm going to experiment again with my image streams in FFmpeg ...

2 Likes

I used this one: node-onvif to write a simple nodejs program to scan for Onvif cameras and get their snapshot and rtsp URLs.

I just use these URLs in my python-openCV AI code with node-red doing the plumbing of start/stop, notifications, etc.

PTZ camera are generally out of my price range :slight_smile:

Unless node-red can open multiple rtsp streams and grab periodic snapshots I'm not sure what a node-red-onvif brings to the party. Onvif is really useful for automatically getting the URLs but once I some how find the URLs, my Python can use either jpeg snapshots or frame grabs from rtsp streams.

My latest code is doing about 30 fps using 10 1920x1080 rtsp streams (approx 3 fps per camera) from my Lorex security DVR on my i7 desktop while I'm doing this and a bunch of other stuff on it. -- was a nightmare to find the URLs, they only "support" a lame activeX control in Internet Exploder, and their excuse for tech support never even bothered to answer my queries. If you are looking for a security DVR I suggest taking Lorex off your list.

In case it helps, here is my javascript code to discover Onvif cameras on your subnet and dump their URLs and profiles: onvif_discoverProfile.txt (3.1 KB)

Change *.txt to *.js to run it if your nodejs doesn't run a *.txt extension, my version ran it as *.txt.

Hi @wb666greene , that is indeed the library that is being used in node-red-contrib-onvif. I also used that one in the beginning, but it was a bit too limited for my purposes (as you can see in my comments above).

We had recently a nice discussion about RTSP in Node-RED. It seemed to be very easy to get an RTSP stream in Node-RED, as you can see here. I haven't tried to capture multiple RTSP streams simultaneously, but I don't see any reason why that shouldn't work. If you have any doubts, please share them with us in that discussion!

To be honest I don't really agree with your scepticism. Indeed a large part of Onvif is just getting information from your device (e.g. camera), but there is much more that makes it worth for me integrating it into Node-RED:

  1. Users can easily send a broadcast from their flow editor, to see which devices on their network support the Onvif protocol.
  2. Users can get the information very easily within their favorite flow editor.
  3. Users can pan/tilt/zoom cameras from the flow editor or the dashboard.
  4. Users can grab snapshot images very easily.
  5. Users can setup live (rtsp) streams without having to know anything about streaming.
  6. Users can get event streams from their camera, e.g. when motion is detected by their camera (without having to dig into the manuals of their camera).
  7. ...

And the advantage of Node-RED is that I'm not polluting your software. If you don't like my Onvif developments, you just don't download them...

@dceejay, @davidcgu: I have found last night my latest developments on one of my Raspberries, and have put them on Github (but you cannot download them yet!). I will try to make at least the Config/Discovery/PTZ nodes available this weekend, so you can start experimenting with it and give me feedback. I will try to reorganise the other nodes in the suite next week ...

1 Like

I certainly will give them a try when you've released them, especially if I ever get a PTZ capable Onvif camera.

But once the snapshot URLs have been found, other than for PTZ cameras, I'm not seeing much utility in Onvif beyond automating finding the URLs -- it is great when it works. But since using other http/rtsp access methods will work with the URLs for cameras that aren't Onvif or have broken support, using Onvif for these reduces your universe of usable cameras.

Can node-red display 10 rtsp streams at once? I haven't yet had time to play with the things discussed in the rtsp thread here, ffmpeg issues scare me away from trying lots of things until I can scrounge up another "throw-away" system so as to not risk breaking things that are working with an ffmpeg "upgrade".

I'm certainly interested in the names of any "low cost" Onvif compatible PTZ cameras. Standardized software for PTZ control and automatic camera discovery seem to be main benefit with Onvif.

1 Like

I plan to rejoin that thread once I've got more rtsp experience (thanks for the link to save me the search!), but so far it is not pretty.

Code and streams that play perfectly on my Ubuntu 16.04 i7 desktop overnight (ignoring some ffmpeg/gstreamer warnings : "Invalid UE golomb code") throw real errors on my Ubuntu 18.04 i3:

[h264 @ 0x33484c0] error while decoding MB 27 64, bytestream -9
[rtsp @ 0x25d8a40] RTP: PT=60: bad cseq 378a expected=0138
[rtsp @ 0x2cf6040] RTP: PT=60: bad cseq c96a expected=98c1
[rtsp @ 0x2eccc40] RTP: PT=60: bad cseq d6d4 expected=9f2c
[h264 @ 0x2d25840] error while decoding MB 86 40, bytestream -5
Unexpected disconnection! ... 2019-01-18 10:42:20
[h264 @ 0x2c07780] error while decoding MB 33 26, bytestream -14

The Unexpected disconnection message is from one of my try blocks when a sampling thread dies horribly.

Using jpeg snapshots is not a truly general solution either as some allegedly Onvif compatible cameras don't have a snapshot URL, others only offer substandard snapshot resolution (like D1 on a 1920x1080 camera), and still others are "buggy" and don't appear to be locked to h264 keyframes so sometimes they return perfect images, other times they return blocky mosaic images

I think you may be in for a nightmare of github issues if you don't specifiy a list of cameras that are known to work with your onvif nodes.

Edit: During my testing, I've made my code have selectable "front-ends" via command line option. I'm finding rtsp has a lot more overhead. Its not so bad on my i7, but on my i3 with a single Movidius NCS stick and 4 cameras I'm getting ~9.5 fps using Onvif jpeg snapshot URLs vs ~4.4 fps using rtsp URLs. My next test will be to use the exact same cameras, the 4.4 fps test was using my Lorex DVR rtsp URLs (my desired target)

While giving the tests sufficient time to run, I've had more than the usual amount of time to noodle around this forum.

Edit2: Its looking like the i3 system errors on Ubuntu 18.04 may be that openCV rtsp capture is not thread safe, the i7 system seems to have been fast enough to hide the issue. Adding a lock acquire/release around the rtsp frame graps seems to have fixed the issue -- been running 10X longer than it took to happen previously, plan to let it go overnight.

Yes I had the same thoughts when I was developing these nodes, so last summer I added immediately a section about it on my readme page. It has no use to create an issue on my repository, if the library underneath contains a problem. I cannot solve most of the issues anyway ...

Personally while having the capability to control PTZ and Zoom from a special node for me is more than enough.

Motion eye brings already many functionalities that whatever is done, is going to be very difficult to compete, and motion eye is already very easy to interact somehow with node red and gdrive etc...

For displaying the cameras with a simple template you can handle it easy so.... for me that's the goal.

Regards