add @discordjs/opus + jmd.js
This commit is contained in:
7
node_modules/prism-media/src/core/FFmpeg.js
generated
vendored
7
node_modules/prism-media/src/core/FFmpeg.js
generated
vendored
@@ -25,6 +25,7 @@ class FFmpeg extends Duplex {
|
||||
* @memberof core
|
||||
* @param {Object} options Options you would pass to a regular Transform stream, plus an `args` option
|
||||
* @param {Array<string>} options.args Arguments to pass to FFmpeg
|
||||
* @param {boolean} [options.shell=false] Whether FFmpeg should be spawned inside a shell
|
||||
* @example
|
||||
* // By default, if you don't specify an input (`-i ...`) prism will assume you're piping a stream into it.
|
||||
* const transcoder = new prism.FFmpeg({
|
||||
@@ -41,7 +42,7 @@ class FFmpeg extends Duplex {
|
||||
*/
|
||||
constructor(options = {}) {
|
||||
super();
|
||||
this.process = FFmpeg.create(options);
|
||||
this.process = FFmpeg.create({ shell: false, ...options });
|
||||
const EVENTS = {
|
||||
readable: this._reader,
|
||||
data: this._reader,
|
||||
@@ -150,9 +151,9 @@ class FFmpeg extends Duplex {
|
||||
* @private
|
||||
* @throws Will throw an error if FFmpeg cannot be found.
|
||||
*/
|
||||
static create({ args = [] } = {}) {
|
||||
static create({ args = [], shell = false } = {}) {
|
||||
if (!args.includes('-i')) args.unshift('-i', '-');
|
||||
return ChildProcess.spawn(FFmpeg.getInfo().command, args.concat(['pipe:1']), { windowsHide: true });
|
||||
return ChildProcess.spawn(FFmpeg.getInfo().command, args.concat(['pipe:1']), { windowsHide: true, shell });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
5
node_modules/prism-media/src/core/VolumeTransformer.js
generated
vendored
5
node_modules/prism-media/src/core/VolumeTransformer.js
generated
vendored
@@ -66,16 +66,15 @@ class VolumeTransformer extends Transform {
|
||||
chunk = this._chunk = Buffer.concat([this._chunk, chunk]);
|
||||
if (chunk.length < _bytes) return done();
|
||||
|
||||
const transformed = Buffer.allocUnsafe(chunk.length);
|
||||
const complete = Math.floor(chunk.length / _bytes) * _bytes;
|
||||
|
||||
for (let i = 0; i < complete; i += _bytes) {
|
||||
const int = Math.min(_extremum - 1, Math.max(-_extremum, Math.floor(this.volume * this._readInt(chunk, i))));
|
||||
this._writeInt(transformed, int, i);
|
||||
this._writeInt(chunk, int, i);
|
||||
}
|
||||
|
||||
this._chunk = chunk.slice(complete);
|
||||
this.push(transformed);
|
||||
this.push(chunk.slice(0, complete));
|
||||
return done();
|
||||
}
|
||||
|
||||
|
||||
10
node_modules/prism-media/src/opus/Opus.js
generated
vendored
10
node_modules/prism-media/src/opus/Opus.js
generated
vendored
@@ -150,11 +150,11 @@ class Encoder extends OpusStream {
|
||||
this._buffer = Buffer.alloc(0);
|
||||
}
|
||||
|
||||
async _transform(chunk, encoding, done) {
|
||||
_transform(chunk, encoding, done) {
|
||||
this._buffer = Buffer.concat([this._buffer, chunk]);
|
||||
let n = 0;
|
||||
while (this._buffer.length >= this._required * (n + 1)) {
|
||||
const buf = await this._encode(this._buffer.slice(n * this._required, (n + 1) * this._required));
|
||||
const buf = this._encode(this._buffer.slice(n * this._required, (n + 1) * this._required));
|
||||
this.push(buf);
|
||||
n++;
|
||||
}
|
||||
@@ -200,7 +200,11 @@ class Decoder extends OpusStream {
|
||||
this.emit('tags', chunk);
|
||||
return done();
|
||||
}
|
||||
this.push(this._decode(chunk));
|
||||
try {
|
||||
this.push(this._decode(chunk));
|
||||
} catch (e) {
|
||||
return done(e);
|
||||
}
|
||||
return done();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user