#!/usr/bin/env node const onvif = require('node-onvif'); var myArgs = process.argv.slice(2); console.log('myArgs: ', myArgs); function pausecomp(millis) { var date = new Date(); var curDate = null; do { curDate = new Date(); } while(curDate-date < millis); } var xx = parseFloat(myArgs[0]); var yy = parseFloat(myArgs[1]); let device = new onvif.OnvifDevice({ xaddr: 'http://<>:8899/onvif/device_service', user : '<>', pass : '<>' }); // Initialize the OnvifDevice object device.init().then(() => { // The OnvifServicePtz object let ptz = device.services.ptz; if(!ptz) { throw new Error('Your ONVIF network camera does not support the PTZ service.'); } // The parameters for the gotoHomePosition() method let profile = device.getCurrentProfile(); //console.log('Profile: ', profile['token']); let params = { 'ProfileToken': profile['token'], 'Velocity': {'x':xx, 'y':yy, 'z':0}, 'Timeout': 2 }; // Send the GotoHomePosition command using the gotoHomePosition() method //return ptz.getPresets(params); ptz.continuousMove(params); pausecomp(2000); //ptz.stop; console.log('Stop'); params = { 'ProfileToken': profile['token'], 'PanTilt': true, 'Zoom': true }; return ptz.stop(params); }).then((result) => { console.log(JSON.stringify(result.data, null, ' ')); }).catch((error) => { console.error(error); });