blob: 217e34c1c6de3aff594e530f530811e5c979aaae (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
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;
|