node-av 1.1.0 → 1.2.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 (134) hide show
  1. package/README.md +51 -38
  2. package/dist/api/bitstream-filter.d.ts +180 -123
  3. package/dist/api/bitstream-filter.js +180 -125
  4. package/dist/api/bitstream-filter.js.map +1 -1
  5. package/dist/api/decoder.d.ts +279 -132
  6. package/dist/api/decoder.js +285 -142
  7. package/dist/api/decoder.js.map +1 -1
  8. package/dist/api/encoder.d.ts +246 -162
  9. package/dist/api/encoder.js +272 -208
  10. package/dist/api/encoder.js.map +1 -1
  11. package/dist/api/filter-presets.d.ts +690 -94
  12. package/dist/api/filter-presets.js +686 -102
  13. package/dist/api/filter-presets.js.map +1 -1
  14. package/dist/api/filter.d.ts +249 -213
  15. package/dist/api/filter.js +252 -242
  16. package/dist/api/filter.js.map +1 -1
  17. package/dist/api/hardware.d.ts +224 -117
  18. package/dist/api/hardware.js +380 -214
  19. package/dist/api/hardware.js.map +1 -1
  20. package/dist/api/index.d.ts +3 -3
  21. package/dist/api/index.js +1 -1
  22. package/dist/api/index.js.map +1 -1
  23. package/dist/api/io-stream.d.ts +65 -61
  24. package/dist/api/io-stream.js +43 -46
  25. package/dist/api/io-stream.js.map +1 -1
  26. package/dist/api/media-input.d.ts +242 -140
  27. package/dist/api/media-input.js +205 -103
  28. package/dist/api/media-input.js.map +1 -1
  29. package/dist/api/media-output.d.ts +206 -128
  30. package/dist/api/media-output.js +210 -128
  31. package/dist/api/media-output.js.map +1 -1
  32. package/dist/api/pipeline.d.ts +168 -38
  33. package/dist/api/pipeline.js +238 -14
  34. package/dist/api/pipeline.js.map +1 -1
  35. package/dist/api/types.d.ts +21 -187
  36. package/dist/api/utils.d.ts +1 -2
  37. package/dist/api/utils.js +9 -0
  38. package/dist/api/utils.js.map +1 -1
  39. package/dist/lib/audio-fifo.d.ts +127 -170
  40. package/dist/lib/audio-fifo.js +130 -173
  41. package/dist/lib/audio-fifo.js.map +1 -1
  42. package/dist/lib/binding.js +5 -0
  43. package/dist/lib/binding.js.map +1 -1
  44. package/dist/lib/bitstream-filter-context.d.ts +139 -184
  45. package/dist/lib/bitstream-filter-context.js +139 -188
  46. package/dist/lib/bitstream-filter-context.js.map +1 -1
  47. package/dist/lib/bitstream-filter.d.ts +68 -54
  48. package/dist/lib/bitstream-filter.js +68 -54
  49. package/dist/lib/bitstream-filter.js.map +1 -1
  50. package/dist/lib/codec-context.d.ts +316 -380
  51. package/dist/lib/codec-context.js +316 -381
  52. package/dist/lib/codec-context.js.map +1 -1
  53. package/dist/lib/codec-parameters.d.ts +160 -170
  54. package/dist/lib/codec-parameters.js +162 -172
  55. package/dist/lib/codec-parameters.js.map +1 -1
  56. package/dist/lib/codec-parser.d.ts +91 -104
  57. package/dist/lib/codec-parser.js +92 -103
  58. package/dist/lib/codec-parser.js.map +1 -1
  59. package/dist/lib/codec.d.ts +264 -281
  60. package/dist/lib/codec.js +268 -285
  61. package/dist/lib/codec.js.map +1 -1
  62. package/dist/lib/dictionary.d.ts +149 -203
  63. package/dist/lib/dictionary.js +158 -212
  64. package/dist/lib/dictionary.js.map +1 -1
  65. package/dist/lib/error.d.ts +96 -130
  66. package/dist/lib/error.js +98 -128
  67. package/dist/lib/error.js.map +1 -1
  68. package/dist/lib/filter-context.d.ts +284 -218
  69. package/dist/lib/filter-context.js +290 -227
  70. package/dist/lib/filter-context.js.map +1 -1
  71. package/dist/lib/filter-graph.d.ts +251 -292
  72. package/dist/lib/filter-graph.js +253 -294
  73. package/dist/lib/filter-graph.js.map +1 -1
  74. package/dist/lib/filter-inout.d.ts +87 -95
  75. package/dist/lib/filter-inout.js +87 -95
  76. package/dist/lib/filter-inout.js.map +1 -1
  77. package/dist/lib/filter.d.ts +93 -111
  78. package/dist/lib/filter.js +93 -111
  79. package/dist/lib/filter.js.map +1 -1
  80. package/dist/lib/format-context.d.ts +320 -428
  81. package/dist/lib/format-context.js +313 -385
  82. package/dist/lib/format-context.js.map +1 -1
  83. package/dist/lib/frame.d.ts +262 -405
  84. package/dist/lib/frame.js +263 -408
  85. package/dist/lib/frame.js.map +1 -1
  86. package/dist/lib/hardware-device-context.d.ts +149 -203
  87. package/dist/lib/hardware-device-context.js +149 -203
  88. package/dist/lib/hardware-device-context.js.map +1 -1
  89. package/dist/lib/hardware-frames-context.d.ts +170 -180
  90. package/dist/lib/hardware-frames-context.js +171 -181
  91. package/dist/lib/hardware-frames-context.js.map +1 -1
  92. package/dist/lib/index.d.ts +2 -1
  93. package/dist/lib/index.js +2 -2
  94. package/dist/lib/index.js.map +1 -1
  95. package/dist/lib/input-format.d.ts +89 -117
  96. package/dist/lib/input-format.js +89 -117
  97. package/dist/lib/input-format.js.map +1 -1
  98. package/dist/lib/io-context.d.ts +209 -241
  99. package/dist/lib/io-context.js +220 -252
  100. package/dist/lib/io-context.js.map +1 -1
  101. package/dist/lib/log.d.ts +85 -119
  102. package/dist/lib/log.js +85 -122
  103. package/dist/lib/log.js.map +1 -1
  104. package/dist/lib/native-types.d.ts +117 -106
  105. package/dist/lib/native-types.js +0 -7
  106. package/dist/lib/native-types.js.map +1 -1
  107. package/dist/lib/option.d.ts +284 -241
  108. package/dist/lib/option.js +309 -249
  109. package/dist/lib/option.js.map +1 -1
  110. package/dist/lib/output-format.d.ts +77 -101
  111. package/dist/lib/output-format.js +77 -101
  112. package/dist/lib/output-format.js.map +1 -1
  113. package/dist/lib/packet.d.ts +172 -240
  114. package/dist/lib/packet.js +172 -241
  115. package/dist/lib/packet.js.map +1 -1
  116. package/dist/lib/rational.d.ts +0 -2
  117. package/dist/lib/rational.js +0 -2
  118. package/dist/lib/rational.js.map +1 -1
  119. package/dist/lib/software-resample-context.d.ts +241 -325
  120. package/dist/lib/software-resample-context.js +242 -326
  121. package/dist/lib/software-resample-context.js.map +1 -1
  122. package/dist/lib/software-scale-context.d.ts +129 -173
  123. package/dist/lib/software-scale-context.js +131 -175
  124. package/dist/lib/software-scale-context.js.map +1 -1
  125. package/dist/lib/stream.d.ts +87 -197
  126. package/dist/lib/stream.js +87 -197
  127. package/dist/lib/stream.js.map +1 -1
  128. package/dist/lib/utilities.d.ts +372 -181
  129. package/dist/lib/utilities.js +373 -182
  130. package/dist/lib/utilities.js.map +1 -1
  131. package/install/check.js +0 -1
  132. package/package.json +21 -12
  133. package/release_notes.md +43 -59
  134. package/CHANGELOG.md +0 -8
