mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 18:43:31 +01:00
Attempted better ffmpeg handling
This commit is contained in:
@@ -90,9 +90,17 @@ var AudioEncoder = (function () {
|
|||||||
var enc = _child_process2["default"].spawn(_this.getCommand(), ['-hide_banner', '-i', '-', '-f', 's16le', '-ar', '48000', '-ss', options.seek || 0, '-ac', 2, 'pipe:1']);
|
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);
|
||||||
|
|
||||||
|
var ffmpegErrors = "";
|
||||||
|
|
||||||
enc.stdout.pipe(_this.volume);
|
enc.stdout.pipe(_this.volume);
|
||||||
enc.stderr.on("data", function (data) {
|
enc.stderr.on("data", function (data) {
|
||||||
reject(new Error("FFMPEG: " + new Buffer(data).toString().trim()));
|
ffmpegErrors += "\n" + new Buffer(data).toString().trim();
|
||||||
|
});
|
||||||
|
enc.once("exit", function (code, signal) {
|
||||||
|
if (code) {
|
||||||
|
reject(new Error("FFMPEG: " + ffmpegErrors));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
_this.volume.once("readable", function () {
|
_this.volume.once("readable", function () {
|
||||||
@@ -122,9 +130,16 @@ var AudioEncoder = (function () {
|
|||||||
|
|
||||||
var enc = _child_process2["default"].spawn(_this2.getCommand(), ['-hide_banner', '-i', file, '-f', 's16le', '-ar', '48000', '-ss', options.seek || 0, '-ac', 2, 'pipe:1']);
|
var enc = _child_process2["default"].spawn(_this2.getCommand(), ['-hide_banner', '-i', file, '-f', 's16le', '-ar', '48000', '-ss', options.seek || 0, '-ac', 2, 'pipe:1']);
|
||||||
|
|
||||||
|
var ffmpegErrors = "";
|
||||||
|
|
||||||
enc.stdout.pipe(_this2.volume);
|
enc.stdout.pipe(_this2.volume);
|
||||||
enc.stderr.on("data", function (data) {
|
enc.stderr.on("data", function (data) {
|
||||||
reject(new Error("FFMPEG: " + new Buffer(data).toString().trim()));
|
ffmpegErrors += "\n" + new Buffer(data).toString().trim();
|
||||||
|
});
|
||||||
|
enc.once("exit", function (code, signal) {
|
||||||
|
if (code) {
|
||||||
|
reject(new Error("FFMPEG: " + ffmpegErrors));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
_this2.volume.once("readable", function () {
|
_this2.volume.once("readable", function () {
|
||||||
@@ -155,9 +170,16 @@ var AudioEncoder = (function () {
|
|||||||
var options = ffmpegOptions.concat(['-hide_banner', '-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);
|
var enc = _child_process2["default"].spawn(_this3.getCommand(), options);
|
||||||
|
|
||||||
|
var ffmpegErrors = "";
|
||||||
|
|
||||||
enc.stdout.pipe(_this3.volume);
|
enc.stdout.pipe(_this3.volume);
|
||||||
enc.stderr.on("data", function (data) {
|
enc.stderr.on("data", function (data) {
|
||||||
reject(new Error("FFMPEG: " + new Buffer(data).toString().trim()));
|
ffmpegErrors += "\n" + new Buffer(data).toString().trim();
|
||||||
|
});
|
||||||
|
enc.once("exit", function (code, signal) {
|
||||||
|
if (code) {
|
||||||
|
reject(new Error("FFMPEG: " + ffmpegErrors));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
_this3.volume.once("readable", function () {
|
_this3.volume.once("readable", function () {
|
||||||
|
|||||||
@@ -73,10 +73,18 @@ export default class AudioEncoder {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
stream.pipe(enc.stdin);
|
stream.pipe(enc.stdin);
|
||||||
|
|
||||||
|
var ffmpegErrors = "";
|
||||||
|
|
||||||
enc.stdout.pipe(this.volume);
|
enc.stdout.pipe(this.volume);
|
||||||
enc.stderr.on("data", (data) => {
|
enc.stderr.on("data", (data) => {
|
||||||
reject(new Error("FFMPEG: " + new Buffer(data).toString().trim()));
|
ffmpegErrors += "\n" + new Buffer(data).toString().trim();
|
||||||
});
|
});
|
||||||
|
enc.once("exit", (code, signal) => {
|
||||||
|
if (code) {
|
||||||
|
reject(new Error("FFMPEG: " + ffmpegErrors));
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
this.volume.once("readable", () => {
|
this.volume.once("readable", () => {
|
||||||
resolve({
|
resolve({
|
||||||
@@ -111,10 +119,17 @@ export default class AudioEncoder {
|
|||||||
'pipe:1'
|
'pipe:1'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
var ffmpegErrors = "";
|
||||||
|
|
||||||
enc.stdout.pipe(this.volume);
|
enc.stdout.pipe(this.volume);
|
||||||
enc.stderr.on("data", (data) => {
|
enc.stderr.on("data", (data) => {
|
||||||
reject(new Error("FFMPEG: " + new Buffer(data).toString().trim()));
|
ffmpegErrors += "\n" + new Buffer(data).toString().trim();
|
||||||
});
|
});
|
||||||
|
enc.once("exit", (code, signal) => {
|
||||||
|
if (code) {
|
||||||
|
reject(new Error("FFMPEG: " + ffmpegErrors));
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
this.volume.once("readable", () => {
|
this.volume.once("readable", () => {
|
||||||
resolve({
|
resolve({
|
||||||
@@ -148,10 +163,17 @@ export default class AudioEncoder {
|
|||||||
]);
|
]);
|
||||||
var enc = cpoc.spawn(this.getCommand(), options);
|
var enc = cpoc.spawn(this.getCommand(), options);
|
||||||
|
|
||||||
|
var ffmpegErrors = "";
|
||||||
|
|
||||||
enc.stdout.pipe(this.volume);
|
enc.stdout.pipe(this.volume);
|
||||||
enc.stderr.on("data", (data) => {
|
enc.stderr.on("data", (data) => {
|
||||||
reject(new Error("FFMPEG: " + new Buffer(data).toString().trim()));
|
ffmpegErrors += "\n" + new Buffer(data).toString().trim();
|
||||||
});
|
});
|
||||||
|
enc.once("exit", (code, signal) => {
|
||||||
|
if (code) {
|
||||||
|
reject(new Error("FFMPEG: " + ffmpegErrors));
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
this.volume.once("readable", () => {
|
this.volume.once("readable", () => {
|
||||||
resolve({
|
resolve({
|
||||||
|
|||||||
Reference in New Issue
Block a user