Revert "add @discordjs/opus + jmd.js"

This reverts commit 5c2e0737c0.
This commit is contained in:
2021-04-11 12:15:40 +02:00
parent 5c2e0737c0
commit ead89a22d8
977 changed files with 1074 additions and 199471 deletions

View File

@@ -1,27 +1,27 @@
{
"_from": "prism-media@^1.2.9",
"_id": "prism-media@1.2.9",
"_from": "prism-media@^1.2.2",
"_id": "prism-media@1.2.3",
"_inBundle": false,
"_integrity": "sha512-UHCYuqHipbTR1ZsXr5eg4JUmHER8Ss4YEb9Azn+9zzJ7/jlTtD1h0lc4g6tNx3eMlB8Mp6bfll0LPMAV4R6r3Q==",
"_integrity": "sha512-fSrR66n0l6roW9Rx4rSLMyTPTjRTiXy5RVqDOurACQ6si1rKHHKDU5gwBJoCsIV0R3o9gi+K50akl/qyw1C74A==",
"_location": "/prism-media",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "prism-media@^1.2.9",
"raw": "prism-media@^1.2.2",
"name": "prism-media",
"escapedName": "prism-media",
"rawSpec": "^1.2.9",
"rawSpec": "^1.2.2",
"saveSpec": null,
"fetchSpec": "^1.2.9"
"fetchSpec": "^1.2.2"
},
"_requiredBy": [
"/discord.js"
],
"_resolved": "https://registry.npmjs.org/prism-media/-/prism-media-1.2.9.tgz",
"_shasum": "8d4f97b36efdfc82483eb8d3db64020767866f36",
"_spec": "prism-media@^1.2.9",
"_where": "C:\\Users\\j4kub\\Desktop\\git\\gractwo-bot\\node_modules\\discord.js",
"_resolved": "https://registry.npmjs.org/prism-media/-/prism-media-1.2.3.tgz",
"_shasum": "37bbb11726674a73fe56a2df4de76aa91d2141b7",
"_spec": "prism-media@^1.2.2",
"_where": "C:\\Users\\j4kub\\Desktop\\code\\git\\gractwo-bot\\node_modules\\discord.js",
"author": {
"name": "Amish Shah",
"email": "amishshah.2k@gmail.com"
@@ -58,10 +58,10 @@
"main": "src/index.js",
"name": "prism-media",
"peerDependencies": {
"@discordjs/opus": "^0.5.0",
"ffmpeg-static": "^4.2.7 || ^3.0.0 || ^2.4.0",
"@discordjs/opus": "^0.3.3",
"node-opus": "^0.3.3",
"opusscript": "^0.0.8"
"opusscript": "^0.0.7"
},
"peerDependenciesMeta": {
"@discordjs/opus": {
@@ -87,5 +87,5 @@
"test": "npm run lint && jest && npm run docs"
},
"types": "typings/index.d.ts",
"version": "1.2.9"
"version": "1.2.3"
}

View File

@@ -25,7 +25,6 @@ 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({
@@ -42,7 +41,7 @@ class FFmpeg extends Duplex {
*/
constructor(options = {}) {
super();
this.process = FFmpeg.create({ shell: false, ...options });
this.process = FFmpeg.create(options);
const EVENTS = {
readable: this._reader,
data: this._reader,
@@ -151,9 +150,9 @@ class FFmpeg extends Duplex {
* @private
* @throws Will throw an error if FFmpeg cannot be found.
*/
static create({ args = [], shell = false } = {}) {
static create({ args = [] } = {}) {
if (!args.includes('-i')) args.unshift('-i', '-');
return ChildProcess.spawn(FFmpeg.getInfo().command, args.concat(['pipe:1']), { windowsHide: true, shell });
return ChildProcess.spawn(FFmpeg.getInfo().command, args.concat(['pipe:1']), { windowsHide: true });
}
}

View File

@@ -66,15 +66,16 @@ 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(chunk, int, i);
this._writeInt(transformed, int, i);
}
this._chunk = chunk.slice(complete);
this.push(chunk.slice(0, complete));
this.push(transformed);
return done();
}

View File

@@ -150,11 +150,11 @@ class Encoder extends OpusStream {
this._buffer = Buffer.alloc(0);
}
_transform(chunk, encoding, done) {
async _transform(chunk, encoding, done) {
this._buffer = Buffer.concat([this._buffer, chunk]);
let n = 0;
while (this._buffer.length >= this._required * (n + 1)) {
const buf = this._encode(this._buffer.slice(n * this._required, (n + 1) * this._required));
const buf = await this._encode(this._buffer.slice(n * this._required, (n + 1) * this._required));
this.push(buf);
n++;
}
@@ -200,11 +200,7 @@ class Decoder extends OpusStream {
this.emit('tags', chunk);
return done();
}
try {
this.push(this._decode(chunk));
} catch (e) {
return done(e);
}
this.push(this._decode(chunk));
return done();
}
}

View File

@@ -8,14 +8,12 @@ import { vorbis } from './vorbis';
export interface FFmpegOptions {
args?: string[];
shell?: boolean;
}
export interface FFmpegInfo {
command: string;
info: string;
version: string;
output: string;
}
export class FFmpeg extends Duplex {