diff --git a/lib/Voice/AudioEncoder.js b/lib/Voice/AudioEncoder.js index d6a8b9505..8f7728d22 100644 --- a/lib/Voice/AudioEncoder.js +++ b/lib/Voice/AudioEncoder.js @@ -78,7 +78,7 @@ var AudioEncoder = (function () { } } - return "help"; + return; }; AudioEncoder.prototype.encodeStream = function encodeStream(stream, options) { @@ -87,7 +87,12 @@ var AudioEncoder = (function () { return new Promise(function (resolve, reject) { _this.volume = new _VolumeTransformer2["default"](options.volume); - var enc = _child_process2["default"].spawn(_this.getCommand(), ['-i', '-', '-f', 's16le', '-ar', '48000', '-ss', options.seek || 0, '-ac', 2, 'pipe:1']); + var command = _this.getCommand(); + + // check if avconv or ffmpeg were found. + if (!command) return reject(new Error('FFMPEG not found. Make sure it is installed and in path.')); + + var enc = _child_process2["default"].spawn(command, ['-i', '-', '-f', 's16le', '-ar', '48000', '-ss', options.seek || 0, '-ac', 2, 'pipe:1']); var dest = stream.pipe(enc.stdin); @@ -108,7 +113,12 @@ var AudioEncoder = (function () { return new Promise(function (resolve, reject) { _this2.volume = new _VolumeTransformer2["default"](options.volume); - var enc = _child_process2["default"].spawn(_this2.getCommand(), ['-i', file, '-f', 's16le', '-ar', '48000', '-ss', options.seek || 0, '-ac', 2, 'pipe:1']); + var command = _this2.getCommand(); + + // check if avconv or ffmpeg were found. + if (!command) return reject(new Error('FFMPEG not found. Make sure it is installed and in path.')); + + var enc = _child_process2["default"].spawn(command, ['-i', file, '-f', 's16le', '-ar', '48000', '-ss', options.seek || 0, '-ac', 2, 'pipe:1']); _this2.hookEncodingProcess(resolve, reject, enc); }); @@ -120,9 +130,14 @@ var AudioEncoder = (function () { return new Promise(function (resolve, reject) { _this3.volume = new _VolumeTransformer2["default"](volume); + var command = _this3.getCommand(); + + // check if avconv or ffmpeg were found. + if (!command) return reject(new Error('FFMPEG not found. Make sure it is installed and in path.')); + // add options discord.js needs var options = ffmpegOptions.concat(['-f', 's16le', '-ar', '48000', '-ac', 2, 'pipe:1']); - var enc = _child_process2["default"].spawn(_this3.getCommand(), options); + var enc = _child_process2["default"].spawn(command, options); _this3.hookEncodingProcess(resolve, reject, enc); }); diff --git a/src/Voice/AudioEncoder.js b/src/Voice/AudioEncoder.js index 18af17b77..302ea8a96 100644 --- a/src/Voice/AudioEncoder.js +++ b/src/Voice/AudioEncoder.js @@ -55,14 +55,19 @@ export default class AudioEncoder { } } - return "help"; + return; } encodeStream(stream, options) { return new Promise((resolve, reject) => { this.volume = new VolumeTransformer(options.volume); - var enc = cpoc.spawn(this.getCommand(), [ + var command = this.getCommand(); + + // check if avconv or ffmpeg were found. + if (!command) return reject(new Error('FFMPEG not found. Make sure it is installed and in path.')); + + var enc = cpoc.spawn(command, [ '-i', '-', '-f', 's16le', '-ar', '48000', @@ -84,7 +89,12 @@ export default class AudioEncoder { return new Promise((resolve, reject) => { this.volume = new VolumeTransformer(options.volume); - var enc = cpoc.spawn(this.getCommand(), [ + var command = this.getCommand(); + + // check if avconv or ffmpeg were found. + if (!command) return reject(new Error('FFMPEG not found. Make sure it is installed and in path.')); + + var enc = cpoc.spawn(command, [ '-i', file, '-f', 's16le', '-ar', '48000', @@ -101,6 +111,11 @@ export default class AudioEncoder { return new Promise((resolve, reject) => { this.volume = new VolumeTransformer(volume); + var command = this.getCommand(); + + // check if avconv or ffmpeg were found. + if (!command) return reject(new Error('FFMPEG not found. Make sure it is installed and in path.')); + // add options discord.js needs var options = ffmpegOptions.concat([ '-f', 's16le', @@ -108,7 +123,7 @@ export default class AudioEncoder { '-ac', 2, 'pipe:1' ]); - var enc = cpoc.spawn(this.getCommand(), options); + var enc = cpoc.spawn(command, options); this.hookEncodingProcess(resolve, reject, enc); });