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
@@ -2,277 +2,288 @@ import { Filter } from './filter.js';
2
2
  import { HardwareDeviceContext } from './hardware-device-context.js';
3
3
  import { OptionMember } from './option.js';
4
4
  import { Rational } from './rational.js';
5
+ import type { AVPixelFormat, AVSampleFormat } from '../constants/constants.js';
5
6
  import type { Frame } from './frame.js';
6
7
  import type { HardwareFramesContext } from './hardware-frames-context.js';
7
8
  import type { NativeDictionary, NativeFilterContext, NativeFilterGraph, NativeWrapper } from './native-types.js';
8
- import type { IRational } from './types.js';
9
+ import type { ChannelLayout, IRational } from './types.js';
9
10
  /**
10
- * Filter context for media processing.
11
+ * Filter instance in a filter graph.
11
12
  *
12
- * Represents an instance of a filter in a filter graph.
13
- * Manages filter configuration, parameters, and connections.
14
- * Must be created through FilterGraph.createFilter() and properly initialized before use.
13
+ * Represents an instantiated filter within a filter graph. Each context contains
14
+ * a specific filter configuration with its parameters, connections to other filters,
15
+ * and input/output pads. Supports both software and hardware filtering operations.
16
+ * Essential for building complex filter chains for audio/video processing.
15
17
  *
16
18
  * Direct mapping to FFmpeg's AVFilterContext.
17
19
  *
18
20
  * @example
19
21
  * ```typescript
20
- * import { FilterGraph, Filter, FFmpegError } from 'node-av';
22
+ * import { FilterContext, FilterGraph, Filter, FFmpegError } from 'node-av';
21
23
  *
22
- * // Create filter context through FilterGraph
23
- * const filterGraph = new FilterGraph();
24
- * filterGraph.alloc();
24
+ * // Create filter context in a graph
25
+ * const graph = new FilterGraph();
26
+ * const filter = Filter.getByName('scale');
27
+ * const context = graph.createFilter(filter, 'scaler');
25
28
  *
26
- * const bufferFilter = Filter.getByName('buffer');
27
- * const bufferCtx = filterGraph.createFilter(bufferFilter, 'in');
28
- * const initRet = bufferCtx.initStr('video_size=1920x1080:pix_fmt=yuv420p:time_base=1/25:pixel_aspect=1/1');
29
- * FFmpegError.throwIfError(initRet, 'initStr buffer');
29
+ * // Initialize with parameters
30
+ * const ret = context.initStr('640:480');
31
+ * FFmpegError.throwIfError(ret, 'initStr');
30
32
  *
31
- * // Link filters
32
- * const scaleFilter = Filter.getByName('scale');
33
- * const scaleCtx = filterGraph.createFilter(scaleFilter, 'scale');
34
- * const scaleRet = scaleCtx.initStr('1280:720');
35
- * FFmpegError.throwIfError(scaleRet, 'initStr scale');
33
+ * // Link filters together
34
+ * const ret2 = source.link(0, context, 0);
35
+ * FFmpegError.throwIfError(ret2, 'link');
36
36
  *
37
- * const linkRet = bufferCtx.link(0, scaleCtx, 0);
38
- * FFmpegError.throwIfError(linkRet, 'link');
39
- *
40
- * // Configure and use the graph
41
- * const configRet = filterGraph.config();
42
- * FFmpegError.throwIfError(configRet, 'config');
37
+ * // For buffer source/sink
38
+ * const ret3 = await bufferSrc.buffersrcAddFrame(frame);
39
+ * FFmpegError.throwIfError(ret3, 'buffersrcAddFrame');
43
40
  * ```
41
+ *
42
+ * @see [AVFilterContext](https://ffmpeg.org/doxygen/trunk/structAVFilterContext.html) - FFmpeg Doxygen
43
+ * @see {@link FilterGraph} For managing filter graphs
44
+ * @see {@link Filter} For filter descriptors
44
45
  */
