Skip to content

Async off-thread processing for media encoding, decoding and processing.

License

Notifications You must be signed in to change notification settings

Streampunk/codecadon

Repository files navigation

CircleCI npm version License

Codecadon

Codecadon is a Node.js addon using Javascript and C++ to implement async processing for media encoding, decoding and processing.

The implementation is designed to support the dynamorse project and currently provides packing, rescaling and encoding/decoding for h.264 and VP8, largely using FFmpeg.

Support has been added for building codecadon for the Raspberry Pi armhf platforms, although do not expect anything other than relatively poor performance at this stage.

Installation

NPM

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

Codecadon is designed to be required to use from your own application to provide async processing. Install in your project folder with the --save option to add codecadon to the dependencies list:

npm install --save codecadon

Node.js addons use libuv which by default supports up to 4 async threads in a threadpool for activities such as file I/O. These same threads are used by codecadon and if you wish to use a number of the functions in one Node.js process then you will need to set the environment variable UV_THREADPOOL_SIZE to a suitable number before the first use of the libuv threadpool.

Example shell commands to set this variable on different platforms are:

Windows:

set UV_THREADPOOL_SIZE=16

Linux/Mac/Raspberry Pi:

export UV_THREADPOOL_SIZE=16

Using codecadon

To use codecadon in your own application, require the module then create and use workers as required. The processing functions follow a standard pattern as shown in the encoder example code below.

let codecadon = require('codecadon');

let encoder = new codecadon.Encoder(() => {
  // encoder has successfully exited
});
encoder.on('error', err => {
  // handle error
});

// send the parameters for the function (these differ by function), return value is suggested result buffer size
let dstBufLen = encoder.setInfo(srcTags, dstTags, duration, encodeTags);

// async request for processing to be done.
encoder.encode(srcBuf, Buffer.alloc(dstBufLen), (err, result) => {
  if (err) {
    // handle error
  } else if (result) {
    // result is a JS buffer containing the encoded data. Note it may be a different size to dstBuf
  }
});

// async request for the processing thread to quit when it has finished the latest request
encoder.quit(() => {
});

Status, support and further development

There is currently a limited set of video packing formats and codecs supported. There has been no attempt made to tune encoder parameters for performance or quality.

Although the architecture of codecadon 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

This software is released under the Apache 2.0 license. Copyright 2016 Streampunk Media Ltd.

This software uses libraries from the FFmpeg project under the LGPLv3.

Copies of the licenses pertaining to libraries used in this software can be found in the licences folder.

About

Async off-thread processing for media encoding, decoding and processing.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •