node-av 1.0.3 → 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 (162) hide show
  1. package/README.md +56 -41
  2. package/dist/api/bitstream-filter.d.ts +180 -123
  3. package/dist/api/bitstream-filter.js +182 -126
  4. package/dist/api/bitstream-filter.js.map +1 -1
  5. package/dist/api/decoder.d.ts +286 -130
  6. package/dist/api/decoder.js +321 -159
  7. package/dist/api/decoder.js.map +1 -1
  8. package/dist/api/encoder.d.ts +254 -158
  9. package/dist/api/encoder.js +326 -298
  10. package/dist/api/encoder.js.map +1 -1
  11. package/dist/api/filter-presets.d.ts +912 -0
  12. package/dist/api/filter-presets.js +1407 -0
  13. package/dist/api/filter-presets.js.map +1 -0
  14. package/dist/api/filter.d.ts +280 -284
  15. package/dist/api/filter.js +435 -509
  16. package/dist/api/filter.js.map +1 -1
  17. package/dist/api/hardware.d.ts +226 -159
  18. package/dist/api/hardware.js +405 -287
  19. package/dist/api/hardware.js.map +1 -1
  20. package/dist/api/index.d.ts +3 -2
  21. package/dist/api/index.js +1 -0
  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 +45 -47
  25. package/dist/api/io-stream.js.map +1 -1
  26. package/dist/api/media-input.d.ts +244 -141
  27. package/dist/api/media-input.js +207 -104
  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 +212 -129
  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 +22 -182
  36. package/dist/api/utilities/audio-sample.d.ts +1 -1
  37. package/dist/api/utilities/image.d.ts +1 -1
  38. package/dist/api/utilities/media-type.d.ts +1 -1
  39. package/dist/api/utilities/pixel-format.d.ts +1 -1
  40. package/dist/api/utilities/sample-format.d.ts +1 -1
  41. package/dist/api/utilities/timestamp.d.ts +1 -1
  42. package/dist/api/utils.d.ts +1 -2
  43. package/dist/api/utils.js +9 -0
  44. package/dist/api/utils.js.map +1 -1
  45. package/dist/{lib → constants}/channel-layouts.d.ts +1 -1
  46. package/dist/constants/channel-layouts.js.map +1 -0
  47. package/dist/{lib → constants}/constants.d.ts +19 -4
  48. package/dist/{lib → constants}/constants.js +15 -1
  49. package/dist/constants/constants.js.map +1 -0
  50. package/dist/constants/decoders.d.ts +609 -0
  51. package/dist/constants/decoders.js +617 -0
  52. package/dist/constants/decoders.js.map +1 -0
  53. package/dist/constants/encoders.d.ts +285 -0
  54. package/dist/constants/encoders.js +298 -0
  55. package/dist/constants/encoders.js.map +1 -0
  56. package/dist/constants/index.d.ts +4 -0
  57. package/dist/constants/index.js +5 -0
  58. package/dist/constants/index.js.map +1 -0
  59. package/dist/index.d.ts +1 -0
  60. package/dist/index.js +2 -0
  61. package/dist/index.js.map +1 -1
  62. package/dist/lib/audio-fifo.d.ts +128 -171
  63. package/dist/lib/audio-fifo.js +130 -173
  64. package/dist/lib/audio-fifo.js.map +1 -1
  65. package/dist/lib/binding.d.ts +7 -5
  66. package/dist/lib/binding.js +5 -0
  67. package/dist/lib/binding.js.map +1 -1
  68. package/dist/lib/bitstream-filter-context.d.ts +139 -184
  69. package/dist/lib/bitstream-filter-context.js +139 -188
  70. package/dist/lib/bitstream-filter-context.js.map +1 -1
  71. package/dist/lib/bitstream-filter.d.ts +69 -55
  72. package/dist/lib/bitstream-filter.js +68 -54
  73. package/dist/lib/bitstream-filter.js.map +1 -1
  74. package/dist/lib/codec-context.d.ts +317 -381
  75. package/dist/lib/codec-context.js +316 -381
  76. package/dist/lib/codec-context.js.map +1 -1
  77. package/dist/lib/codec-parameters.d.ts +161 -171
  78. package/dist/lib/codec-parameters.js +162 -172
  79. package/dist/lib/codec-parameters.js.map +1 -1
  80. package/dist/lib/codec-parser.d.ts +92 -105
  81. package/dist/lib/codec-parser.js +92 -103
  82. package/dist/lib/codec-parser.js.map +1 -1
  83. package/dist/lib/codec.d.ts +328 -217
  84. package/dist/lib/codec.js +392 -218
  85. package/dist/lib/codec.js.map +1 -1
  86. package/dist/lib/dictionary.d.ts +150 -204
  87. package/dist/lib/dictionary.js +159 -213
  88. package/dist/lib/dictionary.js.map +1 -1
  89. package/dist/lib/error.d.ts +97 -131
  90. package/dist/lib/error.js +98 -128
  91. package/dist/lib/error.js.map +1 -1
  92. package/dist/lib/filter-context.d.ts +317 -194
  93. package/dist/lib/filter-context.js +335 -200
  94. package/dist/lib/filter-context.js.map +1 -1
  95. package/dist/lib/filter-graph.d.ts +252 -293
  96. package/dist/lib/filter-graph.js +253 -294
  97. package/dist/lib/filter-graph.js.map +1 -1
  98. package/dist/lib/filter-inout.d.ts +87 -95
  99. package/dist/lib/filter-inout.js +87 -95
  100. package/dist/lib/filter-inout.js.map +1 -1
  101. package/dist/lib/filter.d.ts +93 -111
  102. package/dist/lib/filter.js +94 -112
  103. package/dist/lib/filter.js.map +1 -1
  104. package/dist/lib/format-context.d.ts +321 -429
  105. package/dist/lib/format-context.js +314 -386
  106. package/dist/lib/format-context.js.map +1 -1
  107. package/dist/lib/frame.d.ts +263 -406
  108. package/dist/lib/frame.js +263 -408
  109. package/dist/lib/frame.js.map +1 -1
  110. package/dist/lib/hardware-device-context.d.ts +150 -204
  111. package/dist/lib/hardware-device-context.js +149 -203
  112. package/dist/lib/hardware-device-context.js.map +1 -1
  113. package/dist/lib/hardware-frames-context.d.ts +171 -181
  114. package/dist/lib/hardware-frames-context.js +171 -181
  115. package/dist/lib/hardware-frames-context.js.map +1 -1
  116. package/dist/lib/index.d.ts +2 -3
  117. package/dist/lib/index.js +2 -5
  118. package/dist/lib/index.js.map +1 -1
  119. package/dist/lib/input-format.d.ts +90 -118
  120. package/dist/lib/input-format.js +89 -117
  121. package/dist/lib/input-format.js.map +1 -1
  122. package/dist/lib/io-context.d.ts +210 -242
  123. package/dist/lib/io-context.js +221 -253
  124. package/dist/lib/io-context.js.map +1 -1
  125. package/dist/lib/log.d.ts +86 -120
  126. package/dist/lib/log.js +85 -122
  127. package/dist/lib/log.js.map +1 -1
  128. package/dist/lib/native-types.d.ts +127 -112
  129. package/dist/lib/native-types.js +9 -0
  130. package/dist/lib/native-types.js.map +1 -1
  131. package/dist/lib/option.d.ts +285 -242
  132. package/dist/lib/option.js +310 -250
  133. package/dist/lib/option.js.map +1 -1
  134. package/dist/lib/output-format.d.ts +78 -102
  135. package/dist/lib/output-format.js +77 -101
  136. package/dist/lib/output-format.js.map +1 -1
  137. package/dist/lib/packet.d.ts +173 -241
  138. package/dist/lib/packet.js +172 -241
  139. package/dist/lib/packet.js.map +1 -1
  140. package/dist/lib/rational.d.ts +0 -2
  141. package/dist/lib/rational.js +0 -2
  142. package/dist/lib/rational.js.map +1 -1
  143. package/dist/lib/software-resample-context.d.ts +242 -326
  144. package/dist/lib/software-resample-context.js +242 -326
  145. package/dist/lib/software-resample-context.js.map +1 -1
  146. package/dist/lib/software-scale-context.d.ts +130 -174
  147. package/dist/lib/software-scale-context.js +132 -176
  148. package/dist/lib/software-scale-context.js.map +1 -1
  149. package/dist/lib/stream.d.ts +88 -198
  150. package/dist/lib/stream.js +87 -197
  151. package/dist/lib/stream.js.map +1 -1
  152. package/dist/lib/types.d.ts +1 -1
  153. package/dist/lib/utilities.d.ts +372 -181
  154. package/dist/lib/utilities.js +373 -182
  155. package/dist/lib/utilities.js.map +1 -1
  156. package/install/check.js +0 -1
  157. package/package.json +32 -24
  158. package/release_notes.md +43 -13
  159. package/CHANGELOG.md +0 -8
  160. package/dist/lib/channel-layouts.js.map +0 -1
  161. package/dist/lib/constants.js.map +0 -1
  162. /package/dist/{lib → constants}/channel-layouts.js +0 -0
@@ -5,339 +5,294 @@ import { Rational } from './rational.js';
5
5
  import type { NativeBitStreamFilterContext, NativeWrapper } from './native-types.js';
6
6
  import type { Packet } from './packet.js';
7
7
  /**
8
- * Bitstream filter context for processing packets.
8
+ * Bitstream filter context for processing compressed video/audio streams.
9
9
  *
10
- * Manages the state for bitstream filtering operations.
11
- * Processes packets through a bitstream filter without decoding.
12
- * Supports packet-by-packet filtering with internal buffering.
10
+ * Applies bitstream filters to modify or analyze compressed packets without
11
+ * full decoding/encoding. Common uses include format conversion (e.g., H.264 MP4 to Annex B),
12
+ * metadata extraction, parameter set manipulation, and packet splitting/merging.
13
+ * Essential for stream compatibility between different containers and decoders.
13
14
  *
14
15
  * Direct mapping to FFmpeg's AVBSFContext.
15
16
  *
16
17
  * @example
17
18
  * ```typescript
18
- * import { BitStreamFilter, BitStreamFilterContext, Packet, FFmpegError } from 'node-av';
19
- * import { AVERROR_EOF, AVERROR } from 'node-av/constants';
19
+ * import { BitStreamFilterContext, BitStreamFilter, Packet, FFmpegError } from 'node-av';
20
20
  *
21
- * // Create and initialize filter context
22
- * const filter = BitStreamFilter.getByName('h264_mp4toannexb');
21
+ * // Create and initialize H.264 stream format converter
23
22
  * const ctx = new BitStreamFilterContext();
23
+ * const filter = BitStreamFilter.getByName('h264_mp4toannexb');
24
+ * if (!filter) {
25
+ * throw new Error('H.264 filter not available');
26
+ * }
24
27
  *
25
- * // Allocate and configure
26
28
  * let ret = ctx.alloc(filter);
27
29
  * FFmpegError.throwIfError(ret, 'alloc');
28
30
  *
29
- * // Copy input parameters from stream to BSF context
30
- * stream.codecpar.copy(ctx.inputCodecParameters);
31
- * ctx.inputTimeBase = stream.timeBase;
32
- *
33
- * // Initialize filter
34
31
  * ret = ctx.init();
35
32
  * FFmpegError.throwIfError(ret, 'init');
36
33
  *
37
34
  * // Process packets
38
- * while (hasMorePackets) {
39
- * const inputPacket = getNextPacket();
40
- *
41
- * // Send packet to filter
42
- * ret = await ctx.sendPacket(inputPacket);
43
- * FFmpegError.throwIfError(ret, 'sendPacket');
44
- *
45
- * // Receive filtered packets
46
- * while (true) {
47
- * const outputPacket = new Packet();
48
- * const result = await ctx.receivePacket(outputPacket);
49
- *
50
- * if (result.eagain || result.eof) break;
51
- * FFmpegError.throwIfError(result.ret || result, 'receivePacket');
52
- *
53
- * // Process filtered packet
54
- * processPacket(outputPacket);
55
- * outputPacket.unref();
56
- * }
57
- * }
35
+ * const inputPacket = new Packet();
36
+ * const outputPacket = new Packet();
58
37
  *
59
- * // Send EOF
60
- * await ctx.sendPacket(null);
38
+ * ret = await ctx.sendPacket(inputPacket);
39
+ * FFmpegError.throwIfError(ret, 'sendPacket');
61
40
  *
62
- * // Drain remaining packets
63
- * while (true) {
64
- * const outputPacket = new Packet();
65
- * const result = await ctx.receivePacket(outputPacket);
66
- * if (result.eof) break;
67
- * // Process remaining packets
41
+ * ret = await ctx.receivePacket(outputPacket);
42
+ * if (ret >= 0) {
43
+ * // Process filtered packet
68
44
  * }
69
45
  *
70
46
  * // Cleanup
71
47
  * ctx.free();
72
48
  * ```
49
+ *
50
+ * @see {@link BitStreamFilter} For available filter types
51
+ * @see {@link Packet} For packet manipulation
73
52
  */
