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