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.
Files changed (104) hide show
  1. package/README.md +23 -0
  2. package/binding.gyp +19 -11
  3. package/dist/api/bitstream-filter.d.ts +13 -12
  4. package/dist/api/bitstream-filter.js +33 -29
  5. package/dist/api/bitstream-filter.js.map +1 -1
  6. package/dist/api/decoder.d.ts +211 -96
  7. package/dist/api/decoder.js +396 -375
  8. package/dist/api/decoder.js.map +1 -1
  9. package/dist/api/demuxer.d.ts +10 -10
  10. package/dist/api/demuxer.js +7 -10
  11. package/dist/api/demuxer.js.map +1 -1
  12. package/dist/api/encoder.d.ts +155 -122
  13. package/dist/api/encoder.js +368 -541
  14. package/dist/api/encoder.js.map +1 -1
  15. package/dist/api/filter-complex.d.ts +769 -0
  16. package/dist/api/filter-complex.js +1596 -0
  17. package/dist/api/filter-complex.js.map +1 -0
  18. package/dist/api/filter-presets.d.ts +68 -0
  19. package/dist/api/filter-presets.js +96 -0
  20. package/dist/api/filter-presets.js.map +1 -1
  21. package/dist/api/filter.d.ts +183 -113
  22. package/dist/api/filter.js +347 -365
  23. package/dist/api/filter.js.map +1 -1
  24. package/dist/api/fmp4-stream.d.ts +2 -2
  25. package/dist/api/fmp4-stream.js.map +1 -1
  26. package/dist/api/index.d.ts +2 -0
  27. package/dist/api/index.js +3 -0
  28. package/dist/api/index.js.map +1 -1
  29. package/dist/api/io-stream.d.ts +3 -3
  30. package/dist/api/io-stream.js.map +1 -1
  31. package/dist/api/muxer.d.ts +10 -10
  32. package/dist/api/muxer.js +6 -6
  33. package/dist/api/muxer.js.map +1 -1
  34. package/dist/api/pipeline.d.ts +2 -2
  35. package/dist/api/pipeline.js +22 -22
  36. package/dist/api/pipeline.js.map +1 -1
  37. package/dist/api/rtp-stream.d.ts +2 -2
  38. package/dist/api/rtp-stream.js.map +1 -1
  39. package/dist/api/types.d.ts +63 -7
  40. package/dist/api/utilities/audio-sample.d.ts +10 -0
  41. package/dist/api/utilities/audio-sample.js +10 -0
  42. package/dist/api/utilities/audio-sample.js.map +1 -1
  43. package/dist/api/utilities/channel-layout.d.ts +1 -0
  44. package/dist/api/utilities/channel-layout.js +1 -0
  45. package/dist/api/utilities/channel-layout.js.map +1 -1
  46. package/dist/api/utilities/image.d.ts +38 -0
  47. package/dist/api/utilities/image.js +38 -0
  48. package/dist/api/utilities/image.js.map +1 -1
  49. package/dist/api/utilities/index.d.ts +1 -0
  50. package/dist/api/utilities/index.js +2 -0
  51. package/dist/api/utilities/index.js.map +1 -1
  52. package/dist/api/utilities/media-type.d.ts +1 -0
  53. package/dist/api/utilities/media-type.js +1 -0
  54. package/dist/api/utilities/media-type.js.map +1 -1
  55. package/dist/api/utilities/pixel-format.d.ts +3 -0
  56. package/dist/api/utilities/pixel-format.js +3 -0
  57. package/dist/api/utilities/pixel-format.js.map +1 -1
  58. package/dist/api/utilities/sample-format.d.ts +5 -0
  59. package/dist/api/utilities/sample-format.js +5 -0
  60. package/dist/api/utilities/sample-format.js.map +1 -1
  61. package/dist/api/utilities/scheduler.d.ts +21 -52
  62. package/dist/api/utilities/scheduler.js +20 -58
  63. package/dist/api/utilities/scheduler.js.map +1 -1
  64. package/dist/api/utilities/streaming.d.ts +32 -1
  65. package/dist/api/utilities/streaming.js +32 -1
  66. package/dist/api/utilities/streaming.js.map +1 -1
  67. package/dist/api/utilities/timestamp.d.ts +14 -0
  68. package/dist/api/utilities/timestamp.js +14 -0
  69. package/dist/api/utilities/timestamp.js.map +1 -1
  70. package/dist/api/utilities/whisper-model.d.ts +310 -0
  71. package/dist/api/utilities/whisper-model.js +528 -0
  72. package/dist/api/utilities/whisper-model.js.map +1 -0
  73. package/dist/api/whisper.d.ts +324 -0
  74. package/dist/api/whisper.js +362 -0
  75. package/dist/api/whisper.js.map +1 -0
  76. package/dist/constants/constants.d.ts +3 -1
  77. package/dist/constants/constants.js +1 -0
  78. package/dist/constants/constants.js.map +1 -1
  79. package/dist/ffmpeg/index.d.ts +3 -3
  80. package/dist/ffmpeg/index.js +3 -3
  81. package/dist/ffmpeg/utils.d.ts +27 -0
  82. package/dist/ffmpeg/utils.js +28 -16
  83. package/dist/ffmpeg/utils.js.map +1 -1
  84. package/dist/lib/binding.d.ts +4 -4
  85. package/dist/lib/binding.js.map +1 -1
  86. package/dist/lib/codec-parameters.d.ts +47 -1
  87. package/dist/lib/codec-parameters.js +55 -0
  88. package/dist/lib/codec-parameters.js.map +1 -1
  89. package/dist/lib/fifo.d.ts +416 -0
  90. package/dist/lib/fifo.js +453 -0
  91. package/dist/lib/fifo.js.map +1 -0
  92. package/dist/lib/frame.d.ts +96 -1
  93. package/dist/lib/frame.js +139 -1
  94. package/dist/lib/frame.js.map +1 -1
  95. package/dist/lib/index.d.ts +1 -0
  96. package/dist/lib/index.js +2 -0
  97. package/dist/lib/index.js.map +1 -1
  98. package/dist/lib/native-types.d.ts +29 -2
  99. package/dist/lib/rational.d.ts +18 -0
  100. package/dist/lib/rational.js +19 -0
  101. package/dist/lib/rational.js.map +1 -1
  102. package/dist/lib/types.d.ts +23 -1
  103. package/install/check.js +2 -2
  104. package/package.json +30 -20
