New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

onvif

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

onvif

Client to ONVIF NVT devices, especially cameras

  • 0.2.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.7K
decreased by-12.11%
Maintainers
1
Weekly downloads
 
Created
Source

ONVIF

Build Status Coverage Status NPM version

ONVIF Client protocol Node.js implementation.

This is a wrapper to ONVIF protocol which allows you to get information about your NVT (network video transmitter) device, its media sources, control PTZ (pan-tilt-zoom) movements and manage presets.

ONVIF

Supported methods

  • GetSystemDateAndTime
  • GetCapabilities
  • GetVideoSources
  • GetProfiles
  • GetServices
  • GetDeviceInformation
  • GetStreamUri
  • GetPresets
  • GotoPreset
  • PTZRelativeMove
  • PTZAbsoluteMove

Installation

npm install onvif

Tests

In the library directory run npm run-script test

Quick example

This example asks your camera to look up and starts a web server at port 3030 that distributes a web page with vlc-plugin container which translates video from the camera.

var
  http = require('http'),
  Cam = require('onvif').Cam;

new Cam({
  hostname: CAMERA_HOST,
  username: USERNAME,
  password: PASSWORD
}, function(err) {
  this.absoluteMove({x: 1, y: 1, zoom: 1});
  this.getStreamUri({protocol:'RTSP'}, function(err, stream) {
    http.createServer(function (req, res) {
      res.writeHead(200, {'Content-Type': 'text/html'});
      res.end('<html><body>' +
        '<embed type="application/x-vlc-plugin" target="' + stream.uri + '"></embed>' +
        '</body></html>');
    }).listen(3030);
  });
});

Troubleshooting

Different cameras have different ONVIF implementation. I've tested this module only with a couple of devices. So if you've experience different problems with this library, please let me know via e-mail. Else please just send the model of your camera to me.

API

var Cam = require('onvif').Cam;

new Cam(options, callback)

Options are:

  • hostname
  • username, password (optional, to deal with majority functions)
  • port (optional)

Callback (optional) executes when the cam is initialised. Single argument for this function is possible error.

Technical description

When the cam object creates it automatically sends three command to the ONVIF device: getCapabilities, getVideoSources and getProfiles. After that it fills correspondent properties of an object:

  • capabilities
    • device
    • events
    • imaging
    • media
    • PTZ
    • extension
  • uri (this is a links to different NVT services)
  • videoSources
    • $.token
    • framerate
    • resolution
  • profiles, array of profile object
    • name
    • videoSourceConfiguration
    • videoEncoderConfiguration
    • PTZConfiguration
  • defaultProfile (link to the first profile in profiles)
  • activeSource (based on the default profile)
    • sourceToken
    • profileToken
    • encoding
    • width
    • height
    • fps
    • bitrate
    • ptz

connect(callback)

Connect to the camera and fill device information properties with getCapabilities, getVideoSources, getProfiles methods

See more detailed information at http://www.onvif.org/ver10/media/wsdl/media.wsdl After cam initialisation we can run several ONVIF commands. There are several common methods that work without credentials. Here are they: getSystemDateAndTime.

getSystemDateAndTime(callback)

Returns a Date object with current camera datetime in the callback. Works without credentials (passed username and password arguments).

getDeviceInformation(callback)

Device. Returns a device information, such as manufacturer, model and firmware version in the callback Works without credentials (passed username and password arguments).

getServices(callback)

Device. Returns in callback and assigns to #services property an array consists of objects with properties: namespace, XAddr, version

getServiceCapabilities(callback)

Device. Returns in callback and assigns to #serviceCapabilities property the capabilities of the device service (not media): network, security and system. If your device supports some auxiliary capabilities they will be there too.

getStreamUri(options, callback)

Media. Returns a URI that can be used to initiate a live media stream using RTSP as the control protocol The options are:

  • stream (optional) - defines if a multicast or unicast stream is requested. Possible values are: 'RTP-Unicast' (default), 'RTP-Multicast'
  • protocol (optional) - defines the network protocol for streaming. Possible values are: 'UDP', 'TCP', 'RTSP' (default), 'HTTP'
  • profileToken (optional) - defines media profile to use and will define the configuration of the content of the stream. Default is #activeSource.profileToken

getPresets(options, callback)

Returns the saved presets as an a key-value object where the key is the name of a preset and a value is a preset token. This method also stores the presets information in a #presets property of an object.

The options are:

  • profileToken (optional) - defines media profile to use and will define the configuration of the content of the stream. Default is #activeSource.profileToken

gotoPreset(options, callback)

Operation to go to a saved preset position for the PTZ node in the selected profile.

The options are:

  • profileToken (optional) - defines media profile to use and will define the configuration of the content of the stream. Default is #activeSource.profileToken
  • preset - the name of preset. List of presets you can get by #getPresets method or in #presets property.

getNodes(callback)

PTZ. Returns the properties of the current PTZ node, if it exists. Use this function to get maximum number of presets, ranges of admitted values for x, y, zoom, iris, focus. Sets all information into #nodes property.

relativeMove(options, callback)

PTZ. This is a relative pan-tilt-zoom method. Options for this method is a delta between desired and current position of the camera.

The options are:

  • x Pan, number or a string within -1 to 1, optional

  • y Tilt, number or a string within -1 to 1, optional

  • zoom Zoom, number or a string within -1 to 1, optional

  • speed An object with properties

    • x Pan speed
    • y Tilt speed
    • zoom Zoom speed

    If the speed option is omitted, the default speed set by the PTZConfiguration will be used.

Callback is optional and means essentially nothing

absoluteMove(options, callback)

PTZ. This is an absolute pan-tilt-zoom method. Options for this method is an absolute position of the camera.

The options are:

  • x Pan, number or a string within -1 to 1, optional

  • y Tilt, number or a string within -1 to 1, optional

  • zoom Zoom, number or a string within -1 to 1, optional

  • speed An object with properties

    • x Pan speed
    • y Tilt speed
    • zoom Zoom speed

    If the speed option is omitted, the default speed set by the PTZConfiguration will be used.

Callback is optional and means essentially nothing

getStatus(options, callback)

PTZ. Returns an object with the current PTZ values.

{
	position: {
		x: 'pan position'
		, y: 'tilt position'
		, zoom: 'zoom'
	}
	, moveStatus: {} // camera moving
	, utcTime: 'current camera datetime'
}

getConfigurations(callback)

PTZ. Get all the existing PTZConfigurations from the device. Configurations saved into #configurations property

getConfigurationOptions(configurationToken, callback)

PTZ. Get supported coordinate systems including their range limitations for selected configuration. Extends corresponding configuration object

sendAuxiliaryCommand(options, callback)

PTZ. Send raw auxiliary commands to the PTZ device mapped by the PTZNode in the selected profile.

The options are:

  • profileToken (optional) - defines media profile to use and will define the configuration of the content of the stream. Default is #activeSource.profileToken
  • data - data for the auxiliary command, you can get it, for example, in the #serviceCapabilities.auxiliaryCommands property

WSDL schemes and docs:

Keywords

FAQs

Package last updated on 12 Mar 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc