node-av 0.0.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.
Files changed (175) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE.md +22 -0
  3. package/README.md +377 -0
  4. package/binding.gyp +78 -0
  5. package/dist/api/bitstream-filter.d.ts +246 -0
  6. package/dist/api/bitstream-filter.js +369 -0
  7. package/dist/api/bitstream-filter.js.map +1 -0
  8. package/dist/api/decoder.d.ts +257 -0
  9. package/dist/api/decoder.js +424 -0
  10. package/dist/api/decoder.js.map +1 -0
  11. package/dist/api/encoder.d.ts +298 -0
  12. package/dist/api/encoder.js +574 -0
  13. package/dist/api/encoder.js.map +1 -0
  14. package/dist/api/filter.d.ts +457 -0
  15. package/dist/api/filter.js +876 -0
  16. package/dist/api/filter.js.map +1 -0
  17. package/dist/api/hardware.d.ts +318 -0
  18. package/dist/api/hardware.js +558 -0
  19. package/dist/api/hardware.js.map +1 -0
  20. package/dist/api/index.d.ts +12 -0
  21. package/dist/api/index.js +20 -0
  22. package/dist/api/index.js.map +1 -0
  23. package/dist/api/io-stream.d.ts +109 -0
  24. package/dist/api/io-stream.js +124 -0
  25. package/dist/api/io-stream.js.map +1 -0
  26. package/dist/api/media-input.d.ts +295 -0
  27. package/dist/api/media-input.js +456 -0
  28. package/dist/api/media-input.js.map +1 -0
  29. package/dist/api/media-output.d.ts +274 -0
  30. package/dist/api/media-output.js +486 -0
  31. package/dist/api/media-output.js.map +1 -0
  32. package/dist/api/pipeline.d.ts +117 -0
  33. package/dist/api/pipeline.js +836 -0
  34. package/dist/api/pipeline.js.map +1 -0
  35. package/dist/api/types.d.ts +440 -0
  36. package/dist/api/types.js +2 -0
  37. package/dist/api/types.js.map +1 -0
  38. package/dist/api/utilities/audio-sample.d.ts +115 -0
  39. package/dist/api/utilities/audio-sample.js +110 -0
  40. package/dist/api/utilities/audio-sample.js.map +1 -0
  41. package/dist/api/utilities/channel-layout.d.ts +83 -0
  42. package/dist/api/utilities/channel-layout.js +87 -0
  43. package/dist/api/utilities/channel-layout.js.map +1 -0
  44. package/dist/api/utilities/image.d.ts +177 -0
  45. package/dist/api/utilities/image.js +183 -0
  46. package/dist/api/utilities/image.js.map +1 -0
  47. package/dist/api/utilities/index.d.ts +8 -0
  48. package/dist/api/utilities/index.js +17 -0
  49. package/dist/api/utilities/index.js.map +1 -0
  50. package/dist/api/utilities/media-type.d.ts +56 -0
  51. package/dist/api/utilities/media-type.js +60 -0
  52. package/dist/api/utilities/media-type.js.map +1 -0
  53. package/dist/api/utilities/pixel-format.d.ts +94 -0
  54. package/dist/api/utilities/pixel-format.js +102 -0
  55. package/dist/api/utilities/pixel-format.js.map +1 -0
  56. package/dist/api/utilities/sample-format.d.ts +132 -0
  57. package/dist/api/utilities/sample-format.js +144 -0
  58. package/dist/api/utilities/sample-format.js.map +1 -0
  59. package/dist/api/utilities/streaming.d.ts +104 -0
  60. package/dist/api/utilities/streaming.js +137 -0
  61. package/dist/api/utilities/streaming.js.map +1 -0
  62. package/dist/api/utilities/timestamp.d.ts +187 -0
  63. package/dist/api/utilities/timestamp.js +200 -0
  64. package/dist/api/utilities/timestamp.js.map +1 -0
  65. package/dist/api/utils.d.ts +61 -0
  66. package/dist/api/utils.js +330 -0
  67. package/dist/api/utils.js.map +1 -0
  68. package/dist/index.d.ts +2 -0
  69. package/dist/index.js +5 -0
  70. package/dist/index.js.map +1 -0
  71. package/dist/lib/audio-fifo.d.ts +339 -0
  72. package/dist/lib/audio-fifo.js +365 -0
  73. package/dist/lib/audio-fifo.js.map +1 -0
  74. package/dist/lib/binding.d.ts +192 -0
  75. package/dist/lib/binding.js +70 -0
  76. package/dist/lib/binding.js.map +1 -0
  77. package/dist/lib/bitstream-filter-context.d.ts +345 -0
  78. package/dist/lib/bitstream-filter-context.js +407 -0
  79. package/dist/lib/bitstream-filter-context.js.map +1 -0
  80. package/dist/lib/bitstream-filter.d.ts +124 -0
  81. package/dist/lib/bitstream-filter.js +138 -0
  82. package/dist/lib/bitstream-filter.js.map +1 -0
  83. package/dist/lib/channel-layouts.d.ts +51 -0
  84. package/dist/lib/channel-layouts.js +55 -0
  85. package/dist/lib/channel-layouts.js.map +1 -0
  86. package/dist/lib/codec-context.d.ts +763 -0
  87. package/dist/lib/codec-context.js +974 -0
  88. package/dist/lib/codec-context.js.map +1 -0
  89. package/dist/lib/codec-parameters.d.ts +362 -0
  90. package/dist/lib/codec-parameters.js +460 -0
  91. package/dist/lib/codec-parameters.js.map +1 -0
  92. package/dist/lib/codec-parser.d.ts +185 -0
  93. package/dist/lib/codec-parser.js +193 -0
  94. package/dist/lib/codec-parser.js.map +1 -0
  95. package/dist/lib/codec.d.ts +432 -0
  96. package/dist/lib/codec.js +492 -0
  97. package/dist/lib/codec.js.map +1 -0
  98. package/dist/lib/constants.d.ts +2037 -0
  99. package/dist/lib/constants.js +1659 -0
  100. package/dist/lib/constants.js.map +1 -0
  101. package/dist/lib/dictionary.d.ts +371 -0
  102. package/dist/lib/dictionary.js +406 -0
  103. package/dist/lib/dictionary.js.map +1 -0
  104. package/dist/lib/error.d.ts +216 -0
  105. package/dist/lib/error.js +254 -0
  106. package/dist/lib/error.js.map +1 -0
  107. package/dist/lib/filter-context.d.ts +445 -0
  108. package/dist/lib/filter-context.js +505 -0
  109. package/dist/lib/filter-context.js.map +1 -0
  110. package/dist/lib/filter-graph.d.ts +556 -0
  111. package/dist/lib/filter-graph.js +608 -0
  112. package/dist/lib/filter-graph.js.map +1 -0
  113. package/dist/lib/filter-inout.d.ts +205 -0
  114. package/dist/lib/filter-inout.js +264 -0
  115. package/dist/lib/filter-inout.js.map +1 -0
  116. package/dist/lib/filter.d.ts +231 -0
  117. package/dist/lib/filter.js +260 -0
  118. package/dist/lib/filter.js.map +1 -0
  119. package/dist/lib/format-context.d.ts +798 -0
  120. package/dist/lib/format-context.js +845 -0
  121. package/dist/lib/format-context.js.map +1 -0
  122. package/dist/lib/frame.d.ts +784 -0
  123. package/dist/lib/frame.js +933 -0
  124. package/dist/lib/frame.js.map +1 -0
  125. package/dist/lib/hardware-device-context.d.ts +407 -0
  126. package/dist/lib/hardware-device-context.js +429 -0
  127. package/dist/lib/hardware-device-context.js.map +1 -0
  128. package/dist/lib/hardware-frames-context.d.ts +374 -0
  129. package/dist/lib/hardware-frames-context.js +430 -0
  130. package/dist/lib/hardware-frames-context.js.map +1 -0
  131. package/dist/lib/index.d.ts +31 -0
  132. package/dist/lib/index.js +54 -0
  133. package/dist/lib/index.js.map +1 -0
  134. package/dist/lib/input-format.d.ts +216 -0
  135. package/dist/lib/input-format.js +246 -0
  136. package/dist/lib/input-format.js.map +1 -0
  137. package/dist/lib/io-context.d.ts +495 -0
  138. package/dist/lib/io-context.js +550 -0
  139. package/dist/lib/io-context.js.map +1 -0
  140. package/dist/lib/log.d.ts +201 -0
  141. package/dist/lib/log.js +219 -0
  142. package/dist/lib/log.js.map +1 -0
  143. package/dist/lib/native-types.d.ts +719 -0
  144. package/dist/lib/native-types.js +2 -0
  145. package/dist/lib/native-types.js.map +1 -0
  146. package/dist/lib/option.d.ts +589 -0
  147. package/dist/lib/option.js +853 -0
  148. package/dist/lib/option.js.map +1 -0
  149. package/dist/lib/output-format.d.ts +179 -0
  150. package/dist/lib/output-format.js +205 -0
  151. package/dist/lib/output-format.js.map +1 -0
  152. package/dist/lib/packet.d.ts +487 -0
  153. package/dist/lib/packet.js +558 -0
  154. package/dist/lib/packet.js.map +1 -0
  155. package/dist/lib/rational.d.ts +210 -0
  156. package/dist/lib/rational.js +233 -0
  157. package/dist/lib/rational.js.map +1 -0
  158. package/dist/lib/software-resample-context.d.ts +572 -0
  159. package/dist/lib/software-resample-context.js +610 -0
  160. package/dist/lib/software-resample-context.js.map +1 -0
  161. package/dist/lib/software-scale-context.d.ts +290 -0
  162. package/dist/lib/software-scale-context.js +308 -0
  163. package/dist/lib/software-scale-context.js.map +1 -0
  164. package/dist/lib/stream.d.ts +322 -0
  165. package/dist/lib/stream.js +408 -0
  166. package/dist/lib/stream.js.map +1 -0
  167. package/dist/lib/types.d.ts +59 -0
  168. package/dist/lib/types.js +8 -0
  169. package/dist/lib/types.js.map +1 -0
  170. package/dist/lib/utilities.d.ts +346 -0
  171. package/dist/lib/utilities.js +424 -0
  172. package/dist/lib/utilities.js.map +1 -0
  173. package/install/check.js +113 -0
  174. package/install/ffmpeg.js +163 -0
  175. package/package.json +107 -0
