node-av 7.0.0-beta.2 → 7.0.0-beta.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 CHANGED
@@ -55,6 +55,12 @@ Native Node.js bindings for FFmpeg with full TypeScript support - including type
55
55
  npm install node-av
56
56
  ```
57
57
 
58
+ The FFmpeg command-line tool is a separate, optional package (see [FFmpeg Binary Access](#ffmpeg-binary-access)):
59
+
60
+ ```bash
61
+ npm install @seydx/node-av-ffmpeg
62
+ ```
63
+
58
64
  ## Quick Start
59
65
 
60
66
  ### Low-Level API
@@ -388,7 +394,11 @@ await using screen2 = await DeviceAPI.openScreen({
388
394
 
389
395
  ## FFmpeg Binary Access
390
396
 
391
- Need direct access to the FFmpeg binary? The library provides an easy way to get FFmpeg binaries that automatically downloads and manages platform-specific builds.
397
+ Need the FFmpeg command-line tool as well? Install `@seydx/node-av-ffmpeg` next to `node-av`. npm installs only the binary for your platform, built from the same FFmpeg as the native bindings, and `node-av/ffmpeg` finds it:
398
+
399
+ ```bash
400
+ npm install node-av @seydx/node-av-ffmpeg
401
+ ```
392
402
 
393
403
  ```typescript
394
404
  import { ffmpegPath, isFfmpegAvailable } from 'node-av/ffmpeg';
@@ -405,7 +415,7 @@ if (isFfmpegAvailable()) {
405
415
  const { stdout } = await execFileAsync(ffmpegPath(), ['-version']);
406
416
  console.log(stdout);
407
417
  } else {
408
- console.log('FFmpeg binary not available - install may have failed');
418
+ console.log('FFmpeg binary not available - run: npm install @seydx/node-av-ffmpeg');
409
419
  }
410
420
 
411
421
  // Direct usage example
@@ -422,7 +432,7 @@ async function convertVideo(input: string, output: string) {
422
432
  }
423
433
  ```
424
434
 
425
- The FFmpeg binary is automatically downloaded during installation from GitHub releases and matches the same build used by the native bindings.
435
+ `ffmpegPath()` throws if the package is not installed, so check `isFfmpegAvailable()` first when the CLI is optional. In Electron apps, unpack `node_modules/@seydx/**` from the ASAR archive so the binary can be executed.
426
436
 
427
437
  ## Resource Management
428
438
 
@@ -556,17 +566,18 @@ Prebuilt binaries are available for multiple platforms:
556
566
 
557
567
  ### Cross-Platform Packaging (CI/CD)
558
568
 
559
- By default the install step fetches the native binding and FFmpeg binary for the
560
- host platform. When packaging for a different target (e.g. building a Windows
561
- Electron app from a Linux CI runner), pass npm's standard `--os` / `--cpu` flags:
569
+ By default npm installs the native binding (and the FFmpeg binary, if
570
+ `@seydx/node-av-ffmpeg` is installed) for the host platform. When packaging for
571
+ a different target (e.g. building a Windows Electron app from a Linux CI
572
+ runner), pass npm's standard `--os` / `--cpu` flags:
562
573
 
563
574
  ```bash
564
575
  # Install Windows x64 binaries while running on Linux
565
576
  npm install --os=win32 --cpu=x64
566
577
  ```
567
578
 
568
- npm filters the platform-specific `optionalDependencies` by these flags, and the
569
- postinstall hook honors them for the bundled FFmpeg binary as well.
579
+ npm filters the platform-specific `optionalDependencies` of both packages by
580
+ these flags.
570
581
 
571
582
  ## Troubleshooting
572
583
 
@@ -1,20 +1,22 @@
1
1
  /**
2
2
  * Get the absolute path to the FFmpeg binary.
3
3
  *
4
- * Returns the path to the FFmpeg executable that was automatically downloaded
5
- * during package installation. The binary is platform-specific and matches
6
- * the FFmpeg version used by the native bindings.
4
+ * The binary ships in the optional `@seydx/node-av-ffmpeg` package
5
+ * (`npm install @seydx/node-av-ffmpeg`), which installs the build for the
6
+ * current platform. It is built from the same FFmpeg as the native bindings.
7
+ * In Electron apps the path points into `app.asar.unpacked`.
7
8
  *
8
9
  * @returns Absolute path to the FFmpeg binary
9
10
  *
11
+ * @throws {Error} If `@seydx/node-av-ffmpeg` is not installed or has no build for this platform
12
+ *
10
13
  * @example
11
14
  * ```typescript
12
15
  * import { ffmpegPath } from 'node-av/ffmpeg';
13
16
  *
14
17
  * const path = ffmpegPath();
15
18
  * console.log('FFmpeg binary at:', path);
16
- * // On Windows: C:\path\to\node_modules\node-av\binary\ffmpeg.exe
17
- * // On Unix: /path/to/node_modules/node-av/binary/ffmpeg
19
+ * // e.g. /path/to/node_modules/@seydx/node-av-ffmpeg-linux-x64/ffmpeg
18
20
  * ```
19
21
  *
20
22
  * @example Convert video using FFmpeg binary
@@ -40,13 +42,12 @@
40
42
  */
