Onvif camera control

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

The lowest cost PTZ camera claiming Onvif compatibality I've found so far is:
Cheap PTZ Onvif camera

What worries me is in the photo there seems to be "adjustments" for focus and zoom, if the Zoom part of PTZ was solid, why would one need screwdriver adjustments? Wishful thinking suggests it might be to support using it without PTZ.

Any one actually used one? At $100 I can "afford" to try it, but the Onvif cameras I've been using, Geovision/USAvision 720p, are ~$25, along with a few "straight from China" Besder 1080p cameras for about the same price that I would not recommend. The Geovision cameras have been rock solid and have built in POE as well as a 12V power pigtail, they have been running since August.

The upside of the Besder cameras is they have allowed me to test and improve my network error handing code :slight_smile:

I have a 3 cameras 2 of them with onvif and from those 2 one with PTZ, 720h and works fine for less than 30€..... onvif protocol works well I have some program on windows and respond to all commands. https://www.aliexpress.com/item/SANNCE-1MP-WiFi-IP-Camera-HD-720P-ONVIF-2-4-Smart-PTZ-Pan-Tilt-Night-Vision/32955188387.html?spm=a2g0s.9042311.0.0.27424c4dlvbt0L

Regards

Its cheap enough, but I've been burned in the past with AliExpress, it also is only PT not PTZ and not outdoor rated. But I could justify an indoor PTZ for testing if the price was right :slight_smile:

Yours could indeed be PTZ, but what that link offers now is PT no zoom (if you read the specs) despite the title saying PTZ, my main issue with AliExpress re-orders often don't get you the same item if you want another!

@davidcgu,
It takes a bit longer as expected:

  • Apperently some of the Onvif nodes that I had build last summer, were still based on the node-onvif library instead of the onvif library. Have updated the code, but need to test all commands.
  • I need to optimize the communication between Node-RED and the camera, to ensure that the number of requests to the camera is minimized. And this makes my code also cleaner. But need to get first some feeback on this issue.
  • Seems that our friend @wb666greene is looking at PT cameras instead of PTZ. Since I have also PT cameras, I really need to create a pull request for the Onvif library (otherwise e.g. we cannot determine the current position of the camera in both directions): indeed an exception occurs when the camera only returns PT info but no Z(oom) info ...

But we will get there soon ...

1 Like

No problem, if someday will have some specific node to be able to integrate the motion of the camera for me will be great.

Frankly speaking I have 2 cameras looking at the entrance at home and one on the 3d printer so really I'm not moving them too much...

Take it easy mate

I´m very new to node-red but I have some ONVIF cameras and would love to get the motion as an event into node-red. So this look promising, please keep it up!

Look at motion or motioneye, however be aware that is a black hole on raspi resources...you can easy make it interact with nodered

Like you say it’s a server side motion and low on resources make that it will not work for me plus that my IP camera have built in video analytic:) So if I can communicate via ONVIF to get the event it’s low on the server side plus I will have great detection. Thanks for the suggestion otherwise!

Hi @Klangen82, I will continue with my Onvif nodes in a couple of days. The configuration issue seems to be solved now, so I can start refactoring my code. If all goes well, I should have a first alfa version available next week. Would be nice if you could also do some tests then ...

2 Likes

Let me know when they are ready and I will give them a try. I hope to also try multiple streams of your exec ffmpeg flow we discussed in another thread tomorrow or Friday.

1 Like