-
Notifications
You must be signed in to change notification settings - Fork 51
/
ffmpegDownload.mjs
36 lines (33 loc) · 1.48 KB
/
ffmpegDownload.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import download from "download";
import fs from "fs";
import path from "path";
// Exit if disabled
if (process.env.ASCOPE_NO_FFMPEG === "true") {
process.exit();
}
// Configuration
const folder = "ffmpeg";
const versions = {
"ffmpeg-mac-x64": "https://github.com/eugeneware/ffmpeg-static/releases/download/b5.0.1/darwin-x64",
"ffmpeg-mac-arm64": "https://github.com/eugeneware/ffmpeg-static/releases/download/b5.0.1/darwin-arm64",
"ffmpeg-linux-x64": "https://github.com/eugeneware/ffmpeg-static/releases/download/b5.0.1/linux-x64",
"ffmpeg-linux-arm64": "https://github.com/eugeneware/ffmpeg-static/releases/download/b5.0.1/linux-arm64",
"ffmpeg-linux-armv7l": "https://github.com/eugeneware/ffmpeg-static/releases/download/b5.0.1/linux-arm",
"ffmpeg-win-x64.exe": "https://github.com/eugeneware/ffmpeg-static/releases/download/b5.0.1/win32-x64",
"ffmpeg-win-arm64.exe": "https://github.com/eugeneware/ffmpeg-static/releases/download/b5.0.1/win32-ia32"
};
// Download files
console.log("Downloading ffmpeg...");
if (!fs.existsSync(folder)) {
fs.mkdirSync(folder);
}
for (let [filename, url] of Object.entries(versions)) {
if (fs.existsSync(path.join(process.cwd(), folder, filename))) {
console.log('Skipped downloading "' + filename + '"');
} else {
download(url, path.join(process.cwd(), folder), { filename: filename }).then(() => {
fs.chmodSync(path.join(process.cwd(), folder, filename), 0o755);
console.log('Finished downloading "' + filename + '"');
});
}
}