@pproenca/webcodecs-ffmpeg-non-free 0.1.0 → 0.1.2

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.
Files changed (3) hide show
  1. package/install.js +18 -0
  2. package/package.json +6 -5
  3. package/resolve.js +26 -1
package/install.js CHANGED
@@ -5,6 +5,7 @@
5
5
  */
6
6
 
7
7
  const os = require('os');
8
+ const fs = require('fs');
8
9
 
9
10
  const TIER_SUFFIX = '-non-free';
10
11
 
@@ -12,14 +13,31 @@ const PLATFORMS = {
12
13
  'darwin-arm64': { os: 'darwin', cpu: 'arm64' },
13
14
  'darwin-x64': { os: 'darwin', cpu: 'x64' },
14
15
  'linux-x64': { os: 'linux', cpu: 'x64' },
16
+ 'linux-x64-musl': { os: 'linux', cpu: 'x64', libc: 'musl' },
15
17
  'linux-arm64': { os: 'linux', cpu: 'arm64' },
16
18
  'win32-x64': { os: 'win32', cpu: 'x64' },
17
19
  'win32-arm64': { os: 'win32', cpu: 'arm64' },
18
20
  };
19
21
 
22
+ /**
23
+ * Detect if running on musl libc (Alpine Linux, etc.)
24
+ */
25
+ function isMusl() {
26
+ if (os.platform() !== 'linux') return false;
27
+ try {
28
+ const arch = os.arch() === 'x64' ? 'x86_64' : os.arch();
29
+ return fs.existsSync(`/lib/ld-musl-${arch}.so.1`);
30
+ } catch {
31
+ return false;
32
+ }
33
+ }
34
+
20
35
  function getPlatformKey() {
21
36
  const platform = os.platform();
22
37
  const arch = os.arch();
38
+ if (platform === 'linux' && arch === 'x64' && isMusl()) {
39
+ return 'linux-x64-musl';
40
+ }
23
41
  return `${platform}-${arch}`;
24
42
  }
25
43
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pproenca/webcodecs-ffmpeg-non-free",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Prebuilt FFmpeg with all codecs including GPL x264/x265 - auto-selects platform",
5
5
  "author": "Pedro Proenca",
6
6
  "homepage": "https://github.com/pproenca/webcodecs-ffmpeg",
@@ -23,10 +23,11 @@
23
23
  "./package": "./package.json"
24
24
  },
25
25
  "optionalDependencies": {
26
- "@pproenca/webcodecs-ffmpeg-linux-arm64-non-free": "0.1.0",
27
- "@pproenca/webcodecs-ffmpeg-darwin-arm64-non-free": "0.1.0",
28
- "@pproenca/webcodecs-ffmpeg-darwin-x64-non-free": "0.1.0",
29
- "@pproenca/webcodecs-ffmpeg-linux-x64-non-free": "0.1.0"
26
+ "@pproenca/webcodecs-ffmpeg-darwin-arm64-non-free": "0.1.2",
27
+ "@pproenca/webcodecs-ffmpeg-darwin-x64-non-free": "0.1.2",
28
+ "@pproenca/webcodecs-ffmpeg-linux-arm64-non-free": "0.1.2",
29
+ "@pproenca/webcodecs-ffmpeg-linux-x64-non-free": "0.1.2",
30
+ "@pproenca/webcodecs-ffmpeg-linux-x64-musl-non-free": "0.1.2"
30
31
  },
31
32
  "scripts": {
32
33
  "postinstall": "node install.js"
package/resolve.js CHANGED
@@ -6,14 +6,39 @@
6
6
  * PKG_CONFIG_PATH: "<!(node -p \"require('@pproenca/webcodecs-ffmpeg-non-free/resolve').pkgconfig\")"
7
7
  */
8
8
  const os = require('os');
9
+ const fs = require('fs');
9
10
  const path = require('path');
10
11
 
11
12
  const TIER_SUFFIX = '-non-free';
12
13
 
14
+ /**
15
+ * Detect if running on musl libc (Alpine Linux, etc.)
16
+ */
17
+ function isMusl() {
18
+ if (os.platform() !== 'linux') return false;
19
+ try {
20
+ const arch = os.arch() === 'x64' ? 'x86_64' : os.arch();
21
+ return fs.existsSync(`/lib/ld-musl-${arch}.so.1`);
22
+ } catch {
23
+ return false;
24
+ }
25
+ }
26
+
13
27
  function getPlatformPkgPath() {
14
28
  const platform = os.platform();
15
29
  const arch = os.arch();
16
- const pkgName = `@pproenca/webcodecs-ffmpeg-${platform}-${arch}-non-free`;
30
+
31
+ // Try musl-specific package first on Linux x64
32
+ if (platform === 'linux' && arch === 'x64' && isMusl()) {
33
+ const muslPkg = `@pproenca/webcodecs-ffmpeg-linux-x64-musl${TIER_SUFFIX}`;
34
+ try {
35
+ return path.dirname(require.resolve(`${muslPkg}/lib`));
36
+ } catch {
37
+ // Fall through to glibc package
38
+ }
39
+ }
40
+
41
+ const pkgName = `@pproenca/webcodecs-ffmpeg-${platform}-${arch}${TIER_SUFFIX}`;
17
42
  try {
18
43
  return path.dirname(require.resolve(`${pkgName}/lib`));
19
44
  } catch (e) {