Intuitive abstractions that make transcoding media easy. Provides behind-the-scenes audio support for discord.js
npm install prism-media
- Opus
krypton
(development)node-opus
(^0.2.7)opusscript
(^0.0.4)
- Other
ffmpeg-binaries
(^3.2.2-3)
const fs = require('fs');
const prism = require('prism-media');
const input = fs.createReadStream('./file.mp3');
const output = fs.createWriteStream('./output.pcm');
const transcoder = new prism.FFmpeg({
args: [
'-analyzeduration', '0',
'-loglevel', '0',
'-f', 's16le',
'-ar', '48000',
'-ac', '2',
],
});
input.pipe(transcoder).pipe(output);
const prism = require('prism-media');
const fs = require('fs');
const opus = require('node-opus');
const decoder = new opus.Decoder({ rate: 48000, channels: 2, frameSize: 960 });
fs.createReadStream('./audio.ogg')
.pipe(new prism.OggOpusDemuxer())
.pipe(decoder)
.pipe(fs.createWriteStream('./audio.pcm'))