45
46
  export declare class FilterContext extends OptionMember<NativeFilterContext> implements Disposable, NativeWrapper<NativeFilterContext> {
46
47
  private _hwDeviceCtx?;
47
48
  /**
48
- * Constructor is internal - use FilterGraph.createFilter().
49
- *
50
- * FilterContexts are created and managed by FilterGraph.
51
- * Do not instantiate directly.
52
- *
49
+ * @param native - The native filter context instance
53
50
  * @internal
54
- *
55
- * @param native - Native AVFilterContext to wrap
56
51
  */
57
52
  constructor(native: NativeFilterContext);
58
53
  /**
59
54
  * Filter instance name.
60
55
  *
61
- * The unique name of this filter instance in the graph.
56
+ * User-assigned name for this filter instance in the graph.
57
+ * Used for identification and debugging.
62
58
  *
63
- * Direct mapping to AVFilterContext->name
59
+ * Direct mapping to AVFilterContext->name.
64
60
  */
65
61
  get name(): string | null;
66
62
  set name(value: string | null);
67
63
  /**
68
- * The filter definition.
69
- *
70
- * The AVFilter that this context is an instance of.
64
+ * Filter descriptor.
71
65
  *
72
- * Direct mapping to AVFilterContext->filter
66
+ * Reference to the filter type this context instantiates.
73
67
  *
74
- * @readonly
68
+ * Direct mapping to AVFilterContext->filter.
75
69
  */
76
70
  get filter(): Filter | null;
77
71
  /**
78
- * The parent filter graph.
72
+ * Parent filter graph.
79
73
  *
80
- * The filter graph that contains this filter context.
74
+ * Reference to the graph containing this filter context.
81
75
  *
82
- * Direct mapping to AVFilterContext->graph
83
- *
84
- * @readonly
76
+ * Direct mapping to AVFilterContext->graph.
85
77
  */
86
78
  get graph(): NativeFilterGraph | null;
87
79
  /**
88
80
  * Number of input pads.
89
81
  *
90
- * The number of input connections this filter can accept.
91
- *
92
- * Direct mapping to AVFilterContext->nb_inputs
82
+ * Total number of input connections this filter can accept.
93
83
  *
94
- * @readonly
84
+ * Direct mapping to AVFilterContext->nb_inputs.
95
85
  */
96
86
  get nbInputs(): number;
97
87
  /**
98
88
  * Number of output pads.
99
89
  *
100
- * Direct mapping to AVFilterContext->nb_outputs
90
+ * Total number of output connections this filter can provide.
101
91
  *
102
- * The number of output connections this filter can provide.
92
+ * Direct mapping to AVFilterContext->nb_outputs.
103
93
  */
104
94
  get nbOutputs(): number;
105
95
  /**
106
- * Filter readiness status.
96
+ * Filter readiness state.
107
97
  *
108
- * Direct mapping to AVFilterContext->ready
98
+ * Indicates if the filter is ready for processing.
99
+ * Non-zero when ready.
109
100
  *
110
- * Non-zero when the filter has been properly initialized.
101
+ * Direct mapping to AVFilterContext->ready.
111
102
  */
112
103
  get ready(): number;
113
104
  /**
114
- * Get or set the hardware device context.
105
+ * Hardware device context.
115
106
  *
116
- * Direct mapping to AVFilterContext->hw_device_ctx
107
+ * Hardware acceleration context for GPU-based filtering.
108
+ * Set to enable hardware-accelerated filter operations.
117
109
  *
118
- * Used for hardware-accelerated filters that need device context.
119
- * Must be set before filter initialization for hardware filters.
110
+ * Direct mapping to AVFilterContext->hw_device_ctx.
120
111
  */
121
112
  get hwDeviceCtx(): HardwareDeviceContext | null;
122
113
  set hwDeviceCtx(value: HardwareDeviceContext | null);
123
114
  /**
124
- * Initialize the filter with options.
115
+ * Initialize filter with dictionary options.
125
116
  *
126
- * Direct mapping to avfilter_init_dict()
117
+ * Configures the filter with key-value option pairs.
118
+ * Must be called after creation and before processing.
127
119
  *
128
- * @param options - Optional dictionary of filter options
120
+ * Direct mapping to avfilter_init_dict().
129
121
  *
122
+ * @param options - Dictionary of filter options
130
123
  * @returns 0 on success, negative AVERROR on error:
131
- * - 0: Success
132
- * - AVERROR(EINVAL): Invalid options
133
- * - AVERROR(ENOMEM): Memory allocation failure
134
- * - <0: Other filter-specific errors
124
+ * - AVERROR_EINVAL: Invalid parameters
125
+ * - AVERROR_ENOMEM: Memory allocation failure
135
126
  *
136
127
  * @example
137
128
  * ```typescript
138
- * import { Dictionary, FilterContext, FFmpegError } from 'node-av';
139
- *
140
- * const options = new Dictionary();
141
- * const ret1 = options.set('width', '1280', 0);
142
- * FFmpegError.throwIfError(ret1, 'set width');
143
- * const ret2 = options.set('height', '720', 0);
144
- * FFmpegError.throwIfError(ret2, 'set height');
129
+ * import { FFmpegError } from 'node-av';
145
130
  *
146
- * const initRet = filterCtx.init(options.getNative());
147
- * FFmpegError.throwIfError(initRet, 'init');
148
- * options.free();
131
+ * const options = { width: '1920', height: '1080' };
132
+ * const ret = context.init(options);
133
+ * FFmpegError.throwIfError(ret, 'init');
149
134
  * ```
150
135
  *
151
- * @see initStr() - Alternative initialization with string arguments
136
+ * @see {@link initStr} For string-based initialization
152
137
  */
153
138
  init(options?: NativeDictionary | null): number;
154
139
  /**
155
- * Initialize the filter with a string argument.
140
+ * Initialize filter with string arguments.
156
141
  *
157
- * Direct mapping to avfilter_init_str()
142
+ * Configures the filter using a string representation of parameters.
143
+ * Format depends on the specific filter.
158
144
  *
159
- * @param args - Filter arguments string (format is filter-specific)
145
+ * Direct mapping to avfilter_init_str().
160
146
  *
147
+ * @param args - Filter arguments string
161
148
  * @returns 0 on success, negative AVERROR on error:
162
- * - 0: Success
163
- * - AVERROR(EINVAL): Invalid arguments
164
- * - AVERROR(ENOMEM): Memory allocation failure
165
- * - <0: Other filter-specific errors
149
+ * - AVERROR_EINVAL: Invalid arguments
150
+ * - AVERROR_ENOMEM: Memory allocation failure
166
151
  *
167
152
  * @example
168
153
  * ```typescript
169
- * import { FilterContext, FFmpegError } from 'node-av';
154
+ * import { FFmpegError } from 'node-av';
170
155
  *
171
- * // Initialize scale filter
172
- * const scaleRet = scaleCtx.initStr('1280:720');
173
- * FFmpegError.throwIfError(scaleRet, 'initStr scale');
156
+ * // Scale filter with width:height
157
+ * const ret = scaleContext.initStr('1920:1080');
158
+ * FFmpegError.throwIfError(ret, 'initStr');
174
159
  *
175
- * // Initialize buffer source
176
- * const bufferRet = bufferCtx.initStr('video_size=1920x1080:pix_fmt=yuv420p:time_base=1/25');
177
- * FFmpegError.throwIfError(bufferRet, 'initStr buffer');
160
+ * // Crop filter with width:height:x:y
161
+ * const ret2 = cropContext.initStr('640:480:100:50');
162
+ * FFmpegError.throwIfError(ret2, 'initStr');
178
163
  * ```
179
164
  *
180
- * @see init() - Alternative initialization with dictionary
165
+ * @see {@link init} For dictionary-based initialization
181
166
  */
182
167
  initStr(args?: string | null): number;
183
168
  /**
184
169
  * Link this filter's output to another filter's input.
185
170
  *
186
- * Direct mapping to avfilter_link()
171
+ * Creates a connection between two filters in the graph.
172
+ * Data flows from this filter's output pad to the destination's input pad.
187
173
  *
188
- * @param srcPad - Output pad index on this filter
189
- * @param dst - Destination filter context
190
- * @param dstPad - Input pad index on destination filter
174
+ * Direct mapping to avfilter_link().
191
175
  *
176
+ * @param srcPad - Output pad index of this filter
177
+ * @param dst - Destination filter context
178
+ * @param dstPad - Input pad index of destination filter
192
179
  * @returns 0 on success, negative AVERROR on error:
193
- * - 0: Success
194
- * - AVERROR(EINVAL): Invalid pad indices or incompatible formats
195
- * - AVERROR(ENOMEM): Memory allocation failure
196
- * - <0: Other linking errors
180
+ * - AVERROR_EINVAL: Invalid pad indices or incompatible formats
181
+ * - AVERROR_ENOMEM: Memory allocation failure
197
182
  *
198
183
  * @example
199
184
  * ```typescript
200
- * import { FilterContext, FFmpegError } from 'node-av';
185
+ * import { FFmpegError } from 'node-av';
201
186
  *
202
- * // Link buffer source to scale filter
203
- * const linkRet1 = bufferCtx.link(0, scaleCtx, 0);
204
- * FFmpegError.throwIfError(linkRet1, 'link buffer to scale');
187
+ * // Link source output 0 to scale input 0
188
+ * const ret = source.link(0, scale, 0);
189
+ * FFmpegError.throwIfError(ret, 'link');
205
190
  *
206
- * // Link scale to sink
207
- * const linkRet2 = scaleCtx.link(0, sinkCtx, 0);
208
- * FFmpegError.throwIfError(linkRet2, 'link scale to sink');
191
+ * // Link scale output 0 to sink input 0
192
+ * const ret2 = scale.link(0, sink, 0);
193
+ * FFmpegError.throwIfError(ret2, 'link');
209
194
  * ```
195
+ *
196
+ * @see {@link unlink} To disconnect filters
210
197
  */
211
198
  link(srcPad: number, dst: FilterContext, dstPad: number): number;
212
199
  /**
213
200
  * Unlink a filter pad.
214
201
  *
215
- * Removes the connection from the specified input pad.
216
- * Note: avfilter_link_free is deprecated, we set pointer to nullptr instead.
202
+ * Disconnects a pad from its linked filter.
203
+ * Used to reconfigure filter connections.
217
204
  *
218
- * @param pad - Input pad index to unlink
205
+ * Direct mapping to avfilter_link_free().
206
+ *
207
+ * @param pad - Pad index to unlink
219
208
  *
220
209
  * @example
221
210
  * ```typescript
222
- * // Unlink the first input pad
223
- * filterCtx.unlink(0);
211
+ * // Disconnect output pad 0
212
+ * context.unlink(0);
224
213
  * ```
214
+ *
215
+ * @see {@link link} To connect filters
225
216
  */
226
217
  unlink(pad: number): void;
227
218
  /**
228
219
  * Add a frame to a buffer source filter.
229
220
  *
230
- * Direct mapping to av_buffersrc_add_frame()
231
- *
232
- * This function is specific to buffer source filters and is used
233
- * to feed frames into the filter graph.
221
+ * Sends a frame into the filter graph through a buffer source.
222
+ * Only valid for buffer source filters. Send null to signal EOF.
234
223
  *
235
- * @param frame - The frame to add (can be null to signal EOF)
224
+ * Direct mapping to av_buffersrc_add_frame().
236
225
  *
226
+ * @param frame - Frame to send, or null for EOF
237
227
  * @returns 0 on success, negative AVERROR on error:
238
- * - 0: Success
239
- * - AVERROR(EAGAIN): The buffer is full, try again later
240
- * - AVERROR(EINVAL): Invalid parameters
241
- * - AVERROR_EOF: The filter has been closed
228
+ * - AVERROR_EAGAIN: Filter needs more output consumption
229
+ * - AVERROR_EOF: Filter has been closed
230
+ * - AVERROR_EINVAL: Not a buffer source filter
231
+ * - AVERROR_ENOMEM: Memory allocation failure
242
232
  *
243
233
  * @example
244
234
  * ```typescript
245
- * import { Frame, FilterContext, FFmpegError } from 'node-av';
246
- *
247
- * // Feed a frame to the buffer source
248
- * const addRet = srcCtx.buffersrcAddFrame(frame);
249
- * FFmpegError.throwIfError(addRet, 'buffersrcAddFrame');
235
+ * import { FFmpegError } from 'node-av';
236
+ * import { AVERROR_EAGAIN } from 'node-av/constants';
237
+ *
238
+ * // Send frame to filter graph
239
+ * const ret = await bufferSrc.buffersrcAddFrame(frame);
240
+ * if (ret === AVERROR_EAGAIN) {
241
+ * // Need to consume output first
242
+ * } else {
243
+ * FFmpegError.throwIfError(ret, 'buffersrcAddFrame');
244
+ * }
250
245
  *
251
- * // Signal end of stream
252
- * const eofRet = srcCtx.buffersrcAddFrame(null);
253
- * FFmpegError.throwIfError(eofRet, 'buffersrcAddFrame EOF');
246
+ * // Signal EOF
247
+ * await bufferSrc.buffersrcAddFrame(null);
254
248
  * ```
249
+ *
250
+ * @see {@link buffersinkGetFrame} To retrieve filtered frames
255
251
  */
256
252
  buffersrcAddFrame(frame: Frame | null): Promise<number>;
257
253
  /**
258
254
  * Set parameters for a buffer source filter.
259
255
  *
260
- * Direct mapping to av_buffersrc_parameters_set()
261
- *
262
- * This function configures a buffer source filter with specific parameters,
263
- * including hardware frames context for hardware-accelerated filtering.
264
- *
265
- * @param params - Parameters for the buffer source
266
- * @returns 0 on success, negative error code on failure
256
+ * Configures the format and properties of frames that will be sent
257
+ * to the buffer source. Must be called before sending frames.
258
+ *
259
+ * Direct mapping to av_buffersrc_parameters_set().
260
+ *
261
+ * @param params - Source parameters
262
+ * @param params.width - Video frame width
263
+ * @param params.height - Video frame height
264
+ * @param params.format - Pixel or sample format
265
+ * @param params.timeBase - Time base for timestamps
266
+ * @param params.frameRate - Video frame rate
267
+ * @param params.sampleAspectRatio - Pixel aspect ratio
268
+ * @param params.hwFramesCtx - Hardware frames context
269
+ * @param params.sampleRate - Audio sample rate
270
+ * @param params.channelLayout - Audio channel layout
271
+ * @returns 0 on success, negative AVERROR on error:
272
+ * - AVERROR_EINVAL: Invalid parameters
273
+ * - AVERROR_ENOMEM: Memory allocation failure
267
274
  *
268
275
  * @example
269
276
  * ```typescript
270
- * const ret = srcCtx.buffersrcParametersSet({
277
+ * import { FFmpegError, Rational } from 'node-av';
278
+ * import { AV_PIX_FMT_YUV420P } from 'node-av/constants';
279
+ *
280
+ * // Configure video buffer source
281
+ * const ret = bufferSrc.buffersrcParametersSet({
271
282
  * width: 1920,
272
283
  * height: 1080,
273
284
  * format: AV_PIX_FMT_YUV420P,
274
- * timeBase: { num: 1, den: 30 },
275
- * hwFramesCtx: hardware.framesContext
285
+ * timeBase: { num: 1, den: 25 },
286
+ * frameRate: { num: 25, den: 1 }
276
287
  * });
277
288
  * FFmpegError.throwIfError(ret, 'buffersrcParametersSet');
278
289
  * ```
@@ -291,139 +302,251 @@ export declare class FilterContext extends OptionMember<NativeFilterContext> imp
291
302
  /**
292
303
  * Get a frame from a buffer sink filter.
293
304
  *
294
- * Direct mapping to av_buffersink_get_frame()
295
- *
296
- * This function is specific to buffer sink filters and is used
297
- * to retrieve filtered frames from the filter graph.
305
+ * Retrieves a filtered frame from the filter graph through a buffer sink.
306
+ * Only valid for buffer sink filters.
298
307
  *
299
- * @param frame - The frame to receive the filtered data
308
+ * Direct mapping to av_buffersink_get_frame().
300
309
  *
310
+ * @param frame - Frame to receive filtered data
301
311
  * @returns 0 on success, negative AVERROR on error:
302
- * - 0: Success, frame contains valid data
303
- * - AVERROR(EAGAIN): No frame available, need more input
304
- * - AVERROR_EOF: End of stream reached
305
- * - AVERROR(EINVAL): Invalid parameters
312
+ * - AVERROR_EAGAIN: No frame available yet
313
+ * - AVERROR_EOF: No more frames will be produced
314
+ * - AVERROR_EINVAL: Not a buffer sink filter
306
315
  *
307
316
  * @example
308
317
  * ```typescript
309
- * import { Frame, FilterContext, FFmpegError } from 'node-av';
318
+ * import { FFmpegError, Frame } from 'node-av';
310
319
  * import { AVERROR_EAGAIN, AVERROR_EOF } from 'node-av/constants';
311
320
  *
312
- * // Get filtered frames
313
321
  * const frame = new Frame();
314
322
  * frame.alloc();
315
323
  *
316
- * let ret = sinkCtx.buffersinkGetFrame(frame);
317
- * while (ret >= 0) {
318
- * // Process the filtered frame
319
- * processFrame(frame);
320
- * frame.unref();
321
- *
322
- * // Try to get another frame
323
- * ret = sinkCtx.buffersinkGetFrame(frame);
324
- * }
325
- *
326
- * if (!FFmpegError.is(ret, AVERROR_EAGAIN) && !FFmpegError.is(ret, AVERROR_EOF)) {
324
+ * const ret = await bufferSink.buffersinkGetFrame(frame);
325
+ * if (ret === AVERROR_EAGAIN) {
326
+ * // No frame available yet
327
+ * } else if (ret === AVERROR_EOF) {
328
+ * // End of stream
329
+ * } else {
327
330
  * FFmpegError.throwIfError(ret, 'buffersinkGetFrame');
331
+ * // Process filtered frame
328
332
  * }
329
333
  * ```
334
+ *
335
+ * @see {@link buffersrcAddFrame} To send frames for filtering
330
336
  */
331
337
  buffersinkGetFrame(frame: Frame): Promise<number>;
332
338
  /**
333
- * Set the frame size for a buffersink filter.
339
+ * Get time base from buffer sink.
334
340
  *
335
- * Direct mapping to av_buffersink_set_frame_size()
341
+ * Returns the time base of frames from a buffer sink filter.
342
+ * Only valid for buffer sink filters.
336
343
  *
337
- * For audio encoders that require a specific frame size.
344
+ * Direct mapping to av_buffersink_get_time_base().
338
345
  *
339
- * @param frameSize - The frame size to set
346
+ * @returns Time base as Rational
340
347
  *
341
348
  * @example
342
349
  * ```typescript
343
- * if (encCtx.frameSize > 0) {
344
- * buffersinkCtx.buffersinkSetFrameSize(encCtx.frameSize);
350
+ * const timeBase = bufferSink.buffersinkGetTimeBase();
351
+ * console.log(`Time base: ${timeBase.num}/${timeBase.den}`);
352
+ * ```
353
+ */
354
+ buffersinkGetTimeBase(): Rational;
355
+ /**
356
+ * Get pixel/sample format from buffer sink.
357
+ *
358
+ * Returns the format of frames from a buffer sink filter.
359
+ * Only valid for buffer sink filters.
360
+ *
361
+ * Direct mapping to av_buffersink_get_format().
362
+ *
363
+ * @returns Pixel format for video, sample format for audio
364
+ *
365
+ * @example
366
+ * ```typescript
367
+ * import { AV_PIX_FMT_YUV420P } from 'node-av/constants';
368
+ *
369
+ * const format = bufferSink.buffersinkGetFormat();
370
+ * if (format === AV_PIX_FMT_YUV420P) {
371
+ * console.log('Output is YUV420P');
345
372
  * }
346
373
  * ```
347
374
  */
375
+ buffersinkGetFormat(): AVPixelFormat | AVSampleFormat;
348
376
  /**
349
- * Get the time base from a buffersink filter.
377
+ * Get frame width from buffer sink.
350
378
  *
351
- * Direct mapping to av_buffersink_get_time_base()
379
+ * Returns the width of video frames from a buffer sink filter.
380
+ * Only valid for video buffer sink filters.
352
381
  *
353
- * Returns the time base of the buffersink filter.
382
+ * Direct mapping to av_buffersink_get_w().
354
383
  *
355
- * @returns The time base as a Rational
384
+ * @returns Frame width in pixels
356
385
  *
357
386
  * @example
358
387
  * ```typescript
359
- * const timeBase = buffersinkCtx.buffersinkGetTimeBase();
360
- * console.log(`Time base: ${timeBase.num}/${timeBase.den}`);
388
+ * const width = bufferSink.buffersinkGetWidth();
389
+ * console.log(`Output width: ${width}px`);
361
390
  * ```
362
391
  */
363
- buffersinkGetTimeBase(): Rational;
392
+ buffersinkGetWidth(): number;
393
+ /**
394
+ * Get frame height from buffer sink.
395
+ *
396
+ * Returns the height of video frames from a buffer sink filter.
397
+ * Only valid for video buffer sink filters.
398
+ *
399
+ * Direct mapping to av_buffersink_get_h().
400
+ *
401
+ * @returns Frame height in pixels
402
+ *
403
+ * @example
404
+ * ```typescript
405
+ * const height = bufferSink.buffersinkGetHeight();
406
+ * console.log(`Output height: ${height}px`);
407
+ * ```
408
+ */
409
+ buffersinkGetHeight(): number;
410
+ /**
411
+ * Get sample aspect ratio from buffer sink.
412
+ *
413
+ * Returns the pixel aspect ratio of video frames from a buffer sink filter.
414
+ * Only valid for video buffer sink filters.
415
+ *
416
+ * Direct mapping to av_buffersink_get_sample_aspect_ratio().
417
+ *
418
+ * @returns Sample aspect ratio as Rational
419
+ *
420
+ * @example
421
+ * ```typescript
422
+ * const sar = bufferSink.buffersinkGetSampleAspectRatio();
423
+ * console.log(`SAR: ${sar.num}:${sar.den}`);
424
+ * ```
425
+ */
426
+ buffersinkGetSampleAspectRatio(): Rational;
427
+ /**
428
+ * Get frame rate from buffer sink.
429
+ *
430
+ * Returns the frame rate of video from a buffer sink filter.
431
+ * Only valid for video buffer sink filters.
432
+ *
433
+ * Direct mapping to av_buffersink_get_frame_rate().
434
+ *
435
+ * @returns Frame rate as Rational
436
+ *
437
+ * @example
438
+ * ```typescript
439
+ * const frameRate = bufferSink.buffersinkGetFrameRate();
440
+ * console.log(`Frame rate: ${frameRate.num}/${frameRate.den} fps`);
441
+ * ```
442
+ */
443
+ buffersinkGetFrameRate(): Rational;
444
+ /**
445
+ * Get sample rate from buffer sink.
446
+ *
447
+ * Returns the sample rate of audio from a buffer sink filter.
448
+ * Only valid for audio buffer sink filters.
449
+ *
450
+ * Direct mapping to av_buffersink_get_sample_rate().
451
+ *
452
+ * @returns Sample rate in Hz
453
+ *
454
+ * @example
455
+ * ```typescript
456
+ * const sampleRate = bufferSink.buffersinkGetSampleRate();
457
+ * console.log(`Sample rate: ${sampleRate} Hz`);
458
+ * ```
459
+ */
460
+ buffersinkGetSampleRate(): number;
461
+ /**
462
+ * Get channel layout from buffer sink.
463
+ *
464
+ * Returns the channel layout of audio from a buffer sink filter.
465
+ * Only valid for audio buffer sink filters.
466
+ *
467
+ * Direct mapping to av_buffersink_get_channel_layout().
468
+ *
469
+ * @returns Channel layout configuration
470
+ *
471
+ * @example
472
+ * ```typescript
473
+ * const layout = bufferSink.buffersinkGetChannelLayout();
474
+ * console.log(`Channels: ${layout.nbChannels}`);
475
+ * ```
476
+ */
477
+ buffersinkGetChannelLayout(): ChannelLayout;
364
478
  /**
365
479
  * Free the filter context.
366
480
  *
367
- * Direct mapping to avfilter_free()
481
+ * Releases all resources associated with the filter context.
482
+ * The context becomes invalid after calling this.
483
+ *
484
+ * Direct mapping to avfilter_free().
368
485
  *
369
486
  * @example
370
487
  * ```typescript
371
- * filterCtx.free();
372
- * // filterCtx is now invalid and should not be used
488
+ * context.free();
489
+ * // Context is now invalid
373
490
  * ```
491
+ *
492
+ * @see {@link Symbol.dispose} For automatic cleanup
374
493
  */
375
494
  free(): void;
376
495
  /**
377
- * Check if this is a source filter context.
496
+ * Check if filter is a source.
378
497
  *
379
- * Source filters have no inputs and generate data.
498
+ * Source filters generate frames without input.
380
499
  *
381
- * @returns true if the filter has no input pads, false otherwise
500
+ * @returns True if filter has no inputs
382
501
  *
383
502
  * @example
384
503
  * ```typescript
385
- * if (filterCtx.isSource()) {
504
+ * if (context.isSource()) {
386
505
  * console.log('This is a source filter');
387
506
  * }
388
507
  * ```
508
+ *
509
+ * @see {@link isSink} To check for sink filters
389
510
  */
390
511
  isSource(): boolean;
391
512
  /**
392
- * Check if this is a sink filter context.
513
+ * Check if filter is a sink.
393
514
  *
394
- * Sink filters have no outputs and consume data.
515
+ * Sink filters consume frames without output.
395
516
  *
396
- * @returns true if the filter has no output pads, false otherwise
517
+ * @returns True if filter has no outputs
397
518
  *
398
519
  * @example
399
520
  * ```typescript
400
- * if (filterCtx.isSink()) {
521
+ * if (context.isSink()) {
401
522
  * console.log('This is a sink filter');
402
523
  * }
403
524
  * ```
525
+ *
526
+ * @see {@link isSource} To check for source filters
404
527
  */
405
528
  isSink(): boolean;
406
529
  /**
407
- * Check if the filter is ready for processing.
530
+ * Check if filter is ready.
408
531
  *
409
- * Filters must be initialized before they can process data.
532
+ * Indicates whether the filter is ready for processing.
410
533
  *
411
- * @returns true if the filter has been properly initialized, false otherwise
534
+ * @returns True if filter is ready
412
535
  *
413
536
  * @example
414
537
  * ```typescript
415
- * filterCtx.initStr('1280:720');
416
- * if (filterCtx.isReady()) {
417
- * console.log('Filter is ready for processing');
538
+ * if (context.isReady()) {
539
+ * // Filter is ready for processing
418
540
  * }
419
541
  * ```
420
542
  */
421
543
  isReady(): boolean;
422
544
  /**
423
- * Get the native FFmpeg AVFilterContext pointer.
545
+ * Get the underlying native FilterContext object.
424
546
  *
425
- * @internal For use by other wrapper classes
426
- * @returns The underlying native filter context object
547
+ * @returns The native FilterContext binding object
548
+ *
549
+ * @internal
427
550
  */
428
551
  getNative(): NativeFilterContext;
429
552
  /**
@@ -435,9 +558,9 @@ export declare class FilterContext extends OptionMember<NativeFilterContext> imp
435
558
  * @example
436
559
  * ```typescript
437
560
  * {
438
- * using filterCtx = filterGraph.createFilter(filter, 'my_filter');
439
- * filterCtx.initStr('args');
440
- * // ... use filter context
561
+ * using context = graph.createFilter(filter, 'test');
562
+ * context.initStr('640:480');
563
+ * // Use context...
441
564
  * } // Automatically freed when leaving scope
442
565
  * ```
443
566
  */