@backendsuraj/offline-ffmpeg 8.0.1 → 8.0.3
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 +1 -1
- package/index.js +58 -18
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -35,7 +35,7 @@ fluentFfmpeg('input.mp4').save('output.mp3');
|
|
|
35
35
|
## Binary Details
|
|
36
36
|
- **Source**: [BtbN/FFmpeg-Builds](https://github.com/BtbN/FFmpeg-Builds/releases)
|
|
37
37
|
- **Version**: 8.0.0
|
|
38
|
-
- **License**:
|
|
38
|
+
- **License**: GPL 3.0
|
|
39
39
|
|
|
40
40
|
## Supported Platforms
|
|
41
41
|
| OS | Architecture | Status |
|
package/index.js
CHANGED
|
@@ -1,33 +1,73 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
const os = require('os');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const fs = require('fs');
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
const platform = os.platform();
|
|
6
|
+
const arch = os.arch();
|
|
7
|
+
|
|
8
|
+
if (platform !== 'linux' && platform !== 'darwin' && platform !== 'win32') {
|
|
9
|
+
console.error(`Unsupported platform: ${platform}`);
|
|
10
|
+
process.exit(1);
|
|
11
|
+
}
|
|
7
12
|
|
|
8
13
|
if (platform === 'darwin') {
|
|
9
14
|
console.error('MacOS support coming soon.');
|
|
10
15
|
process.exit(1);
|
|
11
16
|
}
|
|
12
17
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
const packageName = `@backendsuraj/offline-ffmpeg-${platform}-${arch}`;
|
|
19
|
+
|
|
20
|
+
if (!require('./package.json').optionalDependencies[packageName]) {
|
|
21
|
+
throw `Unsupported platform/architecture: ${platform}-${arch}`;
|
|
17
22
|
}
|
|
18
23
|
|
|
19
|
-
|
|
20
|
-
var binaryName = platform === 'win32' ? 'ffmpeg.exe' : 'ffmpeg';
|
|
24
|
+
const binaryName = platform === 'win32' ? 'ffmpeg.exe' : 'ffmpeg';
|
|
21
25
|
|
|
22
|
-
|
|
26
|
+
// verify-file implementation
|
|
27
|
+
const verifyFile = (file) => {
|
|
28
|
+
try {
|
|
29
|
+
const stats = fs.statSync(file);
|
|
30
|
+
return stats.isFile() && stats.size > 0;
|
|
31
|
+
} catch (e) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
23
35
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
36
|
+
// Strategy 1: npm3 (flat dependencies) - sibling of this package
|
|
37
|
+
const npm3Path = path.resolve(__dirname, '..', `offline-ffmpeg-${platform}-${arch}`);
|
|
38
|
+
|
|
39
|
+
// Strategy 2: npm2 (nested dependencies) - inside this package's node_modules
|
|
40
|
+
const npm2Path = path.resolve(__dirname, 'node_modules', '@backendsuraj', `offline-ffmpeg-${platform}-${arch}`);
|
|
41
|
+
|
|
42
|
+
// Strategy 3: Top level node_modules (handle docker/monorepo edge cases)
|
|
43
|
+
const topLevelPath = path.resolve(__dirname.substring(0, __dirname.indexOf('node_modules')), 'node_modules', '@backendsuraj', `offline-ffmpeg-${platform}-${arch}`);
|
|
44
|
+
|
|
45
|
+
const npm3Binary = path.join(npm3Path, 'bin', binaryName);
|
|
46
|
+
const npm2Binary = path.join(npm2Path, 'bin', binaryName);
|
|
47
|
+
const topLevelBinary = path.join(topLevelPath, 'bin', binaryName);
|
|
48
|
+
|
|
49
|
+
const npm3Package = path.join(npm3Path, 'package.json');
|
|
50
|
+
const npm2Package = path.join(npm2Path, 'package.json');
|
|
51
|
+
const topLevelPackage = path.join(topLevelPath, 'package.json');
|
|
52
|
+
|
|
53
|
+
let ffmpegPath;
|
|
54
|
+
let packageJson;
|
|
27
55
|
|
|
28
|
-
if (
|
|
29
|
-
ffmpegPath =
|
|
56
|
+
if (verifyFile(npm3Binary)) {
|
|
57
|
+
ffmpegPath = npm3Binary;
|
|
58
|
+
packageJson = require(npm3Package);
|
|
59
|
+
} else if (verifyFile(npm2Binary)) {
|
|
60
|
+
ffmpegPath = npm2Binary;
|
|
61
|
+
packageJson = require(npm2Package);
|
|
62
|
+
} else if (verifyFile(topLevelBinary)) {
|
|
63
|
+
ffmpegPath = topLevelBinary;
|
|
64
|
+
packageJson = require(topLevelPackage);
|
|
65
|
+
} else {
|
|
66
|
+
throw `Could not find ffmpeg executable, tried:
|
|
67
|
+
- ${npm3Binary}
|
|
68
|
+
- ${npm2Binary}
|
|
69
|
+
- ${topLevelBinary}`;
|
|
30
70
|
}
|
|
31
71
|
|
|
32
72
|
exports.path = ffmpegPath;
|
|
33
|
-
exports.version =
|
|
73
|
+
exports.version = packageJson.version;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backendsuraj/offline-ffmpeg",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.3",
|
|
4
4
|
"description": "Platform independent binary installer of FFmpeg for node projects (Offline Friendly)",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
"test": "node test.js"
|
|
9
9
|
},
|
|
10
10
|
"author": "Suraj",
|
|
11
|
-
"license": "
|
|
11
|
+
"license": "GPL-3.0",
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
14
14
|
"url": "https://github.com/backendsuraj/offline-ffmpeg"
|
|
15
15
|
},
|
|
16
16
|
"optionalDependencies": {
|
|
17
|
-
"@backendsuraj/offline-ffmpeg-win32-x64": "8.0.
|
|
18
|
-
"@backendsuraj/offline-ffmpeg-linux-x64": "8.0.
|
|
17
|
+
"@backendsuraj/offline-ffmpeg-win32-x64": "8.0.2",
|
|
18
|
+
"@backendsuraj/offline-ffmpeg-linux-x64": "8.0.2"
|
|
19
19
|
}
|
|
20
20
|
}
|