discord-player 5.3.0-dev.3 → 5.3.0

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,33 +1,33 @@
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
- var Util_1 = require("./utils/Util");
29
- Object.defineProperty(exports, "Util", { enumerable: true, get: function () { return Util_1.Util; } });
30
- tslib_1.__exportStar(require("./types/types"), exports);
31
- tslib_1.__exportStar(require("./utils/FFmpegStream"), exports);
32
- // eslint-disable-next-line @typescript-eslint/no-var-requires
33
- 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
+ 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
+ var Util_1 = require("./utils/Util");
29
+ Object.defineProperty(exports, "Util", { enumerable: true, get: function () { return Util_1.Util; } });
30
+ tslib_1.__exportStar(require("./types/types"), exports);
31
+ tslib_1.__exportStar(require("./utils/FFmpegStream"), exports);
32
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
33
+ exports.version = require(`${__dirname}/../package.json`).version;
@@ -1,13 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const VolumeTransformer_1 = require("./VoiceInterface/VolumeTransformer");
4
- try {
5
- // eslint-disable-next-line
6
- const mod = require("prism-media");
7
- if (typeof mod.VolumeTransformer.hasSmoothing !== "boolean") {
8
- Reflect.set(mod, "VolumeTransformer", VolumeTransformer_1.VolumeTransformer);
9
- }
10
- }
11
- catch {
12
- /* do nothing */
13
- }
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const VolumeTransformer_1 = require("./VoiceInterface/VolumeTransformer");
4
+ try {
5
+ // eslint-disable-next-line
6
+ const mod = require("prism-media");
7
+ if (typeof mod.VolumeTransformer.hasSmoothing !== "boolean") {
8
+ Reflect.set(mod, "VolumeTransformer", VolumeTransformer_1.VolumeTransformer);
9
+ }
10
+ }
11
+ catch {
12
+ /* do nothing */
13
+ }
@@ -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,98 +1,98 @@
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)) {
54
- if (typeof this.filters[k] === "string")
55
- yield { name: k, value: v };
56
- }
57
- }
58
- static get names() {
59
- return Object.keys(this).filter((p) => !["names", "length"].includes(p) && typeof this.filters[p] !== "function");
60
- }
61
- // @ts-expect-error AudioFilters.length
62
- static get length() {
63
- return Object.keys(this).filter((p) => !["names", "length"].includes(p) && typeof this.filters[p] !== "function").length;
64
- }
65
- static toString() {
66
- return this.names.map((m) => this[m]).join(","); // eslint-disable-line @typescript-eslint/no-explicit-any
67
- }
68
- /**
69
- * Create ffmpeg args from the specified filters name
70
- * @param filter The filter name
71
- * @returns
72
- */
73
- static create(filters) {
74
- if (!filters || !Array.isArray(filters))
75
- return this.toString();
76
- return filters
77
- .filter((predicate) => typeof predicate === "string")
78
- .map((m) => this.get(m))
79
- .join(",");
80
- }
81
- /**
82
- * Defines audio filter
83
- * @param filterName The name of the filter
84
- * @param value The ffmpeg args
85
- */
86
- static define(filterName, value) {
87
- this.filters[filterName] = value;
88
- }
89
- /**
90
- * Defines multiple audio filters
91
- * @param filtersArray Array of filters containing the filter name and ffmpeg args
92
- */
93
- static defineBulk(filtersArray) {
94
- filtersArray.forEach((arr) => this.define(arr.name, arr.value));
95
- }
96
- }
97
- exports.AudioFilters = AudioFilters;
98
- 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 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)) {
54
+ if (typeof this.filters[k] === "string")
55
+ yield { name: k, value: v };
56
+ }
57
+ }
58
+ static get names() {
59
+ return Object.keys(this).filter((p) => !["names", "length"].includes(p) && typeof this.filters[p] !== "function");
60
+ }
61
+ // @ts-expect-error AudioFilters.length
62
+ static get length() {
63
+ return Object.keys(this).filter((p) => !["names", "length"].includes(p) && typeof this.filters[p] !== "function").length;
64
+ }
65
+ static toString() {
66
+ return this.names.map((m) => this[m]).join(","); // eslint-disable-line @typescript-eslint/no-explicit-any
67
+ }
68
+ /**
69
+ * Create ffmpeg args from the specified filters name
70
+ * @param filter The filter name
71
+ * @returns
72
+ */
73
+ static create(filters) {
74
+ if (!filters || !Array.isArray(filters))
75
+ return this.toString();
76
+ return filters
77
+ .filter((predicate) => typeof predicate === "string")
78
+ .map((m) => this.get(m))
79
+ .join(",");
80
+ }
81
+ /**
82
+ * Defines audio filter
83
+ * @param filterName The name of the filter
84
+ * @param value The ffmpeg args
85
+ */
86
+ static define(filterName, value) {
87
+ this.filters[filterName] = value;
88
+ }
89
+ /**
90
+ * Defines multiple audio filters
91
+ * @param filtersArray Array of filters containing the filter name and ffmpeg args
92
+ */
93
+ static defineBulk(filtersArray) {
94
+ filtersArray.forEach((arr) => this.define(arr.name, arr.value));
95
+ }
96
+ }
97
+ exports.AudioFilters = AudioFilters;
98
+ 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;