41
43
  export declare function ffmpegPath(): string;
42
44
  /**
43
- * Check if the FFmpeg binary is available and executable.
45
+ * Check if the FFmpeg binary is available.
44
46
  *
45
- * Verifies that the FFmpeg binary exists at the expected location.
46
- * This is useful for checking if the installation was successful
47
- * before attempting to use the binary.
47
+ * Returns whether `@seydx/node-av-ffmpeg` is installed with a build for
48
+ * this platform, i.e. whether {@link ffmpegPath} will succeed.
48
49
  *
49
- * @returns `true` if FFmpeg binary exists, `false` otherwise
50
+ * @returns `true` if the FFmpeg binary exists, `false` otherwise
50
51
  *
51
52
  * @example
52
53
  * ```typescript
@@ -56,9 +57,7 @@ export declare function ffmpegPath(): string;
56
57
  * console.log('FFmpeg is ready to use');
57
58
  * // Safe to use ffmpegPath() and execute FFmpeg commands
58
59
  * } else {
59
- * console.log('FFmpeg binary not found');
60
- * console.log('Expected location:', ffmpegPath());
61
- * console.log('Try running: npm install node-av');
60
+ * console.log('FFmpeg binary not found, run: npm install @seydx/node-av-ffmpeg');
62
61
  * }
63
62
  * ```
64
63
  *
@@ -1,29 +1,67 @@
1
1
  import { existsSync } from 'node:fs';
2
- import { resolve } from 'node:path';
3
- import { getDirname } from '../utils/electron.js';
4
- import { getPlatform } from './utils.js';
2
+ import { createRequire } from 'node:module';
3
+ import { dirname, join, resolve } from 'node:path';
4
+ import { getDirname, getUnpackedPath } from '../utils/electron.js';
5
5
  import { FFMPEG_VERSION } from './version.js';
6
6
  const __dirname = getDirname(import.meta.url);
7
- const ffmpegBinaryPath = resolve(__dirname, '../../binary');
8
- const ffmpegFile = 'ffmpeg' + (getPlatform() === 'win32' ? '.exe' : '');
9
- const ffmpegExtractedFilePath = resolve(ffmpegBinaryPath, ffmpegFile);
7
+ const require = createRequire(import.meta.url);
8
+ const FFMPEG_PACKAGE = '@seydx/node-av-ffmpeg';
9
+ const ffmpegFile = 'ffmpeg' + (process.platform === 'win32' ? '.exe' : '');
10
+ // Local build (development, CI tests): binary/ next to dist/
11
+ const localFfmpegPath = resolve(__dirname, '../../binary', ffmpegFile);
12
+ let resolvedFfmpegPath = null;
13
+ /**
14
+ * Find the FFmpeg binary.
15
+ *
16
+ * Checks the local `binary/` folder first, then the platform package installed by `@seydx/node-av-ffmpeg`.
17
+ *
18
+ * @returns Absolute path to the binary, or `null` if neither is installed
19
+ *
20
+ * @internal
21
+ */
22
+ function findFfmpeg() {
23
+ if (resolvedFfmpegPath) {
24
+ return resolvedFfmpegPath;
25
+ }
26
+ if (existsSync(localFfmpegPath)) {
27
+ resolvedFfmpegPath = localFfmpegPath;
28
+ return resolvedFfmpegPath;
29
+ }
30
+ try {
31
+ // The platform package is a dependency of the meta package, not of node-av, so it is
32
+ // resolved from there (strict layouts like pnpm don't expose it to node-av directly).
33
+ const metaPackageJson = require.resolve(`${FFMPEG_PACKAGE}/package.json`);
34
+ const platformPackageJson = createRequire(metaPackageJson).resolve(`${FFMPEG_PACKAGE}-${process.platform}-${process.arch}/package.json`);
35
+ const path = getUnpackedPath(join(dirname(platformPackageJson), ffmpegFile));
36
+ if (existsSync(path)) {
37
+ resolvedFfmpegPath = path;
38
+ return resolvedFfmpegPath;
39
+ }
40
+ }
41
+ catch {
42
+ // Not installed, or no build for this platform
43
+ }
44
+ return null;
45
+ }
10
46
  /**
11
47
  * Get the absolute path to the FFmpeg binary.
12
48
  *
13
- * Returns the path to the FFmpeg executable that was automatically downloaded
14
- * during package installation. The binary is platform-specific and matches
15
- * the FFmpeg version used by the native bindings.
49
+ * The binary ships in the optional `@seydx/node-av-ffmpeg` package
50
+ * (`npm install @seydx/node-av-ffmpeg`), which installs the build for the
51
+ * current platform. It is built from the same FFmpeg as the native bindings.
52
+ * In Electron apps the path points into `app.asar.unpacked`.
16
53
  *
17
54
  * @returns Absolute path to the FFmpeg binary
18
55
  *
56
+ * @throws {Error} If `@seydx/node-av-ffmpeg` is not installed or has no build for this platform
57
+ *
19
58
  * @example
20
59
  * ```typescript
21
60
  * import { ffmpegPath } from 'node-av/ffmpeg';
22
61
  *
23
62
  * const path = ffmpegPath();
24
63
  * console.log('FFmpeg binary at:', path);
25
- * // On Windows: C:\path\to\node_modules\node-av\binary\ffmpeg.exe
26
- * // On Unix: /path/to/node_modules/node-av/binary/ffmpeg
64
+ * // e.g. /path/to/node_modules/@seydx/node-av-ffmpeg-linux-x64/ffmpeg
27
65
  * ```
28
66
  *
29
67
  * @example Convert video using FFmpeg binary
@@ -48,16 +86,19 @@ const ffmpegExtractedFilePath = resolve(ffmpegBinaryPath, ffmpegFile);
48
86
  * ```
49
87
  */
