Skip to content

Hackzzila/prism-media

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Build Status dependencies devDependencies npm

Intuitive abstractions that make transcoding media easy. Provides behind-the-scenes audio support for discord.js

npm install prism-media


Dependencies

FFmpeg Transform

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);

OggOpus Demuxer

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'))

About

🎶 Easily transcode media using node.js

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 99.6%
  • TypeScript 0.4%