2.0.0-rc2 β’ Published 4 years ago
ndj v2.0.0-rc2
Installation
nDJ requires ffmpeg
(currently tested with 4.3.2, but 4.x should work fine). You can install ffmpeg
through npm with npm i -S ffmpeg-static@4.3.0
, or put ffmpeg
on your PATH.
Installation is as simple as:
$ npm i ndj
Features
- βΎοΈ Supports up to 1,024 clips
- π Super fast
- π Support for 90+ filters & effects
- βοΈ Beautiful chaining API
- π Heavily documented
- π‘ Can output to a buffer instead of a file
Limitations
- While nDJ can output to a buffer, nDJ cannot have buffers as inputs
mix
is synchronous and blocking due to a limitation/bug/developer incompetence (you should use nDJ in a worker thread)
Usage
The below example shows very basic usage of nDJ, using simple effects & filters.
import nDJ from 'ndj';
const mixer = new nDJ({
// # of channels the output should have
channels: 'stereo',
// Sample rate of the output
sampleRate: 48000,
// Custom ffmpeg path
ffmpeg: '/usr/bin/other-ffmpeg'
});
mixer
.clip('clip1.mp3')
// Play only the first second of the stream
.cut(0, 1)
// Delay by 0.5s
.delay(0.5)
// Raise the volume by 1.5x
.volume(1.5)
// Slow the speed by 0.75x
.speed(0.75)
.clip('clip2.mp3')
.delay(0.5)
.volume(0.5)
.global
// Increase volume across all clips by 1.5x
.volume(1.5);
// Mixes to an MP3 file & returns the file path
const outputFilePath = mixer.mix('mp3');
// Mixes to a raw PCM file (signed 16-bit little-endian by default)
const outputPCMFilePath = mixer.mix('raw');
// Mixes to a buffer instead of a file
const outputBuffer = mixer.mix('mp3', true);
Documentation
A list of effects & filters can be found here. More documentation for the nDJ mixer class can be found here.