50
88
  export function ffmpegPath() {
51
- return ffmpegExtractedFilePath;
89
+ const path = findFfmpeg();
90
+ if (!path) {
91
+ throw new Error(`FFmpeg binary not found for ${process.platform}-${process.arch}. Install it with: npm install ${FFMPEG_PACKAGE}`);
92
+ }
93
+ return path;
52
94
  }
53
95
  /**
54
- * Check if the FFmpeg binary is available and executable.
96
+ * Check if the FFmpeg binary is available.
55
97
  *
56
- * Verifies that the FFmpeg binary exists at the expected location.
57
- * This is useful for checking if the installation was successful
58
- * before attempting to use the binary.
98
+ * Returns whether `@seydx/node-av-ffmpeg` is installed with a build for
99
+ * this platform, i.e. whether {@link ffmpegPath} will succeed.
59
100
  *
60
- * @returns `true` if FFmpeg binary exists, `false` otherwise
101
+ * @returns `true` if the FFmpeg binary exists, `false` otherwise
61
102
  *
62
103
  * @example
63
104
  * ```typescript
@@ -67,9 +108,7 @@ export function ffmpegPath() {
67
108
  * console.log('FFmpeg is ready to use');
68
109
  * // Safe to use ffmpegPath() and execute FFmpeg commands
69
110
  * } else {
70
- * console.log('FFmpeg binary not found');
71
- * console.log('Expected location:', ffmpegPath());
72
- * console.log('Try running: npm install node-av');
111
+ * console.log('FFmpeg binary not found, run: npm install @seydx/node-av-ffmpeg');
73
112
  * }
74
113
  * ```
75
114
  *
@@ -94,7 +133,7 @@ export function ffmpegPath() {
94
133
  * ```
95
134
  */
96
135
  export function isFfmpegAvailable() {
97
- return existsSync(ffmpegExtractedFilePath);
136
+ return findFfmpeg() !== null;
98
137
  }
