node-av 1.1.0 → 1.3.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 (166) hide show
  1. package/README.md +51 -59
  2. package/dist/api/bitstream-filter.d.ts +183 -123
  3. package/dist/api/bitstream-filter.js +185 -127
  4. package/dist/api/bitstream-filter.js.map +1 -1
  5. package/dist/api/decoder.d.ts +282 -130
  6. package/dist/api/decoder.js +290 -142
  7. package/dist/api/decoder.js.map +1 -1
  8. package/dist/api/encoder.d.ts +249 -160
  9. package/dist/api/encoder.js +276 -207
  10. package/dist/api/encoder.js.map +1 -1
  11. package/dist/api/filter-presets.d.ts +1944 -96
  12. package/dist/api/filter-presets.js +2059 -105
  13. package/dist/api/filter-presets.js.map +1 -1
  14. package/dist/api/filter.d.ts +264 -200
  15. package/dist/api/filter.js +269 -231
  16. package/dist/api/filter.js.map +1 -1
  17. package/dist/api/hardware.d.ts +246 -117
  18. package/dist/api/hardware.js +440 -217
  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 -55
  24. package/dist/api/io-stream.js +43 -40
  25. package/dist/api/io-stream.js.map +1 -1
  26. package/dist/api/media-input.d.ts +242 -139
  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 +208 -126
  30. package/dist/api/media-output.js +212 -126
  31. package/dist/api/media-output.js.map +1 -1
  32. package/dist/api/pipeline.d.ts +361 -38
  33. package/dist/api/pipeline.js +255 -14
  34. package/dist/api/pipeline.js.map +1 -1
  35. package/dist/api/types.d.ts +26 -187
  36. package/dist/api/utilities/audio-sample.d.ts +0 -8
  37. package/dist/api/utilities/audio-sample.js +0 -8
  38. package/dist/api/utilities/audio-sample.js.map +1 -1
  39. package/dist/api/utilities/channel-layout.d.ts +0 -8
  40. package/dist/api/utilities/channel-layout.js +0 -8
  41. package/dist/api/utilities/channel-layout.js.map +1 -1
  42. package/dist/api/utilities/image.d.ts +0 -8
  43. package/dist/api/utilities/image.js +0 -8
  44. package/dist/api/utilities/image.js.map +1 -1
  45. package/dist/api/utilities/index.d.ts +3 -3
  46. package/dist/api/utilities/index.js +3 -3
  47. package/dist/api/utilities/index.js.map +1 -1
  48. package/dist/api/utilities/media-type.d.ts +1 -9
  49. package/dist/api/utilities/media-type.js +1 -9
  50. package/dist/api/utilities/media-type.js.map +1 -1
  51. package/dist/api/utilities/pixel-format.d.ts +1 -9
  52. package/dist/api/utilities/pixel-format.js +1 -9
  53. package/dist/api/utilities/pixel-format.js.map +1 -1
  54. package/dist/api/utilities/sample-format.d.ts +1 -9
  55. package/dist/api/utilities/sample-format.js +1 -9
  56. package/dist/api/utilities/sample-format.js.map +1 -1
  57. package/dist/api/utilities/streaming.d.ts +0 -8
  58. package/dist/api/utilities/streaming.js +0 -8
  59. package/dist/api/utilities/streaming.js.map +1 -1
  60. package/dist/api/utilities/timestamp.d.ts +0 -8
  61. package/dist/api/utilities/timestamp.js +0 -8
  62. package/dist/api/utilities/timestamp.js.map +1 -1
  63. package/dist/api/utils.d.ts +1 -2
  64. package/dist/api/utils.js +11 -0
  65. package/dist/api/utils.js.map +1 -1
  66. package/dist/constants/constants.d.ts +1 -1
  67. package/dist/constants/constants.js +2 -0
  68. package/dist/constants/constants.js.map +1 -1
  69. package/dist/lib/audio-fifo.d.ts +127 -170
  70. package/dist/lib/audio-fifo.js +130 -173
  71. package/dist/lib/audio-fifo.js.map +1 -1
  72. package/dist/lib/binding.d.ts +1 -0
  73. package/dist/lib/binding.js +7 -0
  74. package/dist/lib/binding.js.map +1 -1
  75. package/dist/lib/bitstream-filter-context.d.ts +139 -184
  76. package/dist/lib/bitstream-filter-context.js +139 -188
  77. package/dist/lib/bitstream-filter-context.js.map +1 -1
  78. package/dist/lib/bitstream-filter.d.ts +68 -54
  79. package/dist/lib/bitstream-filter.js +68 -54
  80. package/dist/lib/bitstream-filter.js.map +1 -1
  81. package/dist/lib/codec-context.d.ts +316 -380
  82. package/dist/lib/codec-context.js +316 -381
  83. package/dist/lib/codec-context.js.map +1 -1
  84. package/dist/lib/codec-parameters.d.ts +160 -170
  85. package/dist/lib/codec-parameters.js +162 -172
  86. package/dist/lib/codec-parameters.js.map +1 -1
  87. package/dist/lib/codec-parser.d.ts +91 -104
  88. package/dist/lib/codec-parser.js +92 -103
  89. package/dist/lib/codec-parser.js.map +1 -1
  90. package/dist/lib/codec.d.ts +266 -283
  91. package/dist/lib/codec.js +270 -287
  92. package/dist/lib/codec.js.map +1 -1
  93. package/dist/lib/dictionary.d.ts +149 -203
  94. package/dist/lib/dictionary.js +158 -212
  95. package/dist/lib/dictionary.js.map +1 -1
  96. package/dist/lib/error.d.ts +96 -130
  97. package/dist/lib/error.js +98 -128
  98. package/dist/lib/error.js.map +1 -1
  99. package/dist/lib/filter-context.d.ts +284 -218
  100. package/dist/lib/filter-context.js +290 -227
  101. package/dist/lib/filter-context.js.map +1 -1
  102. package/dist/lib/filter-graph.d.ts +251 -292
  103. package/dist/lib/filter-graph.js +253 -294
  104. package/dist/lib/filter-graph.js.map +1 -1
  105. package/dist/lib/filter-inout.d.ts +87 -95
  106. package/dist/lib/filter-inout.js +87 -95
  107. package/dist/lib/filter-inout.js.map +1 -1
  108. package/dist/lib/filter.d.ts +93 -111
  109. package/dist/lib/filter.js +93 -111
  110. package/dist/lib/filter.js.map +1 -1
  111. package/dist/lib/format-context.d.ts +320 -428
  112. package/dist/lib/format-context.js +313 -385
  113. package/dist/lib/format-context.js.map +1 -1
  114. package/dist/lib/frame.d.ts +262 -405
  115. package/dist/lib/frame.js +263 -408
  116. package/dist/lib/frame.js.map +1 -1
  117. package/dist/lib/hardware-device-context.d.ts +149 -203
  118. package/dist/lib/hardware-device-context.js +149 -203
  119. package/dist/lib/hardware-device-context.js.map +1 -1
  120. package/dist/lib/hardware-frames-context.d.ts +170 -180
  121. package/dist/lib/hardware-frames-context.js +171 -181
  122. package/dist/lib/hardware-frames-context.js.map +1 -1
  123. package/dist/lib/index.d.ts +3 -2
  124. package/dist/lib/index.js +3 -3
  125. package/dist/lib/index.js.map +1 -1
  126. package/dist/lib/input-format.d.ts +89 -117
  127. package/dist/lib/input-format.js +89 -117
  128. package/dist/lib/input-format.js.map +1 -1
  129. package/dist/lib/io-context.d.ts +209 -241
  130. package/dist/lib/io-context.js +220 -252
  131. package/dist/lib/io-context.js.map +1 -1
  132. package/dist/lib/log.d.ts +85 -119
  133. package/dist/lib/log.js +85 -122
  134. package/dist/lib/log.js.map +1 -1
  135. package/dist/lib/native-types.d.ts +118 -106
  136. package/dist/lib/native-types.js +0 -7
  137. package/dist/lib/native-types.js.map +1 -1
  138. package/dist/lib/option.d.ts +437 -218
  139. package/dist/lib/option.js +462 -226
  140. package/dist/lib/option.js.map +1 -1
  141. package/dist/lib/output-format.d.ts +77 -101
  142. package/dist/lib/output-format.js +77 -101
  143. package/dist/lib/output-format.js.map +1 -1
  144. package/dist/lib/packet.d.ts +172 -240
  145. package/dist/lib/packet.js +172 -241
  146. package/dist/lib/packet.js.map +1 -1
  147. package/dist/lib/rational.d.ts +0 -2
  148. package/dist/lib/rational.js +0 -2
  149. package/dist/lib/rational.js.map +1 -1
  150. package/dist/lib/software-resample-context.d.ts +241 -325
  151. package/dist/lib/software-resample-context.js +242 -326
  152. package/dist/lib/software-resample-context.js.map +1 -1
  153. package/dist/lib/software-scale-context.d.ts +129 -173
  154. package/dist/lib/software-scale-context.js +131 -175
  155. package/dist/lib/software-scale-context.js.map +1 -1
  156. package/dist/lib/stream.d.ts +87 -197
  157. package/dist/lib/stream.js +87 -197
  158. package/dist/lib/stream.js.map +1 -1
  159. package/dist/lib/utilities.d.ts +435 -181
  160. package/dist/lib/utilities.js +438 -182
  161. package/dist/lib/utilities.js.map +1 -1
  162. package/install/check.js +0 -1
  163. package/install/ffmpeg.js +0 -11
  164. package/package.json +25 -18
  165. package/release_notes.md +24 -59
  166. package/CHANGELOG.md +0 -8