@@ -0,0 +1,453 @@
1
+ import { AVFLAG_NONE } from '../constants/constants.js';
2
+ import { bindings } from './binding.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 class Fifo {
39
+ native;
40
+ constructor() {
41
+ this.native = new bindings.Fifo();
42
+ }
43
+ /**
44
+ * Number of elements currently in the FIFO.
45
+ *
46
+ * Direct mapping to av_fifo_can_read().
47
+ */
48
+ get size() {
49
+ return this.native.size;
50
+ }
51
+ /**
52
+ * Number of elements that can be read from the FIFO.
53
+ *
54
+ * Direct mapping to av_fifo_can_read().
55
+ */
56
+ get canRead() {
57
+ return this.native.canRead;
58
+ }
59
+ /**
60
+ * Number of elements that can be written without reallocation.
61
+ *
62
+ * Direct mapping to av_fifo_can_write().
63
+ */
64
+ get canWrite() {
65
+ return this.native.canWrite;
66
+ }
67
+ /**
68
+ * Size in bytes of a single element.
69
+ *
70
+ * Direct mapping to av_fifo_elem_size().
71
+ */
72
+ get elemSize() {
73
+ return this.native.elemSize;
74
+ }
75
+ /**
76
+ * Allocate an AVFifo buffer.
77
+ *
78
+ * Creates a FIFO buffer with the specified element count, size and flags.
79
+ * The FIFO can be configured to automatically grow when full.
80
+ *
81
+ * Direct mapping to av_fifo_alloc2().
82
+ *
83
+ * @param nbElems - Initial number of elements to allocate
84
+ *
85
+ * @param elemSize - Size in bytes of each element
86
+ *
87
+ * @param flags - Optional flags (e.g., AV_FIFO_FLAG_AUTO_GROW). Defaults to 0
88
+ *
89
+ * @throws {Error} If allocation fails (ENOMEM)
90
+ *
91
+ * @example
92
+ * ```typescript
93
+ * import { Fifo } from 'node-av';
94
+ * import { AV_FIFO_FLAG_AUTO_GROW } from 'node-av/constants';
95
+ *
96
+ * // Fixed size FIFO for 100 32-bit integers
97
+ * const fifo1 = new Fifo();
98
+ * fifo1.alloc(100, 4);
99
+ *
100
+ * // Auto-growing FIFO for 8-byte structures
101
+ * const fifo2 = new Fifo();
102
+ * fifo2.alloc(50, 8, AV_FIFO_FLAG_AUTO_GROW);
103
+ * fifo2.setAutoGrowLimit(1000); // Max 1000 elements
104
+ * ```
105
+ *
106
+ * @see {@link grow} To manually grow the FIFO
107
+ * @see {@link setAutoGrowLimit} To set auto-grow limit
108
+ * @see {@link free} To release the FIFO
109
+ */
110
+ alloc(nbElems, elemSize, flags = AVFLAG_NONE) {
111
+ this.native.alloc(nbElems, elemSize, flags);
112
+ }
113
+ /**
114
+ * Free the FIFO buffer and all associated resources.
115
+ *
116
+ * After calling this, the FIFO is invalid and must be reallocated before use.
117
+ *
118
+ * Direct mapping to av_fifo_freep().
119
+ *
120
+ * @example
121
+ * ```typescript
122
+ * fifo.free();
123
+ * // FIFO is now invalid, must call alloc() before using again
124
+ * ```
125
+ *
126
+ * @see {@link Symbol.dispose} For automatic cleanup
127
+ * @see {@link alloc} To allocate
128
+ */
129
+ free() {
130
+ this.native.free();
131
+ }
132
+ /**
133
+ * Write elements to the FIFO.
134
+ *
135
+ * Writes elements to the FIFO buffer. If AV_FIFO_FLAG_AUTO_GROW was set,
136
+ * automatically reallocates if more space is needed (up to auto-grow limit).
137
+ *
138
+ * Direct mapping to av_fifo_write().
139
+ *
140
+ * @param buf - Data buffer containing elements to write
141
+ *
142
+ * @param nbElems - Number of elements to write
143
+ *
144
+ * @returns Number of elements written (>= 0), or negative AVERROR:
145
+ * - AVERROR_EINVAL: Invalid parameters
146
+ * - AVERROR_ENOMEM: Not enough space and auto-grow failed/disabled
147
+ *
148
+ * @example
149
+ * ```typescript
150
+ * import { FFmpegError } from 'node-av';
151
+ *
152
+ * // Write 4 32-bit integers (16 bytes)
153
+ * const data = Buffer.from([
154
+ * 0x01, 0x00, 0x00, 0x00, // 1
155
+ * 0x02, 0x00, 0x00, 0x00, // 2
156
+ * 0x03, 0x00, 0x00, 0x00, // 3
157
+ * 0x04, 0x00, 0x00, 0x00, // 4
158
+ * ]);
159
+ * const written = await fifo.write(data, 4);
160
+ * FFmpegError.throwIfError(written, 'write');
161
+ * console.log(`Wrote ${written} elements`);
162
+ * ```
163
+ *
164
+ * @see {@link read} To retrieve elements from FIFO
165
+ * @see {@link canWrite} To check available space
166
+ */
167
+ async write(buf, nbElems) {
168
+ return await this.native.write(buf, nbElems);
169
+ }
170
+ /**
171
+ * Write elements to the FIFO synchronously.
172
+ * Synchronous version of write.
173
+ *
174
+ * Writes elements to the FIFO buffer. Can write fewer elements than requested
175
+ * if space is limited and auto-grow is disabled or has reached the limit.
176
+ *
177
+ * Direct mapping to av_fifo_write().
178
+ *
179
+ * @param buf - Data buffer containing elements to write
180
+ *
181
+ * @param nbElems - Number of elements to write
182
+ *
183
+ * @returns Number of elements written (>= 0), or negative AVERROR:
184
+ * - AVERROR_EINVAL: Invalid parameters
185
+ * - AVERROR_ENOMEM: Not enough space
186
+ *
187
+ * @example
188
+ * ```typescript
189
+ * import { FFmpegError } from 'node-av';
190
+ *
191
+ * const buffer = Buffer.alloc(32); // 8 elements of 4 bytes each
192
+ * // Fill with data...
193
+ *
194
+ * const written = fifo.writeSync(buffer, 8);
195
+ * FFmpegError.throwIfError(written, 'writeSync');
196
+ * console.log(`Wrote ${written} elements`);
197
+ * ```
198
+ *
199
+ * @see {@link write} For async version
200
+ */
201
+ writeSync(buf, nbElems) {
202
+ return this.native.writeSync(buf, nbElems);
203
+ }
204
+ /**
205
+ * Read and remove elements from the FIFO.
206
+ *
207
+ * Reads up to the specified number of elements from the FIFO.
208
+ * The elements are removed from the FIFO after reading.
209
+ * Buffer must be pre-allocated with sufficient size (nbElems * elemSize).
210
+ *
211
+ * Direct mapping to av_fifo_read().
212
+ *
213
+ * @param buf - Pre-allocated buffer to read into
214
+ *
215
+ * @param nbElems - Maximum number of elements to read
216
+ *
217
+ * @returns Number of elements read (>= 0), or negative AVERROR:
218
+ * - AVERROR_EINVAL: Invalid parameters or insufficient buffer size
219
+ *
220
+ * @example
221
+ * ```typescript
222
+ * import { FFmpegError } from 'node-av';
223
+ *
224
+ * // Check available elements
225
+ * const available = fifo.canRead;
226
+ * if (available >= 10) {
227
+ * // Read 10 elements (40 bytes for 4-byte elements)
228
+ * const outBuffer = Buffer.alloc(40);
229
+ * const read = await fifo.read(outBuffer, 10);
230
+ * FFmpegError.throwIfError(read, 'read');
231
+ * console.log(`Read ${read} elements`);
232
+ * }
233
+ * ```
234
+ *
235
+ * @see {@link peek} To read without removing
236
+ * @see {@link canRead} To check available elements
237
+ */
238
+ async read(buf, nbElems) {
239
+ return await this.native.read(buf, nbElems);
240
+ }
241
+ /**
242
+ * Read and remove elements from the FIFO synchronously.
243
+ * Synchronous version of read.
244
+ *
245
+ * Reads up to the specified number of elements from the FIFO.
246
+ * The elements are removed from the FIFO after reading.
247
+ * Buffer must be pre-allocated with sufficient size.
248
+ *
249
+ * Direct mapping to av_fifo_read().
250
+ *
251
+ * @param buf - Pre-allocated buffer to read into
252
+ *
253
+ * @param nbElems - Maximum number of elements to read
254
+ *
255
+ * @returns Number of elements read (>= 0), or negative AVERROR:
256
+ * - AVERROR_EINVAL: Invalid parameters
257
+ *
258
+ * @example
259
+ * ```typescript
260
+ * import { FFmpegError } from 'node-av';
261
+ *
262
+ * // Read up to 20 elements
263
+ * const readBuffer = Buffer.alloc(20 * fifo.elemSize);
264
+ * const read = fifo.readSync(readBuffer, 20);
265
+ * FFmpegError.throwIfError(read, 'readSync');
266
+ *
267
+ * console.log(`Read ${read} elements from FIFO`);
268
+ * console.log(`FIFO now has ${fifo.canRead} elements remaining`);
269
+ * ```
270
+ *
271
+ * @see {@link read} For async version
272
+ */
273
+ readSync(buf, nbElems) {
274
+ return this.native.readSync(buf, nbElems);
275
+ }
276
+ /**
277
+ * Read elements from the FIFO without removing them.
278
+ *
279
+ * Similar to read() but leaves the elements in the FIFO.
280
+ * Useful for inspecting upcoming data without consuming it.
281
+ * Optionally start reading from an offset.
282
+ *
283
+ * Direct mapping to av_fifo_peek().
284
+ *
285
+ * @param buf - Pre-allocated buffer to peek into
286
+ *
287
+ * @param nbElems - Maximum number of elements to peek
288
+ *
289
+ * @param offset - Offset in elements from start of FIFO. Defaults to 0
290
+ *
291
+ * @returns Number of elements peeked (>= 0), or negative AVERROR:
292
+ * - AVERROR_EINVAL: Invalid parameters or offset too large
293
+ *
294
+ * @example
295
+ * ```typescript
296
+ * import { FFmpegError } from 'node-av';
297
+ *
298
+ * // Peek at next 5 elements without removing them
299
+ * const peekBuffer = Buffer.alloc(5 * fifo.elemSize);
300
+ * const peeked = await fifo.peek(peekBuffer, 5);
301
+ * FFmpegError.throwIfError(peeked, 'peek');
302
+ *
303
+ * // Peek at elements starting at offset 10
304
+ * const peeked2 = await fifo.peek(peekBuffer, 5, 10);
305
+ * FFmpegError.throwIfError(peeked2, 'peek');
306
+ *
307
+ * // Elements are still in FIFO
308
+ * console.log(`FIFO still has ${fifo.canRead} elements`);
309
+ * ```
310
+ *
311
+ * @see {@link read} To read and remove elements
312
+ */
313
+ async peek(buf, nbElems, offset = 0) {
314
+ return await this.native.peek(buf, nbElems, offset);
315
+ }
316
+ /**
317
+ * Read elements from the FIFO without removing them synchronously.
318
+ * Synchronous version of peek.
319
+ *
320
+ * Similar to readSync() but leaves the elements in the FIFO.
321
+ * Useful for inspecting upcoming data without consuming it.
322
+ * Optionally start reading from an offset.
323
+ *
324
+ * Direct mapping to av_fifo_peek().
325
+ *
326
+ * @param buf - Pre-allocated buffer to peek into
327
+ *
328
+ * @param nbElems - Maximum number of elements to peek
329
+ *
330
+ * @param offset - Offset in elements from start of FIFO. Defaults to 0
331
+ *
332
+ * @returns Number of elements peeked (>= 0), or negative AVERROR:
333
+ * - AVERROR_EINVAL: Invalid parameters or offset too large
334
+ *
335
+ * @example
336
+ * ```typescript
337
+ * import { FFmpegError } from 'node-av';
338
+ *
339
+ * // Peek at next elements without removing them
340
+ * const peekBuffer = Buffer.alloc(10 * fifo.elemSize);
341
+ * const peeked = fifo.peekSync(peekBuffer, 10);
342
+ * FFmpegError.throwIfError(peeked, 'peekSync');
343
+ *
344
+ * // Elements are still in FIFO
345
+ * console.log(`FIFO still has ${fifo.canRead} elements`);
346
+ * ```
347
+ *
348
+ * @see {@link peek} For async version
349
+ */
350
+ peekSync(buf, nbElems, offset = 0) {
351
+ return this.native.peekSync(buf, nbElems, offset);
352
+ }
353
+ /**
354
+ * Grow the FIFO buffer by the specified number of elements.
355
+ *
356
+ * Increases the allocated size of the FIFO by adding more space.
357
+ * Existing elements are preserved.
358
+ *
359
+ * Direct mapping to av_fifo_grow2().
360
+ *
361
+ * @param inc - Number of additional elements to allocate
362
+ *
363
+ * @returns 0 on success, negative AVERROR on error:
364
+ * - AVERROR_EINVAL: Invalid size
365
+ * - AVERROR_ENOMEM: Memory allocation failure
366
+ *
367
+ * @example
368
+ * ```typescript
369
+ * import { FFmpegError } from 'node-av';
370
+ *
371
+ * // Grow FIFO to handle more elements
372
+ * const ret = fifo.grow(100);
373
+ * FFmpegError.throwIfError(ret, 'grow');
374
+ * console.log(`New write capacity: ${fifo.canWrite} elements`);
375
+ * ```
376
+ *
377
+ * @see {@link alloc} For initial allocation
378
+ */
379
+ grow(inc) {
380
+ return this.native.grow(inc);
381
+ }
382
+ /**
383
+ * Remove all elements from the FIFO.
384
+ *
385
+ * Empties the FIFO buffer without deallocating it.
386
+ * The FIFO remains allocated and ready for new data.
387
+ *
388
+ * Direct mapping to av_fifo_reset2().
389
+ *
390
+ * @example
391
+ * ```typescript
392
+ * fifo.reset();
393
+ * console.log(fifo.canRead); // 0
394
+ * console.log(fifo.canWrite); // Original allocation size
395
+ * ```
396
+ */
397
+ reset() {
398
+ this.native.reset();
399
+ }
400
+ /**
401
+ * Set the maximum number of elements for auto-grow.
402
+ *
403
+ * When AV_FIFO_FLAG_AUTO_GROW is set, the FIFO will automatically grow
404
+ * up to this limit when full. After reaching the limit, writes will fail.
405
+ *
406
+ * Direct mapping to av_fifo_auto_grow_limit().
407
+ *
408
+ * @param maxElems - Maximum number of elements (0 = unlimited)
409
+ *
410
+ * @example
411
+ * ```typescript
412
+ * import { AV_FIFO_FLAG_AUTO_GROW } from 'node-av/constants';
413
+ *
414
+ * const fifo = new Fifo();
415
+ * fifo.alloc(100, 4, AV_FIFO_FLAG_AUTO_GROW);
416
+ * fifo.setAutoGrowLimit(10000); // Limit to 10000 elements
417
+ * ```
418
+ *
419
+ * @see {@link alloc} For setting auto-grow flag
420
+ */
421
+ setAutoGrowLimit(maxElems) {
422
+ this.native.setAutoGrowLimit(maxElems);
423
+ }
424
+ /**
425
+ * Get the underlying native Fifo object.
426
+ *
427
+ * @returns The native Fifo binding object
428
+ *
429
+ * @internal
430
+ */
431
+ getNative() {
432
+ return this.native;
433
+ }
434
+ /**
435
+ * Dispose of the FIFO buffer.
436
+ *
437
+ * Implements the Disposable interface for automatic cleanup.
438
+ * Equivalent to calling free().
439
+ *
440
+ * @example
441
+ * ```typescript
442
+ * {
443
+ * using fifo = new Fifo();
444
+ * fifo.alloc(100, 4);
445
+ * // Use fifo...
446
+ * } // Automatically freed when leaving scope
447
+ * ```
448
+ */
449
+ [Symbol.dispose]() {
450
+ this.native[Symbol.dispose]();
451
+ }
452
+ }
453
+ //# sourceMappingURL=fifo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fifo.js","sourceRoot":"","sources":["../../src/lib/fifo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAKxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,OAAO,IAAI;IACP,MA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,CAAC;QACd,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;IAChC,CAAC;CACF"}
@@ -1,8 +1,9 @@
1
1
  import { HardwareFramesContext } from './hardware-frames-context.js';
