node-av 4.0.0 → 5.0.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 +23 -0
- package/binding.gyp +19 -11
- package/dist/api/bitstream-filter.d.ts +13 -12
- package/dist/api/bitstream-filter.js +33 -29
- package/dist/api/bitstream-filter.js.map +1 -1
- package/dist/api/decoder.d.ts +211 -96
- package/dist/api/decoder.js +396 -375
- package/dist/api/decoder.js.map +1 -1
- package/dist/api/demuxer.d.ts +10 -10
- package/dist/api/demuxer.js +7 -10
- package/dist/api/demuxer.js.map +1 -1
- package/dist/api/encoder.d.ts +155 -122
- package/dist/api/encoder.js +368 -541
- package/dist/api/encoder.js.map +1 -1
- package/dist/api/filter-complex.d.ts +769 -0
- package/dist/api/filter-complex.js +1596 -0
- package/dist/api/filter-complex.js.map +1 -0
- package/dist/api/filter-presets.d.ts +68 -0
- package/dist/api/filter-presets.js +96 -0
- package/dist/api/filter-presets.js.map +1 -1
- package/dist/api/filter.d.ts +183 -113
- package/dist/api/filter.js +347 -365
- package/dist/api/filter.js.map +1 -1
- package/dist/api/fmp4-stream.d.ts +2 -2
- package/dist/api/fmp4-stream.js.map +1 -1
- package/dist/api/index.d.ts +2 -0
- package/dist/api/index.js +3 -0
- package/dist/api/index.js.map +1 -1
- package/dist/api/io-stream.d.ts +3 -3
- package/dist/api/io-stream.js.map +1 -1
- package/dist/api/muxer.d.ts +10 -10
- package/dist/api/muxer.js +6 -6
- package/dist/api/muxer.js.map +1 -1
- package/dist/api/pipeline.d.ts +2 -2
- package/dist/api/pipeline.js +22 -22
- package/dist/api/pipeline.js.map +1 -1
- package/dist/api/rtp-stream.d.ts +2 -2
- package/dist/api/rtp-stream.js.map +1 -1
- package/dist/api/types.d.ts +63 -7
- package/dist/api/utilities/audio-sample.d.ts +10 -0
- package/dist/api/utilities/audio-sample.js +10 -0
- package/dist/api/utilities/audio-sample.js.map +1 -1
- package/dist/api/utilities/channel-layout.d.ts +1 -0
- package/dist/api/utilities/channel-layout.js +1 -0
- package/dist/api/utilities/channel-layout.js.map +1 -1
- package/dist/api/utilities/image.d.ts +38 -0
- package/dist/api/utilities/image.js +38 -0
- package/dist/api/utilities/image.js.map +1 -1
- package/dist/api/utilities/index.d.ts +1 -0
- package/dist/api/utilities/index.js +2 -0
- package/dist/api/utilities/index.js.map +1 -1
- package/dist/api/utilities/media-type.d.ts +1 -0
- package/dist/api/utilities/media-type.js +1 -0
- package/dist/api/utilities/media-type.js.map +1 -1
- package/dist/api/utilities/pixel-format.d.ts +3 -0
- package/dist/api/utilities/pixel-format.js +3 -0
- package/dist/api/utilities/pixel-format.js.map +1 -1
- package/dist/api/utilities/sample-format.d.ts +5 -0
- package/dist/api/utilities/sample-format.js +5 -0
- package/dist/api/utilities/sample-format.js.map +1 -1
- package/dist/api/utilities/scheduler.d.ts +21 -52
- package/dist/api/utilities/scheduler.js +20 -58
- package/dist/api/utilities/scheduler.js.map +1 -1
- package/dist/api/utilities/streaming.d.ts +32 -1
- package/dist/api/utilities/streaming.js +32 -1
- package/dist/api/utilities/streaming.js.map +1 -1
- package/dist/api/utilities/timestamp.d.ts +14 -0
- package/dist/api/utilities/timestamp.js +14 -0
- package/dist/api/utilities/timestamp.js.map +1 -1
- 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/whisper.d.ts +324 -0
- package/dist/api/whisper.js +362 -0
- package/dist/api/whisper.js.map +1 -0
- package/dist/constants/constants.d.ts +3 -1
- package/dist/constants/constants.js +1 -0
- package/dist/constants/constants.js.map +1 -1
- package/dist/ffmpeg/index.d.ts +3 -3
- package/dist/ffmpeg/index.js +3 -3
- package/dist/ffmpeg/utils.d.ts +27 -0
- package/dist/ffmpeg/utils.js +28 -16
- package/dist/ffmpeg/utils.js.map +1 -1
- package/dist/lib/binding.d.ts +4 -4
- package/dist/lib/binding.js.map +1 -1
- package/dist/lib/codec-parameters.d.ts +47 -1
- package/dist/lib/codec-parameters.js +55 -0
- package/dist/lib/codec-parameters.js.map +1 -1
- 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/frame.d.ts +96 -1
- package/dist/lib/frame.js +139 -1
- package/dist/lib/frame.js.map +1 -1
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.js +2 -0
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/native-types.d.ts +29 -2
- package/dist/lib/rational.d.ts +18 -0
- package/dist/lib/rational.js +19 -0
- package/dist/lib/rational.js.map +1 -1
- package/dist/lib/types.d.ts +23 -1
- package/install/check.js +2 -2
- package/package.json +30 -20
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Rational } from './rational.js';
|
|
2
|
-
import type { AVChromaLocation, AVCodecID, AVColorPrimaries, AVColorRange, AVColorSpace, AVColorTransferCharacteristic, AVMediaType, AVPacketSideDataType, AVPixelFormat, AVProfile, AVSampleFormat } from '../constants/constants.js';
|
|
2
|
+
import type { AVChromaLocation, AVCodecID, AVCodecProp, AVColorPrimaries, AVColorRange, AVColorSpace, AVColorTransferCharacteristic, AVMediaType, AVPacketSideDataType, AVPixelFormat, AVProfile, AVSampleFormat } from '../constants/constants.js';
|
|
3
3
|
import type { CodecContext } from './codec-context.js';
|
|
4
4
|
import type { NativeCodecParameters, NativeWrapper } from './native-types.js';
|
|
5
5
|
import type { ChannelLayout } from './types.js';
|
|
@@ -303,6 +303,52 @@ export declare class CodecParameters implements NativeWrapper<NativeCodecParamet
|
|
|
303
303
|
* ```
|
|
304
304
|
*/
|
|
305
305
|
get nbCodedSideData(): number;
|
|
306
|
+
/**
|
|
307
|
+
* Codec properties.
|
|
308
|
+
*
|
|
309
|
+
* Bitfield of AV_CODEC_PROP_* flags indicating codec features.
|
|
310
|
+
*
|
|
311
|
+
* Direct mapping to AVCodecDescriptor->props.
|
|
312
|
+
*
|
|
313
|
+
* @example
|
|
314
|
+
* ```typescript
|
|
315
|
+
* import { AV_CODEC_PROP_FIELDS } from 'node-av/constants';
|
|
316
|
+
*
|
|
317
|
+
* const props = params.codecProperties;
|
|
318
|
+
* if (props & AV_CODEC_PROP_FIELDS) {
|
|
319
|
+
* console.log('Codec supports interlaced video (fields)');
|
|
320
|
+
* }
|
|
321
|
+
* ```
|
|
322
|
+
*
|
|
323
|
+
* @see {@link hasProperties} For checking specific properties
|
|
324
|
+
*/
|
|
325
|
+
get codecProperties(): AVCodecProp;
|
|
326
|
+
/**
|
|
327
|
+
* Check if codec has specific properties.
|
|
328
|
+
*
|
|
329
|
+
* Tests whether all specified properties are present using bitwise AND.
|
|
330
|
+
*
|
|
331
|
+
* @param props - One or more property values to check
|
|
332
|
+
*
|
|
333
|
+
* @returns true if all specified properties are present, false otherwise
|
|
334
|
+
*
|
|
335
|
+
* @example
|
|
336
|
+
* ```typescript
|
|
337
|
+
* import { AV_CODEC_PROP_FIELDS, AV_CODEC_PROP_REORDER } from 'node-av/constants';
|
|
338
|
+
*
|
|
339
|
+
* if (params.hasProperties(AV_CODEC_PROP_FIELDS)) {
|
|
340
|
+
* console.log('Codec supports interlaced video (fields)');
|
|
341
|
+
* }
|
|
342
|
+
*
|
|
343
|
+
* // Check multiple properties
|
|
344
|
+
* if (params.hasProperties(AV_CODEC_PROP_LOSSY, AV_CODEC_PROP_REORDER)) {
|
|
345
|
+
* console.log('Codec is lossy and supports frame reordering');
|
|
346
|
+
* }
|
|
347
|
+
* ```
|
|
348
|
+
*
|
|
349
|
+
* @see {@link codecProperties} For direct properties access
|
|
350
|
+
*/
|
|
351
|
+
hasProperties(...props: AVCodecProp[]): boolean;
|
|
306
352
|
/**
|
|
307
353
|
* Allocate codec parameters.
|
|
308
354
|
*
|
|
@@ -417,6 +417,61 @@ export class CodecParameters {
|
|
|
417
417
|
get nbCodedSideData() {
|
|
418
418
|
return this.native.nbCodedSideData;
|
|
419
419
|
}
|
|
420
|
+
/**
|
|
421
|
+
* Codec properties.
|
|
422
|
+
*
|
|
423
|
+
* Bitfield of AV_CODEC_PROP_* flags indicating codec features.
|
|
424
|
+
*
|
|
425
|
+
* Direct mapping to AVCodecDescriptor->props.
|
|
426
|
+
*
|
|
427
|
+
* @example
|
|
428
|
+
* ```typescript
|
|
429
|
+
* import { AV_CODEC_PROP_FIELDS } from 'node-av/constants';
|
|
430
|
+
*
|
|
431
|
+
* const props = params.codecProperties;
|
|
432
|
+
* if (props & AV_CODEC_PROP_FIELDS) {
|
|
433
|
+
* console.log('Codec supports interlaced video (fields)');
|
|
434
|
+
* }
|
|
435
|
+
* ```
|
|
436
|
+
*
|
|
437
|
+
* @see {@link hasProperties} For checking specific properties
|
|
438
|
+
*/
|
|
439
|
+
get codecProperties() {
|
|
440
|
+
return this.native.codecProperties;
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* Check if codec has specific properties.
|
|
444
|
+
*
|
|
445
|
+
* Tests whether all specified properties are present using bitwise AND.
|
|
446
|
+
*
|
|
447
|
+
* @param props - One or more property values to check
|
|
448
|
+
*
|
|
449
|
+
* @returns true if all specified properties are present, false otherwise
|
|
450
|
+
*
|
|
451
|
+
* @example
|
|
452
|
+
* ```typescript
|
|
453
|
+
* import { AV_CODEC_PROP_FIELDS, AV_CODEC_PROP_REORDER } from 'node-av/constants';
|
|
454
|
+
*
|
|
455
|
+
* if (params.hasProperties(AV_CODEC_PROP_FIELDS)) {
|
|
456
|
+
* console.log('Codec supports interlaced video (fields)');
|
|
457
|
+
* }
|
|
458
|
+
*
|
|
459
|
+
* // Check multiple properties
|
|
460
|
+
* if (params.hasProperties(AV_CODEC_PROP_LOSSY, AV_CODEC_PROP_REORDER)) {
|
|
461
|
+
* console.log('Codec is lossy and supports frame reordering');
|
|
462
|
+
* }
|
|
463
|
+
* ```
|
|
464
|
+
*
|
|
465
|
+
* @see {@link codecProperties} For direct properties access
|
|
466
|
+
*/
|
|
467
|
+
hasProperties(...props) {
|
|
468
|
+
for (const prop of props) {
|
|
469
|
+
if ((this.native.codecProperties & prop) !== prop) {
|
|
470
|
+
return false;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
return true;
|
|
474
|
+
}
|
|
420
475
|
/**
|
|
421
476
|
* Allocate codec parameters.
|
|
422
477
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codec-parameters.js","sourceRoot":"","sources":["../../src/lib/codec-parameters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"codec-parameters.js","sourceRoot":"","sources":["../../src/lib/codec-parameters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAoBhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,OAAO,eAAe;IAClB,MAAM,CAAwB;IAEtC;QACE,IAAI,CAAC,MAAM,GAAG,IAAI,QAAQ,CAAC,eAAe,EAAE,CAAC;IAC/C,CAAC;IAED;;;;;;OAMG;IACH,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC;IAC/B,CAAC;IAED,IAAI,SAAS,CAAC,KAAkB;QAC9B,IAAI,CAAC,MAAM,CAAC,SAAS,GAAG,KAAK,CAAC;IAChC,CAAC;IAED;;;;;;OAMG;IACH,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;IAC7B,CAAC;IAED,IAAI,OAAO,CAAC,KAAgB;QAC1B,IAAI,CAAC,MAAM,CAAC,OAAO,GAAG,K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CAAC,YAAY,CAAC,SAAS,EAAE,CAAC,CAAC;IAC3D,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,SAAS,CAAC,YAA0B;QAClC,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,YAAY,CAAC,SAAS,EAAE,CAAC,CAAC;IACzD,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,cAAc;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC;IACtC,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;IAC9B,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,gBAAgB,CAAC,IAA0B;QACzC,OAAO,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAC5C,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,mBAAmB;QACjB,OAAO,IAAI,CAAC,MAAM,CAAC,mBAAmB,EAAE,CAAC;IAC3C,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,gBAAgB,CAAC,IAA0B,EAAE,IAAY;QACvD,OAAO,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAClD,CAAC;IAED;;;;;;OAMG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,CAAC,MAAM,CAAC,OAAO,CAAC;QACd,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;IAChC,CAAC;CACF"}
|
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
import type { AVFifoFlag } from '../constants/index.js';
|
|
2
|
+
import type { NativeFifo, NativeWrapper } from './native-types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Generic FIFO (First-In-First-Out) buffer for arbitrary data types.
|
|
5
|
+
*
|
|
6
|
+
* Provides a thread-safe buffer for generic data elements. Unlike AudioFifo which is
|
|
7
|
+
* specialized for audio samples, Fifo can handle any data type by specifying the element size.
|
|
8
|
+
* Supports automatic growth and manual size management.
|
|
9
|
+
*
|
|
10
|
+
* Direct mapping to FFmpeg's AVFifo.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { Fifo, FFmpegError } from 'node-av';
|
|
15
|
+
* import { AV_FIFO_FLAG_AUTO_GROW } from 'node-av/constants';
|
|
16
|
+
*
|
|
17
|
+
* // Create FIFO for 32-bit integers
|
|
18
|
+
* const fifo = new Fifo();
|
|
19
|
+
* fifo.alloc(100, 4, AV_FIFO_FLAG_AUTO_GROW);
|
|
20
|
+
* fifo.setAutoGrowLimit(1000);
|
|
21
|
+
*
|
|
22
|
+
* // Write data
|
|
23
|
+
* const data = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);
|
|
24
|
+
* const written = await fifo.write(data, 2); // Write 2 elements (8 bytes)
|
|
25
|
+
* FFmpegError.throwIfError(written, 'write');
|
|
26
|
+
*
|
|
27
|
+
* // Read data
|
|
28
|
+
* const outBuffer = Buffer.alloc(8);
|
|
29
|
+
* const read = await fifo.read(outBuffer, 2); // Read 2 elements
|
|
30
|
+
* FFmpegError.throwIfError(read, 'read');
|
|
31
|
+
*
|
|
32
|
+
* // Cleanup
|
|
33
|
+
* fifo.free();
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @see [AVFifo](https://ffmpeg.org/doxygen/trunk/structAVFifo.html) - FFmpeg Doxygen
|
|
37
|
+
*/
|
|
38
|
+
export declare class Fifo implements Disposable, NativeWrapper<NativeFifo> {
|
|
39
|
+
private native;
|
|
40
|
+
constructor();
|
|
41
|
+
/**
|
|
42
|
+
* Number of elements currently in the FIFO.
|
|
43
|
+
*
|
|
44
|
+
* Direct mapping to av_fifo_can_read().
|
|
45
|
+
*/
|
|
46
|
+
get size(): number;
|
|
47
|
+
/**
|
|
48
|
+
* Number of elements that can be read from the FIFO.
|
|
49
|
+
*
|
|
50
|
+
* Direct mapping to av_fifo_can_read().
|
|
51
|
+
*/
|
|
52
|
+
get canRead(): number;
|
|
53
|
+
/**
|
|
54
|
+
* Number of elements that can be written without reallocation.
|
|
55
|
+
*
|
|
56
|
+
* Direct mapping to av_fifo_can_write().
|
|
57
|
+
*/
|
|
58
|
+
get canWrite(): number;
|
|
59
|
+
/**
|
|
60
|
+
* Size in bytes of a single element.
|
|
61
|
+
*
|
|
62
|
+
* Direct mapping to av_fifo_elem_size().
|
|
63
|
+
*/
|
|
64
|
+
get elemSize(): number;
|
|
65
|
+
/**
|
|
66
|
+
* Allocate an AVFifo buffer.
|
|
67
|
+
*
|
|
68
|
+
* Creates a FIFO buffer with the specified element count, size and flags.
|
|
69
|
+
* The FIFO can be configured to automatically grow when full.
|
|
70
|
+
*
|
|
71
|
+
* Direct mapping to av_fifo_alloc2().
|
|
72
|
+
*
|
|
73
|
+
* @param nbElems - Initial number of elements to allocate
|
|
74
|
+
*
|
|
75
|
+
* @param elemSize - Size in bytes of each element
|
|
76
|
+
*
|
|
77
|
+
* @param flags - Optional flags (e.g., AV_FIFO_FLAG_AUTO_GROW). Defaults to 0
|
|
78
|
+
*
|
|
79
|
+
* @throws {Error} If allocation fails (ENOMEM)
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```typescript
|
|
83
|
+
* import { Fifo } from 'node-av';
|
|
84
|
+
* import { AV_FIFO_FLAG_AUTO_GROW } from 'node-av/constants';
|
|
85
|
+
*
|
|
86
|
+
* // Fixed size FIFO for 100 32-bit integers
|
|
87
|
+
* const fifo1 = new Fifo();
|
|
88
|
+
* fifo1.alloc(100, 4);
|
|
89
|
+
*
|
|
90
|
+
* // Auto-growing FIFO for 8-byte structures
|
|
91
|
+
* const fifo2 = new Fifo();
|
|
92
|
+
* fifo2.alloc(50, 8, AV_FIFO_FLAG_AUTO_GROW);
|
|
93
|
+
* fifo2.setAutoGrowLimit(1000); // Max 1000 elements
|
|
94
|
+
* ```
|
|
95
|
+
*
|
|
96
|
+
* @see {@link grow} To manually grow the FIFO
|
|
97
|
+
* @see {@link setAutoGrowLimit} To set auto-grow limit
|
|
98
|
+
* @see {@link free} To release the FIFO
|
|
99
|
+
*/
|
|
100
|
+
alloc(nbElems: number, elemSize: number, flags?: AVFifoFlag): void;
|
|
101
|
+
/**
|
|
102
|
+
* Free the FIFO buffer and all associated resources.
|
|
103
|
+
*
|
|
104
|
+
* After calling this, the FIFO is invalid and must be reallocated before use.
|
|
105
|
+
*
|
|
106
|
+
* Direct mapping to av_fifo_freep().
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```typescript
|
|
110
|
+
* fifo.free();
|
|
111
|
+
* // FIFO is now invalid, must call alloc() before using again
|
|
112
|
+
* ```
|
|
113
|
+
*
|
|
114
|
+
* @see {@link Symbol.dispose} For automatic cleanup
|
|
115
|
+
* @see {@link alloc} To allocate
|
|
116
|
+
*/
|
|
117
|
+
free(): void;
|
|
118
|
+
/**
|
|
119
|
+
* Write elements to the FIFO.
|
|
120
|
+
*
|
|
121
|
+
* Writes elements to the FIFO buffer. If AV_FIFO_FLAG_AUTO_GROW was set,
|
|
122
|
+
* automatically reallocates if more space is needed (up to auto-grow limit).
|
|
123
|
+
*
|
|
124
|
+
* Direct mapping to av_fifo_write().
|
|
125
|
+
*
|
|
126
|
+
* @param buf - Data buffer containing elements to write
|
|
127
|
+
*
|
|
128
|
+
* @param nbElems - Number of elements to write
|
|
129
|
+
*
|
|
130
|
+
* @returns Number of elements written (>= 0), or negative AVERROR:
|
|
131
|
+
* - AVERROR_EINVAL: Invalid parameters
|
|
132
|
+
* - AVERROR_ENOMEM: Not enough space and auto-grow failed/disabled
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* ```typescript
|
|
136
|
+
* import { FFmpegError } from 'node-av';
|
|
137
|
+
*
|
|
138
|
+
* // Write 4 32-bit integers (16 bytes)
|
|
139
|
+
* const data = Buffer.from([
|
|
140
|
+
* 0x01, 0x00, 0x00, 0x00, // 1
|
|
141
|
+
* 0x02, 0x00, 0x00, 0x00, // 2
|
|
142
|
+
* 0x03, 0x00, 0x00, 0x00, // 3
|
|
143
|
+
* 0x04, 0x00, 0x00, 0x00, // 4
|
|
144
|
+
* ]);
|
|
145
|
+
* const written = await fifo.write(data, 4);
|
|
146
|
+
* FFmpegError.throwIfError(written, 'write');
|
|
147
|
+
* console.log(`Wrote ${written} elements`);
|
|
148
|
+
* ```
|
|
149
|
+
*
|
|
150
|
+
* @see {@link read} To retrieve elements from FIFO
|
|
151
|
+
* @see {@link canWrite} To check available space
|
|
152
|
+
*/
|
|
153
|
+
write(buf: Buffer, nbElems: number): Promise<number>;
|
|
154
|
+
/**
|
|
155
|
+
* Write elements to the FIFO synchronously.
|
|
156
|
+
* Synchronous version of write.
|
|
157
|
+
*
|
|
158
|
+
* Writes elements to the FIFO buffer. Can write fewer elements than requested
|
|
159
|
+
* if space is limited and auto-grow is disabled or has reached the limit.
|
|
160
|
+
*
|
|
161
|
+
* Direct mapping to av_fifo_write().
|
|
162
|
+
*
|
|
163
|
+
* @param buf - Data buffer containing elements to write
|
|
164
|
+
*
|
|
165
|
+
* @param nbElems - Number of elements to write
|
|
166
|
+
*
|
|
167
|
+
* @returns Number of elements written (>= 0), or negative AVERROR:
|
|
168
|
+
* - AVERROR_EINVAL: Invalid parameters
|
|
169
|
+
* - AVERROR_ENOMEM: Not enough space
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* ```typescript
|
|
173
|
+
* import { FFmpegError } from 'node-av';
|
|
174
|
+
*
|
|
175
|
+
* const buffer = Buffer.alloc(32); // 8 elements of 4 bytes each
|
|
176
|
+
* // Fill with data...
|
|
177
|
+
*
|
|
178
|
+
* const written = fifo.writeSync(buffer, 8);
|
|
179
|
+
* FFmpegError.throwIfError(written, 'writeSync');
|
|
180
|
+
* console.log(`Wrote ${written} elements`);
|
|
181
|
+
* ```
|
|
182
|
+
*
|
|
183
|
+
* @see {@link write} For async version
|
|
184
|
+
*/
|
|
185
|
+
writeSync(buf: Buffer, nbElems: number): number;
|
|
186
|
+
/**
|
|
187
|
+
* Read and remove elements from the FIFO.
|
|
188
|
+
*
|
|
189
|
+
* Reads up to the specified number of elements from the FIFO.
|
|
190
|
+
* The elements are removed from the FIFO after reading.
|
|
191
|
+
* Buffer must be pre-allocated with sufficient size (nbElems * elemSize).
|
|
192
|
+
*
|
|
193
|
+
* Direct mapping to av_fifo_read().
|
|
194
|
+
*
|
|
195
|
+
* @param buf - Pre-allocated buffer to read into
|
|
196
|
+
*
|
|
197
|
+
* @param nbElems - Maximum number of elements to read
|
|
198
|
+
*
|
|
199
|
+
* @returns Number of elements read (>= 0), or negative AVERROR:
|
|
200
|
+
* - AVERROR_EINVAL: Invalid parameters or insufficient buffer size
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
* ```typescript
|
|
204
|
+
* import { FFmpegError } from 'node-av';
|
|
205
|
+
*
|
|
206
|
+
* // Check available elements
|
|
207
|
+
* const available = fifo.canRead;
|
|
208
|
+
* if (available >= 10) {
|
|
209
|
+
* // Read 10 elements (40 bytes for 4-byte elements)
|
|
210
|
+
* const outBuffer = Buffer.alloc(40);
|
|
211
|
+
* const read = await fifo.read(outBuffer, 10);
|
|
212
|
+
* FFmpegError.throwIfError(read, 'read');
|
|
213
|
+
* console.log(`Read ${read} elements`);
|
|
214
|
+
* }
|
|
215
|
+
* ```
|
|
216
|
+
*
|
|
217
|
+
* @see {@link peek} To read without removing
|
|
218
|
+
* @see {@link canRead} To check available elements
|
|
219
|
+
*/
|
|
220
|
+
read(buf: Buffer, nbElems: number): Promise<number>;
|
|
221
|
+
/**
|
|
222
|
+
* Read and remove elements from the FIFO synchronously.
|
|
223
|
+
* Synchronous version of read.
|
|
224
|
+
*
|
|
225
|
+
* Reads up to the specified number of elements from the FIFO.
|
|
226
|
+
* The elements are removed from the FIFO after reading.
|
|
227
|
+
* Buffer must be pre-allocated with sufficient size.
|
|
228
|
+
*
|
|
229
|
+
* Direct mapping to av_fifo_read().
|
|
230
|
+
*
|
|
231
|
+
* @param buf - Pre-allocated buffer to read into
|
|
232
|
+
*
|
|
233
|
+
* @param nbElems - Maximum number of elements to read
|
|
234
|
+
*
|
|
235
|
+
* @returns Number of elements read (>= 0), or negative AVERROR:
|
|
236
|
+
* - AVERROR_EINVAL: Invalid parameters
|
|
237
|
+
*
|
|
238
|
+
* @example
|
|
239
|
+
* ```typescript
|
|
240
|
+
* import { FFmpegError } from 'node-av';
|
|
241
|
+
*
|
|
242
|
+
* // Read up to 20 elements
|
|
243
|
+
* const readBuffer = Buffer.alloc(20 * fifo.elemSize);
|
|
244
|
+
* const read = fifo.readSync(readBuffer, 20);
|
|
245
|
+
* FFmpegError.throwIfError(read, 'readSync');
|
|
246
|
+
*
|
|
247
|
+
* console.log(`Read ${read} elements from FIFO`);
|
|
248
|
+
* console.log(`FIFO now has ${fifo.canRead} elements remaining`);
|
|
249
|
+
* ```
|
|
250
|
+
*
|
|
251
|
+
* @see {@link read} For async version
|
|
252
|
+
*/
|
|
253
|
+
readSync(buf: Buffer, nbElems: number): number;
|
|
254
|
+
/**
|
|
255
|
+
* Read elements from the FIFO without removing them.
|
|
256
|
+
*
|
|
257
|
+
* Similar to read() but leaves the elements in the FIFO.
|
|
258
|
+
* Useful for inspecting upcoming data without consuming it.
|
|
259
|
+
* Optionally start reading from an offset.
|
|
260
|
+
*
|
|
261
|
+
* Direct mapping to av_fifo_peek().
|
|
262
|
+
*
|
|
263
|
+
* @param buf - Pre-allocated buffer to peek into
|
|
264
|
+
*
|
|
265
|
+
* @param nbElems - Maximum number of elements to peek
|
|
266
|
+
*
|
|
267
|
+
* @param offset - Offset in elements from start of FIFO. Defaults to 0
|
|
268
|
+
*
|
|
269
|
+
* @returns Number of elements peeked (>= 0), or negative AVERROR:
|
|
270
|
+
* - AVERROR_EINVAL: Invalid parameters or offset too large
|
|
271
|
+
*
|
|
272
|
+
* @example
|
|
273
|
+
* ```typescript
|
|
274
|
+
* import { FFmpegError } from 'node-av';
|
|
275
|
+
*
|
|
276
|
+
* // Peek at next 5 elements without removing them
|
|
277
|
+
* const peekBuffer = Buffer.alloc(5 * fifo.elemSize);
|
|
278
|
+
* const peeked = await fifo.peek(peekBuffer, 5);
|
|
279
|
+
* FFmpegError.throwIfError(peeked, 'peek');
|
|
280
|
+
*
|
|
281
|
+
* // Peek at elements starting at offset 10
|
|
282
|
+
* const peeked2 = await fifo.peek(peekBuffer, 5, 10);
|
|
283
|
+
* FFmpegError.throwIfError(peeked2, 'peek');
|
|
284
|
+
*
|
|
285
|
+
* // Elements are still in FIFO
|
|
286
|
+
* console.log(`FIFO still has ${fifo.canRead} elements`);
|
|
287
|
+
* ```
|
|
288
|
+
*
|
|
289
|
+
* @see {@link read} To read and remove elements
|
|
290
|
+
*/
|
|
291
|
+
peek(buf: Buffer, nbElems: number, offset?: number): Promise<number>;
|
|
292
|
+
/**
|
|
293
|
+
* Read elements from the FIFO without removing them synchronously.
|
|
294
|
+
* Synchronous version of peek.
|
|
295
|
+
*
|
|
296
|
+
* Similar to readSync() but leaves the elements in the FIFO.
|
|
297
|
+
* Useful for inspecting upcoming data without consuming it.
|
|
298
|
+
* Optionally start reading from an offset.
|
|
299
|
+
*
|
|
300
|
+
* Direct mapping to av_fifo_peek().
|
|
301
|
+
*
|
|
302
|
+
* @param buf - Pre-allocated buffer to peek into
|
|
303
|
+
*
|
|
304
|
+
* @param nbElems - Maximum number of elements to peek
|
|
305
|
+
*
|
|
306
|
+
* @param offset - Offset in elements from start of FIFO. Defaults to 0
|
|
307
|
+
*
|
|
308
|
+
* @returns Number of elements peeked (>= 0), or negative AVERROR:
|
|
309
|
+
* - AVERROR_EINVAL: Invalid parameters or offset too large
|
|
310
|
+
*
|
|
311
|
+
* @example
|
|
312
|
+
* ```typescript
|
|
313
|
+
* import { FFmpegError } from 'node-av';
|
|
314
|
+
*
|
|
315
|
+
* // Peek at next elements without removing them
|
|
316
|
+
* const peekBuffer = Buffer.alloc(10 * fifo.elemSize);
|
|
317
|
+
* const peeked = fifo.peekSync(peekBuffer, 10);
|
|
318
|
+
* FFmpegError.throwIfError(peeked, 'peekSync');
|
|
319
|
+
*
|
|
320
|
+
* // Elements are still in FIFO
|
|
321
|
+
* console.log(`FIFO still has ${fifo.canRead} elements`);
|
|
322
|
+
* ```
|
|
323
|
+
*
|
|
324
|
+
* @see {@link peek} For async version
|
|
325
|
+
*/
|
|
326
|
+
peekSync(buf: Buffer, nbElems: number, offset?: number): number;
|
|
327
|
+
/**
|
|
328
|
+
* Grow the FIFO buffer by the specified number of elements.
|
|
329
|
+
*
|
|
330
|
+
* Increases the allocated size of the FIFO by adding more space.
|
|
331
|
+
* Existing elements are preserved.
|
|
332
|
+
*
|
|
333
|
+
* Direct mapping to av_fifo_grow2().
|
|
334
|
+
*
|
|
335
|
+
* @param inc - Number of additional elements to allocate
|
|
336
|
+
*
|
|
337
|
+
* @returns 0 on success, negative AVERROR on error:
|
|
338
|
+
* - AVERROR_EINVAL: Invalid size
|
|
339
|
+
* - AVERROR_ENOMEM: Memory allocation failure
|
|
340
|
+
*
|
|
341
|
+
* @example
|
|
342
|
+
* ```typescript
|
|
343
|
+
* import { FFmpegError } from 'node-av';
|
|
344
|
+
*
|
|
345
|
+
* // Grow FIFO to handle more elements
|
|
346
|
+
* const ret = fifo.grow(100);
|
|
347
|
+
* FFmpegError.throwIfError(ret, 'grow');
|
|
348
|
+
* console.log(`New write capacity: ${fifo.canWrite} elements`);
|
|
349
|
+
* ```
|
|
350
|
+
*
|
|
351
|
+
* @see {@link alloc} For initial allocation
|
|
352
|
+
*/
|
|
353
|
+
grow(inc: number): number;
|
|
354
|
+
/**
|
|
355
|
+
* Remove all elements from the FIFO.
|
|
356
|
+
*
|
|
357
|
+
* Empties the FIFO buffer without deallocating it.
|
|
358
|
+
* The FIFO remains allocated and ready for new data.
|
|
359
|
+
*
|
|
360
|
+
* Direct mapping to av_fifo_reset2().
|
|
361
|
+
*
|
|
362
|
+
* @example
|
|
363
|
+
* ```typescript
|
|
364
|
+
* fifo.reset();
|
|
365
|
+
* console.log(fifo.canRead); // 0
|
|
366
|
+
* console.log(fifo.canWrite); // Original allocation size
|
|
367
|
+
* ```
|
|
368
|
+
*/
|
|
369
|
+
reset(): void;
|
|
370
|
+
/**
|
|
371
|
+
* Set the maximum number of elements for auto-grow.
|
|
372
|
+
*
|
|
373
|
+
* When AV_FIFO_FLAG_AUTO_GROW is set, the FIFO will automatically grow
|
|
374
|
+
* up to this limit when full. After reaching the limit, writes will fail.
|
|
375
|
+
*
|
|
376
|
+
* Direct mapping to av_fifo_auto_grow_limit().
|
|
377
|
+
*
|
|
378
|
+
* @param maxElems - Maximum number of elements (0 = unlimited)
|
|
379
|
+
*
|
|
380
|
+
* @example
|
|
381
|
+
* ```typescript
|
|
382
|
+
* import { AV_FIFO_FLAG_AUTO_GROW } from 'node-av/constants';
|
|
383
|
+
*
|
|
384
|
+
* const fifo = new Fifo();
|
|
385
|
+
* fifo.alloc(100, 4, AV_FIFO_FLAG_AUTO_GROW);
|
|
386
|
+
* fifo.setAutoGrowLimit(10000); // Limit to 10000 elements
|
|
387
|
+
* ```
|
|
388
|
+
*
|
|
389
|
+
* @see {@link alloc} For setting auto-grow flag
|
|
390
|
+
*/
|
|
391
|
+
setAutoGrowLimit(maxElems: number): void;
|
|
392
|
+
/**
|
|
393
|
+
* Get the underlying native Fifo object.
|
|
394
|
+
*
|
|
395
|
+
* @returns The native Fifo binding object
|
|
396
|
+
*
|
|
397
|
+
* @internal
|
|
398
|
+
*/
|
|
399
|
+
getNative(): NativeFifo;
|
|
400
|
+
/**
|
|
401
|
+
* Dispose of the FIFO buffer.
|
|
402
|
+
*
|
|
403
|
+
* Implements the Disposable interface for automatic cleanup.
|
|
404
|
+
* Equivalent to calling free().
|
|
405
|
+
*
|
|
406
|
+
* @example
|
|
407
|
+
* ```typescript
|
|
408
|
+
* {
|
|
409
|
+
* using fifo = new Fifo();
|
|
410
|
+
* fifo.alloc(100, 4);
|
|
411
|
+
* // Use fifo...
|
|
412
|
+
* } // Automatically freed when leaving scope
|
|
413
|
+
* ```
|
|
414
|
+
*/
|
|
415
|
+
[Symbol.dispose](): void;
|
|
416
|
+
}
|