@@ -4,20 +4,21 @@ import type { AVChromaLocation, AVColorPrimaries, AVColorRange, AVColorSpace, AV
4
4
  import type { NativeFrame, NativeWrapper } from './native-types.js';
5
5
  import type { ChannelLayout } from './types.js';
6
6
  /**
7
- * Frame for uncompressed audio/video data.
7
+ * Container for uncompressed audio/video data.
8
8
  *
9
- * Contains raw audio samples or video pixels after decoding or before encoding.
10
- * Provides full control over allocation, configuration and lifecycle.
11
- * Supports both planar and packed data layouts for audio and video.
9
+ * Stores decoded audio samples or video pixels. Each frame contains raw data
10
+ * for a single video frame or a set of audio samples. Includes format information,
11
+ * timing data, and metadata. Supports both software and hardware (GPU) frames.
12
+ * Essential for decoding, encoding, and filter operations.
12
13
  *
13
14
  * Direct mapping to FFmpeg's AVFrame.
14
15
  *
15
16
  * @example
16
17
  * ```typescript
17
18
  * import { Frame, FFmpegError } from 'node-av';
18
- * import { AV_PIX_FMT_YUV420P, AV_SAMPLE_FMT_FLTP } from 'node-av/constants';
19
+ * import { AV_PIX_FMT_YUV420P } from 'node-av/constants';
19
20
  *
20
- * // Create and allocate frame - full control
21
+ * // Create and allocate frame
21
22
  * const frame = new Frame();
22
23
  * frame.alloc();
23
24
  *
@@ -25,775 +26,635 @@ import type { ChannelLayout } from './types.js';
25
26
  * frame.format = AV_PIX_FMT_YUV420P;
26
27
  * frame.width = 1920;
27
28
  * frame.height = 1080;
28
- * const videoRet = frame.getBuffer(); // Allocate buffers
29
- * FFmpegError.throwIfError(videoRet, 'getBuffer');
29
+ * const ret = frame.allocBuffer();
30
+ * FFmpegError.throwIfError(ret, 'allocBuffer');
30
31
  *
31
- * // Configure audio frame
32
- * const audioFrame = new Frame();
33
- * audioFrame.alloc();
34
- * audioFrame.format = AV_SAMPLE_FMT_FLTP;
35
- * audioFrame.sampleRate = 48000;
36
- * audioFrame.nbSamples = 1024;
37
- * audioFrame.channelLayout = { nbChannels: 2, order: 0, mask: 3n };
38
- * const audioRet = audioFrame.getBuffer(); // Allocate buffers
39
- * FFmpegError.throwIfError(audioRet, 'getBuffer');
40
- *
41
- * // Receive decoded data
42
- * const ret = await codecContext.receiveFrame(frame);
43
- * FFmpegError.throwIfError(ret, 'receiveFrame');
44
- * console.log(`Frame PTS: ${frame.pts}`);
32
+ * // Receive decoded frame
33
+ * const ret2 = await codecContext.receiveFrame(frame);
34
+ * if (ret2 >= 0) {
35
+ * console.log(`Frame PTS: ${frame.pts}`);
36
+ * console.log(`Frame type: ${frame.pictType}`);
37
+ * console.log(`Keyframe: ${frame.keyFrame}`);
38
+ * }
45
39
  *
46
40
  * // Cleanup
47
- * frame.unref(); // Clear data but keep frame allocated
48
- * frame.free(); // Free frame completely
41
+ * frame.unref();
49
42
  * ```
50
43
  *
44
+ * @see [AVFrame](https://ffmpeg.org/doxygen/trunk/structAVFrame.html) - FFmpeg Doxygen
51
45
  * @see {@link CodecContext} For encoding/decoding frames
52
46
  * @see {@link FilterContext} For filtering frames
53
47
  */
54
48
  export declare class Frame implements Disposable, NativeWrapper<NativeFrame> {
55
49
  private native;
56
50
  private _hwFramesCtx?;
57
- /**
58
- * Create a new frame.
59
- *
60
- * The frame is uninitialized - you must call alloc() before use.
61
- * No FFmpeg resources are allocated until alloc() is called.
62
- *
63
- * Direct wrapper around AVFrame.
64
- *
65
- * @example
66
- * ```typescript
67
- * import { Frame } from 'node-av';
68
- *
69
- * const frame = new Frame();
70
- * frame.alloc();
71
- * // Frame is now ready for use
72
- * ```
73
- */
74
51
  constructor();
75
52
  /**
76
- * Format of the frame.
77
- *
78
- * For video: AVPixelFormat (-1 if unknown or unset).
79
- * For audio: AVSampleFormat (-1 if unknown or unset).
80
- *
81
- * Direct mapping to AVFrame->format
53
+ * Pixel format for video frames or sample format for audio.
82
54
  *
83
- * Must be set before calling getBuffer() or allocBuffer().
55
+ * Direct mapping to AVFrame->format.
84
56
  */
85
57
  get format(): AVPixelFormat | AVSampleFormat;
86
58
  set format(value: AVPixelFormat | AVSampleFormat);
87
59
  /**
88
- * Width of the video frame in pixels.
60
+ * Width of video frame in pixels.
89
61
  *
90
- * Direct mapping to AVFrame->width
91
- *
92
- * For video: MUST be set before calling getBuffer() or allocBuffer().
93
- * For audio: unused (0).
62
+ * Direct mapping to AVFrame->width.
94
63
  */
95
64
  get width(): number;
96
65
  set width(value: number);
97
66
  /**
98
- * Height of the video frame in pixels.
99
- *
100
- * Direct mapping to AVFrame->height
67
+ * Height of video frame in pixels.
101
68
  *
102
- * For video: MUST be set before calling getBuffer() or allocBuffer().
103
- * For audio: unused (0).
69
+ * Direct mapping to AVFrame->height.
104
70
  */
105
71
  get height(): number;
106
72
  set height(value: number);
107
73
  /**
108
- * Number of audio samples (per channel) described by this frame.
74
+ * Number of audio samples per channel.
109
75
  *
110
- * Direct mapping to AVFrame->nb_samples
111
- *
112
- * For audio: MUST be set before calling getBuffer() or allocBuffer().
113
- * For video: unused (0).
76
+ * Direct mapping to AVFrame->nb_samples.
114
77
  */
115
78
  get nbSamples(): number;
116
79
  set nbSamples(value: number);
117
80
  /**
118
- * Presentation timestamp in time_base units.
119
- *
120
- * Time when frame should be shown to user.
81
+ * Presentation timestamp.
121
82
  *
122
- * Direct mapping to AVFrame->pts
83
+ * Time when the frame should be presented.
84
+ * In time base units. AV_NOPTS_VALUE if unknown.
123
85
  *
124
- * Can be AV_NOPTS_VALUE if unknown.
86
+ * Direct mapping to AVFrame->pts.
125
87
  */
126
88
  get pts(): bigint;
127
89
  set pts(value: bigint);
128
90
  /**
129
- * DTS copied from the AVPacket that triggered returning this frame.
91
+ * DTS from the packet that produced this frame.
130
92
  *
131
- * If frame threading isn't used, this is also the presentation time
132
- * calculated from only AVPacket.dts values without pts values.
93
+ * Copy of packet DTS for reference.
94
+ * In time base units. AV_NOPTS_VALUE if unknown.
133
95
  *
134
- * Direct mapping to AVFrame->pkt_dts
96
+ * Direct mapping to AVFrame->pkt_dts.
135
97
  */
136
98
  get pktDts(): bigint;
137
99
  set pktDts(value: bigint);
138
100
  /**
139
101
  * Best effort timestamp.
140
102
  *
141
- * Direct mapping to AVFrame->best_effort_timestamp (computed value)
103
+ * Frame timestamp estimated using various heuristics.
104
+ * In time base units.
142
105
  *
143
- * Attempts to provide the most accurate timestamp for the frame.
144
- * Uses pts if available, otherwise falls back to pkt_dts.
106
+ * Direct mapping to AVFrame->best_effort_timestamp.
145
107
  */
146
108
  get bestEffortTimestamp(): bigint;
147
109
  set bestEffortTimestamp(value: bigint);
148
110
  /**
149
- * Time base for pts/dts timestamps.
111
+ * Time base for timestamps.
150
112
  *
151
- * Direct mapping to AVFrame->time_base
113
+ * Defines the unit of the timestamps (seconds per tick).
152
114
  *
153
- * This is the fundamental unit of time (in seconds) in terms
154
- * of which frame timestamps are represented.
115
+ * Direct mapping to AVFrame->time_base.
155
116
  */
156
117
  get timeBase(): Rational;
157
118
  set timeBase(value: Rational);
158
119
  /**
159
120
  * Whether this frame is a keyframe.
160
121
  *
161
- * Direct mapping to AVFrame->key_frame
122
+ * 1 if keyframe, 0 otherwise.
162
123
  *
163
- * 1 -> keyframe, 0 -> not a keyframe.
164
- * It is set to 1 for all frames in intra-only codecs.
165
- * - encoding: Set by libavcodec.
166
- * - decoding: Set by libavcodec.
124
+ * Direct mapping to AVFrame->key_frame.
167
125
  */
168
126
  get keyFrame(): number;
169
127
  set keyFrame(value: number);
170
128
  /**
171
129
  * Picture type of the frame.
172
130
  *
173
- * Direct mapping to AVFrame->pict_type
131
+ * Type of frame (I, P, B, etc.).
174
132
  *
175
- * AV_PICTURE_TYPE_I for intra frames, AV_PICTURE_TYPE_P for predicted frames,
176
- * AV_PICTURE_TYPE_B for bi-directionally predicted frames, etc.
177
- * - encoding: Set by libavcodec. for coded_picture (and set by user for input).
178
- * - decoding: Set by libavcodec.
133
+ * Direct mapping to AVFrame->pict_type.
179
134
  */
180
135
  get pictType(): AVPictureType;
181
136
  set pictType(value: AVPictureType);
182
137
  /**
183
- * Sample aspect ratio for the video frame.
138
+ * Sample aspect ratio.
184
139
  *
185
- * Direct mapping to AVFrame->sample_aspect_ratio
140
+ * Pixel width/height ratio. 0/1 if unknown.
186
141
  *
187
- * 0/1 if unknown/unspecified.
188
- * This is the aspect ratio of a single pixel (width/height).
189
- * For anamorphic video, this differs from the display aspect ratio.
142
+ * Direct mapping to AVFrame->sample_aspect_ratio.
190
143
  */
191
144
  get sampleAspectRatio(): Rational;
192
145
  set sampleAspectRatio(value: Rational);
193
146
  /**
194
- * Sample rate of the audio data.
147
+ * Audio sample rate.
195
148
  *
196
- * Direct mapping to AVFrame->sample_rate
149
+ * Number of samples per second.
197
150
  *
198
- * In samples per second.
199
- * - encoding: MUST be set by user.
200
- * - decoding: MAY be set by libavcodec.
151
+ * Direct mapping to AVFrame->sample_rate.
201
152
  */
202
153
  get sampleRate(): number;
203
154
  set sampleRate(value: number);
204
155
  /**
205
- * Channel layout of the audio data.
156
+ * Audio channel layout.
206
157
  *
207
- * Direct mapping to AVFrame->ch_layout
158
+ * Describes the channel configuration.
208
159
  *
209
- * Describes the number and order of audio channels.
210
- * Must be set before calling getBuffer() for audio frames.
160
+ * Direct mapping to AVFrame->ch_layout.
211
161
  */
212
162
  get channelLayout(): ChannelLayout;
213
163
  set channelLayout(value: ChannelLayout);
214
164
  /**
215
165
  * Number of audio channels.
216
166
  *
217
- * Direct mapping to AVFrame->channels
218
- *
219
167
  * Derived from channel layout.
220
- * @readonly
221
168
  */
222
169
  get channels(): number;
223
170
  /**
224
- * Line size (stride) for each plane.
225
- *
226
- * Direct mapping to AVFrame->linesize
227
- *
228
- * For video, the size in bytes of each picture line.
229
- * For audio, the size in bytes of each plane.
171
+ * Line sizes for each plane.
230
172
  *
231
- * For audio, only linesize[0] may be set. For planar audio, each channel
232
- * plane must be the same size.
173
+ * Number of bytes per line for each data plane.
233
174
  *
234
- * For video the linesizes should be multiples of the CPUs alignment preference,
235
- * this is 16 or 32 for modern desktop CPUs.
236
- * @readonly
175
+ * Direct mapping to AVFrame->linesize.
237
176
  */
238
177
  get linesize(): number[];
239
178
  /**
240
- * MPEG vs JPEG YUV color range.
179
+ * Color range.
241
180
  *
242
- * Direct mapping to AVFrame->color_range
181
+ * MPEG (limited) or JPEG (full) range.
243
182
  *
244
- * AVCOL_RANGE_MPEG (limited/tv/16-235), AVCOL_RANGE_JPEG (full/pc/0-255)
245
- * - encoding: Set by user
246
- * - decoding: Set by libavcodec
183
+ * Direct mapping to AVFrame->color_range.
247
184
  */
248
185
  get colorRange(): AVColorRange;
249
186
  set colorRange(value: AVColorRange);
250
187
  /**
251
- * Chromaticity coordinates of the source primaries.
188
+ * Color primaries.
252
189
  *
253
- * Direct mapping to AVFrame->color_primaries
190
+ * Chromaticity coordinates of the source primaries.
254
191
  *
255
- * AVCOL_PRI_BT709, AVCOL_PRI_BT2020, etc.
256
- * - encoding: Set by user
257
- * - decoding: Set by libavcodec
192
+ * Direct mapping to AVFrame->color_primaries.
258
193
  */
259
194
  get colorPrimaries(): AVColorPrimaries;
260
195
  set colorPrimaries(value: AVColorPrimaries);
261
196
  /**
262
- * Color Transfer Characteristic.
197
+ * Color transfer characteristic.
263
198
  *
264
- * Direct mapping to AVFrame->color_trc
199
+ * Transfer function (gamma).
265
200
  *
266
- * AVCOL_TRC_BT709, AVCOL_TRC_SMPTE2084 (PQ), AVCOL_TRC_ARIB_STD_B67 (HLG), etc.
267
- * - encoding: Set by user
268
- * - decoding: Set by libavcodec
201
+ * Direct mapping to AVFrame->color_trc.
269
202
  */
270
203
  get colorTrc(): AVColorTransferCharacteristic;
271
204
  set colorTrc(value: AVColorTransferCharacteristic);
272
205
  /**
273
- * YUV colorspace type.
206
+ * YUV color space.
274
207
  *
275
- * Direct mapping to AVFrame->colorspace
208
+ * Color space type for YUV content.
276
209
  *
277
- * AVCOL_SPC_BT709, AVCOL_SPC_BT2020_NCL, etc.
278
- * - encoding: Set by user
279
- * - decoding: Set by libavcodec
210
+ * Direct mapping to AVFrame->colorspace.
280
211
  */
281
212
  get colorSpace(): AVColorSpace;
282
213
  set colorSpace(value: AVColorSpace);
283
214
  /**
284
- * Location of chroma samples.
215
+ * Chroma sample location.
285
216
  *
286
- * Direct mapping to AVFrame->chroma_location
217
+ * Position of chroma samples.
287
218
  *
288
- * AVCHROMA_LOC_LEFT (MPEG-1/2/4, H.264 default), AVCHROMA_LOC_CENTER (MPEG-2), etc.
289
- * - encoding: Set by user
290
- * - decoding: Set by libavcodec
219
+ * Direct mapping to AVFrame->chroma_location.
291
220
  */
292
221
  get chromaLocation(): AVChromaLocation;
293
222
  set chromaLocation(value: AVChromaLocation);
294
223
  /**
295
- * Pointers to the data planes/channels.
224
+ * Raw frame data planes.
296
225
  *
297
- * Direct mapping to AVFrame->data
226
+ * Array of buffers containing the frame data.
227
+ * One buffer per plane (e.g., Y, U, V for YUV420P).
298
228
  *
299
- * For video, this is an array of pointers to picture planes.
300
- * For packed audio, this is a single pointer to all audio data.
301
- * For planar audio, each channel has a separate data pointer.
302
- *
303
- * AVFrame.data pointers must point to the first element of an AVFrame.buf array.
304
- * @readonly
229
+ * Direct mapping to AVFrame->data.
305
230
  */
306
231
  get data(): Buffer[] | null;
307
232
  /**
308
- * Pointers to the data planes/channels for frames with more than 8 channels.
233
+ * Extended data planes.
309
234
  *
310
- * Direct mapping to AVFrame->extended_data
235
+ * For audio with >8 channels or planar audio.
236
+ * Points to data planes beyond the first 8.
311
237
  *
312
- * For audio, if the number of channels is greater than 8, this must be used
313
- * to access channels beyond the first 8. Otherwise, data[] should be used.
314
- * @readonly
238
+ * Direct mapping to AVFrame->extended_data.
315
239
  */
316
240
  get extendedData(): Buffer[] | null;
317
241
  /**
318
- * Check if the frame data is writable.
319
- *
320
- * Direct mapping to av_frame_is_writable()
242
+ * Check if frame data is writable.
321
243
  *
322
- * A frame is writable if all its underlying buffers are writable and there's
323
- * only one reference to each buffer. Use makeWritable() to ensure writability.
324
- * @readonly
244
+ * True if the frame data can be modified.
325
245
  */
326
246
  get isWritable(): boolean;
327
247
  /**
328
248
  * Hardware frames context.
329
249
  *
330
- * Direct mapping to AVFrame->hw_frames_ctx
250
+ * Reference to hardware frames context for GPU frames.
251
+ * Null for software frames.
331
252
  *
332
- * For hwaccel-format frames, this should be a reference to the
333
- * AVHWFramesContext describing the frame.
253
+ * Direct mapping to AVFrame->hw_frames_ctx.
334
254
  */
335
255
  get hwFramesCtx(): HardwareFramesContext | null;
336
256
  set hwFramesCtx(value: HardwareFramesContext | null);
337
257
  /**
338
- * Allocate an AVFrame and set its fields to default values.
258
+ * Allocate a new frame.
339
259
  *
340
- * Allocates the AVFrame structure and initializes all fields to default values.
341
- * This only allocates the frame structure itself, not the data buffers.
260
+ * Allocates the frame structure. Must be called before using the frame
261
+ * unless it was created by another function (e.g., clone()).
342
262
  *
343
- * Direct mapping to av_frame_alloc()
263
+ * Direct mapping to av_frame_alloc().
344
264
  *
345
- * @throws {Error} Memory allocation failure (ENOMEM)
265
+ * @throws {Error} If allocation fails (ENOMEM)
346
266
  *
347
267
  * @example
348
268
  * ```typescript
349
- * import { Frame } from 'node-av';
350
- *
351
269
  * const frame = new Frame();
352
270
  * frame.alloc();
353
- * // Frame structure is now allocated
354
- * // Still need to allocate data buffers with getBuffer()
271
+ * // Frame structure is now ready
355
272
  * ```
356
273
  *
357
- * @see {@link getBuffer} To allocate data buffers
358
- * @see {@link free} To free the frame
274
+ * @see {@link allocBuffer} To allocate data buffers
275
+ * @see {@link free} To deallocate the frame
359
276
  */
360
277
  alloc(): void;
361
278
  /**
362
- * Free the frame and any dynamically allocated objects in it.
363
- *
364
- * Frees the frame structure and all associated data buffers.
365
- * If the frame is reference counted, it will be unreferenced first.
279
+ * Free the frame.
366
280
  *
367
- * Direct mapping to av_frame_free()
281
+ * Deallocates the frame and its data. The frame becomes invalid after this.
368
282
  *
369
- * @note
370
- * Calling this multiple times is safe, because we check the freed state
283
+ * Direct mapping to av_frame_free().
371
284
  *
372
285
  * @example
373
286
  * ```typescript
374
- * import { Frame } from 'node-av';
375
- *
376
287
  * frame.free();
377
- * // frame is now invalid and should not be used
288
+ * // Frame is now invalid
378
289
  * ```
379
290
  *
380
- * @see {@link unref} To clear data but keep frame allocated
291
+ * @see {@link unref} To only free data, keeping structure
381
292
  */
382
293
  free(): void;
383
294
  /**
384
- * Set up a new reference to the data described by the source frame.
295
+ * Create a reference to another frame.
385
296
  *
386
- * Creates a reference to the source frame's data buffers.
387
- * Both frames will share the same data through reference counting.
388
- * This function does not copy side data.
297
+ * Sets up this frame as a reference to the source frame's data.
298
+ * Both frames will share the same data buffers.
389
299
  *
390
- * Direct mapping to av_frame_ref()
300
+ * Direct mapping to av_frame_ref().
391
301
  *
392
302
  * @param src - Source frame to reference
393
- *
394
303
  * @returns 0 on success, negative AVERROR on error:
395
- * - 0: Success (frame now references src data)
396
- * - AVERROR(ENOMEM): Memory allocation failure
397
- * - AVERROR(EINVAL): Invalid parameters (null frame)
398
- * - <0: Other errors
304
+ * - AVERROR_ENOMEM: Memory allocation failure
305
+ * - AVERROR_EINVAL: Invalid parameters
399
306
  *
400
307
  * @example
401
308
  * ```typescript
402
- * import { Frame, FFmpegError } from 'node-av';
309
+ * import { FFmpegError } from 'node-av';
403
310
  *
404
- * const ret = frame.ref(sourceFrame);
405
- * FFmpegError.throwIfError(ret, 'frame.ref');
406
- * // frame now references the same data as sourceFrame
311
+ * const frame2 = new Frame();
312
+ * frame2.alloc();
313
+ * const ret = frame2.ref(frame1);
314
+ * FFmpegError.throwIfError(ret, 'ref');
315
+ * // frame2 now references frame1's data
407
316
  * ```
408
317
  *
409
- * @see {@link unref} To remove references
410
- * @see {@link clone} To create a new frame with same data
318
+ * @see {@link unref} To remove reference
319
+ * @see {@link clone} To create independent copy
411
320
  */
412
321
  ref(src: Frame): number;
413
322
  /**
414
- * Unreference all the buffers referenced by frame and reset the frame fields.
323
+ * Unreference the frame.
415
324
  *
416
- * Clears all data from the frame but keeps the frame structure allocated.
417
- * The frame can be reused for the next decode/encode operation.
325
+ * Frees the frame data if this was the last reference.
326
+ * The frame structure remains allocated and can be reused.
418
327
  *
419
- * Direct mapping to av_frame_unref()
328
+ * Direct mapping to av_frame_unref().
420
329
  *
421
330
  * @example
422
331
  * ```typescript
423
- * import { Frame } from 'node-av';
424
- *
425
332
  * frame.unref();
426
- * // Frame is now empty but still allocated
427
- * // Can be reused for next decode/encode
333
+ * // Frame data is freed, structure can be reused
428
334
  * ```
429
335
  *
430
- * @see {@link free} To completely free the frame
336
+ * @see {@link ref} To create reference
337
+ * @see {@link free} To free everything
431
338
  */
432
339
  unref(): void;
433
340
  /**
434
- * Create a new frame that references the same data as this frame.
341
+ * Clone the frame.
435
342
  *
436
- * Creates a new frame and sets it up as a reference to this frame's data.
437
- * This is a shortcut for av_frame_alloc() + av_frame_ref().
343
+ * Creates an independent copy of the frame with its own data buffers.
344
+ * The new frame has the same content but can be modified independently.
438
345
  *
439
- * Direct mapping to av_frame_clone()
346
+ * Direct mapping to av_frame_clone().
440
347
  *
441
- * @returns New frame referencing the same data, or null on error:
442
- * - Frame object: Success (new frame references this frame's data)
443
- * - null: Memory allocation failure (ENOMEM)
348
+ * @returns New frame instance, or null on allocation failure
444
349
  *
445
350
  * @example
446
351
  * ```typescript
447
- * import { Frame } from 'node-av';
448
- *
449
- * const clonedFrame = frame.clone();
450
- * if (!clonedFrame) {
451
- * throw new Error('Failed to clone frame: Out of memory');
352
+ * const copy = frame.clone();
353
+ * if (copy) {
354
+ * // Modify copy without affecting original
355
+ * copy.pts = frame.pts + 1000n;
452
356
  * }
453
- * // clonedFrame references the same data as frame
454
- * // Both frames must be freed independently
455
357
  * ```
456
358
  *
457
- * @see {@link ref} To reference into existing frame
359
+ * @see {@link ref} To create reference instead of copy
360
+ * @see {@link copy} To copy into existing frame
458
361
  */
459
362
  clone(): Frame | null;
460
363
  /**
461
- * Allocate new buffer(s) for audio or video data.
364
+ * Get required buffer size for the frame.
462
365
  *
463
- * Allocates data buffers for the frame based on its parameters.
464
- * Frame parameters must be set before calling this function.
366
+ * Calculates the required buffer size based on frame parameters.
367
+ * Must set format, width/height (video) or format, nb_samples, channel_layout (audio) first.
465
368
  *
466
- * Direct mapping to av_frame_get_buffer()
369
+ * Direct mapping to av_frame_get_buffer().
467
370
  *
468
- * @param align - Required buffer size alignment. 0 for automatic.
469
- *
470
- * @returns 0 on success, negative AVERROR on error:
471
- * - 0: Success (buffers allocated)
472
- * - AVERROR(EINVAL): Invalid frame parameters (format/size not set)
473
- * - AVERROR(ENOMEM): Memory allocation failure
474
- * - <0: Other errors
371
+ * @param align - Buffer size alignment (0 for default)
372
+ * @returns Required buffer size in bytes, or negative AVERROR:
373
+ * - AVERROR_EINVAL: Invalid frame parameters
475
374
  *
476
375
  * @example
477
376
  * ```typescript
478
- * import { Frame, FFmpegError, AV_PIX_FMT_YUV420P } from 'node-av';
377
+ * import { FFmpegError } from 'node-av';
479
378
  *
480
- * // Video frame
481
- * frame.format = AV_PIX_FMT_YUV420P;
482
- * frame.width = 1920;
483
- * frame.height = 1080;
484
- * const ret = frame.getBuffer(0);
485
- * FFmpegError.throwIfError(ret, 'getBuffer');
486
- * // Frame data buffers are now allocated
379
+ * const size = frame.getBuffer();
380
+ * FFmpegError.throwIfError(size, 'getBuffer');
381
+ * console.log(`Buffer size: ${size} bytes`);
487
382
  * ```
488
383
  *
489
- * @see {@link allocBuffer} Convenience wrapper with default alignment
490
- * @see {@link makeWritable} Ensure buffer is writable
491
- *
492
- * Required fields before calling:
493
- * - format (pixel format for video, sample format for audio)
494
- * - width and height for video
495
- * - nb_samples and channel_layout for audio
384
+ * @see {@link allocBuffer} To allocate the buffer
496
385
  */
497
386
  getBuffer(align?: number): number;
498
387
  /**
499
- * Allocate buffer(s) for frame according to its parameters.
388
+ * Allocate data buffers for the frame.
500
389
  *
501
- * Convenience wrapper for getBuffer() with default alignment.
390
+ * Allocates buffers based on frame format and dimensions.
502
391
  * Frame parameters must be set before calling.
503
392
  *
504
- * Direct mapping to av_frame_get_buffer() with align=0
393
+ * Direct mapping to av_frame_get_buffer().
505
394
  *
506
395
  * @returns 0 on success, negative AVERROR on error:
507
- * - 0: Success (buffers allocated)
508
- * - AVERROR(EINVAL): Invalid frame parameters
509
- * - AVERROR(ENOMEM): Memory allocation failure
510
- * - <0: Other errors
396
+ * - AVERROR_EINVAL: Invalid frame parameters
397
+ * - AVERROR_ENOMEM: Memory allocation failure
511
398
  *
512
399
  * @example
513
400
  * ```typescript
514
- * import { Frame, FFmpegError } from 'node-av';
401
+ * import { FFmpegError } from 'node-av';
402
+ * import { AV_PIX_FMT_YUV420P } from 'node-av/constants';
515
403
  *
404
+ * frame.format = AV_PIX_FMT_YUV420P;
405
+ * frame.width = 1920;
406
+ * frame.height = 1080;
516
407
  * const ret = frame.allocBuffer();
517
408
  * FFmpegError.throwIfError(ret, 'allocBuffer');
518
- * // Frame data buffers are now allocated
519
409
  * ```
520
410
  *
521
- * @see {@link getBuffer} With custom alignment
411
+ * @see {@link getBuffer} To get required size
522
412
  */
523
413
  allocBuffer(): number;
524
414
  /**
525
- * Ensure that the frame data is writable.
415
+ * Ensure frame data is writable.
526
416
  *
527
- * Makes a private copy of the frame data if it's currently shared.
528
- * Does nothing if frame is already writable.
417
+ * Creates a private copy of the data if it's shared with other frames.
418
+ * Call before modifying frame data to avoid affecting other references.
529
419
  *
530
- * Direct mapping to av_frame_make_writable()
420
+ * Direct mapping to av_frame_make_writable().
531
421
  *
532
422
  * @returns 0 on success, negative AVERROR on error:
533
- * - 0: Success (frame is now writable)
534
- * - AVERROR(ENOMEM): Memory allocation failure
535
- * - AVERROR(EINVAL): Invalid parameters
536
- * - <0: Other errors
423
+ * - AVERROR_ENOMEM: Memory allocation failure
424
+ * - AVERROR_EINVAL: Invalid frame
537
425
  *
538
426
  * @example
539
427
  * ```typescript
540
- * import { Frame, FFmpegError } from 'node-av';
428
+ * import { FFmpegError } from 'node-av';
541
429
  *
542
- * if (!frame.isWritable) {
543
- * const ret = frame.makeWritable();
544
- * FFmpegError.throwIfError(ret, 'makeWritable');
545
- * }
546
- * // Frame data can now be modified safely
430
+ * // Ensure we can safely modify data
431
+ * const ret = frame.makeWritable();
432
+ * FFmpegError.throwIfError(ret, 'makeWritable');
433
+ * // Now safe to modify frame.data
547
434
  * ```
548
- *
549
- * @see {@link isWritable} Check if writable
550
435
  */
551
436
  makeWritable(): number;
552
437
  /**
553
- * Copy only "metadata" fields from src to this frame.
438
+ * Copy frame properties without copying data.
554
439
  *
555
- * Copies all frame properties except the actual data buffers.
556
- * This includes timestamps, format, dimensions, side data, etc.
440
+ * Copies metadata, timestamps, format info, etc. but not the actual data.
441
+ * Useful for preparing output frames with same properties.
557
442
  *
558
- * Direct mapping to av_frame_copy_props()
443
+ * Direct mapping to av_frame_copy_props().
559
444
  *
560
445
  * @param src - Source frame to copy properties from
561
- *
562
- * @returns >=0 on success, negative AVERROR on error:
563
- * - >=0: Success (properties copied)
564
- * - AVERROR(ENOMEM): Memory allocation failure
565
- * - <0: Other errors
446
+ * @returns 0 on success, negative AVERROR on error:
447
+ * - AVERROR_ENOMEM: Memory allocation failure
566
448
  *
567
449
  * @example
568
450
  * ```typescript
569
- * import { Frame, FFmpegError } from 'node-av';
451
+ * import { FFmpegError } from 'node-av';
570
452
  *
571
453
  * const ret = dstFrame.copyProps(srcFrame);
572
454
  * FFmpegError.throwIfError(ret, 'copyProps');
573
- * // dstFrame now has same properties as srcFrame (but not data)
455
+ * // dstFrame now has same properties as srcFrame
574
456
  * ```
575
457
  *
576
- * @see {@link copy} To copy data as well
458
+ * @see {@link copy} To copy both properties and data
577
459
  */
578
460
  copyProps(src: Frame): number;
579
461
  /**
580
- * Copy the frame data from src to this frame.
581
- *
582
- * Copies the actual data buffers from source to destination.
583
- * Destination must be pre-allocated with same parameters.
462
+ * Copy frame data and properties.
584
463
  *
585
- * Direct mapping to av_frame_copy()
464
+ * Copies both data and metadata from source frame.
465
+ * Destination must have allocated buffers of correct size.
586
466
  *
587
- * @param src - Source frame to copy data from
467
+ * Direct mapping to av_frame_copy().
588
468
  *
589
- * @returns >=0 on success, negative AVERROR on error:
590
- * - >=0: Success (data copied)
591
- * - AVERROR(EINVAL): Frames have different parameters (format, size, etc.)
592
- * - <0: Other errors
469
+ * @param src - Source frame to copy from
470
+ * @returns 0 on success, negative AVERROR on error:
471
+ * - AVERROR_EINVAL: Incompatible frames
593
472
  *
594
473
  * @example
595
474
  * ```typescript
596
- * import { Frame, FFmpegError } from 'node-av';
475
+ * import { FFmpegError } from 'node-av';
597
476
  *
598
- * // Destination must be allocated with same parameters
477
+ * // Allocate destination with same format
599
478
  * dstFrame.format = srcFrame.format;
600
479
  * dstFrame.width = srcFrame.width;
601
480
  * dstFrame.height = srcFrame.height;
602
- * const allocRet = dstFrame.allocBuffer();
603
- * FFmpegError.throwIfError(allocRet, 'allocBuffer');
481
+ * dstFrame.allocBuffer();
604
482
  *
605
483
  * const ret = dstFrame.copy(srcFrame);
606
484
  * FFmpegError.throwIfError(ret, 'copy');
607
- * // Data has been copied to dstFrame
608
485
  * ```
609
486
  *
610
- * @see {@link copyProps} To copy metadata only
487
+ * @see {@link copyProps} To copy only properties
488
+ * @see {@link clone} To create new frame with copy
611
489
  */
612
490
  copy(src: Frame): number;
613
491
  /**
614
- * Fill frame data from a buffer.
615
- *
616
- * Copies raw frame data from a Buffer into this frame's data planes.
617
- * The frame must be allocated with the correct format, width/height (for video),
618
- * or nb_samples (for audio) before calling this method.
492
+ * Fill frame data from buffer.
619
493
  *
620
- * For video frames, the buffer should contain raw pixel data in the frame's pixel format.
621
- * For audio frames, the buffer should contain raw audio samples in the frame's sample format.
494
+ * Copies data from buffer into frame data planes.
495
+ * Frame must have allocated buffers.
622
496
  *
623
- * @param buffer - Buffer containing raw frame data
624
- * @returns 0 on success, negative AVERROR on failure
497
+ * @param buffer - Source buffer with frame data
498
+ * @returns 0 on success, negative AVERROR on error:
499
+ * - AVERROR_EINVAL: Invalid parameters
625
500
  *
626
501
  * @example
627
502
  * ```typescript
628
- * // Video frame from raw YUV420p data
629
- * const frame = new Frame();
630
- * frame.alloc();
631
- * frame.format = AV_PIX_FMT_YUV420P;
632
- * frame.width = 1920;
633
- * frame.height = 1080;
634
- * frame.allocBuffer();
635
- * frame.fromBuffer(rawYuvBuffer);
636
- *
637
- * // Audio frame from raw PCM data
638
- * const audioFrame = new Frame();
639
- * audioFrame.alloc();
640
- * audioFrame.format = AV_SAMPLE_FMT_FLTP;
641
- * audioFrame.nbSamples = 1024;
642
- * audioFrame.channelLayout = { order: 0, nb_channels: 2, u: { mask: 3n } };
643
- * audioFrame.allocBuffer();
644
- * audioFrame.fromBuffer(rawPcmBuffer);
503
+ * import { FFmpegError } from 'node-av';
504
+ *
505
+ * const buffer = Buffer.from(rawVideoData);
506
+ * const ret = frame.fromBuffer(buffer);
507
+ * FFmpegError.throwIfError(ret, 'fromBuffer');
645
508
  * ```
646
509
  */
647
510
  fromBuffer(buffer: Buffer): number;
648
511
  /**
649
- * Transfer data to or from hardware surfaces.
512
+ * Transfer data between hardware and software frames.
650
513
  *
651
- * Transfers frame data between hardware (GPU) and software (CPU) memory.
652
- * Can be used for both upload and download operations.
514
+ * Copies frame data between GPU and system memory.
515
+ * Direction depends on source and destination frame types.
653
516
  *
654
- * Direct mapping to av_hwframe_transfer_data()
517
+ * Direct mapping to av_hwframe_transfer_data().
655
518
  *
656
- * @param dst - Destination frame
657
- * @param flags - Transfer flags (currently unused, should be set to zero)
658
- *
659
- * @returns Promise resolving to 0 on success, negative AVERROR on error:
660
- * - 0: Success (data transferred)
661
- * - AVERROR(ENOSYS): Operation not supported
662
- * - AVERROR(EINVAL): Invalid parameters
663
- * - AVERROR(ENOMEM): Memory allocation failure
664
- * - <0: Other hardware-specific errors
519
+ * @param dst - Destination frame (software or hardware)
520
+ * @param flags - Transfer flags (0 for default)
521
+ * @returns 0 on success, negative AVERROR on error:
522
+ * - AVERROR_EINVAL: Invalid parameters
523
+ * - AVERROR_ENOMEM: Memory allocation failure
665
524
  *
666
525
  * @example
667
526
  * ```typescript
668
- * import { Frame, FFmpegError } from 'node-av';
527
+ * import { FFmpegError } from 'node-av';
669
528
  *
670
- * // Transfer from hardware to software frame
529
+ * // Download from GPU to CPU
671
530
  * const swFrame = new Frame();
672
531
  * swFrame.alloc();
673
- * const ret = await hwFrame.hwframeTransferData(swFrame, 0);
532
+ * const ret = await hwFrame.hwframeTransferData(swFrame);
674
533
  * FFmpegError.throwIfError(ret, 'hwframeTransferData');
675
- * // Data is now in CPU memory
676
534
  * ```
677
535
  *
678
- * @see {@link isHwFrame} Check if frame is hardware frame
536
+ * @see {@link isHwFrame} To check if frame is hardware
537
+ * @see {@link isSwFrame} To check if frame is software
679
538
  */
680
539
  hwframeTransferData(dst: Frame, flags?: number): Promise<number>;
681
540
  /**
682
541
  * Check if this is a hardware frame.
683
542
  *
684
- * A frame is considered a hardware frame if it has a hw_frames_ctx set.
685
- *
686
- * Direct check of AVFrame->hw_frames_ctx
543
+ * Returns true if frame data is in GPU memory.
687
544
  *
688
- * @returns True if this is a hardware frame, false otherwise
545
+ * @returns True if hardware frame, false otherwise
689
546
  *
690
547
  * @example
691
548
  * ```typescript
692
- * import { Frame } from 'node-av';
693
- *
694
549
  * if (frame.isHwFrame()) {
695
550
  * console.log('Frame is in GPU memory');
696
- * } else {
697
- * console.log('Frame is in CPU memory');
698
551
  * }
699
552
  * ```
700
553
  *
701
- * @see {@link hwframeTransferData} To transfer between CPU and GPU
554
+ * @see {@link isSwFrame} To check for software frame
555
+ * @see {@link hwframeTransferData} To transfer between GPU/CPU
702
556
  */
703
557
  isHwFrame(): boolean;
704
558
  /**
705
559
  * Check if this is a software frame.
706
560
  *
707
- * A frame is considered a software frame if it doesn't have hw_frames_ctx
708
- * but has actual data pointers.
709
- *
710
- * Direct check of AVFrame->data[0] && !AVFrame->hw_frames_ctx
561
+ * Returns true if frame data is in system memory.
711
562
  *
712
- * @returns True if this is a software frame, false otherwise
563
+ * @returns True if software frame, false otherwise
713
564
  *
714
565
  * @example
715
566
  * ```typescript
716
- * import { Frame } from 'node-av';
717
- *
718
567
  * if (frame.isSwFrame()) {
719
- * console.log('Frame is in CPU memory');
720
- * // Safe to access frame.data
568
+ * console.log('Frame is in system memory');
721
569
  * }
722
570
  * ```
723
571
  *
724
- * @see {@link isHwFrame} To check for hardware frames
572
+ * @see {@link isHwFrame} To check for hardware frame
573
+ * @see {@link hwframeTransferData} To transfer between GPU/CPU
725
574
  */
726
575
  isSwFrame(): boolean;
727
576
  /**
728
- * Get side data from the frame.
577
+ * Get frame side data.
578
+ *
579
+ * Retrieves additional data associated with the frame
580
+ * (e.g., motion vectors, film grain, HDR metadata).
729
581
  *
730
- * Direct mapping to av_frame_get_side_data()
582
+ * Direct mapping to av_frame_get_side_data().
731
583
  *
732
- * @param type - The type of side data to retrieve
733
- * @returns Buffer containing the side data, or null if not found
584
+ * @param type - Type of side data to retrieve
585
+ * @returns Side data buffer, or null if not present
734
586
  *
735
587
  * @example
736
588
  * ```typescript
737
- * import { Frame } from 'node-av';
738
- * import { AV_FRAME_DATA_A53_CC } from 'node-av/constants';
589
+ * import { AV_FRAME_DATA_MOTION_VECTORS } from 'node-av/constants';
739
590
  *
740
- * // Check for closed captions
741
- * const ccData = frame.getSideData(AV_FRAME_DATA_A53_CC);
742
- * if (ccData) {
743
- * console.log('Found closed caption data:', ccData.length, 'bytes');
591
+ * const motionVectors = frame.getSideData(AV_FRAME_DATA_MOTION_VECTORS);
592
+ * if (motionVectors) {
593
+ * console.log(`Motion data size: ${motionVectors.length} bytes`);
744
594
  * }
745
595
  * ```
596
+ *
597
+ * @see {@link newSideData} To add side data
598
+ * @see {@link removeSideData} To remove side data
746
599
  */
747
600
  getSideData(type: AVFrameSideDataType): Buffer | null;
748
601
  /**
749
- * Allocate new side data for the frame.
602
+ * Allocate new side data.
750
603
  *
751
- * Allocates a new side data buffer of the specified size.
752
- * Returns a Buffer that references the allocated memory.
753
- * Direct mapping to av_frame_new_side_data()
604
+ * Allocates side data buffer attached to the frame.
605
+ * Returns buffer that can be written to directly.
606
+ *
607
+ * Direct mapping to av_frame_new_side_data().
608
+ *
609
+ * @param type - Type of side data
610
+ * @param size - Size in bytes to allocate
611
+ * @returns Allocated buffer for writing
754
612
  *
755
- * @param type - The type of side data to allocate
756
- * @param size - Size of the side data buffer to allocate
757
- * @returns Buffer referencing the allocated side data
758
613
  * @throws {Error} If allocation fails
759
614
  *
760
615
  * @example
761
616
  * ```typescript
762
- * import { Frame } from 'node-av';
763
617
  * import { AV_FRAME_DATA_MASTERING_DISPLAY_METADATA } from 'node-av/constants';
764
618
  *
765
- * // Allocate HDR metadata
766
- * const hdrBuffer = frame.newSideData(
619
+ * // Allocate and write HDR metadata
620
+ * const hdrData = frame.newSideData(
767
621
  * AV_FRAME_DATA_MASTERING_DISPLAY_METADATA,
768
- * 24 // Size of mastering display metadata structure
622
+ * 40
769
623
  * );
770
- * // Write HDR metadata to the buffer
624
+ * // Write metadata to buffer...
771
625
  * ```
626
+ *
627
+ * @see {@link getSideData} To retrieve side data
628
+ * @see {@link removeSideData} To remove side data
772
629
  */
773
630
  newSideData(type: AVFrameSideDataType, size: number): Buffer;
774
631
  /**
775
- * Remove side data from the frame.
632
+ * Remove side data from frame.
633
+ *
634
+ * Removes specific type of side data.
776
635
  *
777
- * Removes and frees the specified type of side data from the frame.
778
- * Direct mapping to av_frame_remove_side_data()
636
+ * Direct mapping to av_frame_remove_side_data().
779
637
  *
780
- * @param type - The type of side data to remove
638
+ * @param type - Type of side data to remove
781
639
  *
782
640
  * @example
783
641
  * ```typescript
784
- * import { Frame } from 'node-av';
785
642
  * import { AV_FRAME_DATA_MOTION_VECTORS } from 'node-av/constants';
786
643
  *
787
- * // Remove motion vectors data
788
644
  * frame.removeSideData(AV_FRAME_DATA_MOTION_VECTORS);
645
+ * // Motion vectors removed
789
646
  * ```
647
+ *
648
+ * @see {@link getSideData} To retrieve side data
649
+ * @see {@link newSideData} To add side data
790
650
  */
791
651
  removeSideData(type: AVFrameSideDataType): void;
792
652
  /**
793
- * Get the native FFmpeg AVFrame pointer.
653
+ * Get the underlying native Frame object.
654
+ *
655
+ * @returns The native Frame binding object
794
656
  *
795
- * @internal For use by other wrapper classes
796
- * @returns The underlying native frame object
657
+ * @internal
797
658
  */
798
659
  getNative(): NativeFrame;
799
660
  /**
@@ -804,16 +665,12 @@ export declare class Frame implements Disposable, NativeWrapper<NativeFrame> {
804
665
  *
805
666
  * @example
806
667
  * ```typescript
807
- * import { Frame } from 'node-av';
808
- *
809
668
  * {
810
669
  * using frame = new Frame();
811
670
  * frame.alloc();
812
- * // ... use frame
671
+ * // Use frame...
813
672
  * } // Automatically freed when leaving scope
814
673
  * ```
815
- *
816
- * @see {@link free} For manual cleanup
817
674
  */
818
675
  [Symbol.dispose](): void;
819
676
  }