2
2
  import { Rational } from './rational.js';
3
3
  import type { AVChromaLocation, AVColorPrimaries, AVColorRange, AVColorSpace, AVColorTransferCharacteristic, AVFrameSideDataType, AVMediaType, AVPictureType, AVPixelFormat, AVSampleFormat } from '../constants/constants.js';
4
+ import { Dictionary } from './dictionary.js';
4
5
  import type { NativeFrame, NativeWrapper } from './native-types.js';
5
- import type { ChannelLayout } from './types.js';
6
+ import type { AudioFrame, ChannelLayout, VideoFrame } from './types.js';
6
7
  /**
7
8
  * Container for uncompressed audio/video data.
8
9
  *
@@ -49,6 +50,63 @@ export declare class Frame implements Disposable, NativeWrapper<NativeFrame> {
49
50
  private native;
50
51
  private _hwFramesCtx?;
51
52
  constructor();
53
+ /**
54
+ * Create a video frame from a buffer with pixel data.
55
+ *
56
+ * Allocates frame buffers, sets properties, and copies buffer data.
57
+ * Convenience factory method that combines frame allocation and data copy.
58
+ *
59
+ * @param buffer - Buffer containing raw pixel data
60
+ *
61
+ * @param props - Video Frame properties
62
+ *
63
+ * @returns Allocated frame with data from buffer
64
+ *
65
+ * @throws {FFmpegError} If allocation or buffer copy fails
66
+ *
67
+ * @example
68
+ * ```typescript
69
+ * import { Frame, AV_PIX_FMT_RGBA, FFmpegError } from 'node-av';
70
+ *
71
+ * const rawPixels = Buffer.alloc(1920 * 1080 * 4); // RGBA data
72
+ * using frame = Frame.fromVideoBuffer(rawPixels, {
73
+ * width: 1920,
74
+ * height: 1080,
75
+ * format: AV_PIX_FMT_RGBA,
76
+ * timeBase: { num: 1, den: 30 }
77
+ * });
78
+ * ```
79
+ */
80
+ static fromVideoBuffer(buffer: Buffer, props: VideoFrame): Frame;
81
+ /**
82
+ * Create an audio frame from a buffer with sample data.
83
+ *
84
+ * Allocates frame buffers, sets properties, and copies buffer data.
85
+ * Convenience factory method that combines frame allocation and data copy.
86
+ *
87
+ * @param buffer - Buffer containing raw audio samples
88
+ *
89
+ * @param props - Frame properties
90
+ *
91
+ * @returns Allocated frame with data from buffer
92
+ *
93
+ * @throws {FFmpegError} If allocation or buffer copy fails
94
+ *
95
+ * @example
96
+ * ```typescript
97
+ * import { Frame, AV_SAMPLE_FMT_FLT, AV_CH_LAYOUT_STEREO, FFmpegError } from 'node-av';
98
+ *
99
+ * const samples = Buffer.alloc(960 * 2 * 4); // 960 samples, stereo, float32
100
+ * using frame = Frame.fromAudioBuffer(samples, {
101
+ * nbSamples: 960,
102
+ * format: AV_SAMPLE_FMT_FLT,
103
+ * sampleRate: 48000,
104
+ * channelLayout: AV_CH_LAYOUT_STEREO,
105
+ * timeBase: { num: 1, den: 48000 }
106
+ * });
107
+ * ```
108
+ */
109
+ static fromAudioBuffer(buffer: Buffer, props: AudioFrame): Frame;
52
110
  /**
53
111
  * Pixel format for video frames or sample format for audio.
54
112
  *
@@ -921,6 +979,43 @@ export declare class Frame implements Disposable, NativeWrapper<NativeFrame> {
921
979
  * @see {@link newSideData} To add side data
922
980
  */
