node-av 2.4.0 → 2.5.0

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
@@ -220,6 +220,44 @@ try {
220
220
  }
221
221
  ```
222
222
 
223
+ ## FFmpeg Binary Access
224
+
225
+ 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.
226
+
227
+ ```typescript
228
+ import { ffmpegPath, isFfmpegAvailable } from 'node-av/ffmpeg';
229
+ import { execFile } from 'node:child_process';
230
+ import { promisify } from 'node:util';
231
+
232
+ const execFileAsync = promisify(execFile);
233
+
234
+ // Check if FFmpeg binary is available
235
+ if (isFfmpegAvailable()) {
236
+ console.log('FFmpeg binary found at:', ffmpegPath());
237
+
238
+ // Use FFmpeg binary directly
239
+ const { stdout } = await execFileAsync(ffmpegPath(), ['-version']);
240
+ console.log(stdout);
241
+ } else {
242
+ console.log('FFmpeg binary not available - install may have failed');
243
+ }
244
+
245
+ // Direct usage example
246
+ async function convertVideo(input: string, output: string) {
247
+ const args = [
248
+ '-i', input,
249
+ '-c:v', 'libx264',
250
+ '-crf', '23',
251
+ '-c:a', 'aac',
252
+ output
253
+ ];
254
+
255
+ await execFileAsync(ffmpegPath(), args);
256
+ }
257
+ ```
258
+
259
+ The FFmpeg binary is automatically downloaded during installation from GitHub releases and matches the same build used by the native bindings.
260
+
223
261
  ## Performance
224
262
 
225
263
  NodeAV executes all media operations directly through FFmpeg's native C libraries. The Node.js bindings add minimal overhead - mostly just the JavaScript-to-C boundary crossings. During typical operations like transcoding or filtering, most processing time is spent in FFmpeg's optimized C code.
@@ -0,0 +1,2 @@
1
+ export declare const ffmpegPath: () => string;
2
+ export declare const isFfmpegAvailable: () => boolean;
@@ -0,0 +1,14 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { dirname, resolve } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ import { getPlatform } from './utils.js';
5
+ const __filename = fileURLToPath(import.meta.url);
6
+ const __dirname = dirname(__filename);
7
+ const ffmpegBinaryPath = resolve(__dirname, '../../binary');
8
+ const ffmpegFile = 'ffmpeg' + (getPlatform() === 'win32' ? '.exe' : '');
9
+ const ffmpegExtractedFilePath = resolve(ffmpegBinaryPath, ffmpegFile);
10
+ export const ffmpegPath = () => ffmpegExtractedFilePath;
11
+ export const isFfmpegAvailable = () => {
12
+ return existsSync(ffmpegExtractedFilePath);
13
+ };
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEtC,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,MAAM,CAAC,MAAM,UAAU,GAAG,GAAW,EAAE,CAAC,uBAAuB,CAAC;AAEhE,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAY,EAAE;IAC7C,OAAO,UAAU,CAAC,uBAAuB,CAAC,CAAC;AAC7C,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,118 @@
1
+ #!/usr/bin/env node
2
+ import axios from 'axios';
3
+ import { chmodSync, createWriteStream, mkdirSync, rmSync } 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 { pipeline } from 'node:stream/promises';
8
+ import { fileURLToPath } from 'node:url';
9
+ import { Open } from 'unzipper';
10
+ import { ffmpegPath } from './index.js';
11
+ import { getArchitecture, getPlatform, getPlatformType } from './utils.js';
12
+ if (process.env.SKIP_FFMPEG === 'true') {
13
+ console.log('Skipping ffmpeg download');
14
+ process.exit(0);
15
+ }
16
+ const __filename = fileURLToPath(import.meta.url);
17
+ const __dirname = dirname(__filename);
18
+ const __require = createRequire(import.meta.url);
19
+ const releasesUrl = 'https://api.github.com/repos/seydx/node-av/releases';
20
+ const ffmpegVersion = 'v7.1.2';
21
+ const pJson = __require('../../package.json');
22
+ const binaries = {
23
+ darwin: {
24
+ x64: `ffmpeg-${ffmpegVersion}-macos-x64-jellyfin.zip`,
25
+ arm64: `ffmpeg-${ffmpegVersion}-macos-arm64-jellyfin.zip`,
26
+ },
27
+ linux: {
28
+ x64: `ffmpeg-${ffmpegVersion}-linux-x64-jellyfin.zip`,
29
+ arm64: `ffmpeg-${ffmpegVersion}-linux-arm64-jellyfin.zip`,
30
+ },
31
+ win32: {
32
+ x64: `ffmpeg-${ffmpegVersion}-win-x64.zip`,
33
+ arm64: `ffmpeg-${ffmpegVersion}-win-arm64.zip`,
34
+ },
35
+ };
36
+ const arch = getArchitecture();
37
+ const sysPlatform = getPlatform();
38
+ let filename = binaries[sysPlatform]?.[arch];
39
+ if (!filename) {
40
+ console.error(`No ffmpeg binary found for architecture (${sysPlatform} / ${arch})`);
41
+ process.exit(0);
42
+ }
43
+ if (sysPlatform === 'win32' && getPlatformType() !== 'Windows_NT') {
44
+ filename = filename.replace('.zip', '-jellyfin.zip');
45
+ }
46
+ console.log(`Detected platform: ${sysPlatform} / ${arch}`);
47
+ console.log(`Using binary: ${filename}`);
48
+ const ffmpegBinaryPath = resolve(__dirname, '../../binary');
49
+ const ffmpegFilePath = resolve(ffmpegBinaryPath, filename);
50
+ const ffmpegExtractedFilePath = ffmpegPath();
51
+ const isZipUrl = (url) => {
52
+ const pathArray = new URL(url).pathname.split('/');
53
+ const fileName = pathArray[pathArray.length - 1];
54
+ return fileName !== undefined && extname(fileName) === '.zip';
55
+ };
56
+ const downloadFile = async (url) => {
57
+ console.log(`Downloading FFmpeg ${ffmpegVersion} to ${ffmpegFilePath}...`);
58
+ const { data } = await axios.get(url, {
59
+ onDownloadProgress: (progressEvent) => {
60
+ if (process.env.CI || !progressEvent.total) {
61
+ return;
62
+ }
63
+ const percent = Math.round((progressEvent.loaded / progressEvent.total) * 100) + '%';
64
+ process.stdout.write('\r' + percent);
65
+ if (progressEvent.loaded === progressEvent.total) {
66
+ process.stdout.write('\r');
67
+ }
68
+ },
69
+ timeout: 30 * 1000, // 30s
70
+ maxRedirects: 3,
71
+ responseType: 'stream',
72
+ });
73
+ mkdirSync(ffmpegBinaryPath, { recursive: true });
74
+ const streams = [data, createWriteStream(ffmpegFilePath)];
75
+ await pipeline(streams);
76
+ if (isZipUrl(url)) {
77
+ console.log(`Extracting ${ffmpegFilePath} to ${ffmpegExtractedFilePath}...`);
78
+ const directory = await Open.file(ffmpegFilePath);
79
+ await new Promise((resolve, reject) => {
80
+ directory.files[0].stream().pipe(createWriteStream(ffmpegExtractedFilePath)).on('error', reject).on('finish', resolve);
81
+ });
82
+ console.log(`Removing ${ffmpegFilePath}...`);
83
+ rmSync(ffmpegFilePath);
84
+ }
85
+ else {
86
+ console.log(`Renaming ${ffmpegFilePath} to ${ffmpegExtractedFilePath}...`);
87
+ await rename(ffmpegFilePath, ffmpegExtractedFilePath);
88
+ }
89
+ };
90
+ const getReleaseAssets = async (version) => {
91
+ const url = `${releasesUrl}/tags/v${version}`;
92
+ console.log(`Fetching release info from ${url}...`);
93
+ const response = await axios.get(url);
94
+ const assets = response.data.assets.map((asset) => asset.browser_download_url);
95
+ const files = assets.map((asset) => asset.split(`${version}/`)[1]);
96
+ return {
97
+ assets,
98
+ files,
99
+ };
100
+ };
101
+ const downloadFFmpeg = async () => {
102
+ const release = await getReleaseAssets(pJson.version);
103
+ if (!filename || !release.assets.find((r) => r.endsWith(filename))) {
104
+ throw new Error(`No ffmpeg binary found for architecture (${sysPlatform} / ${arch})`);
105
+ }
106
+ const downloadUrl = release.assets.find((r) => r.endsWith(filename));
107
+ await downloadFile(downloadUrl);
108
+ if (sysPlatform === 'linux' || sysPlatform === 'darwin') {
109
+ console.log(`Making ${ffmpegExtractedFilePath} executable...`);
110
+ chmodSync(ffmpegExtractedFilePath, 0o755);
111
+ }
112
+ console.log('Done!');
113
+ };
114
+ downloadFFmpeg().catch((error) => {
115
+ console.error('Error downloading FFmpeg:', error?.messge ?? error);
116
+ process.exit(0);
117
+ });
118
+ //# sourceMappingURL=install.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install.js","sourceRoot":"","sources":["../../src/ffmpeg/install.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC1E,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,sBAAsB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE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AE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAE,CAAC;IAEtE,MAAM,YAAY,CAAC,WAAW,CAAC,CAAC;IAEhC,IAAI,WAAW,KAAK,OAAO,IAAI,WAAW,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,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AACvB,CAAC,CAAC;AAEF,cAAc,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IAC/B,OAAO,CAAC,KAAK,CAAC,2BAA2B,EAAE,KAAK,EAAE,MAAM,IAAI,KAAK,CAAC,CAAC;IACnE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export type ARCH = 'arm' | 'arm6' | 'arm7' | 'arm64' | 'ia32' | 'loong64' | 'mips' | 'mipsel' | 'ppc' | 'ppc64' | 'riscv64' | 's390' | 's390x' | 'x64';
2
+ export declare function getPlatform(): NodeJS.Platform;
3
+ export declare function getPlatformType(): string;
4
+ export declare function getArchitecture(): ARCH;
@@ -0,0 +1,56 @@
1
+ import { execSync } from 'child_process';
2
+ import { arch, platform, type } from 'node:os';
3
+ export function getPlatform() {
4
+ if (process.env.npm_config_os) {
5
+ if (!process.env.npm_config_cpu) {
6
+ throw new Error('npm_config_cpu is required when npm_config_os is set');
7
+ }
8
+ return process.env.npm_config_os;
9
+ }
10
+ return platform();
11
+ }
12
+ export function getPlatformType() {
13
+ return type();
14
+ }
15
+ export function getArchitecture() {
16
+ if (process.env.npm_config_cpu) {
17
+ if (!process.env.npm_config_os) {
18
+ throw new Error('npm_config_os is required when npm_config_cpu is set');
19
+ }
20
+ return process.env.npm_config_cpu;
21
+ }
22
+ const sysPlatform = getPlatform();
23
+ let sysArch = arch();
24
+ if (sysPlatform === 'win32') {
25
+ try {
26
+ const output = execSync('wmic cpu get architecture', { encoding: 'utf8' });
27
+ const architecture = output.trim().split('\n')[1].trim();
28
+ if (architecture === '5') {
29
+ sysArch = 'arm6';
30
+ }
31
+ else if (architecture === '7') {
32
+ sysArch = 'arm7';
33
+ }
34
+ }
35
+ catch {
36
+ //
37
+ }
38
+ }
39
+ else if (sysPlatform === 'linux') {
40
+ try {
41
+ const output = execSync('cat /proc/cpuinfo | grep "model name"', { encoding: 'utf8' });
42
+ const modelName = output.trim().split(':')[1].trim();
43
+ if (modelName.includes('ARMv6')) {
44
+ sysArch = 'arm6';
45
+ }
46
+ else if (modelName.includes('ARMv7')) {
47
+ sysArch = 'arm7';
48
+ }
49
+ }
50
+ catch {
51
+ //
52
+ }
53
+ }
54
+ return sysArch;
55
+ }
56
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
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,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,MAAM,UAAU,eAAe;IAC7B,OAAO,IAAI,EAAE,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,eAAe;IAC7B,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE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;gBACvC,OAAO,GAAG,MAAM,CAAC;YACnB,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,EAAE;QACJ,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './lib/index.js';
2
2
  export * from './api/index.js';
3
3
  export * from './constants/index.js';
4
+ export * from './ffmpeg/index.js';
package/dist/index.js CHANGED
@@ -4,4 +4,6 @@ export * from './lib/index.js';
4
4
  export * from './api/index.js';
5
5
  // Export all generated constants
6
6
  export * from './constants/index.js';
7
+ // Export ffmpeg utilities
8
+ export * from './ffmpeg/index.js';
7
9
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,uBAAuB;AACvB,cAAc,gBAAgB,CAAC;AAE/B,wBAAwB;AACxB,cAAc,gBAAgB,CAAC;AAE/B,iCAAiC;AACjC,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,uBAAuB;AACvB,cAAc,gBAAgB,CAAC;AAE/B,wBAAwB;AACxB,cAAc,gBAAgB,CAAC;AAE/B,iCAAiC;AACjC,cAAc,sBAAsB,CAAC;AAErC,0BAA0B;AAC1B,cAAc,mBAAmB,CAAC"}
@@ -42,9 +42,8 @@ function loadBinding() {
42
42
  }
43
43
  // For Windows, detect MinGW vs MSVC environment
44
44
  if (platform === 'win32') {
45
- const useMSVC = type() === 'Windows_NT';
46
- // Try MinGW version first if in MinGW environment
47
- if (!useMSVC) {
45
+ const useMingW = type() !== 'Windows_NT';
46
+ if (useMingW) {
48
47
  try {
49
48
  const packageName = `@seydx/node-av-${platformArch}-mingw`;
50
49
  return require(`${packageName}/node-av.node`);
@@ -53,7 +52,7 @@ function loadBinding() {
53
52
  errors.push(new Error(`MinGW package not found or loading failed: ${err}`));
54
53
  }
55
54
  }
56
- // Try MSVC version (default for Windows)
55
+ // Fallback to MSVC
57
56
  try {
58
57
  const packageName = `@seydx/node-av-${platformArch}-msvc`;
59
58
  return require(`${packageName}/node-av.node`);
@@ -76,7 +75,7 @@ function loadBinding() {
76
75
  const errorMessages = errors.map((e) => e.message).join('\n ');
77
76
  // prettier-ignore
78
77
  throw new Error(`Could not load the node-av native binding for ${platformArch}.\n` +
79
- `Attempted locations:\n ${errorMessages}\n\n`);
78
+ `Errors:\n ${errorMessages}\n\n`);
80
79
  }
81
80
  // Load the native binding with fallback logic
82
81
  const bindings = loadBinding();
@@ -1 +1 @@
1
- {"version":3,"file":"binding.js","sourceRoot":"","sources":["../../src/lib/binding.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAoCzC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAiPtC;;;;;;GAMG;AACH,SAAS,WAAW;IAClB,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/C,MAAM,MAAM,GAAY,EAAE,CAAC;IAE3B,kBAAkB;IAClB,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAClC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAC1B,MAAM,YAAY,GAAG,GAAG,QAAQ,IAAI,IAAI,EAAE,CAAC;IAE3C,8CAA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GAAG,WAAW,EAAE,CAAC;AAE/B,OAAO,EAAE,QAAQ,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-av",
3
- "version": "2.4.0",
3
+ "version": "2.5.0",
4
4
  "description": "FFmpeg bindings for Node.js",
5
5
  "author": "seydx (https://github.com/seydx/av)",
6
6
  "type": "module",
@@ -24,6 +24,11 @@
24
24
  "types": "./dist/constants/index.d.ts",
25
25
  "require": "./dist/constants/index.js",
26
26
  "default": "./dist/constants/index.js"
27
+ },
28
+ "./ffmpeg": {
29
+ "types": "./dist/ffmpeg/index.d.ts",
30
+ "require": "./dist/ffmpeg/index.js",
31
+ "default": "./dist/ffmpeg/index.js"
27
32
  }
28
33
  },
29
34
  "scripts": {
@@ -46,23 +51,24 @@
46
51
  "install-updates": "npm i --save",
47
52
  "lint": "eslint .",
48
53
  "lint:fix": "eslint --fix .",
54
+ "postinstall": "node dist/ffmpeg/install.js",
49
55
  "predocs": "typedoc && cpy README.md docs/ --rename=index.md",
50
- "release:patch": "node scripts/prepare-release.js patch",
51
- "release:minor": "node scripts/prepare-release.js minor",
52
- "release:major": "node scripts/prepare-release.js major",
56
+ "release:patch": "npm run build:tsc && node scripts/prepare-release.js patch",
57
+ "release:minor": "npm run build:tsc && node scripts/prepare-release.js minor",
58
+ "release:major": "npm run build:tsc && node scripts/prepare-release.js major",
53
59
  "test": "tsx --test test/*.test.ts",
54
60
  "test:all": "npm run build:tests && npm run build:tsc && tsx --test test/*.test.ts",
55
61
  "update": "updates --update ./"
56
62
  },
57
63
  "optionalDependencies": {
58
- "@seydx/node-av-darwin-arm64": "^2.4.0",
59
- "@seydx/node-av-darwin-x64": "^2.4.0",
60
- "@seydx/node-av-linux-arm64": "^2.4.0",
61
- "@seydx/node-av-linux-x64": "^2.4.0",
62
- "@seydx/node-av-win32-arm64-mingw": "^2.4.0",
63
- "@seydx/node-av-win32-x64-mingw": "^2.4.0",
64
- "@seydx/node-av-win32-arm64-msvc": "^2.4.0",
65
- "@seydx/node-av-win32-x64-msvc": "^2.4.0"
64
+ "@seydx/node-av-darwin-arm64": "^2.5.0",
65
+ "@seydx/node-av-darwin-x64": "^2.5.0",
66
+ "@seydx/node-av-linux-arm64": "^2.5.0",
67
+ "@seydx/node-av-linux-x64": "^2.5.0",
68
+ "@seydx/node-av-win32-arm64-mingw": "^2.5.0",
69
+ "@seydx/node-av-win32-arm64-msvc": "^2.5.0",
70
+ "@seydx/node-av-win32-x64-mingw": "^2.5.0",
71
+ "@seydx/node-av-win32-x64-msvc": "^2.5.0"
66
72
  },
67
73
  "devDependencies": {
68
74
  "@camera.ui/ffmpeg": "^0.0.14",
@@ -78,14 +84,14 @@
78
84
  "cpy-cli": "^6.0.0",
79
85
  "cross-env": "^10.0.0",
80
86
  "eslint": "^9.36.0",
81
- "eslint-plugin-jsdoc": "^60.3.1",
87
+ "eslint-plugin-jsdoc": "^60.4.0",
82
88
  "globals": "^16.4.0",
83
89
  "node-addon-api": "^8.5.0",
84
90
  "node-gyp": "^11.4.2",
85
91
  "pngjs": "^7.0.0",
86
92
  "prettier": "^3.6.2",
87
93
  "rimraf": "^6.0.1",
88
- "tsx": "^4.20.5",
94
+ "tsx": "^4.20.6",
89
95
  "typedoc": "^0.28.13",
90
96
  "typedoc-plugin-markdown": "^4.9.0",
91
97
  "typedoc-vitepress-theme": "^1.1.2",
@@ -109,5 +115,8 @@
109
115
  "repository": {
110
116
  "type": "git",
111
117
  "url": "git+https://github.com/seydx/av.git"
118
+ },
119
+ "dependencies": {
120
+ "unzipper": "^0.12.3"
112
121
  }
113
122
  }