@revizly/node-av 5.2.2-beta.1
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/BUILD_LINUX.md +61 -0
- package/LICENSE.md +22 -0
- package/README.md +662 -0
- package/build_mac_local.sh +69 -0
- package/dist/api/audio-frame-buffer.d.ts +205 -0
- package/dist/api/audio-frame-buffer.js +287 -0
- package/dist/api/audio-frame-buffer.js.map +1 -0
- package/dist/api/bitstream-filter.d.ts +820 -0
- package/dist/api/bitstream-filter.js +1242 -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 +1088 -0
- package/dist/api/decoder.js +1775 -0
- package/dist/api/decoder.js.map +1 -0
- package/dist/api/demuxer.d.ts +1219 -0
- package/dist/api/demuxer.js +2081 -0
- package/dist/api/demuxer.js.map +1 -0
- package/dist/api/device.d.ts +586 -0
- package/dist/api/device.js +961 -0
- package/dist/api/device.js.map +1 -0
- package/dist/api/encoder.d.ts +1132 -0
- package/dist/api/encoder.js +1988 -0
- package/dist/api/encoder.js.map +1 -0
- package/dist/api/filter-complex.d.ts +821 -0
- package/dist/api/filter-complex.js +1604 -0
- package/dist/api/filter-complex.js.map +1 -0
- package/dist/api/filter-presets.d.ts +1286 -0
- package/dist/api/filter-presets.js +2152 -0
- package/dist/api/filter-presets.js.map +1 -0
- package/dist/api/filter.d.ts +1234 -0
- package/dist/api/filter.js +1976 -0
- package/dist/api/filter.js.map +1 -0
- package/dist/api/fmp4-stream.d.ts +426 -0
- package/dist/api/fmp4-stream.js +739 -0
- package/dist/api/fmp4-stream.js.map +1 -0
- package/dist/api/hardware.d.ts +651 -0
- package/dist/api/hardware.js +1260 -0
- package/dist/api/hardware.js.map +1 -0
- package/dist/api/index.d.ts +17 -0
- package/dist/api/index.js +32 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/io-stream.d.ts +307 -0
- package/dist/api/io-stream.js +282 -0
- package/dist/api/io-stream.js.map +1 -0
- package/dist/api/muxer.d.ts +957 -0
- package/dist/api/muxer.js +2002 -0
- package/dist/api/muxer.js.map +1 -0
- package/dist/api/pipeline.d.ts +607 -0
- package/dist/api/pipeline.js +1145 -0
- package/dist/api/pipeline.js.map +1 -0
- package/dist/api/utilities/async-queue.d.ts +120 -0
- package/dist/api/utilities/async-queue.js +211 -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/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/electron-shared-texture.d.ts +328 -0
- package/dist/api/utilities/electron-shared-texture.js +503 -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 +12 -0
- package/dist/api/utilities/index.js +25 -0
- package/dist/api/utilities/index.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/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/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/whisper-model.d.ts +310 -0
- package/dist/api/utilities/whisper-model.js +528 -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/whisper.d.ts +324 -0
- package/dist/api/whisper.js +362 -0
- package/dist/api/whisper.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 +2325 -0
- package/dist/constants/constants.js +1887 -0
- package/dist/constants/constants.js.map +1 -0
- package/dist/constants/decoders.d.ts +633 -0
- package/dist/constants/decoders.js +641 -0
- package/dist/constants/decoders.js.map +1 -0
- package/dist/constants/encoders.d.ts +295 -0
- package/dist/constants/encoders.js +308 -0
- package/dist/constants/encoders.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 +5 -0
- package/dist/constants/index.js +6 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/ffmpeg/index.d.ts +99 -0
- package/dist/ffmpeg/index.js +115 -0
- package/dist/ffmpeg/index.js.map +1 -0
- package/dist/ffmpeg/utils.d.ts +31 -0
- package/dist/ffmpeg/utils.js +68 -0
- package/dist/ffmpeg/utils.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 +228 -0
- package/dist/lib/binding.js +60 -0
- package/dist/lib/binding.js.map +1 -0
- package/dist/lib/bitstream-filter-context.d.ts +379 -0
- package/dist/lib/bitstream-filter-context.js +441 -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 +1071 -0
- package/dist/lib/codec-context.js +1354 -0
- package/dist/lib/codec-context.js.map +1 -0
- package/dist/lib/codec-parameters.d.ts +616 -0
- package/dist/lib/codec-parameters.js +761 -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 +586 -0
- package/dist/lib/codec.js +713 -0
- package/dist/lib/codec.js.map +1 -0
- package/dist/lib/device.d.ts +291 -0
- package/dist/lib/device.js +324 -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 +242 -0
- package/dist/lib/error.js +303 -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 +712 -0
- package/dist/lib/filter-context.js +789 -0
- package/dist/lib/filter-context.js.map +1 -0
- package/dist/lib/filter-graph-segment.d.ts +160 -0
- package/dist/lib/filter-graph-segment.js +171 -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 +198 -0
- package/dist/lib/filter-inout.js +257 -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 +1254 -0
- package/dist/lib/format-context.js +1379 -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 +1222 -0
- package/dist/lib/frame.js +1435 -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 +419 -0
- package/dist/lib/hardware-frames-context.js +477 -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 +696 -0
- package/dist/lib/io-context.js +769 -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 +946 -0
- package/dist/lib/native-types.js +2 -0
- package/dist/lib/native-types.js.map +1 -0
- package/dist/lib/option.d.ts +927 -0
- package/dist/lib/option.js +1583 -0
- package/dist/lib/option.js.map +1 -0
- package/dist/lib/output-format.d.ts +180 -0
- package/dist/lib/output-format.js +213 -0
- package/dist/lib/output-format.js.map +1 -0
- package/dist/lib/packet.d.ts +501 -0
- package/dist/lib/packet.js +590 -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 +379 -0
- package/dist/lib/stream.js +526 -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 +1127 -0
- package/dist/lib/utilities.js +1225 -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 +4 -0
- package/dist/utils/index.js +5 -0
- package/dist/utils/index.js.map +1 -0
- package/install/check.js +121 -0
- package/install/ffmpeg.js +66 -0
- package/jellyfin-ffmpeg.patch +181 -0
- package/package.json +129 -0
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
import { bindings } from './binding.js';
|
|
2
|
+
/**
|
|
3
|
+
* Audio FIFO (First-In-First-Out) buffer for managing audio samples.
|
|
4
|
+
*
|
|
5
|
+
* Provides a thread-safe buffer for audio sample data, supporting both planar and interleaved formats.
|
|
6
|
+
* Automatically handles buffer reallocation when needed. Essential for audio resampling,
|
|
7
|
+
* format conversion, and buffering operations.
|
|
8
|
+
*
|
|
9
|
+
* Direct mapping to FFmpeg's AVAudioFifo.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { AudioFifo, FFmpegError } from 'node-av';
|
|
14
|
+
* import { AV_SAMPLE_FMT_FLTP } from 'node-av/constants';
|
|
15
|
+
*
|
|
16
|
+
* // Create FIFO for stereo float planar audio
|
|
17
|
+
* const fifo = new AudioFifo();
|
|
18
|
+
* fifo.alloc(AV_SAMPLE_FMT_FLTP, 2, 4096);
|
|
19
|
+
*
|
|
20
|
+
* // Write samples
|
|
21
|
+
* const leftChannel = Buffer.alloc(1024 * 4); // 1024 float samples
|
|
22
|
+
* const rightChannel = Buffer.alloc(1024 * 4);
|
|
23
|
+
* const written = await fifo.write([leftChannel, rightChannel], 1024);
|
|
24
|
+
* FFmpegError.throwIfError(written, 'write');
|
|
25
|
+
*
|
|
26
|
+
* // Read samples when enough available
|
|
27
|
+
* if (fifo.size >= 512) {
|
|
28
|
+
* const outLeft = Buffer.alloc(512 * 4);
|
|
29
|
+
* const outRight = Buffer.alloc(512 * 4);
|
|
30
|
+
* const read = await fifo.read([outLeft, outRight], 512);
|
|
31
|
+
* FFmpegError.throwIfError(read, 'read');
|
|
32
|
+
* }
|
|
33
|
+
*
|
|
34
|
+
* // Cleanup
|
|
35
|
+
* fifo.free();
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @see [AudioFifo](https://ffmpeg.org/doxygen/trunk/structAVAudioFifo.html) - FFmpeg Doxygen
|
|
39
|
+
*/
|
|
40
|
+
export class AudioFifo {
|
|
41
|
+
native;
|
|
42
|
+
constructor() {
|
|
43
|
+
this.native = new bindings.AudioFifo();
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Number of samples currently in the FIFO.
|
|
47
|
+
*
|
|
48
|
+
* Direct mapping to av_audio_fifo_size().
|
|
49
|
+
*/
|
|
50
|
+
get size() {
|
|
51
|
+
return this.native.size;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Number of samples that can be written without reallocation.
|
|
55
|
+
*
|
|
56
|
+
* Direct mapping to av_audio_fifo_space().
|
|
57
|
+
*/
|
|
58
|
+
get space() {
|
|
59
|
+
return this.native.space;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Allocate an AVAudioFifo buffer.
|
|
63
|
+
*
|
|
64
|
+
* Creates a FIFO buffer for the specified audio format and size.
|
|
65
|
+
* The FIFO will automatically grow if more data is written than allocated.
|
|
66
|
+
*
|
|
67
|
+
* Direct mapping to av_audio_fifo_alloc().
|
|
68
|
+
*
|
|
69
|
+
* @param sampleFmt - Sample format (e.g., AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP)
|
|
70
|
+
*
|
|
71
|
+
* @param channels - Number of audio channels
|
|
72
|
+
*
|
|
73
|
+
* @param nbSamples - Initial buffer size in samples
|
|
74
|
+
*
|
|
75
|
+
* @throws {Error} If allocation fails (ENOMEM)
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* import { AudioFifo } from 'node-av';
|
|
80
|
+
* import { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP } from 'node-av/constants';
|
|
81
|
+
*
|
|
82
|
+
* // For interleaved 16-bit stereo
|
|
83
|
+
* const fifo1 = new AudioFifo();
|
|
84
|
+
* fifo1.alloc(AV_SAMPLE_FMT_S16, 2, 4096);
|
|
85
|
+
*
|
|
86
|
+
* // For planar float 5.1 audio
|
|
87
|
+
* const fifo2 = new AudioFifo();
|
|
88
|
+
* fifo2.alloc(AV_SAMPLE_FMT_FLTP, 6, 8192);
|
|
89
|
+
* ```
|
|
90
|
+
*
|
|
91
|
+
* @see {@link realloc} To resize the FIFO
|
|
92
|
+
* @see {@link free} To release the FIFO
|
|
93
|
+
*/
|
|
94
|
+
alloc(sampleFmt, channels, nbSamples) {
|
|
95
|
+
this.native.alloc(sampleFmt, channels, nbSamples);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Free the FIFO buffer and all associated resources.
|
|
99
|
+
*
|
|
100
|
+
* After calling this, the FIFO is invalid and must be reallocated before use.
|
|
101
|
+
*
|
|
102
|
+
* Direct mapping to av_audio_fifo_free().
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```typescript
|
|
106
|
+
* fifo.free();
|
|
107
|
+
* // FIFO is now invalid, must call alloc() before using again
|
|
108
|
+
* ```
|
|
109
|
+
*
|
|
110
|
+
* @see {@link Symbol.dispose} For automatic cleanup
|
|
111
|
+
* @see {@link alloc} To allocate
|
|
112
|
+
*/
|
|
113
|
+
free() {
|
|
114
|
+
this.native.free();
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Write audio samples to the FIFO.
|
|
118
|
+
*
|
|
119
|
+
* Writes samples to the FIFO buffer. Automatically reallocates if more space is needed.
|
|
120
|
+
* For planar formats, provide an array of buffers (one per channel).
|
|
121
|
+
* For interleaved formats, provide a single buffer.
|
|
122
|
+
*
|
|
123
|
+
* Direct mapping to av_audio_fifo_write().
|
|
124
|
+
*
|
|
125
|
+
* @param data - Audio data buffer(s). Array for planar, single Buffer for interleaved
|
|
126
|
+
*
|
|
127
|
+
* @param nbSamples - Number of samples to write
|
|
128
|
+
*
|
|
129
|
+
* @returns Number of samples written, or negative AVERROR:
|
|
130
|
+
* - AVERROR_EINVAL: Invalid parameters
|
|
131
|
+
* - AVERROR_ENOMEM: Memory allocation failure
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```typescript
|
|
135
|
+
* import { FFmpegError } from 'node-av';
|
|
136
|
+
*
|
|
137
|
+
* // Planar format (e.g., FLTP) - separate buffers per channel
|
|
138
|
+
* const leftData = Buffer.alloc(1024 * 4); // 1024 float samples
|
|
139
|
+
* const rightData = Buffer.alloc(1024 * 4);
|
|
140
|
+
* const written = await fifo.write([leftData, rightData], 1024);
|
|
141
|
+
* FFmpegError.throwIfError(written, 'write');
|
|
142
|
+
* console.log(`Wrote ${written} samples`);
|
|
143
|
+
*
|
|
144
|
+
* // Interleaved format (e.g., S16) - single buffer
|
|
145
|
+
* const interleavedData = Buffer.alloc(1024 * 2 * 2); // 1024 stereo S16 samples
|
|
146
|
+
* const written2 = await fifo.write(interleavedData, 1024);
|
|
147
|
+
* FFmpegError.throwIfError(written2, 'write');
|
|
148
|
+
* ```
|
|
149
|
+
*
|
|
150
|
+
* @see {@link read} To retrieve samples from FIFO
|
|
151
|
+
* @see {@link space} To check available space
|
|
152
|
+
*/
|
|
153
|
+
async write(data, nbSamples) {
|
|
154
|
+
return await this.native.write(data, nbSamples);
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Write samples to the FIFO synchronously.
|
|
158
|
+
* Synchronous version of write.
|
|
159
|
+
*
|
|
160
|
+
* Adds audio samples to the FIFO buffer.
|
|
161
|
+
* The FIFO automatically handles format and layout conversions.
|
|
162
|
+
* Can write fewer samples than requested if space is limited.
|
|
163
|
+
*
|
|
164
|
+
* Direct mapping to av_audio_fifo_write().
|
|
165
|
+
*
|
|
166
|
+
* @param data - Audio data buffer(s). Array for planar, single Buffer for interleaved
|
|
167
|
+
*
|
|
168
|
+
* @param nbSamples - Number of samples to write per channel
|
|
169
|
+
*
|
|
170
|
+
* @returns Number of samples written, or negative AVERROR:
|
|
171
|
+
* - AVERROR_EINVAL: Invalid parameters
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* ```typescript
|
|
175
|
+
* import { FFmpegError } from 'node-av';
|
|
176
|
+
*
|
|
177
|
+
* // Interleaved stereo data (2 channels * 1024 samples * 4 bytes)
|
|
178
|
+
* const buffer = Buffer.alloc(2 * 1024 * 4);
|
|
179
|
+
* // Fill with audio data...
|
|
180
|
+
*
|
|
181
|
+
* const written = fifo.writeSync(buffer, 1024);
|
|
182
|
+
* FFmpegError.throwIfError(written, 'writeSync');
|
|
183
|
+
* console.log(`Wrote ${written} samples`);
|
|
184
|
+
* ```
|
|
185
|
+
*
|
|
186
|
+
* @see {@link write} For async version
|
|
187
|
+
*/
|
|
188
|
+
writeSync(data, nbSamples) {
|
|
189
|
+
return this.native.writeSync(data, nbSamples);
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Read and remove samples from the FIFO.
|
|
193
|
+
*
|
|
194
|
+
* Reads up to the specified number of samples from the FIFO.
|
|
195
|
+
* The samples are removed from the FIFO after reading.
|
|
196
|
+
* Buffers must be pre-allocated with sufficient size.
|
|
197
|
+
*
|
|
198
|
+
* Direct mapping to av_audio_fifo_read().
|
|
199
|
+
*
|
|
200
|
+
* @param data - Pre-allocated buffer(s) to read into. Array for planar, single Buffer for interleaved
|
|
201
|
+
*
|
|
202
|
+
* @param nbSamples - Maximum number of samples to read
|
|
203
|
+
*
|
|
204
|
+
* @returns Number of samples read, or negative AVERROR:
|
|
205
|
+
* - AVERROR_EINVAL: Invalid parameters
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* ```typescript
|
|
209
|
+
* import { FFmpegError } from 'node-av';
|
|
210
|
+
*
|
|
211
|
+
* // Check available samples
|
|
212
|
+
* const available = fifo.size;
|
|
213
|
+
* if (available >= 1024) {
|
|
214
|
+
* // Planar format
|
|
215
|
+
* const leftOut = Buffer.alloc(1024 * 4);
|
|
216
|
+
* const rightOut = Buffer.alloc(1024 * 4);
|
|
217
|
+
* const read = await fifo.read([leftOut, rightOut], 1024);
|
|
218
|
+
* FFmpegError.throwIfError(read, 'read');
|
|
219
|
+
* console.log(`Read ${read} samples`);
|
|
220
|
+
* }
|
|
221
|
+
* ```
|
|
222
|
+
*
|
|
223
|
+
* @see {@link peek} To read without removing
|
|
224
|
+
* @see {@link size} To check available samples
|
|
225
|
+
*/
|
|
226
|
+
async read(data, nbSamples) {
|
|
227
|
+
return await this.native.read(data, nbSamples);
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Read and remove samples from the FIFO synchronously.
|
|
231
|
+
* Synchronous version of read.
|
|
232
|
+
*
|
|
233
|
+
* Reads up to the specified number of samples from the FIFO.
|
|
234
|
+
* The samples are removed from the FIFO after reading.
|
|
235
|
+
* Buffers must be pre-allocated with sufficient size.
|
|
236
|
+
*
|
|
237
|
+
* Direct mapping to av_audio_fifo_read().
|
|
238
|
+
*
|
|
239
|
+
* @param data - Pre-allocated buffer(s) to read into. Array for planar, single Buffer for interleaved
|
|
240
|
+
*
|
|
241
|
+
* @param nbSamples - Maximum number of samples to read
|
|
242
|
+
*
|
|
243
|
+
* @returns Number of samples read, or negative AVERROR:
|
|
244
|
+
* - AVERROR_EINVAL: Invalid parameters
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
* ```typescript
|
|
248
|
+
* import { FFmpegError } from 'node-av';
|
|
249
|
+
*
|
|
250
|
+
* // Read up to 1024 samples
|
|
251
|
+
* const readBuffer = Buffer.alloc(2 * 1024 * 4); // stereo float32
|
|
252
|
+
* const read = fifo.readSync(readBuffer, 1024);
|
|
253
|
+
* FFmpegError.throwIfError(read, 'readSync');
|
|
254
|
+
*
|
|
255
|
+
* console.log(`Read ${read} samples from FIFO`);
|
|
256
|
+
* console.log(`FIFO now has ${fifo.size} samples remaining`);
|
|
257
|
+
* ```
|
|
258
|
+
*
|
|
259
|
+
* @see {@link read} For async version
|
|
260
|
+
*/
|
|
261
|
+
readSync(data, nbSamples) {
|
|
262
|
+
return this.native.readSync(data, nbSamples);
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Read samples from the FIFO without removing them.
|
|
266
|
+
*
|
|
267
|
+
* Similar to read() but leaves the samples in the FIFO.
|
|
268
|
+
* Useful for inspecting upcoming data without consuming it.
|
|
269
|
+
*
|
|
270
|
+
* Direct mapping to av_audio_fifo_peek().
|
|
271
|
+
*
|
|
272
|
+
* @param data - Pre-allocated buffer(s) to peek into. Array for planar, single Buffer for interleaved
|
|
273
|
+
*
|
|
274
|
+
* @param nbSamples - Maximum number of samples to peek
|
|
275
|
+
*
|
|
276
|
+
* @returns Number of samples peeked, or negative AVERROR:
|
|
277
|
+
* - AVERROR_EINVAL: Invalid parameters
|
|
278
|
+
*
|
|
279
|
+
* @example
|
|
280
|
+
* ```typescript
|
|
281
|
+
* import { FFmpegError } from 'node-av';
|
|
282
|
+
*
|
|
283
|
+
* // Peek at next samples without removing them
|
|
284
|
+
* const peekBuffer = Buffer.alloc(256 * 4);
|
|
285
|
+
* const peeked = await fifo.peek(peekBuffer, 256);
|
|
286
|
+
* FFmpegError.throwIfError(peeked, 'peek');
|
|
287
|
+
*
|
|
288
|
+
* // Samples are still in FIFO
|
|
289
|
+
* console.log(`FIFO still has ${fifo.size} samples`);
|
|
290
|
+
* ```
|
|
291
|
+
*
|
|
292
|
+
* @see {@link read} To read and remove samples
|
|
293
|
+
*/
|
|
294
|
+
async peek(data, nbSamples) {
|
|
295
|
+
return await this.native.peek(data, nbSamples);
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Read samples from the FIFO without removing them synchronously.
|
|
299
|
+
* Synchronous version of peek.
|
|
300
|
+
*
|
|
301
|
+
* Similar to readSync() but leaves the samples in the FIFO.
|
|
302
|
+
* Useful for inspecting upcoming data without consuming it.
|
|
303
|
+
*
|
|
304
|
+
* Direct mapping to av_audio_fifo_peek().
|
|
305
|
+
*
|
|
306
|
+
* @param data - Pre-allocated buffer(s) to peek into. Array for planar, single Buffer for interleaved
|
|
307
|
+
*
|
|
308
|
+
* @param nbSamples - Maximum number of samples to peek
|
|
309
|
+
*
|
|
310
|
+
* @returns Number of samples peeked, or negative AVERROR:
|
|
311
|
+
* - AVERROR_EINVAL: Invalid parameters
|
|
312
|
+
*
|
|
313
|
+
* @example
|
|
314
|
+
* ```typescript
|
|
315
|
+
* import { FFmpegError } from 'node-av';
|
|
316
|
+
*
|
|
317
|
+
* // Peek at next samples without removing them
|
|
318
|
+
* const peekBuffer = Buffer.alloc(256 * 4);
|
|
319
|
+
* const peeked = fifo.peekSync(peekBuffer, 256);
|
|
320
|
+
* FFmpegError.throwIfError(peeked, 'peekSync');
|
|
321
|
+
*
|
|
322
|
+
* // Samples are still in FIFO
|
|
323
|
+
* console.log(`FIFO still has ${fifo.size} samples`);
|
|
324
|
+
* ```
|
|
325
|
+
*
|
|
326
|
+
* @see {@link peek} For async version
|
|
327
|
+
*/
|
|
328
|
+
peekSync(data, nbSamples) {
|
|
329
|
+
return this.native.peekSync(data, nbSamples);
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Remove samples from the FIFO without reading them.
|
|
333
|
+
*
|
|
334
|
+
* Discards the specified number of samples from the FIFO.
|
|
335
|
+
* Useful for skipping unwanted audio data.
|
|
336
|
+
*
|
|
337
|
+
* Direct mapping to av_audio_fifo_drain().
|
|
338
|
+
*
|
|
339
|
+
* @param nbSamples - Number of samples to discard
|
|
340
|
+
*
|
|
341
|
+
* @example
|
|
342
|
+
* ```typescript
|
|
343
|
+
* // Skip 100 samples
|
|
344
|
+
* fifo.drain(100);
|
|
345
|
+
* console.log(`FIFO now has ${fifo.size} samples`);
|
|
346
|
+
* ```
|
|
347
|
+
*
|
|
348
|
+
* @see {@link reset} To remove all samples
|
|
349
|
+
*/
|
|
350
|
+
drain(nbSamples) {
|
|
351
|
+
this.native.drain(nbSamples);
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Remove all samples from the FIFO.
|
|
355
|
+
*
|
|
356
|
+
* Empties the FIFO buffer without deallocating it.
|
|
357
|
+
* The FIFO remains allocated and ready for new data.
|
|
358
|
+
*
|
|
359
|
+
* Direct mapping to av_audio_fifo_reset().
|
|
360
|
+
*
|
|
361
|
+
* @example
|
|
362
|
+
* ```typescript
|
|
363
|
+
* fifo.reset();
|
|
364
|
+
* console.log(fifo.size); // 0
|
|
365
|
+
* console.log(fifo.space); // Original allocation size
|
|
366
|
+
* ```
|
|
367
|
+
*
|
|
368
|
+
* @see {@link drain} To remove specific number of samples
|
|
369
|
+
*/
|
|
370
|
+
reset() {
|
|
371
|
+
this.native.reset();
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Resize the FIFO buffer.
|
|
375
|
+
*
|
|
376
|
+
* Changes the allocated size of the FIFO. Can grow or shrink the buffer.
|
|
377
|
+
* Existing samples are preserved up to the new size.
|
|
378
|
+
*
|
|
379
|
+
* Direct mapping to av_audio_fifo_realloc().
|
|
380
|
+
*
|
|
381
|
+
* @param nbSamples - New allocation size in samples
|
|
382
|
+
*
|
|
383
|
+
* @returns 0 on success, negative AVERROR on error:
|
|
384
|
+
* - AVERROR_EINVAL: Invalid size
|
|
385
|
+
* - AVERROR_ENOMEM: Memory allocation failure
|
|
386
|
+
*
|
|
387
|
+
* @example
|
|
388
|
+
* ```typescript
|
|
389
|
+
* import { FFmpegError } from 'node-av';
|
|
390
|
+
*
|
|
391
|
+
* // Grow FIFO to handle larger buffers
|
|
392
|
+
* const ret = fifo.realloc(16384);
|
|
393
|
+
* FFmpegError.throwIfError(ret, 'realloc');
|
|
394
|
+
* console.log(`New space: ${fifo.space} samples`);
|
|
395
|
+
* ```
|
|
396
|
+
*
|
|
397
|
+
* @see {@link alloc} For initial allocation
|
|
398
|
+
*/
|
|
399
|
+
realloc(nbSamples) {
|
|
400
|
+
return this.native.realloc(nbSamples);
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Get the underlying native AudioFifo object.
|
|
404
|
+
*
|
|
405
|
+
* @returns The native AudioFifo binding object
|
|
406
|
+
*
|
|
407
|
+
* @internal
|
|
408
|
+
*/
|
|
409
|
+
getNative() {
|
|
410
|
+
return this.native;
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* Dispose of the audio FIFO buffer.
|
|
414
|
+
*
|
|
415
|
+
* Implements the Disposable interface for automatic cleanup.
|
|
416
|
+
* Equivalent to calling free().
|
|
417
|
+
*
|
|
418
|
+
* @example
|
|
419
|
+
* ```typescript
|
|
420
|
+
* {
|
|
421
|
+
* using fifo = new AudioFifo();
|
|
422
|
+
* fifo.alloc(AV_SAMPLE_FMT_FLTP, 2, 4096);
|
|
423
|
+
* // Use fifo...
|
|
424
|
+
* } // Automatically freed when leaving scope
|
|
425
|
+
* ```
|
|
426
|
+
*/
|
|
427
|
+
[Symbol.dispose]() {
|
|
428
|
+
this.native[Symbol.dispose]();
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
//# sourceMappingURL=audio-fifo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audio-fifo.js","sourceRoot":"","sources":["../../src/lib/audio-fifo.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Native bindings loader
|
|
3
|
+
*
|
|
4
|
+
* This module loads the native C++ bindings compiled by node-gyp.
|
|
5
|
+
* All native classes are accessed through this single entry point.
|
|
6
|
+
*/
|
|
7
|
+
import type { AVCodecID, AVError, AVHWDeviceType, AVLogLevel, AVMediaType, AVOptionSearchFlags, AVPixelFormat, AVSampleFormat, FFDecoderCodec, FFEncoderCodec } from '../constants/index.js';
|
|
8
|
+
import type { PosixError } from './error.js';
|
|
9
|
+
import type { NativeAudioFifo, NativeBitStreamFilter, NativeBitStreamFilterContext, NativeCodec, NativeCodecContext, NativeCodecParameters, NativeCodecParser, NativeDeviceModule, NativeDictionary, NativeFFmpegError, NativeFifo, NativeFilter, NativeFilterContext, NativeFilterGraph, NativeFilterInOut, NativeFormatContext, NativeFrame, NativeFrameUtils, NativeHardwareDeviceContext, NativeHardwareFramesContext, NativeInputFormat, NativeIOContext, NativeLog, NativeOption, NativeOutputFormat, NativePacket, NativeSoftwareResampleContext, NativeSoftwareScaleContext, NativeStream, NativeSyncQueue } from './native-types.js';
|
|
10
|
+
import type { ChannelLayout, DtsPredictState, IDimension, IRational } from './types.js';
|
|
11
|
+
type NativePacketConstructor = new () => NativePacket;
|
|
12
|
+
type NativeFrameConstructor = new () => NativeFrame;
|
|
13
|
+
interface NativeCodecConstructor {
|
|
14
|
+
new (): NativeCodec;
|
|
15
|
+
findDecoder(id: AVCodecID): NativeCodec | null;
|
|
16
|
+
findEncoder(id: AVCodecID): NativeCodec | null;
|
|
17
|
+
findDecoderByName(name: FFDecoderCodec): NativeCodec | null;
|
|
18
|
+
findEncoderByName(name: FFEncoderCodec): NativeCodec | null;
|
|
19
|
+
getCodecList(): NativeCodec[];
|
|
20
|
+
iterateCodecs(opaque?: bigint | null): {
|
|
21
|
+
codec: NativeCodec;
|
|
22
|
+
opaque: bigint;
|
|
23
|
+
} | null;
|
|
24
|
+
}
|
|
25
|
+
type NativeCodecContextConstructor = new () => NativeCodecContext;
|
|
26
|
+
type NativeCodecParametersConstructor = new () => NativeCodecParameters;
|
|
27
|
+
type NativeCodecParserConstructor = new () => NativeCodecParser;
|
|
28
|
+
type NativeFormatContextConstructor = new () => NativeFormatContext;
|
|
29
|
+
type NativeStreamConstructor = new () => NativeStream;
|
|
30
|
+
interface NativeInputFormatConstructor {
|
|
31
|
+
new (): NativeInputFormat;
|
|
32
|
+
findInputFormat(shortName: string): NativeInputFormat | null;
|
|
33
|
+
probe(buffer: Buffer, filename?: string): NativeInputFormat | null;
|
|
34
|
+
probeBuffer(ioContext: NativeIOContext, maxProbeSize?: number): Promise<NativeInputFormat | null>;
|
|
35
|
+
probeBufferSync(ioContext: NativeIOContext, maxProbeSize?: number): NativeInputFormat | null;
|
|
36
|
+
}
|
|
37
|
+
interface NativeOutputFormatConstructor {
|
|
38
|
+
new (): NativeOutputFormat;
|
|
39
|
+
guessFormat(shortName: string | null, filename: string | null, mimeType: string | null): NativeOutputFormat | null;
|
|
40
|
+
}
|
|
41
|
+
type NativeIOContextConstructor = new () => NativeIOContext;
|
|
42
|
+
type NativeDictionaryConstructor = new () => NativeDictionary;
|
|
43
|
+
interface NativeFFmpegErrorConstructor {
|
|
44
|
+
new (code?: number): NativeFFmpegError;
|
|
45
|
+
strerror(errnum: number): string;
|
|
46
|
+
getAverror(errorName: PosixError): AVError;
|
|
47
|
+
}
|
|
48
|
+
interface NativeFilterConstructor {
|
|
49
|
+
new (): NativeFilter;
|
|
50
|
+
getByName(name: string): NativeFilter | null;
|
|
51
|
+
getList(): NativeFilter[];
|
|
52
|
+
}
|
|
53
|
+
type NativeFilterContextConstructor = new () => NativeFilterContext;
|
|
54
|
+
type NativeFilterGraphConstructor = new () => NativeFilterGraph;
|
|
55
|
+
type NativeFilterInOutConstructor = new () => NativeFilterInOut;
|
|
56
|
+
interface NativeBitStreamFilterConstructor {
|
|
57
|
+
new (): NativeBitStreamFilter;
|
|
58
|
+
getByName(name: string): NativeBitStreamFilter | null;
|
|
59
|
+
iterate(): NativeBitStreamFilter[];
|
|
60
|
+
}
|
|
61
|
+
type NativeBitStreamFilterContextConstructor = new () => NativeBitStreamFilterContext;
|
|
62
|
+
type NativeAudioFifoConstructor = new () => NativeAudioFifo;
|
|
63
|
+
type NativeFifoConstructor = new () => NativeFifo;
|
|
64
|
+
type NativeSoftwareScaleContextConstructor = new () => NativeSoftwareScaleContext;
|
|
65
|
+
type NativeSoftwareResampleContextConstructor = new () => NativeSoftwareResampleContext;
|
|
66
|
+
type NativeFrameUtilsConstructor = new (width: number, height: number) => NativeFrameUtils;
|
|
67
|
+
interface NativeHardwareDeviceContextConstructor {
|
|
68
|
+
new (): NativeHardwareDeviceContext;
|
|
69
|
+
getTypeName(type: AVHWDeviceType): string | null;
|
|
70
|
+
iterateTypes(): AVHWDeviceType[];
|
|
71
|
+
findTypeByName(name: string): AVHWDeviceType;
|
|
72
|
+
}
|
|
73
|
+
type NativeHardwareFramesContextConstructor = new () => NativeHardwareFramesContext;
|
|
74
|
+
interface NativeLogConstructor {
|
|
75
|
+
new (): NativeLog;
|
|
76
|
+
setLevel(level: AVLogLevel): void;
|
|
77
|
+
getLevel(): AVLogLevel;
|
|
78
|
+
log(level: AVLogLevel, message: string): void;
|
|
79
|
+
setCallback(callback: ((level: AVLogLevel, message: string) => void) | null, options?: any): void;
|
|
80
|
+
resetCallback(): void;
|
|
81
|
+
}
|
|
82
|
+
interface NativeOptionStatic {
|
|
83
|
+
next(obj: OptionCapableObject, prev?: NativeOption): NativeOption | null;
|
|
84
|
+
find(obj: OptionCapableObject, name: string, searchFlags?: AVOptionSearchFlags): NativeOption | null;
|
|
85
|
+
find2(obj: OptionCapableObject, name: string, searchFlags?: AVOptionSearchFlags): {
|
|
86
|
+
option: NativeOption;
|
|
87
|
+
isDifferentTarget: boolean;
|
|
88
|
+
} | null;
|
|
89
|
+
get(obj: OptionCapableObject, name: string, searchFlags?: AVOptionSearchFlags): string | null;
|
|
90
|
+
getInt(obj: OptionCapableObject, name: string, searchFlags?: AVOptionSearchFlags): number | null;
|
|
91
|
+
getDouble(obj: OptionCapableObject, name: string, searchFlags?: AVOptionSearchFlags): number | null;
|
|
92
|
+
getRational(obj: OptionCapableObject, name: string, searchFlags?: AVOptionSearchFlags): IRational | null;
|
|
93
|
+
getPixelFormat(obj: OptionCapableObject, name: string, searchFlags?: AVOptionSearchFlags): AVPixelFormat | null;
|
|
94
|
+
getSampleFormat(obj: OptionCapableObject, name: string, searchFlags?: AVOptionSearchFlags): AVSampleFormat | null;
|
|
95
|
+
getImageSize(obj: OptionCapableObject, name: string, searchFlags?: AVOptionSearchFlags): IDimension | null;
|
|
96
|
+
getChannelLayout(obj: OptionCapableObject, name: string, searchFlags?: AVOptionSearchFlags): ChannelLayout | null;
|
|
97
|
+
getDict(obj: OptionCapableObject, name: string, searchFlags?: AVOptionSearchFlags): NativeDictionary | null;
|
|
98
|
+
set(obj: OptionCapableObject, name: string, value: string, searchFlags?: AVOptionSearchFlags): number;
|
|
99
|
+
setInt(obj: OptionCapableObject, name: string, value: number | bigint, searchFlags?: AVOptionSearchFlags): number;
|
|
100
|
+
setDouble(obj: OptionCapableObject, name: string, value: number, searchFlags?: AVOptionSearchFlags): number;
|
|
101
|
+
setRational(obj: OptionCapableObject, name: string, value: {
|
|
102
|
+
num: number;
|
|
103
|
+
den: number;
|
|
104
|
+
}, searchFlags?: AVOptionSearchFlags): number;
|
|
105
|
+
setPixelFormat(obj: OptionCapableObject, name: string, value: number, searchFlags?: AVOptionSearchFlags): number;
|
|
106
|
+
setSampleFormat(obj: OptionCapableObject, name: string, value: number, searchFlags?: AVOptionSearchFlags): number;
|
|
107
|
+
setImageSize(obj: OptionCapableObject, name: string, width: number, height: number, searchFlags?: AVOptionSearchFlags): number;
|
|
108
|
+
setChannelLayout(obj: OptionCapableObject, name: string, value: number, searchFlags?: AVOptionSearchFlags): number;
|
|
109
|
+
setDict(obj: OptionCapableObject, name: string, value: NativeDictionary, searchFlags?: AVOptionSearchFlags): number;
|
|
110
|
+
setBin(obj: OptionCapableObject, name: string, value: Buffer, searchFlags?: AVOptionSearchFlags): number;
|
|
111
|
+
setDefaults(obj: OptionCapableObject): void;
|
|
112
|
+
copy(dest: OptionCapableObject, src: OptionCapableObject): number;
|
|
113
|
+
isSetToDefault(obj: OptionCapableObject, name: string, searchFlags?: AVOptionSearchFlags): boolean | null;
|
|
114
|
+
serialize(obj: OptionCapableObject, optFlags?: number, flags?: number, keyValSep?: string, pairsSep?: string): string | null;
|
|
115
|
+
free(obj: OptionCapableObject): void;
|
|
116
|
+
show(obj: OptionCapableObject, reqFlags?: number, rejFlags?: number): number;
|
|
117
|
+
}
|
|
118
|
+
interface NativeSyncQueueConstructor {
|
|
119
|
+
create(type: number, bufferSizeUs: number): NativeSyncQueue;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* The complete native binding interface
|
|
123
|
+
*/
|
|
124
|
+
export interface NativeBinding {
|
|
125
|
+
Packet: NativePacketConstructor;
|
|
126
|
+
Frame: NativeFrameConstructor;
|
|
127
|
+
Codec: NativeCodecConstructor;
|
|
128
|
+
CodecContext: NativeCodecContextConstructor;
|
|
129
|
+
CodecParameters: NativeCodecParametersConstructor;
|
|
130
|
+
CodecParser: NativeCodecParserConstructor;
|
|
131
|
+
FormatContext: NativeFormatContextConstructor;
|
|
132
|
+
Stream: NativeStreamConstructor;
|
|
133
|
+
InputFormat: NativeInputFormatConstructor;
|
|
134
|
+
OutputFormat: NativeOutputFormatConstructor;
|
|
135
|
+
IOContext: NativeIOContextConstructor;
|
|
136
|
+
Filter: NativeFilterConstructor;
|
|
137
|
+
FilterContext: NativeFilterContextConstructor;
|
|
138
|
+
FilterGraph: NativeFilterGraphConstructor;
|
|
139
|
+
FilterInOut: NativeFilterInOutConstructor;
|
|
140
|
+
BitStreamFilter: NativeBitStreamFilterConstructor;
|
|
141
|
+
BitStreamFilterContext: NativeBitStreamFilterContextConstructor;
|
|
142
|
+
AudioFifo: NativeAudioFifoConstructor;
|
|
143
|
+
Fifo: NativeFifoConstructor;
|
|
144
|
+
SoftwareScaleContext: NativeSoftwareScaleContextConstructor;
|
|
145
|
+
SoftwareResampleContext: NativeSoftwareResampleContextConstructor;
|
|
146
|
+
FrameUtils: NativeFrameUtilsConstructor;
|
|
147
|
+
HardwareDeviceContext: NativeHardwareDeviceContextConstructor;
|
|
148
|
+
HardwareFramesContext: NativeHardwareFramesContextConstructor;
|
|
149
|
+
Dictionary: NativeDictionaryConstructor;
|
|
150
|
+
FFmpegError: NativeFFmpegErrorConstructor;
|
|
151
|
+
Log: NativeLogConstructor;
|
|
152
|
+
Option: NativeOptionStatic;
|
|
153
|
+
SyncQueue: NativeSyncQueueConstructor;
|
|
154
|
+
Device: NativeDeviceModule;
|
|
155
|
+
getFFmpegInfo: () => {
|
|
156
|
+
version: string;
|
|
157
|
+
configuration: string;
|
|
158
|
+
libraries: {
|
|
159
|
+
avutil: string;
|
|
160
|
+
avcodec: string;
|
|
161
|
+
avformat: string;
|
|
162
|
+
avfilter: string;
|
|
163
|
+
avdevice: string;
|
|
164
|
+
swscale: string;
|
|
165
|
+
swresample: string;
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
avGetBytesPerSample: (sampleFmt: AVSampleFormat) => number;
|
|
169
|
+
avGetSampleFmtName: (sampleFmt: AVSampleFormat) => string | null;
|
|
170
|
+
avGetSampleFmtFromName: (name: string) => AVSampleFormat;
|
|
171
|
+
avGetPackedSampleFmt: (sampleFmt: AVSampleFormat) => AVSampleFormat;
|
|
172
|
+
avGetPlanarSampleFmt: (sampleFmt: AVSampleFormat) => AVSampleFormat;
|
|
173
|
+
avSampleFmtIsPlanar: (sampleFmt: AVSampleFormat) => boolean;
|
|
174
|
+
avGetCodecName: (codecId: AVCodecID) => string | null;
|
|
175
|
+
avGetCodecString: (codecpar: NativeCodecParameters, frameRate?: IRational) => string | null;
|
|
176
|
+
avGetMimeTypeDash: (codecpar: NativeCodecParameters) => string | null;
|
|
177
|
+
avGetPixFmtName: (pixFmt: AVPixelFormat) => string | null;
|
|
178
|
+
avGetPixFmtFromName: (name: string) => AVPixelFormat;
|
|
179
|
+
avIsHardwarePixelFormat: (pixFmt: AVPixelFormat) => boolean;
|
|
180
|
+
avGetHardwareDeviceTypeName: (type: AVHWDeviceType) => string | null;
|
|
181
|
+
avGetHardwareDeviceTypeFromName: (name: string) => AVHWDeviceType;
|
|
182
|
+
avGetMediaTypeString: (mediaType: AVMediaType) => string | null;
|
|
183
|
+
avImageAlloc: (width: number, height: number, pixFmt: AVPixelFormat, align: number) => {
|
|
184
|
+
buffer: Buffer;
|
|
185
|
+
size: number;
|
|
186
|
+
linesizes: number[];
|
|
187
|
+
} | number;
|
|
188
|
+
avImageCopy2: (dstData: Buffer[], dstLinesizes: number[], srcData: Buffer[], srcLinesizes: number[], pixFmt: AVPixelFormat, width: number, height: number) => void;
|
|
189
|
+
avImageGetBufferSize: (pixFmt: AVPixelFormat, width: number, height: number, align: number) => number;
|
|
190
|
+
avImageCopyToBuffer: (dst: Buffer, dstSize: number, srcData: Buffer[] | null, srcLinesize: number[] | null, pixFmt: AVPixelFormat, width: number, height: number, align: number) => number;
|
|
191
|
+
avImageCrop: (dstBuffer: Buffer, srcBuffer: Buffer, pixFmt: AVPixelFormat, srcWidth: number, srcHeight: number, cropX: number, cropY: number, cropWidth: number, cropHeight: number) => number;
|
|
192
|
+
avTs2Str: (ts: bigint | number | null) => string;
|
|
193
|
+
avTs2TimeStr: (ts: bigint | number | null, timeBase: IRational) => string;
|
|
194
|
+
avCompareTs: (tsA: bigint | number | null, tbA: IRational, tsB: bigint | number | null, tbB: IRational) => number;
|
|
195
|
+
avRescaleQ: (a: bigint | number | null, bq: IRational, cq: IRational) => bigint;
|
|
196
|
+
avRescaleRnd: (a: bigint | number, b: bigint | number, c: bigint | number, rnd: number) => bigint;
|
|
197
|
+
avRescaleDelta: (inTb: IRational, inTs: bigint | number, fsTb: IRational, duration: number, lastRef: {
|
|
198
|
+
value: bigint;
|
|
199
|
+
}, outTb: IRational) => bigint;
|
|
200
|
+
avMulQ: (a: IRational, b: IRational) => IRational;
|
|
201
|
+
avInvQ: (q: IRational) => IRational;
|
|
202
|
+
avAddQ: (a: IRational, b: IRational) => IRational;
|
|
203
|
+
avGcd: (a: bigint | number, b: bigint | number) => bigint;
|
|
204
|
+
avRescaleQRnd: (a: bigint | number | null, bq: IRational, cq: IRational, rnd: number) => bigint;
|
|
205
|
+
avGetAudioFrameDuration2: (codecpar: NativeCodecParameters, frameBytes: number) => number;
|
|
206
|
+
avUsleep: (usec: number) => void;
|
|
207
|
+
avSamplesAlloc: (nbChannels: number, nbSamples: number, sampleFmt: AVSampleFormat, align: number) => {
|
|
208
|
+
data: Buffer[];
|
|
209
|
+
linesize: number;
|
|
210
|
+
size: number;
|
|
211
|
+
} | number;
|
|
212
|
+
avSamplesGetBufferSize: (nbChannels: number, nbSamples: number, sampleFmt: AVSampleFormat, align: number) => {
|
|
213
|
+
size: number;
|
|
214
|
+
linesize: number;
|
|
215
|
+
} | number;
|
|
216
|
+
avChannelLayoutDescribe: (channelLayout: Partial<ChannelLayout>) => string | null;
|
|
217
|
+
avSdpCreate: (contexts: NativeFormatContext[]) => string | null;
|
|
218
|
+
dtsPredict: (packet: NativePacket, stream: NativeStream, state: DtsPredictState) => DtsPredictState;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Union type for all native FFmpeg objects that support AVOptions.
|
|
222
|
+
*
|
|
223
|
+
* These objects have an AVClass structure as their first member,
|
|
224
|
+
* which enables the AVOption API for runtime configuration.
|
|
225
|
+
*/
|
|
226
|
+
export type OptionCapableObject = NativeCodecContext | NativeFormatContext | NativeFilterContext | NativeFilterGraph | NativeSoftwareScaleContext | NativeSoftwareResampleContext | NativeIOContext | NativeBitStreamFilterContext;
|
|
227
|
+
declare const bindings: NativeBinding;
|
|
228
|
+
export { bindings };
|