923
981
  removeSideData(type: AVFrameSideDataType): void;
982
+ /**
983
+ * Get frame metadata dictionary.
984
+ *
985
+ * Returns metadata attached to the frame by filters or demuxers.
986
+ * Metadata is stored as key-value pairs in a Dictionary.
987
+ * Useful for reading filter-generated metadata (e.g., whisper transcription).
988
+ *
989
+ * Direct mapping to AVFrame->metadata.
990
+ *
991
+ * @returns Dictionary containing frame metadata
992
+ *
993
+ * @example
994
+ * ```typescript
995
+ * // Read whisper filter metadata
996
+ * const metadata = frame.getMetadata();
997
+ * const text = metadata.get('lavfi.whisper.text');
998
+ * const duration = metadata.get('lavfi.whisper.duration');
999
+ *
1000
+ * if (text) {
1001
+ * console.log(`Transcribed: ${text}`);
1002
+ * console.log(`Duration: ${duration}s`);
1003
+ * }
1004
+ * ```
1005
+ *
1006
+ * @example
1007
+ * ```typescript
1008
+ * // Read scene detection metadata
1009
+ * const metadata = frame.getMetadata();
1010
+ * const score = metadata.get('lavfi.scene_score');
1011
+ * if (score) {
1012
+ * console.log(`Scene change score: ${score}`);
1013
+ * }
1014
+ * ```
1015
+ *
1016
+ * @see {@link Dictionary} For metadata dictionary operations
1017
+ */
1018
+ getMetadata(): Dictionary;
924
1019
  /**
925
1020
  * Apply cropping to the frame.
926
1021
  *