@@ -0,0 +1,487 @@
1
+ import type { AVPacketFlag, AVPacketSideDataType } from './constants.js';
2
+ import type { NativePacket, NativeWrapper } from './native-types.js';
3
+ import type { IRational } from './types.js';
4
+ /**
5
+ * Packet for compressed audio/video data.
6
+ *
7
+ * Contains compressed audio/video data read from demuxer or to be sent to muxer.
8
+ * Packets are the fundamental unit of data exchange between demuxers, muxers,
9
+ * encoders, and decoders in FFmpeg. User has full control over allocation and lifecycle.
10
+ *
11
+ * Direct mapping to FFmpeg's AVPacket.
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * import { Packet, FormatContext, CodecContext, FFmpegError } from 'node-av';
16
+ *
17
+ * // Create and allocate packet - full control
18
+ * const packet = new Packet();
19
+ * packet.alloc();
20
+ *
21
+ * // Read from demuxer
22
+ * const ret = await formatContext.readFrame(packet);
23
+ * FFmpegError.throwIfError(ret, 'readFrame');
24
+ *
25
+ * // Process packet
26
+ * console.log(`Stream: ${packet.streamIndex}, PTS: ${packet.pts}`);
27
+ *
28
+ * // Send to decoder
29
+ * const sendRet = await codecContext.sendPacket(packet);
30
+ * FFmpegError.throwIfError(sendRet, 'sendPacket');
31
+ *
32
+ * // Cleanup
33
+ * packet.unref(); // Clear data but keep packet allocated
34
+ * packet.free(); // Free packet completely
35
+ * ```
36
+ *
37
+ * @see {@link CodecContext} For encoding/decoding packets
38
+ * @see {@link FormatContext} For reading/writing packets
39
+ */
40
+ export declare class Packet implements Disposable, NativeWrapper<NativePacket> {
41
+ private native;
42
+ /**
43
+ * Create a new packet instance.
44
+ *
45
+ * The packet is uninitialized - you must call alloc() before use.
46
+ * No FFmpeg resources are allocated until alloc() is called.
47
+ *
48
+ * Direct wrapper around AVPacket allocation.
49
+ *
50
+ * @example
51
+ * ```typescript
52
+ * import { Packet } from 'node-av';
53
+ *
54
+ * const packet = new Packet();
55
+ * packet.alloc();
56
+ * // Packet is now ready for use
57
+ *
58
+ * // Always free when done
59
+ * packet.free();
60
+ * ```
61
+ */
62
+ constructor();
63
+ /**
64
+ * Stream index this packet belongs to.
65
+ *
66
+ * Direct mapping to AVPacket->stream_index
67
+ *
68
+ * Set by demuxer to indicate which stream this packet belongs to.
69
+ * Must be set by user for muxing.
70
+ */
71
+ get streamIndex(): number;
72
+ set streamIndex(value: number);
73
+ /**
74
+ * Presentation timestamp in AVStream->time_base units.
75
+ *
76
+ * Direct mapping to AVPacket->pts
77
+ *
78
+ * The time at which the decompressed packet will be presented to the user.
79
+ * Can be AV_NOPTS_VALUE if it is not stored in the file.
80
+ * pts MUST be larger or equal to dts as presentation cannot happen before
81
+ * decompression, unless one wants to view hex dumps. Some formats misuse
82
+ * the terms dts and pts/cts to mean something different. Such timestamps
83
+ * must be converted to true pts/dts before they are stored in AVPacket.
84
+ */
85
+ get pts(): bigint;
86
+ set pts(value: bigint);
87
+ /**
88
+ * Decompression timestamp in AVStream->time_base units.
89
+ *
90
+ * Direct mapping to AVPacket->dts
91
+ *
92
+ * The time at which the packet is decompressed.
93
+ * Can be AV_NOPTS_VALUE if it is not stored in the file.
94
+ */
95
+ get dts(): bigint;
96
+ set dts(value: bigint);
97
+ /**
98
+ * Duration of this packet in AVStream->time_base units, 0 if unknown.
99
+ *
100
+ * Direct mapping to AVPacket->duration
101
+ *
102
+ * Equals next_pts - this_pts in presentation order.
103
+ */
104
+ get duration(): bigint;
105
+ set duration(value: bigint);
106
+ /**
107
+ * Byte position in stream, -1 if unknown.
108
+ *
109
+ * Direct mapping to AVPacket->pos
110
+ *
111
+ * Can be used to derive seeking positions for formats without timestamps.
112
+ */
113
+ get pos(): bigint;
114
+ set pos(value: bigint);
115
+ /**
116
+ * Size of packet data in bytes.
117
+ *
118
+ * Direct mapping to AVPacket->size
119
+ *
120
+ * @readonly
121
+ */
122
+ get size(): number;
123
+ /**
124
+ * A combination of AV_PKT_FLAG values.
125
+ *
126
+ * Direct mapping to AVPacket->flags
127
+ *
128
+ * - AV_PKT_FLAG_KEY: The packet contains a keyframe
129
+ * - AV_PKT_FLAG_CORRUPT: The packet content is corrupted
130
+ * - AV_PKT_FLAG_DISCARD: Flag for packets that should be dropped
131
+ * - AV_PKT_FLAG_TRUSTED: The packet comes from a trusted source
132
+ * - AV_PKT_FLAG_DISPOSABLE: Flag for packets that can be dropped if needed
133
+ */
134
+ get flags(): AVPacketFlag;
135
+ set flags(value: AVPacketFlag);
136
+ /**
137
+ * Packet data buffer.
138
+ *
139
+ * Direct mapping to AVPacket->data
140
+ *
141
+ * Can be null if the packet is empty or unallocated.
142
+ * Setting null will unref the packet data.
143
+ * When setting a new buffer, av_packet_from_data() is called internally.
144
+ */
145
+ get data(): Buffer | null;
146
+ set data(value: Buffer | null);
147
+ /**
148
+ * Check if packet contains a keyframe.
149
+ *
150
+ * This is a convenience accessor for the AV_PKT_FLAG_KEY flag.
151
+ */
152
+ get isKeyframe(): boolean;
153
+ set isKeyframe(value: boolean);
154
+ /**
155
+ * Allocate an AVPacket and set its fields to default values.
156
+ *
157
+ * Allocates the AVPacket structure and initializes all fields to default values.
158
+ * This only allocates the packet structure itself, not the data buffers.
159
+ *
160
+ * Direct mapping to av_packet_alloc()
161
+ *
162
+ * @throws {Error} Memory allocation failure (ENOMEM)
163
+ *
164
+ * @example
165
+ * ```typescript
166
+ * import { Packet } from 'node-av';
167
+ *
168
+ * const packet = new Packet();
169
+ * packet.alloc();
170
+ * // Packet is now allocated with default values
171
+ * // pts = AV_NOPTS_VALUE, dts = AV_NOPTS_VALUE
172
+ * // size = 0, data = null
173
+ * ```
174
+ *
175
+ * @see {@link free} Must be called when done
176
+ * @see {@link unref} To clear data but keep allocation
177
+ */
178
+ alloc(): void;
179
+ /**
180
+ * Free the packet.
181
+ *
182
+ * Direct mapping to av_packet_free()
183
+ *
184
+ * If the packet has a reference counted buffer, it will be unreferenced first.
185
+ * After calling this, the packet is no longer usable until alloc() is called again.
186
+ *
187
+ * @note
188
+ * Calling this multiple times is safe, because we check the freed state
189
+ *
190
+ * @example
191
+ * ```typescript
192
+ * packet.free();
193
+ * // packet is now invalid and should not be used
194
+ * ```
195
+ */
196
+ free(): void;
197
+ /**
198
+ * Setup a new reference to the data described by a given packet.
199
+ *
200
+ * If src is reference counted, increase its reference count.
201
+ * Otherwise allocate a new buffer for dst and copy the data from src into it.
202
+ * All the other fields are copied from src.
203
+ *
204
+ * Direct mapping to av_packet_ref()
205
+ *
206
+ * @param src - Source packet to reference
207
+ *
208
+ * @returns 0 on success, negative AVERROR on error:
209
+ * - 0: Success
210
+ * - AVERROR(ENOMEM): Memory allocation failure
211
+ * - AVERROR(EINVAL): Invalid parameters (null packet)
212
+ *
213
+ * @example
214
+ * ```typescript
215
+ * import { Packet, FFmpegError } from 'node-av';
216
+ *
217
+ * const src = new Packet();
218
+ * // ... src contains data ...
219
+ * const dst = new Packet();
220
+ * dst.alloc();
221
+ *
222
+ * const ret = dst.ref(src);
223
+ * FFmpegError.throwIfError(ret, 'packet.ref');
224
+ * // dst now references the same data as src
225
+ * ```
226
+ *
227
+ * @see {@link unref} To remove reference
228
+ * @see {@link clone} For simpler cloning
229
+ */
230
+ ref(src: Packet): number;
231
+ /**
232
+ * Wipe the packet.
233
+ *
234
+ * Direct mapping to av_packet_unref()
235
+ *
236
+ * Unreference the buffer referenced by the packet and reset the
237
+ * remaining packet fields to their default values.
238
+ *
239
+ * The packet remains allocated and can be reused.
240
+ *
241
+ * @example
242
+ * ```typescript
243
+ * packet.unref();
244
+ * // Packet data is cleared but packet remains allocated
245
+ * // Can reuse the packet for another read
246
+ * ```
247
+ *
248
+ * @note The packet must have been allocated with alloc().
249
+ */
250
+ unref(): void;
251
+ /**
252
+ * Create a new packet that references the same data as this packet.
253
+ *
254
+ * This is a shortcut for av_packet_alloc() + av_packet_ref().
255
+ * The new packet shares the same data buffer through reference counting.
256
+ *
257
+ * Direct mapping to av_packet_clone()
258
+ *
259
+ * @returns New packet referencing the same data, or null on error (ENOMEM)
260
+ *
261
+ * @example
262
+ * ```typescript
263
+ * import { Packet } from 'node-av';
264
+ *
265
+ * const original = new Packet();
266
+ * // ... original contains data ...
267
+ *
268
+ * const cloned = original.clone();
269
+ * if (!cloned) {
270
+ * throw new Error('Failed to clone packet: Out of memory');
271
+ * }
272
+ * // cloned references the same data as original
273
+ * // Both packets must be freed independently
274
+ * cloned.free();
275
+ * original.free();
276
+ * ```
277
+ *
278
+ * @see {@link ref} For manual reference setup
279
+ */
280
+ clone(): Packet | null;
281
+ /**
282
+ * Convert valid timing fields (timestamps / durations) in a packet from one timebase to another.
283
+ *
284
+ * Timestamps with unknown values (AV_NOPTS_VALUE) will be ignored.
285
+ * This function is useful when you need to convert packet timestamps between
286
+ * different contexts, for example when remuxing or when the decoder and encoder
287
+ * use different timebases.
288
+ *
289
+ * Direct mapping to av_packet_rescale_ts()
290
+ *
291
+ * @param srcTimebase - Source timebase, in which the timestamps are expressed
292
+ * @param dstTimebase - Destination timebase, to which the timestamps will be converted
293
+ *
294
+ * @example
295
+ * ```typescript
296
+ * import { Packet, Rational } from 'node-av';
297
+ *
298
+ * // Convert from stream timebase to codec timebase
299
+ * const streamTimebase = new Rational(1, 90000); // 90kHz
300
+ * const codecTimebase = new Rational(1, 25); // 25 fps
301
+ *
302
+ * packet.rescaleTs(
303
+ * streamTimebase,
304
+ * codecTimebase
305
+ * );
306
+ * // PTS and DTS are now in codec timebase
307
+ * ```
308
+ *
309
+ * @see {@link Rational} For timebase representation
310
+ */
311
+ rescaleTs(srcTimebase: IRational, dstTimebase: IRational): void;
312
+ /**
313
+ * Ensure the data described by the packet is reference counted.
314
+ *
315
+ * Makes the packet data reference counted if it isn't already.
316
+ * This is useful when you need to share packet data between multiple owners.
317
+ *
318
+ * Direct mapping to av_packet_make_refcounted()
319
+ *
320
+ * @returns 0 on success, negative AVERROR on error:
321
+ * - 0: Success (data is now reference counted)
322
+ * - AVERROR(ENOMEM): Memory allocation failure
323
+ *
324
+ * @example
325
+ * ```typescript
326
+ * import { Packet, FFmpegError } from 'node-av';
327
+ *
328
+ * const ret = packet.makeRefcounted();
329
+ * FFmpegError.throwIfError(ret, 'makeRefcounted');
330
+ * // Packet data is now reference counted
331
+ * // Safe to share with multiple owners
332
+ * ```
333
+ *
334
+ * Note: This function does not ensure that the reference will be writable.
335
+ * Use makeWritable() for that purpose.
336
+ *
337
+ * @see {@link makeWritable} To ensure data is writable
338
+ */
339
+ makeRefcounted(): number;
340
+ /**
341
+ * Create a writable reference for the data described by the packet.
342
+ *
343
+ * If the packet data buffer is already writable, this does nothing.
344
+ * Otherwise, a new buffer is allocated, data is copied, and the old buffer
345
+ * is unreferenced. This avoids data copy if possible.
346
+ *
347
+ * Direct mapping to av_packet_make_writable()
348
+ *
349
+ * @returns 0 on success, negative AVERROR on error:
350
+ * - 0: Success (data is now writable)
351
+ * - AVERROR(ENOMEM): Memory allocation failure
352
+ *
353
+ * @example
354
+ * ```typescript
355
+ * import { Packet, FFmpegError } from 'node-av';
356
+ *
357
+ * // Before modifying packet data
358
+ * const ret = packet.makeWritable();
359
+ * FFmpegError.throwIfError(ret, 'makeWritable');
360
+ *
361
+ * // Now safe to modify packet data
362
+ * const data = packet.data;
363
+ * if (data) {
364
+ * // Modify data buffer directly
365
+ * data[0] = 0xFF;
366
+ * }
367
+ * ```
368
+ *
369
+ * @see {@link makeRefcounted} To make data reference counted
370
+ */
371
+ makeWritable(): number;
372
+ /**
373
+ * Get side data from the packet.
374
+ *
375
+ * Direct mapping to av_packet_get_side_data()
376
+ *
377
+ * @param type - The type of side data to retrieve
378
+ * @returns Buffer containing the side data, or null if not found
379
+ *
380
+ * @example
381
+ * ```typescript
382
+ * import { Packet } from 'node-av';
383
+ * import { AV_PKT_DATA_PALETTE } from 'node-av/constants';
384
+ *
385
+ * const paletteData = packet.getSideData(AV_PKT_DATA_PALETTE);
386
+ * if (paletteData) {
387
+ * console.log('Palette data size:', paletteData.length);
388
+ * }
389
+ * ```
390
+ */
391
+ getSideData(type: AVPacketSideDataType): Buffer | null;
392
+ /**
393
+ * Add side data to the packet.
394
+ *
395
+ * Allocates and adds side data to the packet. The data is copied.
396
+ * Direct mapping to av_packet_add_side_data()
397
+ *
398
+ * @param type - The type of side data to add
399
+ * @param data - Buffer containing the side data
400
+ * @returns 0 on success, negative AVERROR on failure
401
+ *
402
+ * @example
403
+ * ```typescript
404
+ * import { Packet } from 'node-av';
405
+ * import { AV_PKT_DATA_NEW_EXTRADATA } from 'node-av/constants';
406
+ *
407
+ * const extraData = Buffer.from([0x01, 0x02, 0x03]);
408
+ * const ret = packet.addSideData(AV_PKT_DATA_NEW_EXTRADATA, extraData);
409
+ * if (ret < 0) {
410
+ * console.error('Failed to add side data');
411
+ * }
412
+ * ```
413
+ */
414
+ addSideData(type: AVPacketSideDataType, data: Buffer): number;
415
+ /**
416
+ * Allocate new side data for the packet.
417
+ *
418
+ * Allocates a new side data buffer of the specified size.
419
+ * Returns a Buffer that references the allocated memory.
420
+ * Direct mapping to av_packet_new_side_data()
421
+ *
422
+ * @param type - The type of side data to allocate
423
+ * @param size - Size of the side data buffer to allocate
424
+ * @returns Buffer referencing the allocated side data
425
+ * @throws {Error} If allocation fails
426
+ *
427
+ * @example
428
+ * ```typescript
429
+ * import { Packet } from 'node-av';
430
+ * import { AV_PKT_DATA_STRINGS_METADATA } from 'node-av/constants';
431
+ *
432
+ * // Allocate 256 bytes for metadata
433
+ * const metadataBuffer = packet.newSideData(AV_PKT_DATA_STRINGS_METADATA, 256);
434
+ * // Write metadata to the buffer
435
+ * metadataBuffer.write('key=value', 0, 'utf8');
436
+ * ```
437
+ */
438
+ newSideData(type: AVPacketSideDataType, size: number): Buffer;
439
+ /**
440
+ * Free all side data from the packet.
441
+ *
442
+ * Removes and frees all side data attached to the packet.
443
+ * Direct mapping to av_packet_free_side_data()
444
+ *
445
+ * @example
446
+ * ```typescript
447
+ * // Remove all side data from the packet
448
+ * packet.freeSideData();
449
+ * ```
450
+ */
451
+ freeSideData(): void;
452
+ /**
453
+ * Get the native FFmpeg AVPacket pointer.
454
+ *
455
+ * @internal For use by other wrapper classes
456
+ * @returns The underlying native packet object
457
+ */
458
+ getNative(): NativePacket;
459
+ /**
460
+ * Dispose of the packet.
461
+ *
462
+ * Implements the Disposable interface for automatic cleanup.
463
+ * Equivalent to calling free().
464
+ *
465
+ * @example
466
+ * ```typescript
467
+ * import { Packet } from 'node-av';
468
+ *
469
+ * // Using 'using' declaration for automatic cleanup
470
+ * {
471
+ * using packet = new Packet();
472
+ * packet.alloc();
473
+ * // ... use packet
474
+ * } // Automatically freed when leaving scope
475
+ *
476
+ * // Or with try-finally
477
+ * const packet = new Packet();
478
+ * try {
479
+ * packet.alloc();
480
+ * // ... use packet
481
+ * } finally {
482
+ * packet[Symbol.dispose]();
483
+ * }
484
+ * ```
485
+ */
486
+ [Symbol.dispose](): void;
487
+ }