discord-player 5.3.2-dev.2 → 5.3.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/dist/index.js CHANGED
@@ -1,34 +1,38 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.version = exports.Util = exports.StreamDispatcher = exports.VoiceUtils = exports.Track = exports.Queue = exports.QueryResolver = exports.ErrorStatusCode = exports.PlayerError = exports.Player = exports.Playlist = exports.ExtractorModel = exports.AudioFilters = void 0;
4
- const tslib_1 = require("tslib");
5
- // try applying smooth volume patch on load
6
- require("./smoothVolume");
7
- var AudioFilters_1 = require("./utils/AudioFilters");
8
- Object.defineProperty(exports, "AudioFilters", { enumerable: true, get: function () { return AudioFilters_1.AudioFilters; } });
9
- var ExtractorModel_1 = require("./Structures/ExtractorModel");
10
- Object.defineProperty(exports, "ExtractorModel", { enumerable: true, get: function () { return ExtractorModel_1.ExtractorModel; } });
11
- var Playlist_1 = require("./Structures/Playlist");
12
- Object.defineProperty(exports, "Playlist", { enumerable: true, get: function () { return Playlist_1.Playlist; } });
13
- var Player_1 = require("./Player");
14
- Object.defineProperty(exports, "Player", { enumerable: true, get: function () { return Player_1.Player; } });
15
- var PlayerError_1 = require("./Structures/PlayerError");
16
- Object.defineProperty(exports, "PlayerError", { enumerable: true, get: function () { return PlayerError_1.PlayerError; } });
17
- Object.defineProperty(exports, "ErrorStatusCode", { enumerable: true, get: function () { return PlayerError_1.ErrorStatusCode; } });
18
- var QueryResolver_1 = require("./utils/QueryResolver");
19
- Object.defineProperty(exports, "QueryResolver", { enumerable: true, get: function () { return QueryResolver_1.QueryResolver; } });
20
- var Queue_1 = require("./Structures/Queue");
21
- Object.defineProperty(exports, "Queue", { enumerable: true, get: function () { return Queue_1.Queue; } });
22
- var Track_1 = require("./Structures/Track");
23
- Object.defineProperty(exports, "Track", { enumerable: true, get: function () { return Track_1.Track; } });
24
- var VoiceUtils_1 = require("./VoiceInterface/VoiceUtils");
25
- Object.defineProperty(exports, "VoiceUtils", { enumerable: true, get: function () { return VoiceUtils_1.VoiceUtils; } });
26
- var StreamDispatcher_1 = require("./VoiceInterface/StreamDispatcher");
27
- Object.defineProperty(exports, "StreamDispatcher", { enumerable: true, get: function () { return StreamDispatcher_1.StreamDispatcher; } });
28
- tslib_1.__exportStar(require("./VoiceInterface/VolumeTransformer"), exports);
29
- var Util_1 = require("./utils/Util");
30
- Object.defineProperty(exports, "Util", { enumerable: true, get: function () { return Util_1.Util; } });
31
- tslib_1.__exportStar(require("./types/types"), exports);
32
- tslib_1.__exportStar(require("./utils/FFmpegStream"), exports);
33
- // eslint-disable-next-line @typescript-eslint/no-var-requires
34
- exports.version = require(`${__dirname}/../package.json`).version;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.version = exports.Util = exports.StreamDispatcher = exports.VoiceUtils = exports.Track = exports.Queue = exports.QueryResolver = exports.ErrorStatusCode = exports.PlayerError = exports.Player = exports.Playlist = exports.ExtractorModel = exports.AudioFilters = void 0;
4
+ const tslib_1 = require("tslib");
5
+ // try applying smooth volume patch on load
6
+ require("./smoothVolume");
7
+ const discord_js_1 = require("discord.js");
8
+ var AudioFilters_1 = require("./utils/AudioFilters");
9
+ Object.defineProperty(exports, "AudioFilters", { enumerable: true, get: function () { return AudioFilters_1.AudioFilters; } });
10
+ var ExtractorModel_1 = require("./Structures/ExtractorModel");
11
+ Object.defineProperty(exports, "ExtractorModel", { enumerable: true, get: function () { return ExtractorModel_1.ExtractorModel; } });
12
+ var Playlist_1 = require("./Structures/Playlist");
13
+ Object.defineProperty(exports, "Playlist", { enumerable: true, get: function () { return Playlist_1.Playlist; } });
14
+ var Player_1 = require("./Player");
15
+ Object.defineProperty(exports, "Player", { enumerable: true, get: function () { return Player_1.Player; } });
16
+ var PlayerError_1 = require("./Structures/PlayerError");
17
+ Object.defineProperty(exports, "PlayerError", { enumerable: true, get: function () { return PlayerError_1.PlayerError; } });
18
+ Object.defineProperty(exports, "ErrorStatusCode", { enumerable: true, get: function () { return PlayerError_1.ErrorStatusCode; } });
19
+ var QueryResolver_1 = require("./utils/QueryResolver");
20
+ Object.defineProperty(exports, "QueryResolver", { enumerable: true, get: function () { return QueryResolver_1.QueryResolver; } });
21
+ var Queue_1 = require("./Structures/Queue");
22
+ Object.defineProperty(exports, "Queue", { enumerable: true, get: function () { return Queue_1.Queue; } });
23
+ var Track_1 = require("./Structures/Track");
24
+ Object.defineProperty(exports, "Track", { enumerable: true, get: function () { return Track_1.Track; } });
25
+ var VoiceUtils_1 = require("./VoiceInterface/VoiceUtils");
26
+ Object.defineProperty(exports, "VoiceUtils", { enumerable: true, get: function () { return VoiceUtils_1.VoiceUtils; } });
27
+ var StreamDispatcher_1 = require("./VoiceInterface/StreamDispatcher");
28
+ Object.defineProperty(exports, "StreamDispatcher", { enumerable: true, get: function () { return StreamDispatcher_1.StreamDispatcher; } });
29
+ tslib_1.__exportStar(require("./VoiceInterface/VolumeTransformer"), exports);
30
+ var Util_1 = require("./utils/Util");
31
+ Object.defineProperty(exports, "Util", { enumerable: true, get: function () { return Util_1.Util; } });
32
+ tslib_1.__exportStar(require("./types/types"), exports);
33
+ tslib_1.__exportStar(require("./utils/FFmpegStream"), exports);
34
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
35
+ exports.version = require(`${__dirname}/../package.json`).version;
36
+ if (!discord_js_1.version.startsWith("14")) {
37
+ process.emitWarning(`Discord.js v${discord_js_1.version} is incompatible with Discord Player v${exports.version}! Please use >=v14.x of Discord.js`);
38
+ }
@@ -1,15 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const VolumeTransformer_1 = require("./VoiceInterface/VolumeTransformer");
4
- if (!("DISABLE_DISCORD_PLAYER_SMOOTH_VOLUME" in process.env)) {
5
- try {
6
- // eslint-disable-next-line
7
- const mod = require("prism-media");
8
- if (typeof mod.VolumeTransformer.hasSmoothing !== "boolean") {
9
- Reflect.set(mod, "VolumeTransformer", VolumeTransformer_1.VolumeTransformer);
10
- }
11
- }
12
- catch {
13
- /* do nothing */
14
- }
15
- }
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const VolumeTransformer_1 = require("./VoiceInterface/VolumeTransformer");
4
+ if (!("DISABLE_DISCORD_PLAYER_SMOOTH_VOLUME" in process.env)) {
5
+ try {
6
+ // eslint-disable-next-line
7
+ const mod = require("prism-media");
8
+ if (typeof mod.VolumeTransformer.hasSmoothing !== "boolean") {
9
+ Reflect.set(mod, "VolumeTransformer", VolumeTransformer_1.VolumeTransformer);
10
+ }
11
+ }
12
+ catch {
13
+ /* do nothing */
14
+ }
15
+ }
@@ -1,58 +1,58 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.QueueRepeatMode = exports.QueryType = void 0;
4
- /**
5
- * The search query type
6
- * This can be one of:
7
- * - AUTO
8
- * - YOUTUBE
9
- * - YOUTUBE_PLAYLIST
10
- * - SOUNDCLOUD_TRACK
11
- * - SOUNDCLOUD_PLAYLIST
12
- * - SOUNDCLOUD
13
- * - SPOTIFY_SONG
14
- * - SPOTIFY_ALBUM
15
- * - SPOTIFY_PLAYLIST
16
- * - FACEBOOK
17
- * - VIMEO
18
- * - ARBITRARY
19
- * - REVERBNATION
20
- * - YOUTUBE_SEARCH
21
- * - YOUTUBE_VIDEO
22
- * - SOUNDCLOUD_SEARCH
23
- * @typedef {number} QueryType
24
- */
25
- var QueryType;
26
- (function (QueryType) {
27
- QueryType[QueryType["AUTO"] = 0] = "AUTO";
28
- QueryType[QueryType["YOUTUBE"] = 1] = "YOUTUBE";
29
- QueryType[QueryType["YOUTUBE_PLAYLIST"] = 2] = "YOUTUBE_PLAYLIST";
30
- QueryType[QueryType["SOUNDCLOUD_TRACK"] = 3] = "SOUNDCLOUD_TRACK";
31
- QueryType[QueryType["SOUNDCLOUD_PLAYLIST"] = 4] = "SOUNDCLOUD_PLAYLIST";
32
- QueryType[QueryType["SOUNDCLOUD"] = 5] = "SOUNDCLOUD";
33
- QueryType[QueryType["SPOTIFY_SONG"] = 6] = "SPOTIFY_SONG";
34
- QueryType[QueryType["SPOTIFY_ALBUM"] = 7] = "SPOTIFY_ALBUM";
35
- QueryType[QueryType["SPOTIFY_PLAYLIST"] = 8] = "SPOTIFY_PLAYLIST";
36
- QueryType[QueryType["FACEBOOK"] = 9] = "FACEBOOK";
37
- QueryType[QueryType["VIMEO"] = 10] = "VIMEO";
38
- QueryType[QueryType["ARBITRARY"] = 11] = "ARBITRARY";
39
- QueryType[QueryType["REVERBNATION"] = 12] = "REVERBNATION";
40
- QueryType[QueryType["YOUTUBE_SEARCH"] = 13] = "YOUTUBE_SEARCH";
41
- QueryType[QueryType["YOUTUBE_VIDEO"] = 14] = "YOUTUBE_VIDEO";
42
- QueryType[QueryType["SOUNDCLOUD_SEARCH"] = 15] = "SOUNDCLOUD_SEARCH";
43
- })(QueryType = exports.QueryType || (exports.QueryType = {}));
44
- /**
45
- * The queue repeat mode. This can be one of:
46
- * - OFF
47
- * - TRACK
48
- * - QUEUE
49
- * - AUTOPLAY
50
- * @typedef {number} QueueRepeatMode
51
- */
52
- var QueueRepeatMode;
53
- (function (QueueRepeatMode) {
54
- QueueRepeatMode[QueueRepeatMode["OFF"] = 0] = "OFF";
55
- QueueRepeatMode[QueueRepeatMode["TRACK"] = 1] = "TRACK";
56
- QueueRepeatMode[QueueRepeatMode["QUEUE"] = 2] = "QUEUE";
57
- QueueRepeatMode[QueueRepeatMode["AUTOPLAY"] = 3] = "AUTOPLAY";
58
- })(QueueRepeatMode = exports.QueueRepeatMode || (exports.QueueRepeatMode = {}));
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QueueRepeatMode = exports.QueryType = void 0;
4
+ /**
5
+ * The search query type
6
+ * This can be one of:
7
+ * - AUTO
8
+ * - YOUTUBE
9
+ * - YOUTUBE_PLAYLIST
10
+ * - SOUNDCLOUD_TRACK
11
+ * - SOUNDCLOUD_PLAYLIST
12
+ * - SOUNDCLOUD
13
+ * - SPOTIFY_SONG
14
+ * - SPOTIFY_ALBUM
15
+ * - SPOTIFY_PLAYLIST
16
+ * - FACEBOOK
17
+ * - VIMEO
18
+ * - ARBITRARY
19
+ * - REVERBNATION
20
+ * - YOUTUBE_SEARCH
21
+ * - YOUTUBE_VIDEO
22
+ * - SOUNDCLOUD_SEARCH
23
+ * @typedef {number} QueryType
24
+ */
25
+ var QueryType;
26
+ (function (QueryType) {
27
+ QueryType[QueryType["AUTO"] = 0] = "AUTO";
28
+ QueryType[QueryType["YOUTUBE"] = 1] = "YOUTUBE";
29
+ QueryType[QueryType["YOUTUBE_PLAYLIST"] = 2] = "YOUTUBE_PLAYLIST";
30
+ QueryType[QueryType["SOUNDCLOUD_TRACK"] = 3] = "SOUNDCLOUD_TRACK";
31
+ QueryType[QueryType["SOUNDCLOUD_PLAYLIST"] = 4] = "SOUNDCLOUD_PLAYLIST";
32
+ QueryType[QueryType["SOUNDCLOUD"] = 5] = "SOUNDCLOUD";
33
+ QueryType[QueryType["SPOTIFY_SONG"] = 6] = "SPOTIFY_SONG";
34
+ QueryType[QueryType["SPOTIFY_ALBUM"] = 7] = "SPOTIFY_ALBUM";
35
+ QueryType[QueryType["SPOTIFY_PLAYLIST"] = 8] = "SPOTIFY_PLAYLIST";
36
+ QueryType[QueryType["FACEBOOK"] = 9] = "FACEBOOK";
37
+ QueryType[QueryType["VIMEO"] = 10] = "VIMEO";
38
+ QueryType[QueryType["ARBITRARY"] = 11] = "ARBITRARY";
39
+ QueryType[QueryType["REVERBNATION"] = 12] = "REVERBNATION";
40
+ QueryType[QueryType["YOUTUBE_SEARCH"] = 13] = "YOUTUBE_SEARCH";
41
+ QueryType[QueryType["YOUTUBE_VIDEO"] = 14] = "YOUTUBE_VIDEO";
42
+ QueryType[QueryType["SOUNDCLOUD_SEARCH"] = 15] = "SOUNDCLOUD_SEARCH";
43
+ })(QueryType = exports.QueryType || (exports.QueryType = {}));
44
+ /**
45
+ * The queue repeat mode. This can be one of:
46
+ * - OFF
47
+ * - TRACK
48
+ * - QUEUE
49
+ * - AUTOPLAY
50
+ * @typedef {number} QueueRepeatMode
51
+ */
52
+ var QueueRepeatMode;
53
+ (function (QueueRepeatMode) {
54
+ QueueRepeatMode[QueueRepeatMode["OFF"] = 0] = "OFF";
55
+ QueueRepeatMode[QueueRepeatMode["TRACK"] = 1] = "TRACK";
56
+ QueueRepeatMode[QueueRepeatMode["QUEUE"] = 2] = "QUEUE";
57
+ QueueRepeatMode[QueueRepeatMode["AUTOPLAY"] = 3] = "AUTOPLAY";
58
+ })(QueueRepeatMode = exports.QueueRepeatMode || (exports.QueueRepeatMode = {}));
@@ -1,97 +1,95 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AudioFilters = void 0;
4
- const bass = (g) => `bass=g=${g}:f=110:w=0.3`;
5
- class AudioFilters {
6
- constructor() {
7
- return AudioFilters;
8
- }
9
- static get filters() {
10
- return {
11
- bassboost_low: bass(15),
12
- bassboost: bass(20),
13
- bassboost_high: bass(30),
14
- "8D": "apulsator=hz=0.09",
15
- vaporwave: "aresample=48000,asetrate=48000*0.8",
16
- nightcore: "aresample=48000,asetrate=48000*1.25",
17
- phaser: "aphaser=in_gain=0.4",
18
- tremolo: "tremolo",
19
- vibrato: "vibrato=f=6.5",
20
- reverse: "areverse",
21
- treble: "treble=g=5",
22
- normalizer2: "dynaudnorm=g=101",
23
- normalizer: "acompressor",
24
- surrounding: "surround",
25
- pulsator: "apulsator=hz=1",
26
- subboost: "asubboost",
27
- karaoke: "stereotools=mlev=0.03",
28
- flanger: "flanger",
29
- gate: "agate",
30
- haas: "haas",
31
- mcompand: "mcompand",
32
- mono: "pan=mono|c0=.5*c0+.5*c1",
33
- mstlr: "stereotools=mode=ms>lr",
34
- mstrr: "stereotools=mode=ms>rr",
35
- compressor: "compand=points=-80/-105|-62/-80|-15.4/-15.4|0/-12|20/-7.6",
36
- expander: "compand=attacks=0:points=-80/-169|-54/-80|-49.5/-64.6|-41.1/-41.1|-25.8/-15|-10.8/-4.5|0/0|20/8.3",
37
- softlimiter: "compand=attacks=0:points=-80/-80|-12.4/-12.4|-6/-8|0/-6.8|20/-2.8",
38
- chorus: "chorus=0.7:0.9:55:0.4:0.25:2",
39
- chorus2d: "chorus=0.6:0.9:50|60:0.4|0.32:0.25|0.4:2|1.3",
40
- chorus3d: "chorus=0.5:0.9:50|60|40:0.4|0.32|0.3:0.25|0.4|0.3:2|2.3|1.3",
41
- fadein: "afade=t=in:ss=0:d=10",
42
- dim: `afftfilt="'real=re * (1-clip((b/nb)*b,0,1))':imag='im * (1-clip((b/nb)*b,0,1))'"`,
43
- earrape: "channelsplit,sidechaingate=level_in=64"
44
- };
45
- }
46
- static get(name) {
47
- return this.filters[name];
48
- }
49
- static has(name) {
50
- return name in this.filters;
51
- }
52
- static *[Symbol.iterator]() {
53
- for (const [k, v] of Object.entries(this.filters)) {
54
- yield { name: k, value: v };
55
- }
56
- }
57
- static get names() {
58
- return Object.keys(this.filters);
59
- }
60
- // @ts-expect-error AudioFilters.length
61
- static get length() {
62
- return this.names.length;
63
- }
64
- static toString() {
65
- return this.names.map((m) => this[m]).join(","); // eslint-disable-line @typescript-eslint/no-explicit-any
66
- }
67
- /**
68
- * Create ffmpeg args from the specified filters name
69
- * @param filter The filter name
70
- * @returns
71
- */
72
- static create(filters) {
73
- if (!filters || !Array.isArray(filters))
74
- return this.toString();
75
- return filters
76
- .filter((predicate) => typeof predicate === "string")
77
- .map((m) => this.get(m))
78
- .join(",");
79
- }
80
- /**
81
- * Defines audio filter
82
- * @param filterName The name of the filter
83
- * @param value The ffmpeg args
84
- */
85
- static define(filterName, value) {
86
- this.filters[filterName] = value;
87
- }
88
- /**
89
- * Defines multiple audio filters
90
- * @param filtersArray Array of filters containing the filter name and ffmpeg args
91
- */
92
- static defineBulk(filtersArray) {
93
- filtersArray.forEach((arr) => this.define(arr.name, arr.value));
94
- }
95
- }
96
- exports.AudioFilters = AudioFilters;
97
- exports.default = AudioFilters;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AudioFilters = void 0;
4
+ const bass = (g) => `bass=g=${g}:f=110:w=0.3`;
5
+ class AudioFilters {
6
+ constructor() {
7
+ return AudioFilters;
8
+ }
9
+ static get(name) {
10
+ return this.filters[name];
11
+ }
12
+ static has(name) {
13
+ return name in this.filters;
14
+ }
15
+ static *[Symbol.iterator]() {
16
+ for (const [k, v] of Object.entries(this.filters)) {
17
+ yield { name: k, value: v };
18
+ }
19
+ }
20
+ static get names() {
21
+ return Object.keys(this.filters);
22
+ }
23
+ // @ts-expect-error AudioFilters.length
24
+ static get length() {
25
+ return this.names.length;
26
+ }
27
+ static toString() {
28
+ return this.names.map((m) => this[m]).join(","); // eslint-disable-line @typescript-eslint/no-explicit-any
29
+ }
30
+ /**
31
+ * Create ffmpeg args from the specified filters name
32
+ * @param filter The filter name
33
+ * @returns
34
+ */
35
+ static create(filters) {
36
+ if (!filters || !Array.isArray(filters))
37
+ return this.toString();
38
+ return filters
39
+ .filter((predicate) => typeof predicate === "string")
40
+ .map((m) => this.get(m))
41
+ .join(",");
42
+ }
43
+ /**
44
+ * Defines audio filter
45
+ * @param filterName The name of the filter
46
+ * @param value The ffmpeg args
47
+ */
48
+ static define(filterName, value) {
49
+ this.filters[filterName] = value;
50
+ }
51
+ /**
52
+ * Defines multiple audio filters
53
+ * @param filtersArray Array of filters containing the filter name and ffmpeg args
54
+ */
55
+ static defineBulk(filtersArray) {
56
+ filtersArray.forEach((arr) => this.define(arr.name, arr.value));
57
+ }
58
+ }
59
+ exports.AudioFilters = AudioFilters;
60
+ AudioFilters.filters = {
61
+ bassboost_low: bass(15),
62
+ bassboost: bass(20),
63
+ bassboost_high: bass(30),
64
+ "8D": "apulsator=hz=0.09",
65
+ vaporwave: "aresample=48000,asetrate=48000*0.8",
66
+ nightcore: "aresample=48000,asetrate=48000*1.25",
67
+ phaser: "aphaser=in_gain=0.4",
68
+ tremolo: "tremolo",
69
+ vibrato: "vibrato=f=6.5",
70
+ reverse: "areverse",
71
+ treble: "treble=g=5",
72
+ normalizer2: "dynaudnorm=g=101",
73
+ normalizer: "acompressor",
74
+ surrounding: "surround",
75
+ pulsator: "apulsator=hz=1",
76
+ subboost: "asubboost",
77
+ karaoke: "stereotools=mlev=0.03",
78
+ flanger: "flanger",
79
+ gate: "agate",
80
+ haas: "haas",
81
+ mcompand: "mcompand",
82
+ mono: "pan=mono|c0=.5*c0+.5*c1",
83
+ mstlr: "stereotools=mode=ms>lr",
84
+ mstrr: "stereotools=mode=ms>rr",
85
+ compressor: "compand=points=-80/-105|-62/-80|-15.4/-15.4|0/-12|20/-7.6",
86
+ expander: "compand=attacks=0:points=-80/-169|-54/-80|-49.5/-64.6|-41.1/-41.1|-25.8/-15|-10.8/-4.5|0/0|20/8.3",
87
+ softlimiter: "compand=attacks=0:points=-80/-80|-12.4/-12.4|-6/-8|0/-6.8|20/-2.8",
88
+ chorus: "chorus=0.7:0.9:55:0.4:0.25:2",
89
+ chorus2d: "chorus=0.6:0.9:50|60:0.4|0.32:0.25|0.4:2|1.3",
90
+ chorus3d: "chorus=0.5:0.9:50|60|40:0.4|0.32|0.3:0.25|0.4|0.3:2|2.3|1.3",
91
+ fadein: "afade=t=in:ss=0:d=10",
92
+ dim: `afftfilt="'real=re * (1-clip((b/nb)*b,0,1))':imag='im * (1-clip((b/nb)*b,0,1))'"`,
93
+ earrape: "channelsplit,sidechaingate=level_in=64"
94
+ };
95
+ exports.default = AudioFilters;
@@ -1,53 +1,53 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createFFmpegStream = exports.FFMPEG_ARGS_PIPED = exports.FFMPEG_ARGS_STRING = void 0;
4
- const prism_media_1 = require("prism-media");
5
- function FFMPEG_ARGS_STRING(stream, fmt) {
6
- // prettier-ignore
7
- return [
8
- "-reconnect", "1",
9
- "-reconnect_streamed", "1",
10
- "-reconnect_delay_max", "5",
11
- "-i", stream,
12
- "-analyzeduration", "0",
13
- "-loglevel", "0",
14
- "-f", `${typeof fmt === "string" ? fmt : "s16le"}`,
15
- "-ar", "48000",
16
- "-ac", "2"
17
- ];
18
- }
19
- exports.FFMPEG_ARGS_STRING = FFMPEG_ARGS_STRING;
20
- function FFMPEG_ARGS_PIPED(fmt) {
21
- // prettier-ignore
22
- return [
23
- "-analyzeduration", "0",
24
- "-loglevel", "0",
25
- "-f", `${typeof fmt === "string" ? fmt : "s16le"}`,
26
- "-ar", "48000",
27
- "-ac", "2"
28
- ];
29
- }
30
- exports.FFMPEG_ARGS_PIPED = FFMPEG_ARGS_PIPED;
31
- /**
32
- * Creates FFmpeg stream
33
- * @param stream The source stream
34
- * @param options FFmpeg stream options
35
- */
36
- function createFFmpegStream(stream, options) {
37
- if (options.skip && typeof stream !== "string")
38
- return stream;
39
- options ?? (options = {});
40
- const args = typeof stream === "string" ? FFMPEG_ARGS_STRING(stream, options.fmt) : FFMPEG_ARGS_PIPED(options.fmt);
41
- if (!Number.isNaN(options.seek))
42
- args.unshift("-ss", String(options.seek));
43
- if (Array.isArray(options.encoderArgs))
44
- args.push(...options.encoderArgs);
45
- const transcoder = new prism_media_1.FFmpeg({ shell: false, args });
46
- transcoder.on("close", () => transcoder.destroy());
47
- if (typeof stream !== "string") {
48
- stream.on("error", () => transcoder.destroy());
49
- stream.pipe(transcoder);
50
- }
51
- return transcoder;
52
- }
53
- exports.createFFmpegStream = createFFmpegStream;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createFFmpegStream = exports.FFMPEG_ARGS_PIPED = exports.FFMPEG_ARGS_STRING = void 0;
4
+ const prism_media_1 = require("prism-media");
5
+ function FFMPEG_ARGS_STRING(stream, fmt) {
6
+ // prettier-ignore
7
+ return [
8
+ "-reconnect", "1",
9
+ "-reconnect_streamed", "1",
10
+ "-reconnect_delay_max", "5",
11
+ "-i", stream,
12
+ "-analyzeduration", "0",
13
+ "-loglevel", "0",
14
+ "-f", `${typeof fmt === "string" ? fmt : "s16le"}`,
15
+ "-ar", "48000",
16
+ "-ac", "2"
17
+ ];
18
+ }
19
+ exports.FFMPEG_ARGS_STRING = FFMPEG_ARGS_STRING;
20
+ function FFMPEG_ARGS_PIPED(fmt) {
21
+ // prettier-ignore
22
+ return [
23
+ "-analyzeduration", "0",
24
+ "-loglevel", "0",
25
+ "-f", `${typeof fmt === "string" ? fmt : "s16le"}`,
26
+ "-ar", "48000",
27
+ "-ac", "2"
28
+ ];
29
+ }
30
+ exports.FFMPEG_ARGS_PIPED = FFMPEG_ARGS_PIPED;
31
+ /**
32
+ * Creates FFmpeg stream
33
+ * @param stream The source stream
34
+ * @param options FFmpeg stream options
35
+ */
36
+ function createFFmpegStream(stream, options) {
37
+ if (options.skip && typeof stream !== "string")
38
+ return stream;
39
+ options ?? (options = {});
40
+ const args = typeof stream === "string" ? FFMPEG_ARGS_STRING(stream, options.fmt) : FFMPEG_ARGS_PIPED(options.fmt);
41
+ if (!Number.isNaN(options.seek))
42
+ args.unshift("-ss", String(options.seek));
43
+ if (Array.isArray(options.encoderArgs))
44
+ args.push(...options.encoderArgs);
45
+ const transcoder = new prism_media_1.FFmpeg({ shell: false, args });
46
+ transcoder.on("close", () => transcoder.destroy());
47
+ if (typeof stream !== "string") {
48
+ stream.on("error", () => transcoder.destroy());
49
+ stream.pipe(transcoder);
50
+ }
51
+ return transcoder;
52
+ }
53
+ exports.createFFmpegStream = createFFmpegStream;