npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

grandiose

v0.0.4

Published

Node.JS native bindings to the Newtek NDI SDK.

Downloads

45

Readme

Grandiose

Node.js native bindings to NewTek NDI(tm). For more information on NDI(tm), see:

http://NDI.NewTek.com/

This module will allow a Node.JS program to find, receive and send NDI(tm) video, audio and metadata streams over IP networks. All calls a asynchronous and use Javascript promises with all of the underlying work of NDI running on separate threads from the event loop.

NDI(tm) is a realisation of a grand vision for what IP media streams should and can be, hence a steampunk themed name of gra-NDI-ose.

Installation

Grandiose only supports Windows x64 platforms at this time. Other platforms may be added in the future.

Install Node.js for your platform. This software has been developed against the long term stable (LTS) release.

On Windows, the NDI(tm) DLL requires that the Visual Studio 2013 C run-times are installed, available from:

https://www.microsoft.com/en-us/download/details.aspx?id=40784

Grandiose is designed to be required to use from your own application to provide async processing. For example:

npm install --save grandiose

Using grandiose

Finding streams

A list of all currently available NDI(tm) sources available on the current local area network (or VLAN) can be retrieved. For example, to print a list of sources to the console, try:

const grandiose = require('grandiose');

grandiose.find()
  .then(console.log)
  .catch(console.error);

The result is an array, for example here are some local sources to machine :

[ { name: 'GINGER (Intel(R) HD Graphics 520 1)',
    urlAddress: '169.254.82.1:5962' },
  { name: 'GINGER (Test Pattern)',
    urlAddress: '169.254.82.1:5961' },
  { name: 'GINGER (TOSHIBA Web Camera - HD)',
    urlAddress: '169.254.82.1:5963' } ]

The find operation can be configured with an options object and a wait time in measured in milliseconds:

grandiose.find(<opts>, <wait_time>);

The options are as follows:

grandiose.find({
  // Should sources on the same system be found?
  showLocalSources: true,
  // Show only sources in a named group. May be an array.
  groups: "studio3",
  // Specific IP addresses or machine names to check
  // These are possibly on a different VLAN and not visible over MDNS
  extraIPs: [ "192.168.1.122", "mixer.studio7.zbc.com" ]
}) // ...

Receiving streams

First of all, find a stream using the method above or create an object representing a source:

const grandiose = require('grandiose');
let source = { name: "<source_name>", urlAddress: "<IP-address>:<port>" };

In an async function, create a receiver as follows:

let receiver = await grandiose.receive({ source: source });

An example of the receiver object resolved by this promise is shown below:

{ embedded: [External],
  video: [Function: video],
  audio: [Function: audio],
  metadata: [Function: metadata],
  data: [Function: data],
  source:
   { name: 'LEMARR (Test Pattern)',
     urlAddress: '169.254.82.1:5961' },
  colorFormat: 100, // grandiose.COLOR_FORMAT_FASTEST
  bandwidth: 100,   // grandiose.BANDWIDTH_HIGHEST
  allowVideoFields: true }

The embedded value is the native receiver returned by the NDI(tm) SDK. The video, audio, metadata and data functions return promises to retrieve data from the source. These promises are backed by calls that are thread safe.

The colorFormat, bandwidth and allowVideoFields parameters are those used to set up the receiver. These can be configured as options when creating the receiver as follows:

let receiver = await grandiose.receive({
  source: source, // required source parameter
  // Preferred colour space - without and with alpha channel
  // One of COLOR_FORMAT_RGBX_RGBA, COLOR_FORMAT_BGRX_BGRA,
  //   COLOR_FORMAT_UYVY_RGBA, COLOR_FORMAT_UYVY_BGRA or
  //   the default of COLOR_FORMAT_FASTEST
  colorFormat: grandiose.COLOR_FORMAT_UYVY_RGBA,
  // Select bandwidth level. One of grandiose.BANDWIDTH_METADATA_ONLY,
  //   BANDWIDTH_AUDIO_ONLY, BANDWIDTH_LOWEST and the default value
  //   of BANDWIDTH_HIGHEST
  bandwidth: grandiose.BANDWIDTH_AUDIO_ONLY,
  // Set to false to receive only progressive video frames
  allowVideoFields: true, // default is true
  // An optional name for the receiver, otherwise one will be generated
  name: "rooftop"
}, );

Video

Request video frames from the source as follows:

