Make FFMPEG error reject encoding

This commit is contained in:
abalabahaha
2016-03-06 13:04:23 -08:00
parent dd6c158250
commit 4e58de8cd6
2 changed files with 28 additions and 10 deletions

View File

@@ -87,10 +87,13 @@ var AudioEncoder = (function () {
return new Promise(function (resolve, reject) {
_this.volume = new _VolumeTransformer2["default"](options.volume || 1);
var enc = _child_process2["default"].spawn(_this.getCommand(), ['-loglevel', '0', '-i', '-', '-f', 's16le', '-ar', '48000', '-ss', options.seek || 0, '-ac', 2, 'pipe:1'], { stdio: ['pipe', 'pipe', 'ignore'] });
var enc = _child_process2["default"].spawn(_this.getCommand(), ['-hide_banner', '-i', '-', '-f', 's16le', '-ar', '48000', '-ss', options.seek || 0, '-ac', 2, 'pipe:1']);
stream.pipe(enc.stdin);
enc.stdout.pipe(_this.volume);
enc.stderr.on("data", function (data) {
reject(new Error("FFMPEG: " + new Buffer(data).toString().trim()));
});
_this.volume.once("readable", function () {
resolve({
@@ -117,9 +120,12 @@ var AudioEncoder = (function () {
return new Promise(function (resolve, reject) {
_this2.volume = new _VolumeTransformer2["default"](options.volume || 1);
var enc = _child_process2["default"].spawn(_this2.getCommand(), ['-loglevel', '0', '-i', file, '-f', 's16le', '-ar', '48000', '-ss', options.seek || 0, '-ac', 2, 'pipe:1'], { stdio: ['pipe', 'pipe', 'ignore'] });
var enc = _child_process2["default"].spawn(_this2.getCommand(), ['-hide_banner', '-i', file, '-f', 's16le', '-ar', '48000', '-ss', options.seek || 0, '-ac', 2, 'pipe:1']);
enc.stdout.pipe(_this2.volume);
enc.stderr.on("data", function (data) {
reject(new Error("FFMPEG: " + new Buffer(data).toString().trim()));
});
_this2.volume.once("readable", function () {
resolve({
@@ -146,10 +152,13 @@ var AudioEncoder = (function () {
_this3.volume = new _VolumeTransformer2["default"](1);
// add options discord.js needs
var options = ffmpegOptions.concat(['-loglevel', '0', '-f', 's16le', '-ar', '48000', '-ac', 2, 'pipe:1']);
var enc = _child_process2["default"].spawn(_this3.getCommand(), options, { stdio: ['pipe', 'pipe', 'ignore'] });
var options = ffmpegOptions.concat(['-hide_banner', '-f', 's16le', '-ar', '48000', '-ac', 2, 'pipe:1']);
var enc = _child_process2["default"].spawn(_this3.getCommand(), options);
enc.stdout.pipe(_this3.volume);
enc.stderr.on("data", function (data) {
reject(new Error("FFMPEG: " + new Buffer(data).toString().trim()));
});
_this3.volume.once("readable", function () {
resolve({