node-av-lgpl 0.0.0 → 7.1.0-beta.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.
- package/LICENSE.md +22 -0
- package/README.md +711 -0
- package/dist/api/audio-frame-buffer.d.ts +636 -0
- package/dist/api/audio-frame-buffer.js +1027 -0
- package/dist/api/audio-frame-buffer.js.map +1 -0
- package/dist/api/bitstream-filter.d.ts +938 -0
- package/dist/api/bitstream-filter.js +1427 -0
- package/dist/api/bitstream-filter.js.map +1 -0
- package/dist/api/constants.d.ts +44 -0
- package/dist/api/constants.js +45 -0
- package/dist/api/constants.js.map +1 -0
- package/dist/api/data/test_av1.ivf +0 -0
- package/dist/api/data/test_h264.h264 +0 -0
- package/dist/api/data/test_hevc.h265 +0 -0
- package/dist/api/data/test_mjpeg.mjpeg +0 -0
- package/dist/api/data/test_vp8.ivf +0 -0
- package/dist/api/data/test_vp9.ivf +0 -0
- package/dist/api/decoder.d.ts +1413 -0
- package/dist/api/decoder.js +2367 -0
- package/dist/api/decoder.js.map +1 -0
- package/dist/api/demuxer.d.ts +1295 -0
- package/dist/api/demuxer.js +2344 -0
- package/dist/api/demuxer.js.map +1 -0
- package/dist/api/device.d.ts +589 -0
- package/dist/api/device.js +964 -0
- package/dist/api/device.js.map +1 -0
- package/dist/api/encoder-pool.d.ts +262 -0
- package/dist/api/encoder-pool.js +397 -0
- package/dist/api/encoder-pool.js.map +1 -0
- package/dist/api/encoder.d.ts +1509 -0
- package/dist/api/encoder.js +2619 -0
- package/dist/api/encoder.js.map +1 -0
- package/dist/api/filter-complex.d.ts +828 -0
- package/dist/api/filter-complex.js +1661 -0
- package/dist/api/filter-complex.js.map +1 -0
- package/dist/api/filter-presets.d.ts +800 -0
- package/dist/api/filter-presets.js +1554 -0
- package/dist/api/filter-presets.js.map +1 -0
- package/dist/api/filter.d.ts +1339 -0
- package/dist/api/filter.js +2075 -0
- package/dist/api/filter.js.map +1 -0
- package/dist/api/fmp4-stream.d.ts +797 -0
- package/dist/api/fmp4-stream.js +1428 -0
- package/dist/api/fmp4-stream.js.map +1 -0
- package/dist/api/hardware.d.ts +677 -0
- package/dist/api/hardware.js +1300 -0
- package/dist/api/hardware.js.map +1 -0
- package/dist/api/index.d.ts +21 -0
- package/dist/api/index.js +38 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/io-stream.d.ts +308 -0
- package/dist/api/io-stream.js +358 -0
- package/dist/api/io-stream.js.map +1 -0
- package/dist/api/muxer.d.ts +1311 -0
- package/dist/api/muxer.js +2672 -0
- package/dist/api/muxer.js.map +1 -0
- package/dist/api/pipeline.d.ts +801 -0
- package/dist/api/pipeline.js +1344 -0
- package/dist/api/pipeline.js.map +1 -0
- package/dist/api/probe.d.ts +128 -0
- package/dist/api/probe.js +227 -0
- package/dist/api/probe.js.map +1 -0
- package/dist/api/rtp-stream.d.ts +497 -0
- package/dist/api/rtp-stream.js +1131 -0
- package/dist/api/rtp-stream.js.map +1 -0
- package/dist/api/scaler.d.ts +561 -0
- package/dist/api/scaler.js +918 -0
- package/dist/api/scaler.js.map +1 -0
- package/dist/api/types.d.ts +17 -0
- package/dist/api/types.js +2 -0
- package/dist/api/types.js.map +1 -0
- package/dist/api/utilities/async-queue.d.ts +149 -0
- package/dist/api/utilities/async-queue.js +254 -0
- package/dist/api/utilities/async-queue.js.map +1 -0
- package/dist/api/utilities/audio-sample.d.ts +117 -0
- package/dist/api/utilities/audio-sample.js +112 -0
- package/dist/api/utilities/audio-sample.js.map +1 -0
- package/dist/api/utilities/audio-transcode.d.ts +20 -0
- package/dist/api/utilities/audio-transcode.js +27 -0
- package/dist/api/utilities/audio-transcode.js.map +1 -0
- package/dist/api/utilities/channel-layout.d.ts +76 -0
- package/dist/api/utilities/channel-layout.js +80 -0
- package/dist/api/utilities/channel-layout.js.map +1 -0
- package/dist/api/utilities/codec-format.d.ts +87 -0
- package/dist/api/utilities/codec-format.js +117 -0
- package/dist/api/utilities/codec-format.js.map +1 -0
- package/dist/api/utilities/context-options.d.ts +25 -0
- package/dist/api/utilities/context-options.js +23 -0
- package/dist/api/utilities/context-options.js.map +1 -0
- package/dist/api/utilities/electron-shared-texture.d.ts +368 -0
- package/dist/api/utilities/electron-shared-texture.js +540 -0
- package/dist/api/utilities/electron-shared-texture.js.map +1 -0
- package/dist/api/utilities/image.d.ts +207 -0
- package/dist/api/utilities/image.js +213 -0
- package/dist/api/utilities/image.js.map +1 -0
- package/dist/api/utilities/index.d.ts +14 -0
- package/dist/api/utilities/index.js +27 -0
- package/dist/api/utilities/index.js.map +1 -0
- package/dist/api/utilities/live-decoding.d.ts +15 -0
- package/dist/api/utilities/live-decoding.js +32 -0
- package/dist/api/utilities/live-decoding.js.map +1 -0
- package/dist/api/utilities/media-type.d.ts +49 -0
- package/dist/api/utilities/media-type.js +53 -0
- package/dist/api/utilities/media-type.js.map +1 -0
- package/dist/api/utilities/packet-age-watchdog.d.ts +198 -0
- package/dist/api/utilities/packet-age-watchdog.js +594 -0
- package/dist/api/utilities/packet-age-watchdog.js.map +1 -0
- package/dist/api/utilities/pixel-format.d.ts +89 -0
- package/dist/api/utilities/pixel-format.js +97 -0
- package/dist/api/utilities/pixel-format.js.map +1 -0
- package/dist/api/utilities/sample-format.d.ts +129 -0
- package/dist/api/utilities/sample-format.js +141 -0
- package/dist/api/utilities/sample-format.js.map +1 -0
- package/dist/api/utilities/scale-size.d.ts +51 -0
- package/dist/api/utilities/scale-size.js +55 -0
- package/dist/api/utilities/scale-size.js.map +1 -0
- package/dist/api/utilities/scheduler.d.ts +138 -0
- package/dist/api/utilities/scheduler.js +98 -0
- package/dist/api/utilities/scheduler.js.map +1 -0
- package/dist/api/utilities/streaming.d.ts +186 -0
- package/dist/api/utilities/streaming.js +309 -0
- package/dist/api/utilities/streaming.js.map +1 -0
- package/dist/api/utilities/timestamp.d.ts +193 -0
- package/dist/api/utilities/timestamp.js +206 -0
- package/dist/api/utilities/timestamp.js.map +1 -0
- package/dist/api/utilities/video-transcode.d.ts +218 -0
- package/dist/api/utilities/video-transcode.js +624 -0
- package/dist/api/utilities/video-transcode.js.map +1 -0
- package/dist/api/utilities/whisper-model.d.ts +330 -0
- package/dist/api/utilities/whisper-model.js +587 -0
- package/dist/api/utilities/whisper-model.js.map +1 -0
- package/dist/api/utils.d.ts +19 -0
- package/dist/api/utils.js +39 -0
- package/dist/api/utils.js.map +1 -0
- package/dist/api/webrtc-stream.d.ts +294 -0
- package/dist/api/webrtc-stream.js +546 -0
- package/dist/api/webrtc-stream.js.map +1 -0
- package/dist/api/whisper.d.ts +326 -0
- package/dist/api/whisper.js +402 -0
- package/dist/api/whisper.js.map +1 -0
- package/dist/constants/bsf-options.d.ts +364 -0
- package/dist/constants/bsf-options.js +7 -0
- package/dist/constants/bsf-options.js.map +1 -0
- package/dist/constants/channel-layouts.d.ts +53 -0
- package/dist/constants/channel-layouts.js +57 -0
- package/dist/constants/channel-layouts.js.map +1 -0
- package/dist/constants/constants.d.ts +2435 -0
- package/dist/constants/constants.js +1989 -0
- package/dist/constants/constants.js.map +1 -0
- package/dist/constants/decoders.d.ts +651 -0
- package/dist/constants/decoders.js +641 -0
- package/dist/constants/decoders.js.map +1 -0
- package/dist/constants/encoders.d.ts +314 -0
- package/dist/constants/encoders.js +309 -0
- package/dist/constants/encoders.js.map +1 -0
- package/dist/constants/filter-options.d.ts +12099 -0
- package/dist/constants/filter-options.js +7 -0
- package/dist/constants/filter-options.js.map +1 -0
- package/dist/constants/format-options.d.ts +4319 -0
- package/dist/constants/format-options.js +7 -0
- package/dist/constants/format-options.js.map +1 -0
- package/dist/constants/formats.d.ts +18 -0
- package/dist/constants/formats.js +7 -0
- package/dist/constants/formats.js.map +1 -0
- package/dist/constants/hardware.d.ts +26 -0
- package/dist/constants/hardware.js +27 -0
- package/dist/constants/hardware.js.map +1 -0
- package/dist/constants/index.d.ts +10 -0
- package/dist/constants/index.js +6 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/constants/options.d.ts +6217 -0
- package/dist/constants/options.js +7 -0
- package/dist/constants/options.js.map +1 -0
- package/dist/ffmpeg/index.d.ts +101 -0
- package/dist/ffmpeg/index.js +161 -0
- package/dist/ffmpeg/index.js.map +1 -0
- package/dist/ffmpeg/version.d.ts +6 -0
- package/dist/ffmpeg/version.js +7 -0
- package/dist/ffmpeg/version.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/audio-fifo.d.ts +399 -0
- package/dist/lib/audio-fifo.js +431 -0
- package/dist/lib/audio-fifo.js.map +1 -0
- package/dist/lib/binding.d.ts +242 -0
- package/dist/lib/binding.js +102 -0
- package/dist/lib/binding.js.map +1 -0
- package/dist/lib/bitstream-filter-context.d.ts +381 -0
- package/dist/lib/bitstream-filter-context.js +443 -0
- package/dist/lib/bitstream-filter-context.js.map +1 -0
- package/dist/lib/bitstream-filter.d.ts +140 -0
- package/dist/lib/bitstream-filter.js +154 -0
- package/dist/lib/bitstream-filter.js.map +1 -0
- package/dist/lib/codec-context.d.ts +1069 -0
- package/dist/lib/codec-context.js +1336 -0
- package/dist/lib/codec-context.js.map +1 -0
- package/dist/lib/codec-parameters.d.ts +664 -0
- package/dist/lib/codec-parameters.js +813 -0
- package/dist/lib/codec-parameters.js.map +1 -0
- package/dist/lib/codec-parser.d.ts +201 -0
- package/dist/lib/codec-parser.js +213 -0
- package/dist/lib/codec-parser.js.map +1 -0
- package/dist/lib/codec.d.ts +617 -0
- package/dist/lib/codec.js +746 -0
- package/dist/lib/codec.js.map +1 -0
- package/dist/lib/device.d.ts +294 -0
- package/dist/lib/device.js +326 -0
- package/dist/lib/device.js.map +1 -0
- package/dist/lib/dictionary.d.ts +333 -0
- package/dist/lib/dictionary.js +372 -0
- package/dist/lib/dictionary.js.map +1 -0
- package/dist/lib/error.d.ts +311 -0
- package/dist/lib/error.js +395 -0
- package/dist/lib/error.js.map +1 -0
- package/dist/lib/fifo.d.ts +416 -0
- package/dist/lib/fifo.js +453 -0
- package/dist/lib/fifo.js.map +1 -0
- package/dist/lib/filter-context.d.ts +714 -0
- package/dist/lib/filter-context.js +783 -0
- package/dist/lib/filter-context.js.map +1 -0
- package/dist/lib/filter-graph-segment.d.ts +161 -0
- package/dist/lib/filter-graph-segment.js +172 -0
- package/dist/lib/filter-graph-segment.js.map +1 -0
- package/dist/lib/filter-graph.d.ts +641 -0
- package/dist/lib/filter-graph.js +704 -0
- package/dist/lib/filter-graph.js.map +1 -0
- package/dist/lib/filter-inout.d.ts +202 -0
- package/dist/lib/filter-inout.js +261 -0
- package/dist/lib/filter-inout.js.map +1 -0
- package/dist/lib/filter.d.ts +243 -0
- package/dist/lib/filter.js +272 -0
- package/dist/lib/filter.js.map +1 -0
- package/dist/lib/format-context.d.ts +1335 -0
- package/dist/lib/format-context.js +1455 -0
- package/dist/lib/format-context.js.map +1 -0
- package/dist/lib/frame-utils.d.ts +116 -0
- package/dist/lib/frame-utils.js +98 -0
- package/dist/lib/frame-utils.js.map +1 -0
- package/dist/lib/frame.d.ts +1315 -0
- package/dist/lib/frame.js +1535 -0
- package/dist/lib/frame.js.map +1 -0
- package/dist/lib/hardware-device-context.d.ts +362 -0
- package/dist/lib/hardware-device-context.js +383 -0
- package/dist/lib/hardware-device-context.js.map +1 -0
- package/dist/lib/hardware-frames-context.d.ts +418 -0
- package/dist/lib/hardware-frames-context.js +471 -0
- package/dist/lib/hardware-frames-context.js.map +1 -0
- package/dist/lib/index.d.ts +35 -0
- package/dist/lib/index.js +60 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/input-format.d.ts +249 -0
- package/dist/lib/input-format.js +306 -0
- package/dist/lib/input-format.js.map +1 -0
- package/dist/lib/io-context.d.ts +698 -0
- package/dist/lib/io-context.js +771 -0
- package/dist/lib/io-context.js.map +1 -0
- package/dist/lib/log.d.ts +174 -0
- package/dist/lib/log.js +184 -0
- package/dist/lib/log.js.map +1 -0
- package/dist/lib/native-types.d.ts +1024 -0
- package/dist/lib/native-types.js +2 -0
- package/dist/lib/native-types.js.map +1 -0
- package/dist/lib/option.d.ts +953 -0
- package/dist/lib/option.js +1607 -0
- package/dist/lib/option.js.map +1 -0
- package/dist/lib/output-format.d.ts +222 -0
- package/dist/lib/output-format.js +259 -0
- package/dist/lib/output-format.js.map +1 -0
- package/dist/lib/packet.d.ts +521 -0
- package/dist/lib/packet.js +613 -0
- package/dist/lib/packet.js.map +1 -0
- package/dist/lib/rational.d.ts +251 -0
- package/dist/lib/rational.js +278 -0
- package/dist/lib/rational.js.map +1 -0
- package/dist/lib/software-resample-context.d.ts +552 -0
- package/dist/lib/software-resample-context.js +592 -0
- package/dist/lib/software-resample-context.js.map +1 -0
- package/dist/lib/software-scale-context.d.ts +344 -0
- package/dist/lib/software-scale-context.js +366 -0
- package/dist/lib/software-scale-context.js.map +1 -0
- package/dist/lib/stream.d.ts +384 -0
- package/dist/lib/stream.js +525 -0
- package/dist/lib/stream.js.map +1 -0
- package/dist/lib/sync-queue.d.ts +179 -0
- package/dist/lib/sync-queue.js +197 -0
- package/dist/lib/sync-queue.js.map +1 -0
- package/dist/lib/types.d.ts +34 -0
- package/dist/lib/types.js +2 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/utilities.d.ts +1198 -0
- package/dist/lib/utilities.js +1302 -0
- package/dist/lib/utilities.js.map +1 -0
- package/dist/utils/electron.d.ts +49 -0
- package/dist/utils/electron.js +63 -0
- package/dist/utils/electron.js.map +1 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.js +7 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/libc.d.ts +11 -0
- package/dist/utils/libc.js +35 -0
- package/dist/utils/libc.js.map +1 -0
- package/dist/utils/variant.d.ts +26 -0
- package/dist/utils/variant.js +31 -0
- package/dist/utils/variant.js.map +1 -0
- package/dist/webrtc/index.d.ts +4 -0
- package/dist/webrtc/index.js +7 -0
- package/dist/webrtc/index.js.map +1 -0
- package/install/check.js +124 -0
- package/install/ffmpeg.js +66 -0
- package/package.json +165 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/constants/options.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the absolute path to the FFmpeg binary.
|
|
3
|
+
*
|
|
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
|
+
* so node-av-lgpl and node-av-light use `@seydx/node-av-ffmpeg-lgpl` and
|
|
8
|
+
* `@seydx/node-av-ffmpeg-light` instead.
|
|
9
|
+
* In Electron apps the path points into `app.asar.unpacked`.
|
|
10
|
+
*
|
|
11
|
+
* @returns Absolute path to the FFmpeg binary
|
|
12
|
+
*
|
|
13
|
+
* @throws {Error} If the FFmpeg CLI package is not installed or has no build for this platform
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* import { ffmpegPath } from 'node-av/ffmpeg';
|
|
18
|
+
*
|
|
19
|
+
* const path = ffmpegPath();
|
|
20
|
+
* console.log('FFmpeg binary at:', path);
|
|
21
|
+
* // e.g. /path/to/node_modules/@seydx/node-av-ffmpeg-linux-x64/ffmpeg
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @example Convert video using FFmpeg binary
|
|
25
|
+
* ```typescript
|
|
26
|
+
* import { ffmpegPath } from 'node-av/ffmpeg';
|
|
27
|
+
* import { execFile } from 'node:child_process';
|
|
28
|
+
* import { promisify } from 'node:util';
|
|
29
|
+
*
|
|
30
|
+
* const execFileAsync = promisify(execFile);
|
|
31
|
+
*
|
|
32
|
+
* async function convertVideo(input: string, output: string) {
|
|
33
|
+
* const args = [
|
|
34
|
+
* '-i', input,
|
|
35
|
+
* '-c:v', 'libx264',
|
|
36
|
+
* '-crf', '23',
|
|
37
|
+
* '-c:a', 'aac',
|
|
38
|
+
* output
|
|
39
|
+
* ];
|
|
40
|
+
*
|
|
41
|
+
* await execFileAsync(ffmpegPath(), args);
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare function ffmpegPath(): string;
|
|
46
|
+
/**
|
|
47
|
+
* Check if the FFmpeg binary is available.
|
|
48
|
+
*
|
|
49
|
+
* Returns whether the FFmpeg CLI package (`@seydx/node-av-ffmpeg`, or the
|
|
50
|
+
* one of the node-av-lgpl and node-av-light variants) is installed with a
|
|
51
|
+
* build for this platform, i.e. whether {@link ffmpegPath} will succeed.
|
|
52
|
+
*
|
|
53
|
+
* @returns `true` if the FFmpeg binary exists, `false` otherwise
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* import { isFfmpegAvailable, ffmpegPath } from 'node-av/ffmpeg';
|
|
58
|
+
*
|
|
59
|
+
* if (isFfmpegAvailable()) {
|
|
60
|
+
* console.log('FFmpeg is ready to use');
|
|
61
|
+
* // Safe to use ffmpegPath() and execute FFmpeg commands
|
|
62
|
+
* } else {
|
|
63
|
+
* console.log('FFmpeg binary not found, run: npm install @seydx/node-av-ffmpeg');
|
|
64
|
+
* }
|
|
65
|
+
* ```
|
|
66
|
+
*
|
|
67
|
+
* @example Conditional FFmpeg usage
|
|
68
|
+
* ```typescript
|
|
69
|
+
* import { isFfmpegAvailable, ffmpegPath } from 'node-av/ffmpeg';
|
|
70
|
+
* import { execFile } from 'node:child_process';
|
|
71
|
+
*
|
|
72
|
+
* async function getFFmpegVersion(): Promise<string | null> {
|
|
73
|
+
* if (!isFfmpegAvailable()) {
|
|
74
|
+
* return null;
|
|
75
|
+
* }
|
|
76
|
+
*
|
|
77
|
+
* try {
|
|
78
|
+
* const { stdout } = await execFile(ffmpegPath(), ['-version']);
|
|
79
|
+
* return stdout;
|
|
80
|
+
* } catch (error) {
|
|
81
|
+
* console.error('Failed to execute FFmpeg:', error);
|
|
82
|
+
* return null;
|
|
83
|
+
* }
|
|
84
|
+
* }
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
export declare function isFfmpegAvailable(): boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Get the FFmpeg version used by the binary.
|
|
90
|
+
*
|
|
91
|
+
* @returns FFmpeg version string (e.g. "8.0")
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```typescript
|
|
95
|
+
* import { ffmpegVersion } from 'node-av/ffmpeg';
|
|
96
|
+
*
|
|
97
|
+
* console.log('FFmpeg version:', ffmpegVersion());
|
|
98
|
+
* // Output: FFmpeg version: 8.0
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
export declare function ffmpegVersion(): string;
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
import { dirname, join, resolve } from 'node:path';
|
|
4
|
+
import { getDirname, getUnpackedPath } from '../utils/electron.js';
|
|
5
|
+
import { isMusl } from '../utils/libc.js';
|
|
6
|
+
import { ffmpegPackageName } from '../utils/variant.js';
|
|
7
|
+
import { FFMPEG_VERSION } from './version.js';
|
|
8
|
+
const __dirname = getDirname(import.meta.url);
|
|
9
|
+
const require = createRequire(import.meta.url);
|
|
10
|
+
// @seydx/node-av-ffmpeg, or the -lgpl / -light package of the other variants
|
|
11
|
+
const FFMPEG_PACKAGE = ffmpegPackageName();
|
|
12
|
+
const ffmpegFile = 'ffmpeg' + (process.platform === 'win32' ? '.exe' : '');
|
|
13
|
+
// Local build (development, CI tests): binary/ next to dist/
|
|
14
|
+
const localFfmpegPath = resolve(__dirname, '../../binary', ffmpegFile);
|
|
15
|
+
let resolvedFfmpegPath = null;
|
|
16
|
+
/**
|
|
17
|
+
* Find the FFmpeg binary.
|
|
18
|
+
*
|
|
19
|
+
* Checks the local `binary/` folder first, then the platform package installed by the variant's FFmpeg CLI package.
|
|
20
|
+
*
|
|
21
|
+
* @returns Absolute path to the binary, or `null` if neither is installed
|
|
22
|
+
*
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
function findFfmpeg() {
|
|
26
|
+
if (resolvedFfmpegPath) {
|
|
27
|
+
return resolvedFfmpegPath;
|
|
28
|
+
}
|
|
29
|
+
if (existsSync(localFfmpegPath)) {
|
|
30
|
+
resolvedFfmpegPath = localFfmpegPath;
|
|
31
|
+
return resolvedFfmpegPath;
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
// The platform package is a dependency of the meta package, not of node-av, so it is
|
|
35
|
+
// resolved from there (strict layouts like pnpm don't expose it to node-av directly).
|
|
36
|
+
const metaPackageJson = require.resolve(`${FFMPEG_PACKAGE}/package.json`);
|
|
37
|
+
const platformPackage = `${FFMPEG_PACKAGE}-${process.platform}-${process.arch}${isMusl() ? '-musl' : ''}`;
|
|
38
|
+
const platformPackageJson = createRequire(metaPackageJson).resolve(`${platformPackage}/package.json`);
|
|
39
|
+
const path = getUnpackedPath(join(dirname(platformPackageJson), ffmpegFile));
|
|
40
|
+
if (existsSync(path)) {
|
|
41
|
+
resolvedFfmpegPath = path;
|
|
42
|
+
return resolvedFfmpegPath;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
// Not installed, or no build for this platform
|
|
47
|
+
}
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Get the absolute path to the FFmpeg binary.
|
|
52
|
+
*
|
|
53
|
+
* The binary ships in the optional `@seydx/node-av-ffmpeg` package
|
|
54
|
+
* (`npm install @seydx/node-av-ffmpeg`), which installs the build for the
|
|
55
|
+
* current platform. It is built from the same FFmpeg as the native bindings,
|
|
56
|
+
* so node-av-lgpl and node-av-light use `@seydx/node-av-ffmpeg-lgpl` and
|
|
57
|
+
* `@seydx/node-av-ffmpeg-light` instead.
|
|
58
|
+
* In Electron apps the path points into `app.asar.unpacked`.
|
|
59
|
+
*
|
|
60
|
+
* @returns Absolute path to the FFmpeg binary
|
|
61
|
+
*
|
|
62
|
+
* @throws {Error} If the FFmpeg CLI package is not installed or has no build for this platform
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* import { ffmpegPath } from 'node-av/ffmpeg';
|
|
67
|
+
*
|
|
68
|
+
* const path = ffmpegPath();
|
|
69
|
+
* console.log('FFmpeg binary at:', path);
|
|
70
|
+
* // e.g. /path/to/node_modules/@seydx/node-av-ffmpeg-linux-x64/ffmpeg
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* @example Convert video using FFmpeg binary
|
|
74
|
+
* ```typescript
|
|
75
|
+
* import { ffmpegPath } from 'node-av/ffmpeg';
|
|
76
|
+
* import { execFile } from 'node:child_process';
|
|
77
|
+
* import { promisify } from 'node:util';
|
|
78
|
+
*
|
|
79
|
+
* const execFileAsync = promisify(execFile);
|
|
80
|
+
*
|
|
81
|
+
* async function convertVideo(input: string, output: string) {
|
|
82
|
+
* const args = [
|
|
83
|
+
* '-i', input,
|
|
84
|
+
* '-c:v', 'libx264',
|
|
85
|
+
* '-crf', '23',
|
|
86
|
+
* '-c:a', 'aac',
|
|
87
|
+
* output
|
|
88
|
+
* ];
|
|
89
|
+
*
|
|
90
|
+
* await execFileAsync(ffmpegPath(), args);
|
|
91
|
+
* }
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
export function ffmpegPath() {
|
|
95
|
+
const path = findFfmpeg();
|
|
96
|
+
if (!path) {
|
|
97
|
+
throw new Error(`FFmpeg binary not found for ${process.platform}-${process.arch}. Install it with: npm install ${FFMPEG_PACKAGE}`);
|
|
98
|
+
}
|
|
99
|
+
return path;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Check if the FFmpeg binary is available.
|
|
103
|
+
*
|
|
104
|
+
* Returns whether the FFmpeg CLI package (`@seydx/node-av-ffmpeg`, or the
|
|
105
|
+
* one of the node-av-lgpl and node-av-light variants) is installed with a
|
|
106
|
+
* build for this platform, i.e. whether {@link ffmpegPath} will succeed.
|
|
107
|
+
*
|
|
108
|
+
* @returns `true` if the FFmpeg binary exists, `false` otherwise
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```typescript
|
|
112
|
+
* import { isFfmpegAvailable, ffmpegPath } from 'node-av/ffmpeg';
|
|
113
|
+
*
|
|
114
|
+
* if (isFfmpegAvailable()) {
|
|
115
|
+
* console.log('FFmpeg is ready to use');
|
|
116
|
+
* // Safe to use ffmpegPath() and execute FFmpeg commands
|
|
117
|
+
* } else {
|
|
118
|
+
* console.log('FFmpeg binary not found, run: npm install @seydx/node-av-ffmpeg');
|
|
119
|
+
* }
|
|
120
|
+
* ```
|
|
121
|
+
*
|
|
122
|
+
* @example Conditional FFmpeg usage
|
|
123
|
+
* ```typescript
|
|
124
|
+
* import { isFfmpegAvailable, ffmpegPath } from 'node-av/ffmpeg';
|
|
125
|
+
* import { execFile } from 'node:child_process';
|
|
126
|
+
*
|
|
127
|
+
* async function getFFmpegVersion(): Promise<string | null> {
|
|
128
|
+
* if (!isFfmpegAvailable()) {
|
|
129
|
+
* return null;
|
|
130
|
+
* }
|
|
131
|
+
*
|
|
132
|
+
* try {
|
|
133
|
+
* const { stdout } = await execFile(ffmpegPath(), ['-version']);
|
|
134
|
+
* return stdout;
|
|
135
|
+
* } catch (error) {
|
|
136
|
+
* console.error('Failed to execute FFmpeg:', error);
|
|
137
|
+
* return null;
|
|
138
|
+
* }
|
|
139
|
+
* }
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
export function isFfmpegAvailable() {
|
|
143
|
+
return findFfmpeg() !== null;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Get the FFmpeg version used by the binary.
|
|
147
|
+
*
|
|
148
|
+
* @returns FFmpeg version string (e.g. "8.0")
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* ```typescript
|
|
152
|
+
* import { ffmpegVersion } from 'node-av/ffmpeg';
|
|
153
|
+
*
|
|
154
|
+
* console.log('FFmpeg version:', ffmpegVersion());
|
|
155
|
+
* // Output: FFmpeg version: 8.0
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
158
|
+
export function ffmpegVersion() {
|
|
159
|
+
return FFMPEG_VERSION;
|
|
160
|
+
}
|
|
161
|
+
//# 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,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEnD,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,SAAS,GAAG,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC9C,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE/C,6EAA6E;AAC7E,MAAM,cAAc,GAAG,iBAAiB,EAAE,CAAC;AAC3C,MAAM,UAAU,GAAG,QAAQ,GAAG,CAAC,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAE3E,6DAA6D;AAC7D,MAAM,eAAe,GAAG,OAAO,CAAC,SAAS,EAAE,cAAc,EAAE,UAAU,CAAC,CAAC;AAEvE,IAAI,kBAAkB,GAAkB,IAAI,CAAC;AAE7C;;;;;;;;GAQG;AACH,SAAS,UAAU;IACjB,IAAI,kBAAkB,EAAE,CAAC;QACvB,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IAED,IAAI,UAAU,CAAC,eAAe,CAAC,EAAE,CAAC;QAChC,kBAAkB,GAAG,eAAe,CAAC;QACrC,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IAED,IAAI,CAAC;QACH,qFAAqF;QACrF,sFAAsF;QACtF,MAAM,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,cAAc,eAAe,CAAC,CAAC;QAC1E,MAAM,eAAe,GAAG,GAAG,cAAc,IAAI,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,IAAI,GAAG,MAAM,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QAC1G,MAAM,mBAAmB,GAAG,aAAa,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,GAAG,eAAe,eAAe,CAAC,CAAC;QACtG,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/ffmpeg/version.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG,OAAO,CAAC"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Export low-level API
|
|
2
|
+
export * from './lib/index.js';
|
|
3
|
+
// Export high-level API
|
|
4
|
+
export * from './api/index.js';
|
|
5
|
+
// Export all generated constants
|
|
6
|
+
export * from './constants/index.js';
|
|
7
|
+
// Export ffmpeg utilities
|
|
8
|
+
export * from './ffmpeg/index.js';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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;AAErC,0BAA0B;AAC1B,cAAc,mBAAmB,CAAC"}
|