1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-12-23 22:33:17 +00:00
musix-oss/node_modules/prism-media/src/transcoders/MediaTranscoder.js

32 lines
916 B
JavaScript
Raw Normal View History

2019-05-30 09:06:47 +00:00
const Ffmpeg = require('./ffmpeg/Ffmpeg');
const transcoders = [
'ffmpeg',
];
class MediaTranscoder {
constructor(prism) {
this.prism = prism;
this.ffmpeg = new Ffmpeg(this);
}
static verifyOptions(options) {
if (!options) throw new Error('Options must be passed to MediaTranscoder.transcode()');
if (!options.type) throw new Error('Options.type must be passed to MediaTranscoder.transcode()');
if (!transcoders.includes(options.type)) throw new Error(`Options.type must be: ${transcoders.join(' ')}`);
return options;
}
/**
* Transcodes a media stream based on specified options
* @param {Object} options the options to use when transcoding
* @returns {ReadableStream} the transcodeed stream
*/
transcode(options) {
options = MediaTranscoder.verifyOptions(options);
return this[options.type].transcode(options);
}
}
module.exports = MediaTranscoder;