mugen-ffmpeg 0.0.1
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/README.md +7 -0
- package/bin/mugen_ffmpeg +0 -0
- package/ffmpeg-path.json +6 -0
- package/mugen_ffmpeg.js +19 -0
- package/package.json +20 -0
- package/scripts/installer-binaire.js +160 -0
package/README.md
ADDED
package/bin/mugen_ffmpeg
ADDED
|
Binary file
|
package/ffmpeg-path.json
ADDED
package/mugen_ffmpeg.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { fileURLToPath } from "url";
|
|
4
|
+
|
|
5
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
6
|
+
const fichierChemin = path.join(__dirname, "ffmpeg-path.json");
|
|
7
|
+
|
|
8
|
+
let cheminFFmpeg = null;
|
|
9
|
+
|
|
10
|
+
if (fs.existsSync(fichierChemin)) {
|
|
11
|
+
const contenu = JSON.parse(fs.readFileSync(fichierChemin, "utf-8"));
|
|
12
|
+
cheminFFmpeg = contenu.chemin; // ← ici, correspond à ton JSON
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { cheminFFmpeg };
|
|
16
|
+
|
|
17
|
+
export default {
|
|
18
|
+
cheminFFmpeg
|
|
19
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "mugen-ffmpeg",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Ffmpeg pour tous",
|
|
5
|
+
"main": "mugen_ffmpeg.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"postinstall": "node scripts/installer-binaire.js",
|
|
8
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
9
|
+
},
|
|
10
|
+
"author": "Money Mugen♾️♾️",
|
|
11
|
+
"license": "ISC",
|
|
12
|
+
"type": "module",
|
|
13
|
+
"files": [
|
|
14
|
+
"mugen_ffmpeg.js",
|
|
15
|
+
"scripts/",
|
|
16
|
+
"bin/",
|
|
17
|
+
"ffmpeg-path.json",
|
|
18
|
+
"README.md"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import os from "os";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import https from "https";
|
|
5
|
+
import { execSync } from "child_process";
|
|
6
|
+
|
|
7
|
+
console.log("mugen-ffmpeg en cours d'installation...\n");
|
|
8
|
+
|
|
9
|
+
/* =========================
|
|
10
|
+
Détection de l'environnement
|
|
11
|
+
========================= */
|
|
12
|
+
const plateforme = os.platform();
|
|
13
|
+
const architecture = os.arch();
|
|
14
|
+
|
|
15
|
+
console.log("Détection de l'OS en cours...");
|
|
16
|
+
console.log(` → OS détecté : ${plateforme}\n`);
|
|
17
|
+
|
|
18
|
+
console.log("Détection de l'architecture en cours...");
|
|
19
|
+
console.log(` → Architecture détectée : ${architecture}\n`);
|
|
20
|
+
|
|
21
|
+
/* =========================
|
|
22
|
+
Sources FFmpeg statiques
|
|
23
|
+
========================= */
|
|
24
|
+
const sourcesFFmpeg = {
|
|
25
|
+
"linux-arm64":
|
|
26
|
+
"https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-arm64-static.tar.xz",
|
|
27
|
+
"linux-x64":
|
|
28
|
+
"https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz"
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const clePlateforme = `${plateforme}-${architecture}`;
|
|
32
|
+
|
|
33
|
+
if (!sourcesFFmpeg[clePlateforme]) {
|
|
34
|
+
console.error("Plateforme non supportée :", clePlateforme);
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const urlFFmpeg = sourcesFFmpeg[clePlateforme];
|
|
39
|
+
|
|
40
|
+
/* =========================
|
|
41
|
+
Chemins
|
|
42
|
+
========================= */
|
|
43
|
+
const racinePackage = process.cwd();
|
|
44
|
+
const dossierBinLocal = path.join(racinePackage, "bin");
|
|
45
|
+
const cheminFinalLocal = path.join(dossierBinLocal, "mugen_ffmpeg");
|
|
46
|
+
|
|
47
|
+
const dossierCache = path.join(os.homedir(), ".cache", "mugen-ffmpeg", clePlateforme);
|
|
48
|
+
const cheminCache = path.join(dossierCache, "mugen_ffmpeg");
|
|
49
|
+
|
|
50
|
+
const archive = path.join(dossierBinLocal, "ffmpeg.tar.xz");
|
|
51
|
+
|
|
52
|
+
/* =========================
|
|
53
|
+
Préparation des dossiers
|
|
54
|
+
========================= */
|
|
55
|
+
fs.mkdirSync(dossierBinLocal, { recursive: true });
|
|
56
|
+
|
|
57
|
+
/* =========================
|
|
58
|
+
1️⃣ Vérification cache
|
|
59
|
+
========================= */
|
|
60
|
+
if (fs.existsSync(cheminCache)) {
|
|
61
|
+
console.log("mugen-ffmpeg déjà téléchargé depuis le cache.");
|
|
62
|
+
|
|
63
|
+
fs.copyFileSync(cheminCache, cheminFinalLocal);
|
|
64
|
+
fs.chmodSync(cheminFinalLocal, 0o755);
|
|
65
|
+
|
|
66
|
+
fs.writeFileSync(
|
|
67
|
+
path.join(racinePackage, "ffmpeg-path.json"),
|
|
68
|
+
JSON.stringify(
|
|
69
|
+
{
|
|
70
|
+
chemin: cheminFinalLocal,
|
|
71
|
+
plateforme,
|
|
72
|
+
architecture,
|
|
73
|
+
source: "cache"
|
|
74
|
+
},
|
|
75
|
+
null,
|
|
76
|
+
2
|
|
77
|
+
)
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
console.log("FFmpeg prêt :", cheminFinalLocal);
|
|
81
|
+
process.exit(0);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/* =========================
|
|
85
|
+
2️⃣ Téléchargement
|
|
86
|
+
========================= */
|
|
87
|
+
console.log("Téléchargement en cours...");
|
|
88
|
+
console.log("Attends un peu...");
|
|
89
|
+
console.log("Presque fini...\n");
|
|
90
|
+
|
|
91
|
+
https.get(urlFFmpeg, (res) => {
|
|
92
|
+
if (res.statusCode !== 200) {
|
|
93
|
+
console.error("Échec du téléchargement :", res.statusCode);
|
|
94
|
+
process.exit(1);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const fichier = fs.createWriteStream(archive);
|
|
98
|
+
res.pipe(fichier);
|
|
99
|
+
|
|
100
|
+
fichier.on("finish", () => {
|
|
101
|
+
fichier.close();
|
|
102
|
+
|
|
103
|
+
console.log("Téléchargement terminé.");
|
|
104
|
+
console.log("Extraction en cours...\n");
|
|
105
|
+
|
|
106
|
+
/* =========================
|
|
107
|
+
3️⃣ Extraction
|
|
108
|
+
========================= */
|
|
109
|
+
execSync(`tar -xf "${archive}" -C "${dossierBinLocal}"`);
|
|
110
|
+
|
|
111
|
+
const dossierExtrait = fs
|
|
112
|
+
.readdirSync(dossierBinLocal)
|
|
113
|
+
.find((d) => d.startsWith("ffmpeg-"));
|
|
114
|
+
|
|
115
|
+
if (!dossierExtrait) {
|
|
116
|
+
console.error("Dossier FFmpeg introuvable après extraction.");
|
|
117
|
+
process.exit(1);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const ffmpegExtrait = path.join(dossierBinLocal, dossierExtrait, "ffmpeg");
|
|
121
|
+
|
|
122
|
+
/* =========================
|
|
123
|
+
4️⃣ Installation locale
|
|
124
|
+
========================= */
|
|
125
|
+
fs.copyFileSync(ffmpegExtrait, cheminFinalLocal);
|
|
126
|
+
fs.chmodSync(cheminFinalLocal, 0o755);
|
|
127
|
+
|
|
128
|
+
/* =========================
|
|
129
|
+
5️⃣ Cache global
|
|
130
|
+
========================= */
|
|
131
|
+
fs.mkdirSync(dossierCache, { recursive: true });
|
|
132
|
+
fs.copyFileSync(ffmpegExtrait, cheminCache);
|
|
133
|
+
fs.chmodSync(cheminCache, 0o755);
|
|
134
|
+
|
|
135
|
+
/* =========================
|
|
136
|
+
6️⃣ Nettoyage
|
|
137
|
+
========================= */
|
|
138
|
+
fs.rmSync(path.join(dossierBinLocal, dossierExtrait), { recursive: true, force: true });
|
|
139
|
+
fs.unlinkSync(archive);
|
|
140
|
+
|
|
141
|
+
/* =========================
|
|
142
|
+
7️⃣ Sauvegarde chemin
|
|
143
|
+
========================= */
|
|
144
|
+
fs.writeFileSync(
|
|
145
|
+
path.join(racinePackage, "ffmpeg-path.json"),
|
|
146
|
+
JSON.stringify(
|
|
147
|
+
{
|
|
148
|
+
chemin: cheminFinalLocal, // ← correspond au mugen_ffmpeg.js
|
|
149
|
+
plateforme,
|
|
150
|
+
architecture,
|
|
151
|
+
source: "download"
|
|
152
|
+
},
|
|
153
|
+
null,
|
|
154
|
+
2
|
|
155
|
+
)
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
console.log("FFmpeg prêt :", cheminFinalLocal);
|
|
159
|
+
});
|
|
160
|
+
});
|