let timeout = 5000; // Optional timeout, default is 10000ms
try {
  for ( let x = 0 ; x < 10 ; x++) {
    let videoFrame = await receiver.video(timeout);
    console.log(videoFrame);
  }
} catch (e) { console.error(e); }

Here is the output associated with a video frame created by an NDI(tm) test pattern:

{ type: 'video',
  xres: 1920,
  yres: 1080,
  frameRateN: 30000,
  frameRateD: 1001,
  pictureAspectRatio: 1.7777777910232544, // 16:9
  timestamp: [ 1538569443, 717845600 ], // PTP timestamp
  frameFormatType: 1, // grandiose.FORMAT_TYPE_INTERLACED
  timecode: [ 0, 0 ], // Measured in nanoseconds
  lineStrideBytes: 3840,
  data: <Buffer 80 10 80 10 80 10 80 10 ... > }

NDI presents 8-bit integer data for video, meaning samples are byte-aligned.

Note that the returned promise may be rejected if the request times out or another error occurs.

The receiver instance will disconnect on the next garbage collection, so make sure that you don't hold onto a reference.

Audio

Audio follows a similar pattern to video, except that a couple of options are available to control for format of audio returned into Javasript.

let timeout = 8000; // Optional timeout value in ms
let audioFrame = await receiver.audio({
    // One of three audio formats that NDI(tm) utilities can provide:
    //  grandiose.AUDIO_FORMAT_INT_16_INTERLEAVED,
    //  AUDIO_FORMAT_FLOAT_32_INTERLEAVED and the default value of
    //  AUDIO_FORMAT_FLOAT_32_SEPARATE
    audioFormat: grandiose.AUDIO_FORMAT_INT_16_INTERLEAVED,
    // The audio reference level in dB. This specifies how many dB above
    // the reference level (+4dBU) is the full range of integer audio.
    referenceLevel: 0 // default is 0dB
  }, timeout);

An example of an audio frame resolved from this promise is:

{ type: 'audio',
  audioFormat: 2, // grandiose.AUDIO_FORMAT_INT_16_INTERLEAVED
  referenceLevel: 0, // 0dB above reference level
  sampleRate: 48000, // Hz
  channels: 4,
  samples: 4800, // Number of samples in this frame
  channelStrideInBytes: 9600, // number of bytes per channel in buffer
  timestamp: [ 1538578787, 132614500 ], // PTP timestamp
  timecode: [ 0, 800000000 ], // timecode as PTP value
  data: <Buffer 00 00 00 00 00 00 00 00 89 10 89 10 89 10 89 ... > }

Metadata

Follows a similar pattern to video and audio, waiting for any metadata messages in the stream.

let metadataFrame = await receiver.metadata();

The result is an object with a data property that is string containing the metadata, expected to be a short XML document.

Next available data

A means to receive the next available data payload in the stream, whether that is video, audio or metadata, allowing the application to filter the streams as required based on the type parameter. The optional arguments used for audio can also be used here.

let dataFrame = await receiver.data();
if (dataFrame.type == 'video') { /* Process just the video */ }
else if (dataFrame.type == 'metadata') { console.log(dataFrame.data); }

Sending streams

To follow.

Other

To find out the version of NDI(tm), use:

grandiose.version(); // e.g. 'NDI SDK WIN64 00:29:47 Jun 26 2018 3.5.9.0'

To check if the installed CPU is supported for NDI(tm), use:

grandiose.isSupportedCPU(); // e.g. true

Status, support and further development

Support for sending streams is in progress. Support for x86, Mac and Linux platforms is being considered.

Although the architecture of grandiose is such that it could be used at scale in production environments, development is not yet complete. In its current state, it is recommended that this software is used in development environments and for building prototypes. Future development will make this more appropriate for production use.

Contributions can be made via pull requests and will be considered by the author on their merits. Enhancement requests and bug reports should be raised as github issues. For support, please contact Streampunk Media.

License

Apart from the exceptions in the following section, this software is released under the Apache 2.0 license. Copyright 2018 Streampunk Media Ltd.

License exceptions

The software uses libraries provided under a royalty-free license from NewTek, Inc..

  • The include files are licensed separately by a NewTek under the MIT license.
  • The DLL and library are provided for convenience of installation and are covered by the NewTek license contained in the lib folder.

Trademarks

NDI(tm) is a trademark of NewTek, Inc..