mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
handle ffmpeg/avconv not found (#501)
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user