mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 09:03:29 +01:00
Fix arbitrary ffmpeg
This commit is contained in:
@@ -107,9 +107,9 @@ export default class AudioEncoder {
|
||||
});
|
||||
}
|
||||
|
||||
encodeArbitraryFFmpeg(ffmpegOptions, volume) {
|
||||
encodeArbitraryFFmpeg(ffmpegOptions, options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.volume = new VolumeTransformer(volume);
|
||||
this.volume = new VolumeTransformer(options.volume);
|
||||
|
||||
var command = this.getCommand();
|
||||
|
||||
@@ -117,13 +117,13 @@ export default class AudioEncoder {
|
||||
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([
|
||||
var ffmpegOptions = ffmpegOptions.concat([
|
||||
'-f', 's16le',
|
||||
'-ar', '48000',
|
||||
'-ac', 2,
|
||||
'pipe:1'
|
||||
]);
|
||||
var enc = cpoc.spawn(command, options);
|
||||
var enc = cpoc.spawn(command, ffmpegOptions);
|
||||
|
||||
this.hookEncodingProcess(resolve, reject, enc);
|
||||
});
|
||||
|
||||
@@ -283,20 +283,23 @@ export default class VoiceConnection extends EventEmitter {
|
||||
})
|
||||
}
|
||||
|
||||
playArbitraryFFmpeg(ffmpegOptions, volume, callback = function (err, str) { }) {
|
||||
playArbitraryFFmpeg(ffmpegOptions, options, callback = function (err, str) { }) {
|
||||
var self = this;
|
||||
self.stopPlaying();
|
||||
if (typeof volume === "function") {
|
||||
// volume is the callback
|
||||
callback = volume;
|
||||
}
|
||||
if (!ffmpegOptions instanceof Array) {
|
||||
ffmpegOptions = [];
|
||||
}
|
||||
var volume = volume !== undefined ? volume : this.getVolume();
|
||||
if (typeof options === "function") {
|
||||
// options is the callback
|
||||
callback = options;
|
||||
}
|
||||
if (typeof options !== "object") {
|
||||
options = {};
|
||||
}
|
||||
options.volume = options.volume !== undefined ? options.volume : this.getVolume();
|
||||
return new Promise((resolve, reject) => {
|
||||
this.encoder
|
||||
.encodeArbitraryFFmpeg(ffmpegOptions, volume)
|
||||
.encodeArbitraryFFmpeg(ffmpegOptions, options)
|
||||
.catch(error)
|
||||
.then(data => {
|
||||
self.streamProc = data.proc;
|
||||
|
||||
Reference in New Issue
Block a user