summaryrefslogtreecommitdiff
path: root/node_modules/prism-media/src/transcoders/ffmpeg/Ffmpeg.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/prism-media/src/transcoders/ffmpeg/Ffmpeg.js')
-rw-r--r--node_modules/prism-media/src/transcoders/ffmpeg/Ffmpeg.js56
1 files changed, 0 insertions, 56 deletions
diff --git a/node_modules/prism-media/src/transcoders/ffmpeg/Ffmpeg.js b/node_modules/prism-media/src/transcoders/ffmpeg/Ffmpeg.js
deleted file mode 100644
index b34dadc..0000000
--- a/node_modules/prism-media/src/transcoders/ffmpeg/Ffmpeg.js
+++ /dev/null
@@ -1,56 +0,0 @@
-const ChildProcess = require('child_process');
-const FfmpegProcess = require('./FfmpegProcess');
-
-class FfmpegTranscoder {
- constructor(mediaTranscoder) {
- this.mediaTranscoder = mediaTranscoder;
- this.command = FfmpegTranscoder.selectFfmpegCommand();
- this.processes = [];
- }
-
- static verifyOptions(options) {
- if (!options) throw new Error('Options not provided!');
- if (!options.media) throw new Error('Media must be provided');
- if (!options.ffmpegArguments || !(options.ffmpegArguments instanceof Array)) {
- throw new Error('FFMPEG Arguments must be an array');
- }
- if (options.ffmpegArguments.includes('-i')) return options;
- if (typeof options.media === 'string') {
- options.ffmpegArguments = ['-i', `${options.media}`].concat(options.ffmpegArguments).concat(['pipe:1']);
- } else {
- options.ffmpegArguments = ['-i', '-'].concat(options.ffmpegArguments).concat(['pipe:1']);
- }
- return options;
- }
-
- /**
- * Transcodes an input using FFMPEG
- * @param {FfmpegTranscoderOptions} options the options to use
- * @returns {FfmpegProcess} the created FFMPEG process
- * @throws {FFMPEGOptionsError}
- */
- transcode(options) {
- if (!this.command) this.command = FfmpegTranscoder.selectFfmpegCommand();
- const proc = new FfmpegProcess(this, FfmpegTranscoder.verifyOptions(options));
- this.processes.push(proc);
- return proc;
- }
-
- static selectFfmpegCommand() {
- try {
- const ffmpegStatic = require('ffmpeg-static');
- return ffmpegStatic.path || ffmpegStatic;
- } catch (err1) {
- try {
- return require('ffmpeg-binaries');
- } catch (err2) {
- for (const command of ['ffmpeg', 'avconv', './ffmpeg', './avconv']) {
- if (!ChildProcess.spawnSync(command, ['-h']).error) return command;
- }
- throw new Error('FFMPEG not found');
- }
- }
- }
-}
-
-module.exports = FfmpegTranscoder;