74
53
  export declare class BitStreamFilterContext extends OptionMember<NativeBitStreamFilterContext> implements Disposable, NativeWrapper<NativeBitStreamFilterContext> {
75
54
  private _filter?;
76
- /**
77
- * Create a new bitstream filter context.
78
- *
79
- * The context is uninitialized - you must call alloc() and init() before use.
80
- * No FFmpeg resources are allocated until initialization.
81
- *
82
- * Direct wrapper around AVBSFContext.
83
- *
84
- * @example
85
- * ```typescript
86
- * const ctx = new BitStreamFilterContext();
87
- * ctx.alloc(filter);
88
- * ctx.init();
89
- * // Context is now ready for filtering
90
- * ```
91
- */
92
55
  constructor();
93
56
  /**
94
- * Check if the context is initialized.
57
+ * Check if the context has been initialized.
95
58
  *
96
- * Returns true if init() has been called successfully.
97
- *
98
- * @returns True if initialized, false otherwise
59
+ * Returns true if init() has been successfully called.
60
+ * The context must be initialized before sending/receiving packets.
99
61
  */
100
62
  get isInitialized(): boolean;
101
63
  /**
102
- * Input codec parameters (read-only reference, mutable contents).
103
- *
104
- * Returns a reference to the BSF context's internal codec parameters.
105
- * While you cannot replace this object (no setter), you can modify its contents
106
- * or use it as a destination for copy operations.
64
+ * Input codec parameters.
107
65
  *
108
- * You must configure these parameters before calling init().
109
- *
110
- * Maps to AVBSFContext->par_in.
111
- *
112
- * @example
113
- * ```typescript
114
- * // Copy parameters from input stream to BSF context
115
- * if (ctx.inputCodecParameters) {
116
- * stream.codecpar.copy(ctx.inputCodecParameters);
66
+ * Parameters describing the input stream format.
67
+ * These are automatically configured from the input packets in most cases.
117
68
  *
118
- * // Or set individual properties
119
- * ctx.inputCodecParameters.codecType = AVMEDIA_TYPE_VIDEO;
120
- * ctx.inputCodecParameters.codecId = AV_CODEC_ID_H264;
121
- * }
122
- * ```
69
+ * Direct mapping to AVBSFContext->par_in.
123
70
  */
124
71
  get inputCodecParameters(): CodecParameters | null;
125
72
  /**
126
- * Output codec parameters (read-only reference, read-only contents).
127
- *
128
- * Returns a reference to the BSF context's output codec parameters.
129
- * These are automatically configured by the filter during init().
130
- * You should not modify these parameters.
131
- *
132
- * Maps to AVBSFContext->par_out.
73
+ * Output codec parameters.
133
74
  *
134
- * @example
135
- * ```typescript
136
- * // After initialization, read the output parameters
137
- * console.log(`Output codec: ${ctx.outputCodecParameters?.codecId}`);
75
+ * Parameters describing the output stream format after filtering.
76
+ * These reflect any changes made by the bitstream filter.
138
77
  *
139
- * // Use them to configure downstream components
140
- * if (ctx.outputCodecParameters) {
141
- * ctx.outputCodecParameters.copy(nextStream.codecpar);
142
- * }
143
- * ```
78
+ * Direct mapping to AVBSFContext->par_out.
144
79
  */
145
80
  get outputCodecParameters(): CodecParameters | null;
146
81
  /**
147
82
  * Input time base.
148
83
  *
149
- * Time base for input packet timestamps.
150
- * Must be set before calling init().
84
+ * Time base of the input packets (timestamps per second).
85
+ * Must be set before init() for proper timestamp handling.
151
86
  *
152
- * Maps to AVBSFContext->time_base_in.
153
- *
154
- * @example
155
- * ```typescript
156
- * ctx.inputTimeBase = new Rational(1, 1000); // 1ms time base
157
- * ```
87
+ * Direct mapping to AVBSFContext->time_base_in.
158
88
  */
159
89
  get inputTimeBase(): Rational;
160
90
  set inputTimeBase(value: Rational);
161
91
  /**
162
92
  * Output time base.
163
93
  *
164
- * Time base for output packet timestamps.
165
- * Set by the filter during init().
94
+ * Time base of the output packets after filtering.
95
+ * May differ from input if the filter modifies timing.
166
96
  *
167
- * Maps to AVBSFContext->time_base_out.
168
- *
169
- * @example
170
- * ```typescript
171
- * // After initialization
172
- * console.log(`Output time base: ${ctx.outputTimeBase.num}/${ctx.outputTimeBase.den}`);
173
- * ```
97
+ * Direct mapping to AVBSFContext->time_base_out.
174
98
  */
175
99
  get outputTimeBase(): Rational | null;
176
100
  /**
177
101
  * The bitstream filter being used.
178
102
  *
179
- * Reference to the filter this context was allocated with.
103
+ * Reference to the filter descriptor allocated to this context.
180
104
  *
181
- * Maps to AVBSFContext->filter.
182
- *
183
- * @example
184
- * ```typescript
185
- * console.log(`Using filter: ${ctx.filter?.name}`);
186
- * ```
105
+ * Direct mapping to AVBSFContext->filter.
187
106
  */
188
107
  get filter(): BitStreamFilter | null;
189
108
  /**
190
- * Allocate the bitstream filter context.
109
+ * Allocate a bitstream filter context.
191
110
  *
192
- * Allocates the context for the specified filter.
193
- * Must be called before any other operations.
194
- * After allocation, configure input parameters before calling init().
111
+ * Allocates and configures the context for the specified filter.
112
+ * Must be called before init().
195
113
  *
196
- * Calls av_bsf_alloc() internally.
114
+ * Direct mapping to av_bsf_alloc().
197
115
  *
198
116
  * @param filter - The bitstream filter to use
199
- * @returns 0 on success, negative error code on failure
117
+ * @returns 0 on success, negative AVERROR on error:
118
+ * - AVERROR_ENOMEM: Memory allocation failure
119
+ * - AVERROR_EINVAL: Invalid filter
200
120
  *
201
121
  * @example
202
122
  * ```typescript
123
+ * import { FFmpegError } from 'node-av';
124
+ *
203
125
  * const filter = BitStreamFilter.getByName('h264_mp4toannexb');
204
- * const ctx = new BitStreamFilterContext();
126
+ * if (!filter) {
127
+ * throw new Error('Filter not found');
128
+ * }
129
+ *
205
130
  * const ret = ctx.alloc(filter);
206
131
  * FFmpegError.throwIfError(ret, 'alloc');
207
132
  * ```
133
+ *
134
+ * @see {@link init} To initialize after allocation
135
+ * @see {@link BitStreamFilter.getByName} To get filter by name
208
136
  */
209
137
  alloc(filter: BitStreamFilter): number;
210
138
  /**
211
139
  * Initialize the bitstream filter context.
212
140
  *
213
- * Prepares the filter for use after parameters have been set.
214
- * Sets up output parameters based on input and filter configuration.
215
- * Must be called after alloc() and parameter configuration.
141
+ * Initializes the filter with the configured parameters.
142
+ * Must be called after alloc() and before processing packets.
216
143
  *
217
- * Calls av_bsf_init() internally.
144
+ * Direct mapping to av_bsf_init().
218
145
  *
219
- * @returns 0 on success, negative error code on failure
146
+ * @returns 0 on success, negative AVERROR on error:
147
+ * - AVERROR_EINVAL: Invalid parameters
148
+ * - AVERROR_ENOMEM: Memory allocation failure
220
149
  *
221
150
  * @example
222
151
  * ```typescript
223
- * // After allocation and parameter setup
224
- * const ret = ctx.init();
225
- * FFmpegError.throwIfError(ret, 'init');
152
+ * import { FFmpegError } from 'node-av';
153
+ *
154
+ * // Allocate and initialize
155
+ * const ret1 = ctx.alloc(filter);
156
+ * FFmpegError.throwIfError(ret1, 'alloc');
157
+ *
158
+ * // Set parameters if needed
159
+ * ctx.inputTimeBase = new Rational(1, 25);
160
+ *
161
+ * const ret2 = ctx.init();
162
+ * FFmpegError.throwIfError(ret2, 'init');
226
163
  * ```
164
+ *
165
+ * @see {@link alloc} Must be called first
166
+ * @see {@link isInitialized} To check initialization status
227
167
  */
228
168
  init(): number;
229
169
  /**
230
170
  * Free the bitstream filter context.
231
171
  *
232
172
  * Releases all resources associated with the context.
233
- * The context cannot be used after calling this method.
173
+ * The context becomes invalid after calling this.
234
174
  *
235
- * Calls av_bsf_free() internally.
175
+ * Direct mapping to av_bsf_free().
236
176
  *
237
177
  * @example
238
178
  * ```typescript
239
179
  * ctx.free();
240
- * // Context is now freed and unusable
180
+ * // Context is now invalid
241
181
  * ```
182
+ *
183
+ * @see {@link Symbol.dispose} For automatic cleanup
184
+ * @see {@link alloc} To allocate
242
185
  */
243
186
  free(): void;
244
187
  /**
245
188
  * Flush the bitstream filter.
246
189
  *
247
- * Resets the internal filter state.
248
- * Should be called when seeking or switching streams.
190
+ * Resets the internal state and discards any buffered data.
191
+ * Useful when seeking or switching streams.
249
192
  *
250
- * Calls av_bsf_flush() internally.
193
+ * Direct mapping to av_bsf_flush().
251
194
  *
252
195
  * @example
253
196
  * ```typescript
254
- * // When seeking
197
+ * // Flush when seeking
255
198
  * ctx.flush();
256
- * // Filter is reset and ready for new packets
199
+ * // Now ready to process packets from new position
257
200
  * ```
258
201
  */
259
202
  flush(): void;
260
203
  /**
261
- * Send a packet to the filter.
262
- *
263
- * Submits a packet for filtering.
264
- * The filter takes ownership of the packet.
265
- * Pass null to signal end of stream.
204
+ * Send a packet to the bitstream filter.
266
205
  *
267
- * After sending a packet, call receivePacket() repeatedly
268
- * until it returns EAGAIN or EOF.
206
+ * Submits a packet for filtering. The filter may buffer the packet
207
+ * internally and require multiple calls to receivePacket() to retrieve
208
+ * all output. Send null to signal end of stream.
269
209
  *
270
- * Calls av_bsf_send_packet() internally.
210
+ * Direct mapping to av_bsf_send_packet().
271
211
  *
272
- * @param packet - Packet to filter, or null for EOF
273
- * @returns Promise resolving to 0 on success, error code on failure
212
+ * @param packet - Packet to filter, or null to signal EOF
213
+ * @returns 0 on success, negative AVERROR on error:
214
+ * - AVERROR_EAGAIN: Filter needs output to be consumed first
215
+ * - AVERROR_EOF: Filter has been flushed
216
+ * - AVERROR_EINVAL: Invalid parameters
217
+ * - AVERROR_ENOMEM: Memory allocation failure
274
218
  *
275
219
  * @example
276
220
  * ```typescript
277
- * // Send packet
221
+ * import { FFmpegError } from 'node-av';
222
+ * import { AVERROR_EAGAIN } from 'node-av';
223
+ *
278
224
  * const ret = await ctx.sendPacket(inputPacket);
279
- * if (ret < 0 && ret !== AVERROR_EAGAIN) {
280
- * throw new Error('Failed to send packet');
225
+ * if (ret === AVERROR_EAGAIN) {
226
+ * // Need to receive packets first
227
+ * const ret2 = await ctx.receivePacket(outputPacket);
228
+ * FFmpegError.throwIfError(ret2, 'receivePacket');
229
+ * } else {
230
+ * FFmpegError.throwIfError(ret, 'sendPacket');
281
231
  * }
282
232
  *
283
233
  * // Send EOF
284
234
  * await ctx.sendPacket(null);
285
235
  * ```
236
+ *
237
+ * @see {@link receivePacket} To retrieve filtered packets
286
238
  */
287
239
  sendPacket(packet: Packet | null): Promise<number>;
288
240
  /**
289
- * Receive a filtered packet.
241
+ * Receive a filtered packet from the bitstream filter.
290
242
  *
291
- * Gets a filtered packet from the filter.
292
- * Must be called repeatedly after sendPacket() until EAGAIN or EOF.
293
- * One input packet may produce multiple output packets.
243
+ * Retrieves a packet that has been processed by the filter.
244
+ * May need to be called multiple times after each sendPacket().
294
245
  *
295
- * Calls av_bsf_receive_packet() internally.
246
+ * Direct mapping to av_bsf_receive_packet().
296
247
  *
297
248
  * @param packet - Packet to receive filtered data into
298
- * @returns Promise resolving to 0 on success, negative error code on failure
249
+ * @returns 0 on success, negative AVERROR on error:
250
+ * - AVERROR_EAGAIN: Need more input
251
+ * - AVERROR_EOF: No more packets available
252
+ * - AVERROR_EINVAL: Invalid parameters
299
253
  *
300
254
  * @example
301
255
  * ```typescript
302
- * import { AVERROR_EAGAIN, AVERROR_EOF } from 'node-av/constants';
303
- *
304
- * const packet = new Packet();
305
- * const ret = await ctx.receivePacket(packet);
306
- *
307
- * if (ret === AVERROR_EAGAIN) {
308
- * // Need to send more packets
309
- * } else if (ret === AVERROR_EOF) {
310
- * // No more packets
311
- * } else if (ret < 0) {
312
- * // Error occurred
313
- * } else {
314
- * // Got a packet successfully
315
- * processPacket(packet);
256
+ * import { FFmpegError } from 'node-av';
257
+ * import { AVERROR_EAGAIN, AVERROR_EOF } from 'node-av';
258
+ *
259
+ * // Receive all available packets
260
+ * while (true) {
261
+ * const ret = await ctx.receivePacket(outputPacket);
262
+ * if (ret === AVERROR_EAGAIN || ret === AVERROR_EOF) {
263
+ * break;
264
+ * }
265
+ * FFmpegError.throwIfError(ret, 'receivePacket');
266
+ *
267
+ * // Process filtered packet
268
+ * console.log(`Filtered packet size: ${outputPacket.size}`);
316
269
  * }
317
270
  * ```
271
+ *
272
+ * @see {@link sendPacket} To submit packets for filtering
318
273
  */
319
274
  receivePacket(packet: Packet): Promise<number>;
320
275
  /**
321
- * Get the underlying native object.
276
+ * Get the underlying native BitStreamFilterContext object.
322
277
  *
323
- * For advanced use cases that need direct access to the native bindings.
278
+ * @returns The native BitStreamFilterContext binding object
324
279
  *
325
- * @returns Native BitStreamFilterContext object
326
280
  * @internal
327
281
  */
328
282
  getNative(): NativeBitStreamFilterContext;
329
283
  /**
330
- * Dispose of the context resources.
284
+ * Dispose of the bitstream filter context.
331
285
  *
332
- * Automatically called when using the `using` statement.
333
- * Frees all associated FFmpeg resources.
286
+ * Implements the Disposable interface for automatic cleanup.
287
+ * Equivalent to calling free().
334
288
  *
335
289
  * @example
336
290
  * ```typescript
337
291
  * {
338
292
  * using ctx = new BitStreamFilterContext();
339
293
  * ctx.alloc(filter);
340
- * // ... use context
294
+ * ctx.init();
295
+ * // Use context...
341
296
  * } // Automatically freed when leaving scope
342
297
  * ```
343
298
  */