-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcopyFFmpeg.js
More file actions
26 lines (21 loc) · 884 Bytes
/
Copy pathcopyFFmpeg.js
File metadata and controls
26 lines (21 loc) · 884 Bytes
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
// copyFFmpeg.js
const fs = require('fs');
const path = require('path');
const ffmpegPath = require('ffmpeg-static');
const ffprobePath = require('ffprobe-static').path;
const ffmpegBinaryDir = path.join(__dirname, 'ffmpeg-binaries');
// Create the directory if it doesn't exist
if (!fs.existsSync(ffmpegBinaryDir)) {
fs.mkdirSync(ffmpegBinaryDir, { recursive: true });
}
const ffmpegExt = process.platform === 'win32' ? '.exe' : '';
const ffmpegDest = path.join(ffmpegBinaryDir, `ffmpeg${ffmpegExt}`);
if (!fs.existsSync(ffmpegDest)) {
fs.copyFileSync(ffmpegPath, ffmpegDest);
}
const ffprobeExt = process.platform === 'win32' ? '.exe' : '';
const ffprobeDest = path.join(ffmpegBinaryDir, `ffprobe${ffprobeExt}`);
if (!fs.existsSync(ffprobeDest)) {
fs.copyFileSync(ffprobePath, ffprobeDest);
}
console.log('FFmpeg binaries copied successfully to:', ffmpegBinaryDir);