refactor: remove deasync and fluent-ffmpeg dependencies
This commit is contained in:
@@ -55,11 +55,9 @@
|
|||||||
"@discordjs/collection": "^1.5.3",
|
"@discordjs/collection": "^1.5.3",
|
||||||
"@sapphire/async-queue": "^1.5.3",
|
"@sapphire/async-queue": "^1.5.3",
|
||||||
"@sapphire/shapeshift": "^3.9.5",
|
"@sapphire/shapeshift": "^3.9.5",
|
||||||
"deasync": "^0.1.30",
|
|
||||||
"discord-api-types": "^0.37.103",
|
"discord-api-types": "^0.37.103",
|
||||||
"fetch-cookie": "^2.1.0",
|
"fetch-cookie": "^2.1.0",
|
||||||
"find-process": "^1.4.7",
|
"find-process": "^1.4.7",
|
||||||
"fluent-ffmpeg": "^2.1.3",
|
|
||||||
"prism-media": "^1.3.5",
|
"prism-media": "^1.3.5",
|
||||||
"qrcode": "^1.5.4",
|
"qrcode": "^1.5.4",
|
||||||
"tough-cookie": "^4.1.4",
|
"tough-cookie": "^4.1.4",
|
||||||
|
|||||||
46
pnpm-lock.yaml
generated
46
pnpm-lock.yaml
generated
@@ -20,9 +20,6 @@ importers:
|
|||||||
'@sapphire/shapeshift':
|
'@sapphire/shapeshift':
|
||||||
specifier: ^3.9.5
|
specifier: ^3.9.5
|
||||||
version: 3.9.7
|
version: 3.9.7
|
||||||
deasync:
|
|
||||||
specifier: ^0.1.30
|
|
||||||
version: 0.1.30
|
|
||||||
discord-api-types:
|
discord-api-types:
|
||||||
specifier: ^0.37.103
|
specifier: ^0.37.103
|
||||||
version: 0.37.103
|
version: 0.37.103
|
||||||
@@ -32,9 +29,6 @@ importers:
|
|||||||
find-process:
|
find-process:
|
||||||
specifier: ^1.4.7
|
specifier: ^1.4.7
|
||||||
version: 1.4.7
|
version: 1.4.7
|
||||||
fluent-ffmpeg:
|
|
||||||
specifier: ^2.1.3
|
|
||||||
version: 2.1.3
|
|
||||||
prism-media:
|
prism-media:
|
||||||
specifier: ^1.3.5
|
specifier: ^1.3.5
|
||||||
version: 1.3.5
|
version: 1.3.5
|
||||||
@@ -854,9 +848,6 @@ packages:
|
|||||||
resolution: {integrity: sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==}
|
resolution: {integrity: sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==}
|
||||||
engines: {node: '>=8'}
|
engines: {node: '>=8'}
|
||||||
|
|
||||||
async@0.2.10:
|
|
||||||
resolution: {integrity: sha512-eAkdoKxU6/LkKDBzLpT+t6Ff5EtfSF4wx1WfJiPEEV7WNLnDaRXk0oVysiEPm262roaachGexwUv94WhSgN5TQ==}
|
|
||||||
|
|
||||||
asynckit@0.4.0:
|
asynckit@0.4.0:
|
||||||
resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==}
|
resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==}
|
||||||
|
|
||||||
@@ -910,9 +901,6 @@ packages:
|
|||||||
bcrypt-pbkdf@1.0.2:
|
bcrypt-pbkdf@1.0.2:
|
||||||
resolution: {integrity: sha512-qeFIXtP4MSoi6NLqO12WfqARWWuCKi2Rn/9hJLEmtB5yTNr9DqFWkJRCf2qShWzPeAMRnOgCrq0sg/KLv5ES9w==}
|
resolution: {integrity: sha512-qeFIXtP4MSoi6NLqO12WfqARWWuCKi2Rn/9hJLEmtB5yTNr9DqFWkJRCf2qShWzPeAMRnOgCrq0sg/KLv5ES9w==}
|
||||||
|
|
||||||
bindings@1.5.0:
|
|
||||||
resolution: {integrity: sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==}
|
|
||||||
|
|
||||||
bluebird@3.7.2:
|
bluebird@3.7.2:
|
||||||
resolution: {integrity: sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==}
|
resolution: {integrity: sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==}
|
||||||
|
|
||||||
@@ -1261,10 +1249,6 @@ packages:
|
|||||||
dateformat@3.0.3:
|
dateformat@3.0.3:
|
||||||
resolution: {integrity: sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q==}
|
resolution: {integrity: sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q==}
|
||||||
|
|
||||||
deasync@0.1.30:
|
|
||||||
resolution: {integrity: sha512-OaAjvEQuQ9tJsKG4oHO9nV1UHTwb2Qc2+fadB0VeVtD0Z9wiG1XPGLJ4W3aLhAoQSYTaLROFRbd5X20Dkzf7MQ==}
|
|
||||||
engines: {node: '>=0.11.0'}
|
|
||||||
|
|
||||||
debug@3.2.7:
|
debug@3.2.7:
|
||||||
resolution: {integrity: sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==}
|
resolution: {integrity: sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
@@ -1649,9 +1633,6 @@ packages:
|
|||||||
resolution: {integrity: sha512-B/SdeSIeRv7VlOgIjtH3dkxMI+tEy5m+OeCXfAUsirBoVoY+bGtsmvmmTFPm/G23TBY4RiTtjpcgePCfwXRjqA==}
|
resolution: {integrity: sha512-B/SdeSIeRv7VlOgIjtH3dkxMI+tEy5m+OeCXfAUsirBoVoY+bGtsmvmmTFPm/G23TBY4RiTtjpcgePCfwXRjqA==}
|
||||||
engines: {node: '>=8'}
|
engines: {node: '>=8'}
|
||||||
|
|
||||||
file-uri-to-path@1.0.0:
|
|
||||||
resolution: {integrity: sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==}
|
|
||||||
|
|
||||||
fill-range@7.1.1:
|
fill-range@7.1.1:
|
||||||
resolution: {integrity: sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==}
|
resolution: {integrity: sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==}
|
||||||
engines: {node: '>=8'}
|
engines: {node: '>=8'}
|
||||||
@@ -1694,10 +1675,6 @@ packages:
|
|||||||
flatted@3.3.1:
|
flatted@3.3.1:
|
||||||
resolution: {integrity: sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==}
|
resolution: {integrity: sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==}
|
||||||
|
|
||||||
fluent-ffmpeg@2.1.3:
|
|
||||||
resolution: {integrity: sha512-Be3narBNt2s6bsaqP6Jzq91heDgOEaDCJAXcE3qcma/EJBSy5FB4cvO31XBInuAuKBx8Kptf8dkhjK0IOru39Q==}
|
|
||||||
engines: {node: '>=18'}
|
|
||||||
|
|
||||||
for-each@0.3.3:
|
for-each@0.3.3:
|
||||||
resolution: {integrity: sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==}
|
resolution: {integrity: sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==}
|
||||||
|
|
||||||
@@ -2693,9 +2670,6 @@ packages:
|
|||||||
nice-try@1.0.5:
|
nice-try@1.0.5:
|
||||||
resolution: {integrity: sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==}
|
resolution: {integrity: sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==}
|
||||||
|
|
||||||
node-addon-api@1.7.2:
|
|
||||||
resolution: {integrity: sha512-ibPK3iA+vaY1eEjESkQkM0BbCqFOaZMiXRTtdB0u7b4djtY6JnsjvPdUHVMg6xQt3B8fpTTWHI9A+ADjM9frzg==}
|
|
||||||
|
|
||||||
node-fetch@2.7.0:
|
node-fetch@2.7.0:
|
||||||
resolution: {integrity: sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==}
|
resolution: {integrity: sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==}
|
||||||
engines: {node: 4.x || >=6.0.0}
|
engines: {node: 4.x || >=6.0.0}
|
||||||
@@ -4897,8 +4871,6 @@ snapshots:
|
|||||||
|
|
||||||
astral-regex@2.0.0: {}
|
astral-regex@2.0.0: {}
|
||||||
|
|
||||||
async@0.2.10: {}
|
|
||||||
|
|
||||||
asynckit@0.4.0: {}
|
asynckit@0.4.0: {}
|
||||||
|
|
||||||
available-typed-arrays@1.0.7:
|
available-typed-arrays@1.0.7:
|
||||||
@@ -4978,10 +4950,6 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
tweetnacl: 0.14.5
|
tweetnacl: 0.14.5
|
||||||
|
|
||||||
bindings@1.5.0:
|
|
||||||
dependencies:
|
|
||||||
file-uri-to-path: 1.0.0
|
|
||||||
|
|
||||||
bluebird@3.7.2: {}
|
bluebird@3.7.2: {}
|
||||||
|
|
||||||
brace-expansion@1.1.11:
|
brace-expansion@1.1.11:
|
||||||
@@ -5404,11 +5372,6 @@ snapshots:
|
|||||||
|
|
||||||
dateformat@3.0.3: {}
|
dateformat@3.0.3: {}
|
||||||
|
|
||||||
deasync@0.1.30:
|
|
||||||
dependencies:
|
|
||||||
bindings: 1.5.0
|
|
||||||
node-addon-api: 1.7.2
|
|
||||||
|
|
||||||
debug@3.2.7:
|
debug@3.2.7:
|
||||||
dependencies:
|
dependencies:
|
||||||
ms: 2.1.3
|
ms: 2.1.3
|
||||||
@@ -5918,8 +5881,6 @@ snapshots:
|
|||||||
array-back: 4.0.2
|
array-back: 4.0.2
|
||||||
glob: 7.2.3
|
glob: 7.2.3
|
||||||
|
|
||||||
file-uri-to-path@1.0.0: {}
|
|
||||||
|
|
||||||
fill-range@7.1.1:
|
fill-range@7.1.1:
|
||||||
dependencies:
|
dependencies:
|
||||||
to-regex-range: 5.0.1
|
to-regex-range: 5.0.1
|
||||||
@@ -5970,11 +5931,6 @@ snapshots:
|
|||||||
|
|
||||||
flatted@3.3.1: {}
|
flatted@3.3.1: {}
|
||||||
|
|
||||||
fluent-ffmpeg@2.1.3:
|
|
||||||
dependencies:
|
|
||||||
async: 0.2.10
|
|
||||||
which: 1.3.1
|
|
||||||
|
|
||||||
for-each@0.3.3:
|
for-each@0.3.3:
|
||||||
dependencies:
|
dependencies:
|
||||||
is-callable: 1.2.7
|
is-callable: 1.2.7
|
||||||
@@ -7209,8 +7165,6 @@ snapshots:
|
|||||||
|
|
||||||
nice-try@1.0.5: {}
|
nice-try@1.0.5: {}
|
||||||
|
|
||||||
node-addon-api@1.7.2: {}
|
|
||||||
|
|
||||||
node-fetch@2.7.0(encoding@0.1.13):
|
node-fetch@2.7.0(encoding@0.1.13):
|
||||||
dependencies:
|
dependencies:
|
||||||
whatwg-url: 5.0.0
|
whatwg-url: 5.0.0
|
||||||
|
|||||||
@@ -19,8 +19,6 @@ Please use the @dank074/discord-video-stream library for the best support.
|
|||||||
|
|
||||||
const EventEmitter = require('events');
|
const EventEmitter = require('events');
|
||||||
const { Readable: ReadableStream } = require('stream');
|
const { Readable: ReadableStream } = require('stream');
|
||||||
const deasync = require('deasync');
|
|
||||||
const fluent = require('fluent-ffmpeg');
|
|
||||||
const prism = require('prism-media');
|
const prism = require('prism-media');
|
||||||
const { H264NalSplitter } = require('./processing/AnnexBNalSplitter');
|
const { H264NalSplitter } = require('./processing/AnnexBNalSplitter');
|
||||||
const { IvfTransformer } = require('./processing/IvfSplitter');
|
const { IvfTransformer } = require('./processing/IvfSplitter');
|
||||||
@@ -162,45 +160,7 @@ class MediaPlayer extends EventEmitter {
|
|||||||
playUnknownVideo(input, options = {}) {
|
playUnknownVideo(input, options = {}) {
|
||||||
this.destroyVideoDispatcher();
|
this.destroyVideoDispatcher();
|
||||||
const isStream = input instanceof ReadableStream;
|
const isStream = input instanceof ReadableStream;
|
||||||
// Get video info
|
if (!options?.fps) options.fps = 30;
|
||||||
let isDone = false;
|
|
||||||
let data = null;
|
|
||||||
if (!options?.fps) {
|
|
||||||
fluent.ffprobe(input, (err, metadata) => {
|
|
||||||
if (err) {
|
|
||||||
this.emit('error', err);
|
|
||||||
isDone = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let hasAudio = false;
|
|
||||||
let hasVideo = false;
|
|
||||||
let fps = 0;
|
|
||||||
metadata.streams.forEach(stream => {
|
|
||||||
if (stream.codec_type === 'audio') {
|
|
||||||
hasAudio = true;
|
|
||||||
}
|
|
||||||
if (stream.codec_type === 'video') {
|
|
||||||
hasVideo = true;
|
|
||||||
if (stream.avg_frame_rate) {
|
|
||||||
const frameRate = stream.avg_frame_rate.split('/');
|
|
||||||
fps = parseFloat(frameRate[0]) / parseFloat(frameRate[1]);
|
|
||||||
} else if (stream.r_frame_rate) {
|
|
||||||
const frameRate = stream.r_frame_rate.split('/');
|
|
||||||
fps = parseFloat(frameRate[0]) / parseFloat(frameRate[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
data = {
|
|
||||||
audio: hasAudio,
|
|
||||||
video: hasVideo,
|
|
||||||
fps: hasVideo ? fps : null,
|
|
||||||
};
|
|
||||||
isDone = true;
|
|
||||||
});
|
|
||||||
deasync.loopWhile(() => !isDone);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!options?.fps) options.fps = data?.fps || 30;
|
|
||||||
|
|
||||||
const args = [
|
const args = [
|
||||||
'-i',
|
'-i',
|
||||||
@@ -261,10 +221,6 @@ class MediaPlayer extends EventEmitter {
|
|||||||
this.emit('debug', `[ffmpeg-video_process]: ${data.toString()}`);
|
this.emit('debug', `[ffmpeg-video_process]: ${data.toString()}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (data?.audio && options?.includeAudio) {
|
|
||||||
this.playUnknown(input, options?.audioOptions || {});
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (this.voiceConnection.videoCodec) {
|
switch (this.voiceConnection.videoCodec) {
|
||||||
case 'VP8': {
|
case 'VP8': {
|
||||||
return this.playIvfVideo(ffmpeg, options, streams);
|
return this.playIvfVideo(ffmpeg, options, streams);
|
||||||
|
|||||||
Reference in New Issue
Block a user