mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 02:23:31 +01:00
Make FFMPEG error reject encoding
This commit is contained in:
@@ -87,10 +87,13 @@ var AudioEncoder = (function () {
|
|||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
_this.volume = new _VolumeTransformer2["default"](options.volume || 1);
|
_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);
|
stream.pipe(enc.stdin);
|
||||||
enc.stdout.pipe(_this.volume);
|
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 () {
|
_this.volume.once("readable", function () {
|
||||||
resolve({
|
resolve({
|
||||||
@@ -117,9 +120,12 @@ var AudioEncoder = (function () {
|
|||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
_this2.volume = new _VolumeTransformer2["default"](options.volume || 1);
|
_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.stdout.pipe(_this2.volume);
|
||||||
|
enc.stderr.on("data", function (data) {
|
||||||
|
reject(new Error("FFMPEG: " + new Buffer(data).toString().trim()));
|
||||||
|
});
|
||||||
|
|
||||||
_this2.volume.once("readable", function () {
|
_this2.volume.once("readable", function () {
|
||||||
resolve({
|
resolve({
|
||||||
@@ -146,10 +152,13 @@ var AudioEncoder = (function () {
|
|||||||
_this3.volume = new _VolumeTransformer2["default"](1);
|
_this3.volume = new _VolumeTransformer2["default"](1);
|
||||||
|
|
||||||
// add options discord.js needs
|
// add options discord.js needs
|
||||||
var options = ffmpegOptions.concat(['-loglevel', '0', '-f', 's16le', '-ar', '48000', '-ac', 2, 'pipe:1']);
|
var options = ffmpegOptions.concat(['-hide_banner', '-f', 's16le', '-ar', '48000', '-ac', 2, 'pipe:1']);
|
||||||
var enc = _child_process2["default"].spawn(_this3.getCommand(), options, { stdio: ['pipe', 'pipe', 'ignore'] });
|
var enc = _child_process2["default"].spawn(_this3.getCommand(), options);
|
||||||
|
|
||||||
enc.stdout.pipe(_this3.volume);
|
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 () {
|
_this3.volume.once("readable", function () {
|
||||||
resolve({
|
resolve({
|
||||||
|
|||||||
@@ -63,17 +63,20 @@ export default class AudioEncoder {
|
|||||||
this.volume = new VolumeTransformer(options.volume || 1);
|
this.volume = new VolumeTransformer(options.volume || 1);
|
||||||
|
|
||||||
var enc = cpoc.spawn(this.getCommand(), [
|
var enc = cpoc.spawn(this.getCommand(), [
|
||||||
'-loglevel', '0',
|
'-hide_banner',
|
||||||
'-i', '-',
|
'-i', '-',
|
||||||
'-f', 's16le',
|
'-f', 's16le',
|
||||||
'-ar', '48000',
|
'-ar', '48000',
|
||||||
'-ss', (options.seek || 0),
|
'-ss', (options.seek || 0),
|
||||||
'-ac', 2,
|
'-ac', 2,
|
||||||
'pipe:1'
|
'pipe:1'
|
||||||
], {stdio: ['pipe', 'pipe', 'ignore']});
|
]);
|
||||||
|
|
||||||
stream.pipe(enc.stdin);
|
stream.pipe(enc.stdin);
|
||||||
enc.stdout.pipe(this.volume);
|
enc.stdout.pipe(this.volume);
|
||||||
|
enc.stderr.on("data", (data) => {
|
||||||
|
reject(new Error("FFMPEG: " + new Buffer(data).toString().trim()));
|
||||||
|
});
|
||||||
|
|
||||||
this.volume.once("readable", () => {
|
this.volume.once("readable", () => {
|
||||||
resolve({
|
resolve({
|
||||||
@@ -99,16 +102,19 @@ export default class AudioEncoder {
|
|||||||
this.volume = new VolumeTransformer(options.volume || 1);
|
this.volume = new VolumeTransformer(options.volume || 1);
|
||||||
|
|
||||||
var enc = cpoc.spawn(this.getCommand(), [
|
var enc = cpoc.spawn(this.getCommand(), [
|
||||||
'-loglevel', '0',
|
'-hide_banner',
|
||||||
'-i', file,
|
'-i', file,
|
||||||
'-f', 's16le',
|
'-f', 's16le',
|
||||||
'-ar', '48000',
|
'-ar', '48000',
|
||||||
'-ss', (options.seek || 0),
|
'-ss', (options.seek || 0),
|
||||||
'-ac', 2,
|
'-ac', 2,
|
||||||
'pipe:1'
|
'pipe:1'
|
||||||
], {stdio: ['pipe', 'pipe', 'ignore']});
|
]);
|
||||||
|
|
||||||
enc.stdout.pipe(this.volume);
|
enc.stdout.pipe(this.volume);
|
||||||
|
enc.stderr.on("data", (data) => {
|
||||||
|
reject(new Error("FFMPEG: " + new Buffer(data).toString().trim()));
|
||||||
|
});
|
||||||
|
|
||||||
this.volume.once("readable", () => {
|
this.volume.once("readable", () => {
|
||||||
resolve({
|
resolve({
|
||||||
@@ -134,15 +140,18 @@ export default class AudioEncoder {
|
|||||||
|
|
||||||
// add options discord.js needs
|
// add options discord.js needs
|
||||||
var options = ffmpegOptions.concat([
|
var options = ffmpegOptions.concat([
|
||||||
'-loglevel', '0',
|
'-hide_banner',
|
||||||
'-f', 's16le',
|
'-f', 's16le',
|
||||||
'-ar', '48000',
|
'-ar', '48000',
|
||||||
'-ac', 2,
|
'-ac', 2,
|
||||||
'pipe:1'
|
'pipe:1'
|
||||||
]);
|
]);
|
||||||
var enc = cpoc.spawn(this.getCommand(), options, {stdio: ['pipe', 'pipe', 'ignore']});
|
var enc = cpoc.spawn(this.getCommand(), options);
|
||||||
|
|
||||||
enc.stdout.pipe(this.volume);
|
enc.stdout.pipe(this.volume);
|
||||||
|
enc.stderr.on("data", (data) => {
|
||||||
|
reject(new Error("FFMPEG: " + new Buffer(data).toString().trim()));
|
||||||
|
});
|
||||||
|
|
||||||
this.volume.once("readable", () => {
|
this.volume.once("readable", () => {
|
||||||
resolve({
|
resolve({
|
||||||
|
|||||||
Reference in New Issue
Block a user