mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
Lib output for arbitrary ffmpeg playback
This commit is contained in:
@@ -113,6 +113,33 @@ var AudioEncoder = (function () {
|
||||
});
|
||||
};
|
||||
|
||||
AudioEncoder.prototype.encodeArbitraryFFmpeg = function encodeArbitraryFFmpeg(ffmpegOptions) {
|
||||
var self = this;
|
||||
return new Promise(function (resolve, reject) {
|
||||
// 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(self.getCommand(), options, { stdio: ['pipe', 'pipe', 'ignore'] });
|
||||
|
||||
enc.stdout.once("readable", function () {
|
||||
resolve({
|
||||
proc: enc,
|
||||
stream: enc.stdout,
|
||||
channels: 2
|
||||
});
|
||||
});
|
||||
|
||||
enc.stdout.on("end", function () {
|
||||
console.log("end");
|
||||
reject("end");
|
||||
});
|
||||
|
||||
enc.stdout.on("close", function () {
|
||||
console.log("close");
|
||||
reject("close");
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
return AudioEncoder;
|
||||
})();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user