@@ -5,536 +5,495 @@ import type { FilterInOut } from './filter-inout.js';
5
5
  import type { Filter } from './filter.js';
6
6
  import type { NativeFilterGraph, NativeWrapper } from './native-types.js';
7
7
  /**
8
- * Filter graph for media processing.
8
+ * Filter graph for audio/video processing pipelines.
9
9
  *
10
- * Container for filters and their connections in a processing pipeline.
11
- * Manages the entire filtering system from sources to sinks.
12
- * Supports complex filter chains with multiple inputs and outputs.
10
+ * Manages a collection of interconnected filters forming a processing pipeline.
11
+ * Filters are connected through their input/output pads to create complex
12
+ * audio/video transformations. Supports both simple linear chains and complex
13
+ * graphs with multiple inputs/outputs. Essential for effects, format conversions,
14
+ * scaling, and other media processing operations.
13
15
  *
14
16
  * Direct mapping to FFmpeg's AVFilterGraph.
15
17
  *
16
18
  * @example
17
19
  * ```typescript
18
- * import { FilterGraph, Filter, FilterContext, FFmpegError } from 'node-av';
20
+ * import { FilterGraph, Filter, FilterInOut, FFmpegError } from 'node-av';
19
21
  *
20
- * // Create and configure a simple filter graph
22
+ * // Create and configure filter graph
21
23
  * const graph = new FilterGraph();
22
24
  * graph.alloc();
23
25
  *
24
- * // Create buffer source
25
- * const bufferFilter = Filter.getByName('buffer');
26
- * if (!bufferFilter) throw new Error('Buffer filter not found');
26
+ * // Create filters
27
27
  * const bufferSrc = graph.createFilter(
28
- * bufferFilter,
29
- * 'in',
30
- * 'video_size=1920x1080:pix_fmt=yuv420p:time_base=1/25'
28
+ * Filter.getByName('buffer')!,
29
+ * 'src',
30
+ * 'video_size=1920x1080:pix_fmt=yuv420p'
31
31
  * );
32
- * if (!bufferSrc) throw new Error('Failed to create buffer source');
33
32
  *
34
- * // Create scale filter
35
- * const scaleFilter = Filter.getByName('scale');
36
- * if (!scaleFilter) throw new Error('Scale filter not found');
37
33
  * const scale = graph.createFilter(
38
- * scaleFilter,
34
+ * Filter.getByName('scale')!,
39
35
  * 'scale',
40
- * '1280:720'
36
+ * '640:480'
41
37
  * );
42
- * if (!scale) throw new Error('Failed to create scale filter');
43
38
  *
44
- * // Create buffer sink
45
- * const sinkFilter = Filter.getByName('buffersink');
46
- * if (!sinkFilter) throw new Error('Buffersink filter not found');
47
39
  * const bufferSink = graph.createFilter(
48
- * sinkFilter,
49
- * 'out'
40
+ * Filter.getByName('buffersink')!,
41
+ * 'sink'
50
42
  * );
51
- * if (!bufferSink) throw new Error('Failed to create buffer sink');
52
43
  *
53
44
  * // Link filters
54
- * const linkRet1 = bufferSrc.link(0, scale, 0);
55
- * FFmpegError.throwIfError(linkRet1, 'link buffer to scale');
45
+ * bufferSrc.link(0, scale, 0);
46
+ * scale.link(0, bufferSink, 0);
56
47
  *
57
- * const linkRet2 = scale.link(0, bufferSink, 0);
58
- * FFmpegError.throwIfError(linkRet2, 'link scale to sink');
48
+ * // Configure graph
49
+ * const ret = await graph.config();
50
+ * FFmpegError.throwIfError(ret, 'config');
59
51
  *
60
- * // Configure the graph
61
- * const configRet = graph.config();
62
- * FFmpegError.throwIfError(configRet, 'config');
63
- *
64
- * // Clean up
65
- * graph.free();
52
+ * // Parse filter string
53
+ * const ret2 = graph.parse2('[in]scale=640:480[out]');
54
+ * FFmpegError.throwIfError(ret2, 'parse2');
66
55
  * ```
56
+ *
57
+ * @see [AVFilterGraph](https://ffmpeg.org/doxygen/trunk/structAVFilterGraph.html) - FFmpeg Doxygen
58
+ * @see {@link FilterContext} For filter instances
59
+ * @see {@link Filter} For filter descriptors
67
60
  */