99
138
  /**
100
139
  * Get the FFmpeg version used by the binary.
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ffmpeg/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,SAAS,GAAG,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC9C,MAAM,gBAAgB,GAAG,OAAO,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;AAC5D,MAAM,UAAU,GAAG,QAAQ,GAAG,CAAC,WAAW,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AACxE,MAAM,uBAAuB,GAAG,OAAO,CAAC,gBAAgB,EAAE,UAAU,CAAC,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,uBAAuB,CAAC;AACjC,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,MAAM,UAAU,iBAAiB;IAC/B,OAAO,UAAU,CAAC,uBAAuB,CAAC,CAAC;AAC7C,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,cAAc,CAAC;AACxB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","s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AO,CAAC,QAAQ,IAAI,OAAO,CAAC,IAAI,eAAe,CAAC,CAAC;QACzI,MAAM,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC;QAC7E,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACrB,kBAAkB,GAAG,IAAI,CAAC;YAC1B,OAAO,kBAAkB,CAAC;QAC5B,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,+CAA+C;IACjD,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,MAAM,UAAU,UAAU;IACxB,MAAM,IAAI,GAAG,UAAU,EAAE,CAAC;IAC1B,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,+BAA+B,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,IAAI,kCAAkC,cAAc,EAAE,CAAC,CAAC;IACrI,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,UAAU,iBAAiB;IAC/B,OAAO,UAAU,EAAE,KAAK,IAAI,CAAC;AAC/B,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,cAAc,CAAC;AACxB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-av",
3
- "version": "7.0.0-beta.2",
3
+ "version": "7.0.0-beta.3",
4
4
  "description": "FFmpeg bindings for Node.js",
5
5
  "author": "seydx (https://github.com/seydx/node-av)",
6
6
  "type": "module",
@@ -79,7 +79,6 @@
79
79
  "lint:fix": "eslint --fix .",
80
80
  "lint:gyp": "node scripts/check-gyp-sync.js",
81
81
  "patch:ffmpeg": "node scripts/patch-ffmpeg.js",
82
- "postinstall": "node dist/ffmpeg/install.js",
83
82
  "predocs": "typedoc && cpy README.md docs/ --rename=index.md",
84
83
  "release:patch": "npm run build:tsc && node scripts/prepare-release.js patch",
85
84
  "release:minor": "npm run build:tsc && node scripts/prepare-release.js minor",
@@ -91,21 +90,22 @@
91
90
  "test:all": "npm run build:tests && npm run build:tsc && tsx --test test/*.test.ts",
92
91
  "update": "updates --update ./"
93
92
  },
94
- "dependencies": {
95
- "unzipper": "^0.12.5"
96
- },
97
93
  "optionalDependencies": {
98
- "@seydx/node-av-darwin-arm64": "7.0.0-beta.2",
99
- "@seydx/node-av-darwin-x64": "7.0.0-beta.2",
100
- "@seydx/node-av-linux-arm64": "7.0.0-beta.2",
101
- "@seydx/node-av-linux-x64": "7.0.0-beta.2",
102
- "@seydx/node-av-win32-arm64-msvc": "7.0.0-beta.2",
103
- "@seydx/node-av-win32-x64-msvc": "7.0.0-beta.2"
94
+ "@seydx/node-av-darwin-arm64": "7.0.0-beta.3",
95
+ "@seydx/node-av-darwin-x64": "7.0.0-beta.3",
96
+ "@seydx/node-av-linux-arm64": "7.0.0-beta.3",
97
+ "@seydx/node-av-linux-x64": "7.0.0-beta.3",
98
+ "@seydx/node-av-win32-arm64-msvc": "7.0.0-beta.3",
99
+ "@seydx/node-av-win32-x64-msvc": "7.0.0-beta.3"
104
100
  },
105
101
  "peerDependencies": {
102
+ "@seydx/node-av-ffmpeg": "*",
106
103
  "werift": ">=0.24.3"
107
104
  },
108
105
  "peerDependenciesMeta": {
106
+ "@seydx/node-av-ffmpeg": {
107
+ "optional": true
108
+ },
109
109
  "werift": {
110
110
  "optional": true
111
111
  }
@@ -115,7 +115,6 @@
115
115
  "@types/node": "^26.6.6",
116
116
  "@types/node-abi": "^3.0.3",
117
117
  "@types/semver": "^7.8.0",
118
- "@types/unzipper": "^0.10.11",
119
118
  "@types/ws": "^8.18.2",
120
119
  "@typescript-eslint/parser": "^8.72.2",
121
120
  "concurrently": "^10.0.7",
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
@@ -1,253 +0,0 @@
1
- #!/usr/bin/env node
2
- import { createHash } from 'node:crypto';
3
- import { chmodSync, createReadStream, createWriteStream, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
4
- import { rename } from 'node:fs/promises';
5
- import { createRequire } from 'node:module';
6
- import { dirname, extname, resolve } from 'node:path';
7
- import { Readable } from 'node:stream';
8
- import { pipeline } from 'node:stream/promises';
9
- import { fileURLToPath } from 'node:url';
10
- import { Open } from 'unzipper';
11
- import { ffmpegPath } from './index.js';
12
- import { getArchitecture, getPlatform, useMingwToolchain } from './utils.js';
13
- import { FFMPEG_VERSION } from './version.js';
14
- if (process.env.SKIP_FFMPEG === 'true') {
15
- console.log('Skipping ffmpeg download');
16
- process.exit(0);
17
- }
18
- const __filename = fileURLToPath(import.meta.url);
19
- const __dirname = dirname(__filename);
20
- const __require = createRequire(import.meta.url);
21
- const releasesUrl = 'https://api.github.com/repos/seydx/node-av/releases';
22
- const releaseDownloadBase = 'https://github.com/seydx/node-av/releases/download';
23
- const pJson = __require('../../package.json');
24
- const ffmpegVersion = `v${FFMPEG_VERSION}`;
25
- // Number of retries per download URL (in addition to the initial attempt).
26
- const DOWNLOAD_RETRIES = 2;
27
- const binaries = {
28
- darwin: {
29
- x64: `ffmpeg-${ffmpegVersion}-macos-x64-jellyfin.zip`,
30
- arm64: `ffmpeg-${ffmpegVersion}-macos-arm64-jellyfin.zip`,
31
- },
32
- linux: {
33
- x64: `ffmpeg-${ffmpegVersion}-linux-x64-jellyfin.zip`,
34
- arm64: `ffmpeg-${ffmpegVersion}-linux-arm64-jellyfin.zip`,
35
- },
36
- win32: {
37
- x64: `ffmpeg-${ffmpegVersion}-win-x64.zip`,
38
- arm64: `ffmpeg-${ffmpegVersion}-win-arm64.zip`,
39
- },
40
- };
41
- const arch = getArchitecture();
42
- const sysPlatform = getPlatform();
43
- let filename = binaries[sysPlatform]?.[arch];
44
- if (!filename) {
45
- console.warn(`Warning: No ffmpeg binary found for architecture (${sysPlatform} / ${arch})`);
46
- console.warn('FFmpeg binary installation will be skipped.');
47
- process.exit(0);
48
- }
49
- // Standard (MSVC-built) Windows Node.js uses the default binary; only a MinGW
50
- // runtime (or an explicit npm_config_libc=mingw when cross-compiling) needs the
51
- // jellyfin build. See useMingwToolchain() for the detection rationale.
52
- if (sysPlatform === 'win32' && useMingwToolchain()) {
53
- filename = filename.replace('.zip', '-jellyfin.zip');
54
- }
55
- console.log(`Detected platform: ${sysPlatform} / ${arch}`);
56
- console.log(`Using binary: ${filename}`);
57
- const ffmpegBinaryPath = resolve(__dirname, '../../binary');
58
- const ffmpegFilePath = resolve(ffmpegBinaryPath, filename);
59
- const ffmpegExtractedFilePath = ffmpegPath();
60
- const versionMarkerPath = resolve(ffmpegBinaryPath, '.ffmpeg-version');
61
- if (existsSync(ffmpegExtractedFilePath) && existsSync(versionMarkerPath)) {
62
- try {
63
- if (readFileSync(versionMarkerPath, 'utf8').trim() === filename) {
64
- console.log(`FFmpeg ${ffmpegVersion} already installed, skipping download`);
65
- process.exit(0);
66
- }
67
- }
68
- catch {
69
- // Unreadable marker - fall through and re-download
70
- }
71
- }
72
- const isZipUrl = (url) => {
73
- const pathArray = new URL(url).pathname.split('/');
74
- const fileName = pathArray[pathArray.length - 1];
75
- return fileName !== undefined && extname(fileName) === '.zip';
76
- };
77
- const sha256OfFile = async (path) => {
78
- const hash = createHash('sha256');
79
- await pipeline(createReadStream(path), hash);
80
- return hash.digest('hex');
81
- };
82
- const fetchExpectedSha256 = async (url) => {
83
- try {
84
- const sumsUrl = new URL(url);
85
- const parts = sumsUrl.pathname.split('/');
86
- parts[parts.length - 1] = 'SHA256SUMS';
87
- sumsUrl.pathname = parts.join('/');
88
- const response = await fetch(sumsUrl);
89
- if (!response.ok) {
90
- return null;
91
- }
92
- const text = await response.text();
93
- for (const line of text.split('\n')) {
94
- // sha256sum format: "<hex> <filename>" (binary mode prefixes "*")
95
- const match = /^([0-9a-fA-F]{64})\s+\*?(.+)$/.exec(line.trim());
96
- if (!match) {
97
- continue;
98
- }
99
- if (match[2] === filename) {
100
- return match[1].toLowerCase();
101
- }
102
- }
103
- return null;
104
- }
105
- catch {
106
- return null;
107
- }
108
- };
109
- const downloadFile = async (url) => {
110
- console.log(`Downloading FFmpeg ${ffmpegVersion} to ${ffmpegFilePath}...`);
111
- const response = await fetch(url);
112
- if (!response.ok) {
113
- throw new Error(`HTTP error! status: ${response.status}`);
114
- }
115
- if (!response.body) {
116
- throw new Error('Response body is null');
117
- }
118
- mkdirSync(ffmpegBinaryPath, { recursive: true });
119
- // Progress tracking (optional, simpler without detailed progress)
120
- const contentLength = response.headers.get('content-length');
121
- let downloaded = 0;
122
- const body = Readable.fromWeb(response.body);
123
- if (!process.env.CI && contentLength) {
124
- body.on('data', (chunk) => {
125
- downloaded += chunk.length;
126
- const percent = Math.round((downloaded / parseInt(contentLength)) * 100);
127
- process.stdout.write(`\r${percent}%`);
128
- });
129
- }
130
- try {
131
- await pipeline(body, createWriteStream(ffmpegFilePath));
132
- if (!process.env.CI && contentLength) {
133
- process.stdout.write('\r');
134
- }
135
- }
136
- catch (downloadError) {
137
- try {
138
- rmSync(ffmpegFilePath);
139
- }
140
- catch {
141
- // Ignore cleanup errors
142
- }
143
- throw downloadError;
144
- }
145
- const expectedSha256 = await fetchExpectedSha256(url);
146
- if (expectedSha256) {
147
- const actualSha256 = await sha256OfFile(ffmpegFilePath);
148
- if (actualSha256 !== expectedSha256) {
149
- console.warn(`Warning: SHA256 mismatch for ${filename} (expected ${expectedSha256}, got ${actualSha256}); aborting extraction.`);
150
- try {
151
- rmSync(ffmpegFilePath);
152
- }
153
- catch {
154
- // Ignore cleanup errors
155
- }
156
- throw new Error(`SHA256 checksum mismatch for ${filename}`);
157
- }
158
- console.log('SHA256 checksum verified');
159
- }
160
- else {
161
- console.log('No SHA256SUMS found for this release, skipping checksum verification');
162
- }
163
- if (isZipUrl(url)) {
164
- console.log(`Extracting ${ffmpegFilePath} to ${ffmpegExtractedFilePath}...`);
165
- try {
166
- const directory = await Open.file(ffmpegFilePath);
167
- if (directory.files?.length === 0) {
168
- throw new Error('No files found in ZIP archive');
169
- }
170
- await new Promise((resolve, reject) => {
171
- directory.files[0].stream().pipe(createWriteStream(ffmpegExtractedFilePath)).on('error', reject).on('finish', resolve);
172
- });
173
- console.log(`Removing ${ffmpegFilePath}...`);
174
- rmSync(ffmpegFilePath);
175
- }
176
- catch (extractError) {
177
- // Clean up on extraction failure
178
- try {
179
- rmSync(ffmpegFilePath);
180
- }
181
- catch {
182
- // Ignore cleanup errors
183
- }
184
- throw new Error(`Failed to extract ZIP: ${extractError}`);
185
- }
186
- }
187
- else {
188
- console.log(`Renaming ${ffmpegFilePath} to ${ffmpegExtractedFilePath}...`);
189
- await rename(ffmpegFilePath, ffmpegExtractedFilePath);
190
- }
191
- };
192
- const downloadFileWithRetries = async (url) => {
193
- for (let attempt = 0;; attempt++) {
194
- try {
195
- await downloadFile(url);
196
- return;
197
- }
198
- catch (error) {
199
- if (attempt >= DOWNLOAD_RETRIES) {
200
- throw error;
201
- }
202
- const delayMs = 1000 * (attempt + 1);
203
- console.warn(`Download failed (${error instanceof Error ? error.message : error}); retrying in ${delayMs}ms (${attempt + 1}/${DOWNLOAD_RETRIES})...`);
204
- await new Promise((resolve) => setTimeout(resolve, delayMs));
205
- }
206
- }
207
- };
208
- const getReleaseAssets = async (version) => {
209
- const url = `${releasesUrl}/tags/v${version}`;
210
- console.log(`Fetching release info from ${url}...`);
211
- const response = await fetch(url);
212
- if (!response.ok) {
213
- throw new Error(`HTTP error! status: ${response.status}`);
214
- }
215
- const data = await response.json();
216
- const assets = data.assets.map((asset) => asset.browser_download_url);
217
- const files = assets.map((asset) => asset.split(`${version}/`)[1]);
218
- return {
219
- assets,
220
- files,
221
- };
222
- };
223
- const downloadFFmpeg = async () => {
224
- const directUrl = `${releaseDownloadBase}/v${pJson.version}/${filename}`;
225
- try {
226
- await downloadFileWithRetries(directUrl);
227
- }
228
- catch (directError) {
229
- console.warn(`Direct download failed (${directError instanceof Error ? directError.message : directError}); trying the release API...`);
230
- const release = await getReleaseAssets(pJson.version);
231
- const apiUrl = release.assets.find((r) => r.endsWith(filename));
232
- if (!apiUrl) {
233
- throw new Error(`No ffmpeg binary found for architecture (${sysPlatform} / ${arch})`);
234
- }
235
- await downloadFileWithRetries(apiUrl);
236
- }
237
- if (sysPlatform === 'linux' || sysPlatform === 'darwin') {
238
- console.log(`Making ${ffmpegExtractedFilePath} executable...`);
239
- chmodSync(ffmpegExtractedFilePath, 0o755);
240
- }
241
- writeFileSync(versionMarkerPath, `${filename}\n`);
242
- console.log('Done!');
243
- };
244
- downloadFFmpeg()
245
- .catch((error) => {
246
- console.warn('Warning: Failed to download FFmpeg binary:', error?.message ?? error);
247
- console.warn('FFmpeg binary will not be available, but the package installation will continue.');
248
- })
249
- .finally(() => {
250
- // Always exit successfully to avoid breaking npm install
251
- process.exit(0);
252
- });
253
- //# sourceMappingURL=install.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"install.js","sourceRoot":"","sources":["../../src/ffmpeg/install.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACrI,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,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AW,KAAK,QAAQ,EAAE,CAAC;QACxD,OAAO,CAAC,GAAG,CAAC,UAAU,uBAAuB,gBAAgB,CAAC,CAAC;QAC/D,SAAS,CAAC,uBAAuB,EAAE,KAAK,CAAC,CAAC;IAC5C,CAAC;IAED,aAAa,CAAC,iBAAiB,EAAE,GAAG,QAAQ,IAAI,CAAC,CAAC;IAElD,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AACvB,CAAC,CAAC;AAEF,cAAc,EAAE;KACb,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACf,OAAO,CAAC,IAAI,CAAC,4CAA4C,EAAE,KAAK,EAAE,OAAO,IAAI,KAAK,CAAC,CAAC;IACpF,OAAO,CAAC,IAAI,CAAC,kFAAkF,CAAC,CAAC;AACnG,CAAC,CAAC;KACD,OAAO,CAAC,GAAG,EAAE;IACZ,yDAAyD;IACzD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -1,47 +0,0 @@
1
- export type ARCH = 'arm' | 'arm6' | 'arm7' | 'arm64' | 'ia32' | 'loong64' | 'mips' | 'mipsel' | 'ppc' | 'ppc64' | 'riscv64' | 's390' | 's390x' | 'x64';
2
- /**
3
- * Get the current platform.
4
- *
5
- * If the environment variable `npm_config_os` is set, its value will be used
6
- * instead. This is useful for cross-compilation scenarios.
7
- *
8
- * @returns The current platform
9
- *
10
- * @internal
11
- */
12
- export declare function getPlatform(): NodeJS.Platform;
13
- /**
14
- * Get the current platform type.
15
- *
16
- * @returns The current platform type
17
- *
18
- * @internal
19
- */
20
- export declare function getPlatformType(): string;
21
- /**
22
- * Determine whether the MinGW (jellyfin) Windows build should be used.
23
- *
24
- * On a native install this reflects the running Node.js: the official Windows
25
- * Node.js is MSVC-built and reports `Windows_NT`, while a Node.js compiled under
26
- * MSYS2/MinGW reports e.g. `MINGW64_NT-*` and needs the MinGW build.
27
- *
28
- * When cross-compiling (`npm_config_os` is set) the host's `os.type()` is
29
- * meaningless for the target, so this defaults to the standard MSVC build and
30
- * only opts into MinGW when `npm_config_libc=mingw` is explicitly passed.
31
- *
32
- * @returns True if the MinGW (jellyfin) build should be used
33
- *
34
- * @internal
35
- */
36
- export declare function useMingwToolchain(): boolean;
37
- /**
38
- * Get the current architecture.
39
- *
40
- * If the environment variable `npm_config_cpu` is set, its value will be used
41
- * instead. This is useful for cross-compilation scenarios.
42
- *
43
- * @returns The current architecture
44
- *
45
- * @internal
46
- */
47
- export declare function getArchitecture(): ARCH;
@@ -1,92 +0,0 @@
1
- import { execSync } from 'child_process';
2
- import { arch, platform, type } from 'node:os';
3
- /**
4
- * Get the current platform.
5
- *
6
- * If the environment variable `npm_config_os` is set, its value will be used
7
- * instead. This is useful for cross-compilation scenarios.
8
- *
9
- * @returns The current platform
10
- *
11
- * @internal
12
- */
13
- export function getPlatform() {
14
- if (process.env.npm_config_os) {
15
- if (!process.env.npm_config_cpu) {
16
- throw new Error('npm_config_cpu is required when npm_config_os is set');
17
- }
18
- return process.env.npm_config_os;
19
- }
20
- return platform();
21
- }
22
- /**
23
- * Get the current platform type.
24
- *
25
- * @returns The current platform type
26
- *
27
- * @internal
28
- */
29
- export function getPlatformType() {
30
- return type();
31
- }
32
- /**
33
- * Determine whether the MinGW (jellyfin) Windows build should be used.
34
- *
35
- * On a native install this reflects the running Node.js: the official Windows
36
- * Node.js is MSVC-built and reports `Windows_NT`, while a Node.js compiled under
37
- * MSYS2/MinGW reports e.g. `MINGW64_NT-*` and needs the MinGW build.
38
- *
39
- * When cross-compiling (`npm_config_os` is set) the host's `os.type()` is
40
- * meaningless for the target, so this defaults to the standard MSVC build and
41
- * only opts into MinGW when `npm_config_libc=mingw` is explicitly passed.
42
- *
43
- * @returns True if the MinGW (jellyfin) build should be used
44
- *
45
- * @internal
46
- */
47
- export function useMingwToolchain() {
48
- // MinGW builds are discontinued, so no install picks the jellyfin zip anymore
49
- // if (process.env.npm_config_os) {
50
- // return process.env.npm_config_libc === 'mingw';
51
- // }
52
- //
53
- // return getPlatformType() !== 'Windows_NT';
54
- return false;
55
- }
56
- /**
57
- * Get the current architecture.
58
- *
59
- * If the environment variable `npm_config_cpu` is set, its value will be used
60
- * instead. This is useful for cross-compilation scenarios.
61
- *
62
- * @returns The current architecture
63
- *
64
- * @internal
65
- */
66
- export function getArchitecture() {
67
- if (process.env.npm_config_cpu) {
68
- if (!process.env.npm_config_os) {
69
- throw new Error('npm_config_os is required when npm_config_cpu is set');
70
- }
71
- return process.env.npm_config_cpu;
72
- }
73
- const sysPlatform = getPlatform();
74
- let sysArch = arch();
75
- if (sysPlatform === 'linux') {
76
- try {
77
- const output = execSync('cat /proc/cpuinfo | grep "model name"', { encoding: 'utf8' });
78
- const modelName = output.trim().split(':')[1].trim();
79
- if (modelName.includes('ARMv6')) {
80
- sysArch = 'arm6';
81
- }
82
- else if (modelName.includes('ARMv7')) {
83
- sysArch = 'arm7';
84
- }
85
- }
86
- catch {
87
- //
88
- }
89
- }
90
- return sysArch;
91
- }
92
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/ffmpeg/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAI/C;;;;;;;;;GASG;AACH,MAAM,UAAU,WAAW;IACzB,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC;QAC9B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;QAC1E,CAAC;QAED,OAAO,OAAO,CAAC,GAAG,CAAC,aAAgC,CAAC;IACtD,CAAC;IAED,OAAO,QAAQ,EAAE,CAAC;AACpB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,eAAe;I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