@zygout/eris 0.19.0 → 0.19.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -20
- package/README.md +71 -80
- package/esm.mjs +72 -72
- package/index.d.ts +4407 -4397
- package/index.js +75 -75
- package/lib/Client.js +4708 -4683
- package/lib/Constants.d.ts +990 -988
- package/lib/Constants.js +1163 -1161
- package/lib/command/Command.js +552 -552
- package/lib/command/CommandClient.js +460 -460
- package/lib/errors/DiscordHTTPError.js +63 -63
- package/lib/errors/DiscordRESTError.js +77 -77
- package/lib/gateway/Shard.js +3029 -3029
- package/lib/gateway/ShardManager.js +164 -164
- package/lib/rest/Endpoints.js +172 -172
- package/lib/rest/RequestHandler.js +459 -459
- package/lib/structures/ApplicationCommand.js +125 -125
- package/lib/structures/AutoModerationRule.js +143 -143
- package/lib/structures/AutocompleteInteraction.js +80 -80
- package/lib/structures/Base.js +81 -81
- package/lib/structures/CategoryChannel.js +77 -77
- package/lib/structures/Channel.js +98 -98
- package/lib/structures/CommandInteraction.js +473 -473
- package/lib/structures/ComponentInteraction.js +538 -538
- package/lib/structures/DMChannel.js +278 -278
- package/lib/structures/Entitlement.js +77 -77
- package/lib/structures/ExtendedUser.js +46 -46
- package/lib/structures/ForumChannel.js +24 -24
- package/lib/structures/GroupChannel.js +106 -106
- package/lib/structures/Guild.js +1677 -1677
- package/lib/structures/GuildAuditLogEntry.js +190 -190
- package/lib/structures/GuildChannel.js +128 -128
- package/lib/structures/GuildIntegration.js +99 -99
- package/lib/structures/GuildPreview.js +97 -97
- package/lib/structures/GuildScheduledEvent.js +176 -176
- package/lib/structures/GuildTemplate.js +76 -76
- package/lib/structures/GuildTextableChannel.js +260 -260
- package/lib/structures/Interaction.js +133 -133
- package/lib/structures/Invite.js +143 -143
- package/lib/structures/Lobby.js +108 -108
- package/lib/structures/LobbyMember.js +59 -59
- package/lib/structures/MediaChannel.js +216 -216
- package/lib/structures/Member.js +371 -371
- package/lib/structures/Message.js +708 -708
- package/lib/structures/ModalSubmitInteraction.js +478 -478
- package/lib/structures/NewsChannel.js +34 -34
- package/lib/structures/NewsThreadChannel.js +12 -12
- package/lib/structures/Permission.js +80 -80
- package/lib/structures/PermissionOverwrite.js +32 -32
- package/lib/structures/PingInteraction.js +39 -39
- package/lib/structures/PrivateThreadChannel.js +25 -25
- package/lib/structures/PublicThreadChannel.js +26 -26
- package/lib/structures/Role.js +163 -163
- package/lib/structures/SKU.js +80 -80
- package/lib/structures/SoundboardSound.js +79 -79
- package/lib/structures/StageChannel.js +59 -59
- package/lib/structures/StageInstance.js +55 -55
- package/lib/structures/Subscription.js +69 -69
- package/lib/structures/TextChannel.js +202 -202
- package/lib/structures/ThreadChannel.js +143 -143
- package/lib/structures/ThreadMember.js +59 -59
- package/lib/structures/UnavailableGuild.js +26 -26
- package/lib/structures/UnknownInteraction.js +502 -502
- package/lib/structures/User.js +296 -296
- package/lib/structures/VoiceChannel.js +166 -166
- package/lib/structures/VoiceState.js +84 -84
- package/lib/util/BrowserWebSocket.js +76 -76
- package/lib/util/Bucket.js +89 -89
- package/lib/util/Collection.js +202 -202
- package/lib/util/MultipartData.js +70 -70
- package/lib/util/Opus.js +33 -33
- package/lib/util/SequentialBucket.js +83 -83
- package/lib/util/emitDeprecation.js +26 -26
- package/lib/voice/Piper.js +300 -300
- package/lib/voice/SharedStream.js +238 -238
- package/lib/voice/VoiceConnection.js +1440 -1440
- package/lib/voice/VoiceConnectionManager.js +151 -151
- package/lib/voice/VoiceDataStream.js +22 -22
- package/lib/voice/streams/BaseTransformer.js +40 -40
- package/lib/voice/streams/DCAOpusTransformer.js +78 -78
- package/lib/voice/streams/FFmpegDuplex.js +192 -192
- package/lib/voice/streams/FFmpegOggTransformer.js +35 -35
- package/lib/voice/streams/FFmpegPCMTransformer.js +26 -26
- package/lib/voice/streams/OggOpusTransformer.js +108 -108
- package/lib/voice/streams/PCMOpusTransformer.js +61 -61
- package/lib/voice/streams/VolumeTransformer.js +50 -50
- package/lib/voice/streams/WebmOpusTransformer.js +258 -258
- package/package.json +83 -82
|
@@ -1,192 +1,192 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const util = require("util");
|
|
3
|
-
const Base = require("../../structures/Base");
|
|
4
|
-
const ChildProcess = require("child_process");
|
|
5
|
-
const DuplexStream = require("stream").Duplex;
|
|
6
|
-
const PassThroughStream = require("stream").PassThrough;
|
|
7
|
-
|
|
8
|
-
const delegateEvents = {
|
|
9
|
-
readable: "_reader",
|
|
10
|
-
data: "_reader",
|
|
11
|
-
end: "_reader",
|
|
12
|
-
drain: "_writer",
|
|
13
|
-
finish: "_writer",
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
class FFmpegDuplex extends DuplexStream {
|
|
17
|
-
constructor(command, options = {}) {
|
|
18
|
-
if (options.highWaterMark === undefined) {
|
|
19
|
-
options.highWaterMark = 0;
|
|
20
|
-
}
|
|
21
|
-
super(options);
|
|
22
|
-
|
|
23
|
-
this.command = command;
|
|
24
|
-
this._reader = new PassThroughStream(options);
|
|
25
|
-
this._writer = new PassThroughStream(options);
|
|
26
|
-
|
|
27
|
-
this._onError = this.emit.bind(this, "error");
|
|
28
|
-
|
|
29
|
-
this._reader.on("error", this._onError);
|
|
30
|
-
this._writer.on("error", this._onError);
|
|
31
|
-
|
|
32
|
-
this._readableState = this._reader._readableState;
|
|
33
|
-
this._writableState = this._writer._writableState;
|
|
34
|
-
|
|
35
|
-
["on", "once", "removeListener", "removeListeners", "listeners"].forEach((method) => {
|
|
36
|
-
const og = DuplexStream.prototype[method];
|
|
37
|
-
|
|
38
|
-
this[method] = function (ev, fn) {
|
|
39
|
-
const substream = delegateEvents[ev];
|
|
40
|
-
if (substream) {
|
|
41
|
-
return this[substream][method](ev, fn);
|
|
42
|
-
} else {
|
|
43
|
-
return og.call(this, ev, fn);
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
destroy() {
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
end(chunk, enc, cb) {
|
|
53
|
-
return this._writer.end(chunk, enc, cb);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
kill() {
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
noop() {
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
pipe(dest, opts) {
|
|
63
|
-
return this._reader.pipe(dest, opts);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
read(size) {
|
|
67
|
-
return this._reader.read(size);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
setEncoding(enc) {
|
|
71
|
-
return this._reader.setEncoding(enc);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
spawn(args, options = {}) {
|
|
75
|
-
let ex, exited, killed, ended;
|
|
76
|
-
let stderr = [];
|
|
77
|
-
|
|
78
|
-
const onStdoutEnd = () => {
|
|
79
|
-
if (exited && !ended) {
|
|
80
|
-
ended = true;
|
|
81
|
-
this._reader.end();
|
|
82
|
-
setImmediate(this.emit.bind(this, "close"));
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
const onStderrData = (chunk) => {
|
|
87
|
-
stderr.push(chunk);
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
const cleanup = () => {
|
|
91
|
-
this._process = this._stderr = this._stdout = this._stdin = stderr = ex = killed = null;
|
|
92
|
-
|
|
93
|
-
this.kill = this.destroy = this.noop;
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
const onExit = (code, signal) => {
|
|
97
|
-
if (exited) {
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
exited = true;
|
|
101
|
-
|
|
102
|
-
if (killed) {
|
|
103
|
-
if (ex) {
|
|
104
|
-
this.emit("error", ex);
|
|
105
|
-
}
|
|
106
|
-
this.emit("close");
|
|
107
|
-
} else if (code === 0 && signal == null) {
|
|
108
|
-
// All is well
|
|
109
|
-
onStdoutEnd();
|
|
110
|
-
} else {
|
|
111
|
-
// Everything else
|
|
112
|
-
ex = new Error("Command failed: " + Buffer.concat(stderr).toString("utf8"));
|
|
113
|
-
ex.killed = this._process.killed || killed;
|
|
114
|
-
ex.code = code;
|
|
115
|
-
ex.signal = signal;
|
|
116
|
-
this.emit("error", ex);
|
|
117
|
-
this.emit("close");
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
cleanup();
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
const onError = (err) => {
|
|
124
|
-
ex = err;
|
|
125
|
-
this._stdout.destroy();
|
|
126
|
-
this._stderr.destroy();
|
|
127
|
-
onExit();
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
const kill = () => {
|
|
131
|
-
if (killed) {
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
this._stdout.destroy();
|
|
135
|
-
this._stderr.destroy();
|
|
136
|
-
|
|
137
|
-
killed = true;
|
|
138
|
-
|
|
139
|
-
try {
|
|
140
|
-
this._process.kill(options.killSignal || "SIGTERM");
|
|
141
|
-
setTimeout(() => this._process && this._process.kill("SIGKILL"), 2000);
|
|
142
|
-
} catch (e) {
|
|
143
|
-
ex = e;
|
|
144
|
-
onExit();
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
this._process = ChildProcess.spawn(this.command, args, options);
|
|
149
|
-
this._stdin = this._process.stdin;
|
|
150
|
-
this._stdout = this._process.stdout;
|
|
151
|
-
this._stderr = this._process.stderr;
|
|
152
|
-
this._writer.pipe(this._stdin);
|
|
153
|
-
this._stdout.pipe(this._reader, {
|
|
154
|
-
end: false,
|
|
155
|
-
});
|
|
156
|
-
this.kill = this.destroy = kill;
|
|
157
|
-
|
|
158
|
-
this._stderr.on("data", onStderrData);
|
|
159
|
-
|
|
160
|
-
// In some cases ECONNRESET can be emitted by stdin because the process is not interested in any
|
|
161
|
-
// more data but the _writer is still piping. Forget about errors emitted on stdin and stdout
|
|
162
|
-
this._stdin.on("error", this.noop);
|
|
163
|
-
this._stdout.on("error", this.noop);
|
|
164
|
-
|
|
165
|
-
this._stdout.on("end", onStdoutEnd);
|
|
166
|
-
|
|
167
|
-
this._process.once("close", onExit);
|
|
168
|
-
this._process.once("error", onError);
|
|
169
|
-
|
|
170
|
-
return this;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
unpipe(dest) {
|
|
174
|
-
return this._reader.unpipe(dest) || this.kill();
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
write(chunk, enc, cb) {
|
|
178
|
-
return this._writer.write(chunk, enc, cb);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
[util.inspect.custom]() {
|
|
182
|
-
return Base.prototype[util.inspect.custom].call(this);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
FFmpegDuplex.prototype.addListener = FFmpegDuplex.prototype.on;
|
|
187
|
-
|
|
188
|
-
FFmpegDuplex.spawn = function (connection, args, options) {
|
|
189
|
-
return new FFmpegDuplex(connection, options).spawn(args, options);
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
module.exports = FFmpegDuplex;
|
|
1
|
+
"use strict";
|
|
2
|
+
const util = require("util");
|
|
3
|
+
const Base = require("../../structures/Base");
|
|
4
|
+
const ChildProcess = require("child_process");
|
|
5
|
+
const DuplexStream = require("stream").Duplex;
|
|
6
|
+
const PassThroughStream = require("stream").PassThrough;
|
|
7
|
+
|
|
8
|
+
const delegateEvents = {
|
|
9
|
+
readable: "_reader",
|
|
10
|
+
data: "_reader",
|
|
11
|
+
end: "_reader",
|
|
12
|
+
drain: "_writer",
|
|
13
|
+
finish: "_writer",
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
class FFmpegDuplex extends DuplexStream {
|
|
17
|
+
constructor(command, options = {}) {
|
|
18
|
+
if (options.highWaterMark === undefined) {
|
|
19
|
+
options.highWaterMark = 0;
|
|
20
|
+
}
|
|
21
|
+
super(options);
|
|
22
|
+
|
|
23
|
+
this.command = command;
|
|
24
|
+
this._reader = new PassThroughStream(options);
|
|
25
|
+
this._writer = new PassThroughStream(options);
|
|
26
|
+
|
|
27
|
+
this._onError = this.emit.bind(this, "error");
|
|
28
|
+
|
|
29
|
+
this._reader.on("error", this._onError);
|
|
30
|
+
this._writer.on("error", this._onError);
|
|
31
|
+
|
|
32
|
+
this._readableState = this._reader._readableState;
|
|
33
|
+
this._writableState = this._writer._writableState;
|
|
34
|
+
|
|
35
|
+
["on", "once", "removeListener", "removeListeners", "listeners"].forEach((method) => {
|
|
36
|
+
const og = DuplexStream.prototype[method];
|
|
37
|
+
|
|
38
|
+
this[method] = function (ev, fn) {
|
|
39
|
+
const substream = delegateEvents[ev];
|
|
40
|
+
if (substream) {
|
|
41
|
+
return this[substream][method](ev, fn);
|
|
42
|
+
} else {
|
|
43
|
+
return og.call(this, ev, fn);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
destroy() {
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
end(chunk, enc, cb) {
|
|
53
|
+
return this._writer.end(chunk, enc, cb);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
kill() {
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
noop() {
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
pipe(dest, opts) {
|
|
63
|
+
return this._reader.pipe(dest, opts);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
read(size) {
|
|
67
|
+
return this._reader.read(size);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
setEncoding(enc) {
|
|
71
|
+
return this._reader.setEncoding(enc);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
spawn(args, options = {}) {
|
|
75
|
+
let ex, exited, killed, ended;
|
|
76
|
+
let stderr = [];
|
|
77
|
+
|
|
78
|
+
const onStdoutEnd = () => {
|
|
79
|
+
if (exited && !ended) {
|
|
80
|
+
ended = true;
|
|
81
|
+
this._reader.end();
|
|
82
|
+
setImmediate(this.emit.bind(this, "close"));
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const onStderrData = (chunk) => {
|
|
87
|
+
stderr.push(chunk);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const cleanup = () => {
|
|
91
|
+
this._process = this._stderr = this._stdout = this._stdin = stderr = ex = killed = null;
|
|
92
|
+
|
|
93
|
+
this.kill = this.destroy = this.noop;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const onExit = (code, signal) => {
|
|
97
|
+
if (exited) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
exited = true;
|
|
101
|
+
|
|
102
|
+
if (killed) {
|
|
103
|
+
if (ex) {
|
|
104
|
+
this.emit("error", ex);
|
|
105
|
+
}
|
|
106
|
+
this.emit("close");
|
|
107
|
+
} else if (code === 0 && signal == null) {
|
|
108
|
+
// All is well
|
|
109
|
+
onStdoutEnd();
|
|
110
|
+
} else {
|
|
111
|
+
// Everything else
|
|
112
|
+
ex = new Error("Command failed: " + Buffer.concat(stderr).toString("utf8"));
|
|
113
|
+
ex.killed = this._process.killed || killed;
|
|
114
|
+
ex.code = code;
|
|
115
|
+
ex.signal = signal;
|
|
116
|
+
this.emit("error", ex);
|
|
117
|
+
this.emit("close");
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
cleanup();
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const onError = (err) => {
|
|
124
|
+
ex = err;
|
|
125
|
+
this._stdout.destroy();
|
|
126
|
+
this._stderr.destroy();
|
|
127
|
+
onExit();
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const kill = () => {
|
|
131
|
+
if (killed) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
this._stdout.destroy();
|
|
135
|
+
this._stderr.destroy();
|
|
136
|
+
|
|
137
|
+
killed = true;
|
|
138
|
+
|
|
139
|
+
try {
|
|
140
|
+
this._process.kill(options.killSignal || "SIGTERM");
|
|
141
|
+
setTimeout(() => this._process && this._process.kill("SIGKILL"), 2000);
|
|
142
|
+
} catch (e) {
|
|
143
|
+
ex = e;
|
|
144
|
+
onExit();
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
this._process = ChildProcess.spawn(this.command, args, options);
|
|
149
|
+
this._stdin = this._process.stdin;
|
|
150
|
+
this._stdout = this._process.stdout;
|
|
151
|
+
this._stderr = this._process.stderr;
|
|
152
|
+
this._writer.pipe(this._stdin);
|
|
153
|
+
this._stdout.pipe(this._reader, {
|
|
154
|
+
end: false,
|
|
155
|
+
});
|
|
156
|
+
this.kill = this.destroy = kill;
|
|
157
|
+
|
|
158
|
+
this._stderr.on("data", onStderrData);
|
|
159
|
+
|
|
160
|
+
// In some cases ECONNRESET can be emitted by stdin because the process is not interested in any
|
|
161
|
+
// more data but the _writer is still piping. Forget about errors emitted on stdin and stdout
|
|
162
|
+
this._stdin.on("error", this.noop);
|
|
163
|
+
this._stdout.on("error", this.noop);
|
|
164
|
+
|
|
165
|
+
this._stdout.on("end", onStdoutEnd);
|
|
166
|
+
|
|
167
|
+
this._process.once("close", onExit);
|
|
168
|
+
this._process.once("error", onError);
|
|
169
|
+
|
|
170
|
+
return this;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
unpipe(dest) {
|
|
174
|
+
return this._reader.unpipe(dest) || this.kill();
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
write(chunk, enc, cb) {
|
|
178
|
+
return this._writer.write(chunk, enc, cb);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
[util.inspect.custom]() {
|
|
182
|
+
return Base.prototype[util.inspect.custom].call(this);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
FFmpegDuplex.prototype.addListener = FFmpegDuplex.prototype.on;
|
|
187
|
+
|
|
188
|
+
FFmpegDuplex.spawn = function (connection, args, options) {
|
|
189
|
+
return new FFmpegDuplex(connection, options).spawn(args, options);
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
module.exports = FFmpegDuplex;
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const FFmpegDuplex = require("./FFmpegDuplex");
|
|
4
|
-
|
|
5
|
-
module.exports = function (options = {}) {
|
|
6
|
-
if (!options.command) {
|
|
7
|
-
throw new Error("Invalid converter command");
|
|
8
|
-
}
|
|
9
|
-
if (options.frameDuration === undefined) {
|
|
10
|
-
options.frameDuration = 60;
|
|
11
|
-
}
|
|
12
|
-
let inputArgs = [
|
|
13
|
-
"-analyzeduration", "0",
|
|
14
|
-
"-loglevel", "24",
|
|
15
|
-
].concat(options.inputArgs || []);
|
|
16
|
-
if (options.format === "pcm") {
|
|
17
|
-
inputArgs = inputArgs.concat(
|
|
18
|
-
"-f", "s16le",
|
|
19
|
-
"-ar", "48000",
|
|
20
|
-
"-ac", "2",
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
inputArgs = inputArgs.concat(
|
|
24
|
-
"-i", options.input || "-",
|
|
25
|
-
"-vn",
|
|
26
|
-
);
|
|
27
|
-
const outputArgs = [
|
|
28
|
-
"-c:a", "libopus",
|
|
29
|
-
"-vbr", "on",
|
|
30
|
-
"-frame_duration", "" + options.frameDuration,
|
|
31
|
-
"-f", "ogg",
|
|
32
|
-
"-",
|
|
33
|
-
];
|
|
34
|
-
return FFmpegDuplex.spawn(options.command, inputArgs.concat(options.encoderArgs || [], outputArgs));
|
|
35
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const FFmpegDuplex = require("./FFmpegDuplex");
|
|
4
|
+
|
|
5
|
+
module.exports = function (options = {}) {
|
|
6
|
+
if (!options.command) {
|
|
7
|
+
throw new Error("Invalid converter command");
|
|
8
|
+
}
|
|
9
|
+
if (options.frameDuration === undefined) {
|
|
10
|
+
options.frameDuration = 60;
|
|
11
|
+
}
|
|
12
|
+
let inputArgs = [
|
|
13
|
+
"-analyzeduration", "0",
|
|
14
|
+
"-loglevel", "24",
|
|
15
|
+
].concat(options.inputArgs || []);
|
|
16
|
+
if (options.format === "pcm") {
|
|
17
|
+
inputArgs = inputArgs.concat(
|
|
18
|
+
"-f", "s16le",
|
|
19
|
+
"-ar", "48000",
|
|
20
|
+
"-ac", "2",
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
inputArgs = inputArgs.concat(
|
|
24
|
+
"-i", options.input || "-",
|
|
25
|
+
"-vn",
|
|
26
|
+
);
|
|
27
|
+
const outputArgs = [
|
|
28
|
+
"-c:a", "libopus",
|
|
29
|
+
"-vbr", "on",
|
|
30
|
+
"-frame_duration", "" + options.frameDuration,
|
|
31
|
+
"-f", "ogg",
|
|
32
|
+
"-",
|
|
33
|
+
];
|
|
34
|
+
return FFmpegDuplex.spawn(options.command, inputArgs.concat(options.encoderArgs || [], outputArgs));
|
|
35
|
+
};
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const FFmpegDuplex = require("./FFmpegDuplex");
|
|
4
|
-
|
|
5
|
-
module.exports = function (options = {}) {
|
|
6
|
-
if (!options.command) {
|
|
7
|
-
throw new Error("Invalid converter command");
|
|
8
|
-
}
|
|
9
|
-
if (options.samplingRate === undefined) {
|
|
10
|
-
options.samplingRate = 48000;
|
|
11
|
-
}
|
|
12
|
-
const inputArgs = [
|
|
13
|
-
"-analyzeduration", "0",
|
|
14
|
-
"-loglevel", "24",
|
|
15
|
-
].concat(options.inputArgs || [],
|
|
16
|
-
"-i", options.input || "-",
|
|
17
|
-
"-vn",
|
|
18
|
-
);
|
|
19
|
-
const outputArgs = [
|
|
20
|
-
"-f", "s16le",
|
|
21
|
-
"-ar", "" + options.samplingRate,
|
|
22
|
-
"-ac", "2",
|
|
23
|
-
"-",
|
|
24
|
-
];
|
|
25
|
-
return FFmpegDuplex.spawn(options.command, inputArgs.concat(options.encoderArgs || [], outputArgs));
|
|
26
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const FFmpegDuplex = require("./FFmpegDuplex");
|
|
4
|
+
|
|
5
|
+
module.exports = function (options = {}) {
|
|
6
|
+
if (!options.command) {
|
|
7
|
+
throw new Error("Invalid converter command");
|
|
8
|
+
}
|
|
9
|
+
if (options.samplingRate === undefined) {
|
|
10
|
+
options.samplingRate = 48000;
|
|
11
|
+
}
|
|
12
|
+
const inputArgs = [
|
|
13
|
+
"-analyzeduration", "0",
|
|
14
|
+
"-loglevel", "24",
|
|
15
|
+
].concat(options.inputArgs || [],
|
|
16
|
+
"-i", options.input || "-",
|
|
17
|
+
"-vn",
|
|
18
|
+
);
|
|
19
|
+
const outputArgs = [
|
|
20
|
+
"-f", "s16le",
|
|
21
|
+
"-ar", "" + options.samplingRate,
|
|
22
|
+
"-ac", "2",
|
|
23
|
+
"-",
|
|
24
|
+
];
|
|
25
|
+
return FFmpegDuplex.spawn(options.command, inputArgs.concat(options.encoderArgs || [], outputArgs));
|
|
26
|
+
};
|