camera.ui icon indicating copy to clipboard operation
camera.ui copied to clipboard

Onvif Support

Open captainerd opened this issue 3 years ago • 10 comments

Okay, i'm getting the feeling seyxd died by covid or vax since don't see activity/replies.. here is the deal

Most cameras if not all except some old i expecting to support ONVIF, onvif is really usefull because i didn't knew what the rtsp url is to put the cameras on the app, it toke me a while to figure out what is going on. with onvif we can detect all the cameras in the network and automatically grab A. a live url for snapshot, B. stream A and low B, and C. motion detect proccessed by camera.

To do this i used two packages.

import onvif from 'node-onvif'; <- for discovery of streaming urls, camera names, etc. import onvifEvents from 'node-onvif-events'; <- for motion detection provided by the camera it self.

Note: node-onvif-events had to be manually installed as npm produced some errors when installing.

The following two functions return an array of objects, each object has these info. ob.snapshot is the url for a live fresh snapshot jpeg image, rtsp is an array of profiles, with urls for streaming note that to pass that info on ffmpeg you will need to replace :// with ://user:password@url

eg. rtsp://192.168.7.25:8554/profile0 needs to be http://user:[email protected]:8554/profile0

[ { snapshot: 'http://192.168.7.25:6688/snapshot/PROFILE_001', rtsp: [ 'rtsp://192.168.7.25:8554/profile0', 'rtsp://192.168.7.25:8554/profile1' ], urn: 'urn:uuid:2171bb3f-aa30-aa30-3030-e062905c7634', name: 'HD%20IPC', xaddr: 'http://192.168.7.25:6688/onvif/device_service' },

`async function testme(username, password) { return new Promise(async (resolve, reject) => { let camojb = {}; const cameras_info = []; console.log('Start the discovery process.'); // Find the ONVIF network cameras. // It will take about 3 seconds. onvif.startProbe().then(async (device_info_list) => { for (let i=0; i<device_info_list.length; i++) { let info = device_info_list[i]; let device = new onvif.OnvifDevice({ xaddr: info.xaddrs[0], user : username, pass : password }); camojb = await getURLs(device); //set obj camojb.urn = info.urn; camojb.name = info.name; camojb .xaddr = info.xaddrs[0]; // Initialize the OnvifDevice object cameras_info.push(camojb); } resolve(cameras_info) }).catch((error) => { console.error(error); }) }) }

async function getURLs(device) { return new Promise(async function(resolve) { let camojb = {}; camojb.snapshot = []; camojb.rtsp = []; device.init().then(() => {

let profile_list =   device.getProfileList();

for(let i=0; i<profile_list.length; i++) {
  camojb.snapshot = profile_list[i].snapshot;
  camojb.rtsp[i] = profile_list[i].stream.rtsp;
}  

}).then(() => { resolve(camojb)

}).catch((error) => { console.error(error); }); }); }`

Now as for motion detection:

`const startMotion = async () => { const detector = await onvifEvents.MotionDetector.create(options.id, options); console.log(new Date(), '>> Motion Detection Listening!!'); detector.listen((motion) => { if (motion) { console.log(new Date(), '>> Motion Detected'); } else { console.log(new Date(), '>> Motion Stopped'); } }); }

startMotion();`

tested both packages inside camera.ui as console.prints and works wonders.. now we need to impelement those into the app. a second feature that i find very important is to use .mkv for filenames and -copy for codecs, as almost all cameras provide already codec video and ffmpeg by default decodes video with mp4 or other extions in filename despite if you are u trying to use -codec copy, codec copy is only accepted on mkv.

captainerd avatar Jun 21 '22 15:06 captainerd

URL for packages i tested.

https://www.npmjs.com/package/node-onvif-events https://github.com/futomi/node-onvif

captainerd avatar Jun 21 '22 15:06 captainerd

Haha, no I'm still alive :D

I am actively working on version 2 of camera.ui and always read all the posts here

I have already implemented a lot (plugins, ring, webRTC, bugfixes, sound detection, new widgets, support for webpush etc etc).

Onvif will also be implemented

seydx avatar Jun 22 '22 00:06 seydx

is version 2 coming soon?

datomi79 avatar Sep 13 '22 11:09 datomi79

Hey @seydx - Just checking to see if ONVIF is on the table and/or if Camera UI is still being developed? As I can see there's been no updates since April and worried I'll be committing to something which is no longer being supported..

hassaniqbaluk avatar Dec 08 '22 16:12 hassaniqbaluk

I feel this may be an inactive project now…

happy to sponsor @seydx if it’s still active.

hassaniqbaluk avatar Dec 10 '22 21:12 hassaniqbaluk

I just stumbled on this. It's awesome! Is this still being developed? Version 2 ETA??

Sceptersax avatar Mar 15 '23 21:03 Sceptersax

UI wise, this seems to be the best NVR project out there. That would be a shame if development on this is stopped.

WEZANGO avatar Mar 31 '23 12:03 WEZANGO

I agree; it seems to have been stopped and unsupported at this point by the looks of things

hassaniqbaluk avatar Mar 31 '23 12:03 hassaniqbaluk

Haha, no I'm still alive :D

I am actively working on version 2 of camera.ui and always read all the posts here

I have already implemented a lot (plugins, ring, webRTC, bugfixes, sound detection, new widgets, support for webpush etc etc).

Onvif will also be implemented

Are you going to push a version of what you did up to now ?

captainerd avatar Apr 20 '23 09:04 captainerd

it would be great to follow those new features!

iurycarlos avatar Apr 20 '23 17:04 iurycarlos