Skip to content

Commit 3ee632f

Browse files
committed
fix: fix ffmpeg setup script
1 parent 30f7eb2 commit 3ee632f

3 files changed

Lines changed: 89 additions & 6 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"fix-webm-duration": "^1.0.6",
3131
"media-recorder-js": "^2.1.0",
3232
"mediasoup-client": "3",
33+
"node-fetch": "^3.3.2",
3334
"os-utils": "^0.0.14",
3435
"recordrtc": "^5.6.2",
3536
"socket.io-client": "^4.8.1",

pnpm-lock.yaml

Lines changed: 46 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/setup-ffmpeg.js

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import path from 'path';
2-
import fs from 'fs';
3-
import unzipper from 'unzipper';
1+
const path = require('path');
2+
const fs = require('fs');
3+
const unzipper = require('unzipper');
4+
const fetch = require('node-fetch');
45

56
const MAC_FFMPEG_ARM_URL = 'https://evermeet.cx/ffmpeg/ffmpeg-121955-g413346bd06.zip';
67
const MAC_FFPROBE_ARM_URL = 'https://evermeet.cx/ffmpeg/ffprobe-121955-g413346bd06.zip';
@@ -21,5 +22,43 @@ function getOutputPath(platform, arch) {
2122
}
2223

2324
async function downloadAndExtract(url, outputPath) {
25+
const res = await fetch(url);
26+
if (!res.ok) {
27+
throw new Error(`Failed to download from ${url}: ${res.statusText}`);
28+
}
29+
30+
await new Promise((resolve, reject) => {
31+
res.body
32+
.pipe(unzipper.Extract({ path: outputPath }))
33+
.on('close', resolve)
34+
.on('error', reject);
35+
});
36+
}
37+
38+
async function main() {
39+
const platform = process.platform;
40+
const arch = process.arch;
41+
42+
const url = getDownloadUrl(platform, arch);
43+
const outputPath = getOutputPath(platform, arch);
2444

45+
if (!url || !outputPath) {
46+
console.log(`No prebuilt binaries available for ${platform} ${arch}. Skipping download.`);
47+
return;
48+
}
49+
if (!fs.existsSync(outputPath)) {
50+
fs.mkdirSync(outputPath, { recursive: true });
51+
}
52+
53+
console.log(`Downloading ffmpeg from ${url.ffmpeg}...`);
54+
await downloadAndExtract(url.ffmpeg, outputPath);
55+
console.log(`Downloading ffprobe from ${url.ffprobe}...`);
56+
await downloadAndExtract(url.ffprobe, outputPath);
57+
58+
console.log(`ffmpeg and ffprobe have been set up at ${outputPath}`);
2559
}
60+
61+
main().catch((err) => {
62+
console.error('Error during setup:', err);
63+
process.exit(1);
64+
});

0 commit comments

Comments
 (0)