68
61
  export declare class FilterGraph extends OptionMember<NativeFilterGraph> implements Disposable, NativeWrapper<NativeFilterGraph> {
69
- /**
70
- * Create a new FilterGraph instance.
71
- *
72
- * The graph is uninitialized - you must call alloc() before use.
73
- * No FFmpeg resources are allocated until alloc() is called.
74
- *
75
- * Direct wrapper around AVFilterGraph.
76
- *
77
- * @example
78
- * ```typescript
79
- * import { FilterGraph } from 'node-av';
80
- *
81
- * const graph = new FilterGraph();
82
- * graph.alloc();
83
- * // Graph is now ready for use
84
- * ```
85
- */
86
62
  constructor();
87
63
  /**
88
64
  * Number of filters in the graph.
89
65
  *
90
- * Direct mapping to AVFilterGraph->nb_filters
66
+ * Total count of filter contexts in this graph.
91
67
  *
92
- * The total count of filters currently in the graph.
68
+ * Direct mapping to AVFilterGraph->nb_filters.
93
69
  */
94
70
  get nbFilters(): number;
95
71
  /**
96
- * Array of all filters in the graph.
97
- *
98
- * Direct mapping to AVFilterGraph->filters
72
+ * Array of filters in the graph.
99
73
  *
100
74
  * All filter contexts currently in the graph.
75
+ *
76
+ * Direct mapping to AVFilterGraph->filters.
101
77
  */
102
78
  get filters(): FilterContext[] | null;
103
79
  /**
104
- * Thread type for graph processing.
80
+ * Threading type for graph execution.
105
81
  *
106
- * Direct mapping to AVFilterGraph->thread_type
82
+ * Controls how filters are executed in parallel.
83
+ * Use AVFILTER_THREAD_SLICE for slice-based threading.
107
84
  *
108
- * Controls threading behavior of the graph (0 = disabled, AVFILTER_THREAD_SLICE = slice threading).
85
+ * Direct mapping to AVFilterGraph->thread_type.
109
86
  */
110
87
  get threadType(): AVFilterConstants;
111
88
  set threadType(value: AVFilterConstants);
112
89
  /**
113
- * Number of threads for graph processing.
90
+ * Number of threads for parallel processing.
114
91
  *
115
- * Direct mapping to AVFilterGraph->nb_threads
92
+ * Number of threads used for filter execution.
93
+ * 0 means automatic detection.
116
94
  *
117
- * 0 means automatic detection based on CPU cores.
95
+ * Direct mapping to AVFilterGraph->nb_threads.
118
96
  */
119
97
  get nbThreads(): number;
120
98
  set nbThreads(value: number);
121
99
  /**
122
- * Software scaler options.
100
+ * Swscale options for scale filter.
123
101
  *
124
- * Direct mapping to AVFilterGraph->scale_sws_opts
102
+ * Options string passed to swscale for scaling operations.
125
103
  *
126
- * Options string passed to the software scaler (e.g., "flags=bicubic").
104
+ * Direct mapping to AVFilterGraph->scale_sws_opts.
127
105
  */
128
106
  get scaleSwsOpts(): string | null;
129
107
  set scaleSwsOpts(value: string | null);
130
108
  /**
131
- * Allocate the filter graph.
109
+ * Allocate a filter graph.
132
110
  *
133
- * Allocates the graph structure and initializes it.
134
- * Must be called before adding filters to the graph.
111
+ * Allocates memory for the filter graph structure.
112
+ * Must be called before using the graph.
135
113
  *
136
- * Direct mapping to avfilter_graph_alloc()
114
+ * Direct mapping to avfilter_graph_alloc().
137
115
  *
138
- * @throws {Error} Memory allocation failure (ENOMEM)
116
+ * @throws {Error} If allocation fails (ENOMEM)
139
117
  *
140
118
  * @example
141
119
  * ```typescript
142
- * import { FilterGraph } from 'node-av';
143
- *
144
120
  * const graph = new FilterGraph();
145
121
  * graph.alloc();
146
- * // Graph is now allocated and ready
122
+ * // Graph is now ready for filter creation
147
123
  * ```
148
124
  *
149
- * @see {@link free} To free the graph
125
+ * @see {@link free} To deallocate
126
+ * @see {@link config} To configure after building
150
127
  */
151
128
  alloc(): void;
152
129
  /**
153
130
  * Free the filter graph.
154
131
  *
155
- * Releases all resources associated with the graph.
156
- * All filters in the graph are also freed.
132
+ * Releases all resources associated with the graph,
133
+ * including all contained filters.
157
134
  *
158
- * Direct mapping to avfilter_graph_free()
135
+ * Direct mapping to avfilter_graph_free().
159
136
  *
160
137
  * @example
161
138
  * ```typescript
162
139
  * graph.free();
163
- * // graph is now invalid and should not be used
140
+ * // Graph is now invalid
164
141
  * ```
142
+ *
143
+ * @see {@link alloc} To allocate
144
+ * @see {@link Symbol.dispose} For automatic cleanup
165
145
  */
166
146
  free(): void;
167
147
  /**
168
- * Create a filter instance in the graph.
148
+ * Create and initialize a filter in the graph.
169
149
  *
170
- * Direct mapping to avfilter_graph_create_filter()
150
+ * Creates a new filter context, adds it to the graph,
151
+ * and initializes it with the provided arguments.
171
152
  *
172
- * @param filter - The filter definition
173
- * @param name - Name for this filter instance (must be unique in the graph)
174
- * @param args - Optional initialization arguments (filter-specific format)
153
+ * Direct mapping to avfilter_graph_create_filter().
175
154
  *
176
- * @returns The created filter context or null on failure
155
+ * @param filter - Filter descriptor to instantiate
156
+ * @param name - Name for this filter instance
157
+ * @param args - Initialization arguments (filter-specific)
158
+ * @returns Created filter context, or null on failure
177
159
  *
178
160
  * @example
179
161
  * ```typescript
180
162
  * // Create a scale filter
181
- * const scaleFilter = Filter.getByName('scale');
182
- * const scaleCtx = graph.createFilter(
183
- * scaleFilter!,
184
- * 'my_scale',
185
- * '1280:720' // width:height
163
+ * const scale = graph.createFilter(
164
+ * Filter.getByName('scale')!,
165
+ * 'scaler',
166
+ * '640:480' // width:height
186
167
  * );
187
168
  *
188
- * // Create a buffer source for video
189
- * const bufferFilter = Filter.getByName('buffer');
190
- * const bufferCtx = graph.createFilter(
191
- * bufferFilter!,
192
- * 'video_in',
193
- * 'video_size=1920x1080:pix_fmt=yuv420p:time_base=1/25:pixel_aspect=1/1'
169
+ * // Create a buffer source
170
+ * const src = graph.createFilter(
171
+ * Filter.getByName('buffer')!,
172
+ * 'source',
173
+ * 'video_size=1920x1080:pix_fmt=yuv420p:time_base=1/25'
194
174
  * );
195
175
  * ```
176
+ *
177
+ * @see {@link allocFilter} To allocate without initializing
178
+ * @see {@link getFilter} To retrieve by name
196
179
  */
197
180
  createFilter(filter: Filter, name: string, args?: string | null): FilterContext | null;
198
181
  /**
199
- * Allocate a filter instance in the graph without initializing it.
182
+ * Allocate a filter in the graph.
200
183
  *
201
- * Direct mapping to avfilter_graph_alloc_filter()
184
+ * Creates a new filter context and adds it to the graph,
185
+ * but does not initialize it. Call init() on the context afterwards.
202
186
  *
203
- * This method allocates the filter but does not initialize it.
204
- * You must call filter.init() or filter.initStr() afterwards.
187
+ * Direct mapping to avfilter_graph_alloc_filter().
205
188
  *
206
- * @param filter - The filter definition
207
- * @param name - Name for this filter instance (must be unique in the graph)
208
- *
209
- * @returns The allocated filter context or null on failure
189
+ * @param filter - Filter descriptor to instantiate
190
+ * @param name - Name for this filter instance
191
+ * @returns Allocated filter context, or null on failure
210
192
  *
211
193
  * @example
212
194
  * ```typescript
213
- * import { FilterGraph, Filter, FFmpegError } from 'node-av';
214
- *
215
- * // Allocate a filter without initializing
216
- * const scaleFilter = Filter.getByName('scale');
217
- * if (!scaleFilter) throw new Error('Scale filter not found');
218
- * const scaleCtx = graph.allocFilter(scaleFilter, 'my_scale');
219
- * if (!scaleCtx) throw new Error('Failed to allocate filter');
220
- *
221
- * // Set options using setOpt
222
- * const ret1 = scaleCtx.setOpt('width', '1280');
223
- * FFmpegError.throwIfError(ret1, 'setOpt width');
224
- * const ret2 = scaleCtx.setOpt('height', '720');
225
- * FFmpegError.throwIfError(ret2, 'setOpt height');
226
- *
227
- * // Initialize the filter
228
- * const initRet = scaleCtx.init();
229
- * FFmpegError.throwIfError(initRet, 'init');
195
+ * import { FFmpegError } from 'node-av';
196
+ *
197
+ * const filter = graph.allocFilter(
198
+ * Filter.getByName('scale')!,
199
+ * 'scaler'
200
+ * );
201
+ * if (filter) {
202
+ * // Initialize separately
203
+ * const ret = filter.initStr('640:480');
204
+ * FFmpegError.throwIfError(ret, 'initStr');
205
+ * }
230
206
  * ```
231
207
  *
232
- * @note This provides an alternative workflow to createFilter,
233
- * allowing options to be set before initialization.
208
+ * @see {@link createFilter} To allocate and initialize
234
209
  */
235
210
  allocFilter(filter: Filter, name: string): FilterContext | null;
236
211
  /**
237
212
  * Get a filter by name from the graph.
238
213
  *
239
- * Direct mapping to avfilter_graph_get_filter()
214
+ * Retrieves an existing filter context by its instance name.
240
215
  *
241
- * @param name - The filter instance name
216
+ * Direct mapping to avfilter_graph_get_filter().
242
217
  *
243
- * @returns The filter context or null if not found
218
+ * @param name - Name of the filter instance
219
+ * @returns Filter context if found, null otherwise
244
220
  *
245
221
  * @example
246
222
  * ```typescript
247
- * const scaleCtx = graph.getFilter('my_scale');
248
- * if (scaleCtx) {
249
- * console.log('Found scale filter');
223
+ * // Find a previously created filter
224
+ * const scaler = graph.getFilter('scaler');
225
+ * if (scaler) {
226
+ * console.log('Found scaler filter');
250
227
  * }
251
228
  * ```
229
+ *
230
+ * @see {@link createFilter} To create new filters
252
231
  */
253
232
  getFilter(name: string): FilterContext | null;
254
233
  /**
255
234
  * Configure the filter graph.
256
235
  *
257
- * Direct mapping to avfilter_graph_config()
236
+ * Validates and finalizes the graph configuration.
237
+ * Must be called after all filters are created and linked.
238
+ *
239
+ * Direct mapping to avfilter_graph_config().
258
240
  *
259
241
  * @returns 0 on success, negative AVERROR on error:
260
- * - 0: Success
261
- * - AVERROR(EINVAL): Invalid graph configuration
262
- * - AVERROR(ENOMEM): Memory allocation failure
263
- * - <0: Other configuration errors
242
+ * - AVERROR_EINVAL: Invalid graph configuration
243
+ * - AVERROR_ENOMEM: Memory allocation failure
264
244
  *
265
245
  * @example
266
246
  * ```typescript
267
- * import { FilterGraph, FFmpegError } from 'node-av';
247
+ * import { FFmpegError } from 'node-av';
268
248
  *
269
- * // After creating and linking all filters
270
- * const ret = graph.config();
249
+ * // Build graph...
250
+ * // Link filters...
251
+ *
252
+ * // Configure the complete graph
253
+ * const ret = await graph.config();
271
254
  * FFmpegError.throwIfError(ret, 'config');
272
255
  * // Graph is now ready for processing
273
256
  * ```
274
257
  *
275
- * @note Must be called after all filters are added and connected.
258
+ * @see {@link validate} To check configuration
276
259
  */
277
260
  config(): Promise<number>;
278
261
  /**
279
- * Parse a filtergraph description.
262
+ * Parse a filter graph description.
280
263
  *
281
- * Direct mapping to avfilter_graph_parse()
264
+ * Parses a textual representation of a filter graph and adds
265
+ * filters to this graph. Handles labeled inputs and outputs.
282
266
  *
283
- * @param filters - Filtergraph description string
284
- * @param inputs - Input pad list
285
- * @param outputs - Output pad list
267
+ * Direct mapping to avfilter_graph_parse().
286
268
  *
269
+ * @param filters - Filter graph description string
270
+ * @param inputs - Linked list of graph inputs
271
+ * @param outputs - Linked list of graph outputs
287
272
  * @returns 0 on success, negative AVERROR on error:
288
- * - 0: Success
289
- * - AVERROR(EINVAL): Invalid filtergraph syntax
290
- * - AVERROR(ENOMEM): Memory allocation failure
291
- * - <0: Other parsing errors
273
+ * - AVERROR_EINVAL: Parse error
274
+ * - AVERROR_ENOMEM: Memory allocation failure
292
275
  *
293
276
  * @example
294
277
  * ```typescript
295
- * import { FilterGraph, FilterInOut, FFmpegError } from 'node-av';
296
- *
297
- * const inputs = new FilterInOut();
298
- * inputs.alloc();
299
- * inputs.name = 'in';
300
- * inputs.filterCtx = bufferSrcCtx;
301
- * inputs.padIdx = 0;
302
- *
303
- * const outputs = new FilterInOut();
304
- * outputs.alloc();
305
- * outputs.name = 'out';
306
- * outputs.filterCtx = bufferSinkCtx;
307
- * outputs.padIdx = 0;
308
- *
309
- * const ret = graph.parse('[in] scale=1280:720 [out]', inputs, outputs);
278
+ * import { FFmpegError, FilterInOut } from 'node-av';
279
+ *
280
+ * const inputs = FilterInOut.createList([
281
+ * { name: 'in', filterCtx: bufferSrc, padIdx: 0 }
282
+ * ]);
283
+ * const outputs = FilterInOut.createList([
284
+ * { name: 'out', filterCtx: bufferSink, padIdx: 0 }
285
+ * ]);
286
+ *
287
+ * const ret = graph.parse(
288
+ * '[in]scale=640:480,format=yuv420p[out]',
289
+ * inputs,
290
+ * outputs
291
+ * );
310
292
  * FFmpegError.throwIfError(ret, 'parse');
311
293
  * ```
294
+ *
295
+ * @see {@link parse2} For simpler syntax
296
+ * @see {@link parsePtr} For alternative parsing
312
297
  */
313
298
  parse(filters: string, inputs: FilterInOut | null, outputs: FilterInOut | null): number;
314
299
  /**
315
- * Parse a filtergraph description (simplified).
300
+ * Parse a filter graph description (simplified).
316
301
  *
317
- * Direct mapping to avfilter_graph_parse2()
302
+ * Parses a textual filter description with automatic input/output handling.
303
+ * Simpler than parse() but less flexible.
318
304
  *
319
- * @param filters - Filtergraph description string
305
+ * Direct mapping to avfilter_graph_parse2().
320
306
  *
307
+ * @param filters - Filter graph description string
321
308
  * @returns 0 on success, negative AVERROR on error:
322
- * - 0: Success
323
- * - AVERROR(EINVAL): Invalid filtergraph syntax
324
- * - AVERROR(ENOMEM): Memory allocation failure
325
- * - <0: Other parsing errors
309
+ * - AVERROR_EINVAL: Parse error
310
+ * - AVERROR_ENOMEM: Memory allocation failure
326
311
  *
327
312
  * @example
328
313
  * ```typescript
329
- * import { FilterGraph, FFmpegError } from 'node-av';
314
+ * import { FFmpegError } from 'node-av';
330
315
  *
331
316
  * // Parse a simple filter chain
332
- * const ret = graph.parse2('scale=1280:720,format=yuv420p');
317
+ * const ret = graph.parse2(
318
+ * 'scale=640:480,format=yuv420p'
319
+ * );
333
320
  * FFmpegError.throwIfError(ret, 'parse2');
334
321
  * ```
335
322
  *
336
- * @note Automatically handles inputs and outputs.
323
+ * @see {@link parse} For labeled inputs/outputs
337
324
  */
338
325
  parse2(filters: string): number;
339
326
  /**
340
- * Parse a filtergraph description (pointer version).
327
+ * Parse a filter graph description with pointer.
341
328
  *
342
- * Direct mapping to avfilter_graph_parse_ptr()
329
+ * Alternative parsing method with different parameter handling.
343
330
  *
344
- * @param filters - Filtergraph description string
345
- * @param inputs - Optional input pad list (FilterInOut)
346
- * @param outputs - Optional output pad list (FilterInOut)
331
+ * Direct mapping to avfilter_graph_parse_ptr().
347
332
  *
333
+ * @param filters - Filter graph description string
334
+ * @param inputs - Optional linked list of inputs
335
+ * @param outputs - Optional linked list of outputs
348
336
  * @returns 0 on success, negative AVERROR on error:
349
- * - 0: Success
350
- * - AVERROR(EINVAL): Invalid filtergraph syntax
351
- * - AVERROR(ENOMEM): Memory allocation failure
352
- * - <0: Other parsing errors
337
+ * - AVERROR_EINVAL: Parse error
338
+ * - AVERROR_ENOMEM: Memory allocation failure
353
339
  *
354
340
  * @example
355
341
  * ```typescript
356
- * import { FilterGraph, FFmpegError } from 'node-av';
342
+ * import { FFmpegError } from 'node-av';
357
343
  *
358
- * // Parse a complex filter graph
359
344
  * const ret = graph.parsePtr(
360
- * '[0:v] scale=1280:720 [scaled]; [scaled] split [out1][out2]'
345
+ * '[in]scale=w=640:h=480[out]'
361
346
  * );
362
347
  * FFmpegError.throwIfError(ret, 'parsePtr');
363
348
  * ```
364
349
  *
365
- * @example
366
- * ```typescript
367
- * import { FilterGraph, FilterInOut, FFmpegError } from 'node-av';
368
- *
369
- * // Parse with explicit inputs/outputs
370
- * const inputs = new FilterInOut();
371
- * inputs.name = 'in';
372
- * inputs.filterCtx = buffersrcCtx;
373
- * inputs.padIdx = 0;
374
- *
375
- * const outputs = new FilterInOut();
376
- * outputs.name = 'out';
377
- * outputs.filterCtx = buffersinkCtx;
378
- * outputs.padIdx = 0;
379
- *
380
- * const ret = graph.parsePtr(filtersDescr, inputs, outputs);
381
- * FFmpegError.throwIfError(ret, 'parsePtr');
382
- * ```
383
- *
384
- * @note Similar to parse2 but with different internal handling.
350
+ * @see {@link parse} For standard parsing
351
+ * @see {@link parse2} For simplified parsing
385
352
  */
386
353
  parsePtr(filters: string, inputs?: FilterInOut | null, outputs?: FilterInOut | null): number;
387
354
  /**
388
- * Validate the filter graph.
355
+ * Validate the filter graph configuration.
389
356
  *
390
- * Direct mapping to avfilter_graph_validate()
357
+ * Checks if the graph is valid and properly configured.
358
+ * Does not finalize the graph like config() does.
391
359
  *
392
360
  * @returns 0 on success, negative AVERROR on error:
393
- * - 0: Valid graph structure
394
- * - AVERROR(EINVAL): Invalid graph structure
395
- * - <0: Other validation errors
361
+ * - AVERROR_EINVAL: Invalid configuration
396
362
  *
397
363
  * @example
398
364
  * ```typescript
399
- * // Validate before configuring
365
+ * import { FFmpegError } from 'node-av';
366
+ *
400
367
  * const ret = graph.validate();
401
- * if (ret < 0) {
402
- * console.error('Graph validation failed');
403
- * }
368
+ * FFmpegError.throwIfError(ret, 'validate');
404
369
  * ```
405
370
  *
406
- * @note Checks that the graph structure is valid without configuring it.
371
+ * @see {@link config} To configure and finalize
407
372
  */
408
373
  validate(): number;
409
374
  /**
410
375
  * Request a frame from the oldest sink.
411
376
  *
412
- * Direct mapping to avfilter_graph_request_oldest()
377
+ * Requests that a frame be output from the oldest sink in the graph.
378
+ * Used to drive the filter graph processing.
379
+ *
380
+ * Direct mapping to avfilter_graph_request_oldest().
413
381
  *
414
382
  * @returns 0 on success, negative AVERROR on error:
415
- * - 0: Success
416
- * - AVERROR_EOF: No more frames available
417
- * - AVERROR(EAGAIN): Need more input data
418
- * - <0: Other processing errors
383
+ * - AVERROR_EOF: End of stream reached
384
+ * - AVERROR_EAGAIN: Need more input
419
385
  *
420
386
  * @example
421
387
  * ```typescript
422
- * import { FilterGraph, FFmpegError } from 'node-av';
388
+ * import { FFmpegError } from 'node-av';
423
389
  * import { AVERROR_EOF, AVERROR_EAGAIN } from 'node-av/constants';
424
390
  *
425
- * // Pull frames from the graph
426
- * while (true) {
427
- * const ret = await graph.requestOldest();
428
- * if (FFmpegError.is(ret, AVERROR_EOF)) {
429
- * break; // No more frames
430
- * }
431
- * if (ret < 0 && !FFmpegError.is(ret, AVERROR_EAGAIN)) {
432
- * FFmpegError.throwIfError(ret, 'requestOldest');
433
- * }
434
- * // Process output from sinks
391
+ * const ret = await graph.requestOldest();
392
+ * if (ret === AVERROR_EOF) {
393
+ * // No more frames
394
+ * } else if (ret === AVERROR_EAGAIN) {
395
+ * // Need to provide more input
396
+ * } else {
397
+ * FFmpegError.throwIfError(ret, 'requestOldest');
435
398
  * }
436
399
  * ```
437
- *
438
- * @note Triggers processing in the graph to produce output.
439
400
  */
440
401
  requestOldest(): Promise<number>;
441
402
  /**
442
- * Get the graph structure as a string.
403
+ * Dump the filter graph to a string.
443
404
  *
444
- * Returns a string representation of the filter graph in DOT format.
445
- * Uses avfilter_graph_dump() internally.
405
+ * Returns a textual representation of the graph structure.
406
+ * Useful for debugging and visualization.
446
407
  *
447
- * @returns String representation of the filter graph or null if not allocated
408
+ * Direct mapping to avfilter_graph_dump().
409
+ *
410
+ * @returns Graph description string, or null on failure
448
411
  *
449
412
  * @example
450
413
  * ```typescript
451
- * const graphDescription = graph.dump();
452
- * console.log('Filter graph:', graphDescription);
414
+ * const graphStr = graph.dump();
415
+ * if (graphStr) {
416
+ * console.log('Graph structure:');
417
+ * console.log(graphStr);
418
+ * }
453
419
  * ```
454
420
  */
455
421
  dump(): string | null;
456
422
  /**
457
- * Send a command to one or more filters in the graph.
458
- *
459
- * Direct mapping to avfilter_graph_send_command()
460
- *
461
- * @param target - Filter name or "all" to send to all filters
462
- * @param cmd - Command name (e.g., "volume", "hue", "rate")
463
- * @param arg - Command argument (e.g., "0.5", "2.0")
464
- * @param flags - Command flags (AVFilterCmdFlag, default: 0)
465
- * - AVFILTER_CMD_FLAG_ONE: Stop once a filter understood the command
466
- * - AVFILTER_CMD_FLAG_FAST: Only execute if fast (hardware acceleration)
423
+ * Send a command to filters in the graph.
467
424
  *
468
- * @returns Error code (negative) or response object { response: string | null }
425
+ * Sends a command to one or more filters for immediate execution.
426
+ * Target can be a specific filter name or "all" for all filters.
469
427
  *
470
- * @example
471
- * ```typescript
472
- * import { FilterGraph, FFmpegError, AVFILTER_CMD_FLAG_ONE } from 'node-av';
428
+ * Direct mapping to avfilter_graph_send_command().
473
429
  *
474
- * // Send volume change command to audio filter
475
- * const result = graph.sendCommand('volume', 'volume', '0.5');
476
- * if (typeof result === 'number') {
477
- * console.error('Command failed:', FFmpegError.strerror(result));
478
- * } else {
479
- * console.log('Response:', result.response);
480
- * }
481
- * ```
430
+ * @param target - Filter name or "all"
431
+ * @param cmd - Command to send
432
+ * @param arg - Command argument
433
+ * @param flags - Command flags
434
+ * @returns Error code or response object
482
435
  *
483
436
  * @example
484
437
  * ```typescript
485
- * // Send command to all filters, stop at first one that handles it
486
- * const result = graph.sendCommand('all', 'enable', 'expr=gte(t,10)', AVFILTER_CMD_FLAG_ONE);
487
- *
488
438
  * // Send command to specific filter
489
- * const result = graph.sendCommand('scale', 'width', '1920');
439
+ * const result = graph.sendCommand(
440
+ * 'volume',
441
+ * 'volume',
442
+ * '0.5'
443
+ * );
444
+ *
445
+ * // Send to all filters
446
+ * const result2 = graph.sendCommand(
447
+ * 'all',
448
+ * 'enable',
449
+ * 'timeline'
450
+ * );
490
451
  * ```
491
452
  *
492
- * @note Not all filters support commands. Check filter documentation.
453
+ * @see {@link queueCommand} For delayed execution
493
454
  */
494
455
  sendCommand(target: string, cmd: string, arg: string, flags?: AVFilterCmdFlag): number | {
495
456
  response: string | null;
496
457
  };
497
458
  /**
498
- * Queue a command to be executed at a specific time.
459
+ * Queue a command for delayed execution.
499
460
  *
500
- * Direct mapping to avfilter_graph_queue_command()
461
+ * Schedules a command to be executed at a specific timestamp.
462
+ * The command is executed when the filter processes a frame with that timestamp.
501
463
  *
502
- * @param target - Filter name or "all" to send to all filters
503
- * @param cmd - Command name (e.g., "volume", "hue", "rate")
504
- * @param arg - Command argument (e.g., "0.5", "2.0")
505
- * @param ts - Timestamp when the command should be executed
506
- * @param flags - Command flags (AVFilterCmdFlag, default: 0)
507
- * - AVFILTER_CMD_FLAG_ONE: Stop once a filter understood the command
508
- * - AVFILTER_CMD_FLAG_FAST: Only execute if fast (hardware acceleration)
464
+ * Direct mapping to avfilter_graph_queue_command().
509
465
  *
466
+ * @param target - Filter name or "all"
467
+ * @param cmd - Command to queue
468
+ * @param arg - Command argument
469
+ * @param ts - Timestamp for execution
470
+ * @param flags - Command flags
510
471
  * @returns 0 on success, negative AVERROR on error
511
472
  *
512
473
  * @example
513
474
  * ```typescript
514
- * import { FilterGraph, FFmpegError, AVFILTER_CMD_FLAG_ONE } from 'node-av';
515
- *
516
- * // Queue volume change at 10 seconds
517
- * const ret = graph.queueCommand('volume', 'volume', '0.2', 10.0);
475
+ * import { FFmpegError } from 'node-av';
476
+ *
477
+ * // Queue volume change at 5 seconds
478
+ * const ret = graph.queueCommand(
479
+ * 'volume',
480
+ * 'volume',
481
+ * '0.2',
482
+ * 5000000, // microseconds
483
+ * 0
484
+ * );
518
485
  * FFmpegError.throwIfError(ret, 'queueCommand');
519
486
  * ```
520
487
  *
521
- * @example
522
- * ```typescript
523
- * // Queue multiple commands at different times
524
- * graph.queueCommand('volume', 'volume', '0.5', 5.0);
525
- * graph.queueCommand('volume', 'volume', '1.0', 10.0);
526
- * graph.queueCommand('volume', 'volume', '0.2', 15.0);
527
- * ```
528
- *
529
- * @note Commands are executed when processing frames with matching timestamps.
530
- * @note Not all filters support queued commands.
488
+ * @see {@link sendCommand} For immediate execution
531
489
  */
532
490
  queueCommand(target: string, cmd: string, arg: string, ts: number, flags?: AVFilterCmdFlag): number;
533
491
  /**
534
- * Get the native FFmpeg AVFilterGraph pointer.
492
+ * Get the underlying native FilterGraph object.
493
+ *
494
+ * @returns The native FilterGraph binding object
535
495
  *
536
- * @internal For use by other wrapper classes
537
- * @returns The underlying native filter graph object
496
+ * @internal
538
497
  */
539
498
  getNative(): NativeFilterGraph;
540
499
  /**
@@ -548,7 +507,7 @@ export declare class FilterGraph extends OptionMember<NativeFilterGraph> impleme
548
507
  * {
549
508
  * using graph = new FilterGraph();
550
509
  * graph.alloc();
551
- * // ... use graph
510
+ * // Build and use graph...
552
511
  * } // Automatically freed when leaving scope
553
512
  * ```
554
513
  */