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
@@ -1,68 +1,43 @@
1
- /**
2
- * Filter - High-level wrapper for media filtering
3
- *
4
- * Implements FFmpeg CLI's filter graph behavior with proper hardware context handling.
5
- * Uses lazy initialization for hardware inputs: graph is built when first frame arrives
6
- * with hw_frames_ctx. For software inputs, initializes immediately.
7
- *
8
- * Handles filter graph creation, frame processing, and format conversion.
9
- * Supports complex filter chains and hardware-accelerated filters.
10
- *
11
- * @module api/filter
12
- */
13
1
  import { Frame } from '../lib/index.js';
14
2
  import type { AVFilterCmdFlag, AVMediaType } from '../constants/constants.js';
15
3
  import type { FilterOptions, StreamInfo } from './types.js';
16
4
  /**
17
- * High-level filter API for media processing.
18
- *
19
- * Provides a simplified interface for FFmpeg's filter system.
20
- * Supports both simple filter chains and complex filter graphs.
21
- * Handles automatic format negotiation and buffer management.
5
+ * High-level filter API for audio and video processing.
22
6
  *
23
- * The filter graph uses lazy initialization for hardware inputs - it's built when
24
- * the first frame arrives with hw_frames_ctx. This matches FFmpeg CLI behavior
25
- * for proper hardware context propagation.
7
+ * Provides simplified interface for applying FFmpeg filters to frames.
8
+ * Handles filter graph construction, frame buffering, and command control.
9
+ * Supports both software and hardware-accelerated filtering operations.
10
+ * Essential component for effects, transformations, and format conversions.
26
11
  *
27
12
  * @example
28
13
  * ```typescript
29
- * import { FilterAPI, Frame } from '@seydx/av/api';
14
+ * import { FilterAPI } from 'node-av/api';
30
15
  *
31
- * // Simple video filter from a stream
32
- * const videoStream = media.video();
33
- * const filter = await FilterAPI.create('scale=1280:720,format=yuv420p', videoStream);
16
+ * // Create video filter
17
+ * const filter = await FilterAPI.create('scale=1280:720', videoInfo);
34
18
  *
35
- * // Process frames
36
- * const outputFrame = await filter.process(inputFrame);
19
+ * // Process frame
20
+ * const output = await filter.process(inputFrame);
21
+ * if (output) {
22
+ * console.log(`Filtered frame: ${output.width}x${output.height}`);
23
+ * output.free();
24
+ * }
37
25
  * ```
38
26
  *
39
27
  * @example
40
28
  * ```typescript
41
- * // Hardware acceleration (decoder -> hw filter -> encoder)
42
- * const hw = await HardwareContext.auto();
43
- * const decoder = await Decoder.create(stream, { hardware: hw });
44
- * const filter = await FilterAPI.create('scale_vt=640:480', decoder.getOutputStreamInfo(), {
45
- * hardware: hw
46
- * });
29
+ * // Hardware-accelerated filtering
30
+ * const hw = HardwareContext.auto();
31
+ * const filter = await FilterAPI.create(
32
+ * 'hwupload,scale_cuda=1920:1080,hwdownload',
33
+ * videoInfo,
34
+ * { hardware: hw }
35
+ * );
47
36
  * ```
48
37
  *
49
- * @example
50
- * ```typescript
51
- * // Software decode -> hardware encode pipeline with hwupload
52
- * const decoder = await Decoder.create(stream);
53
- * const hw = await HardwareContext.auto();
54
- * const filter = await FilterAPI.create('format=nv12,hwupload', decoder.getOutputStreamInfo(), {
55
- * hardware: hw // Required for hwupload to create hw_frames_ctx
56
- * });
57
- * ```
58
- *
59
- * @example
60
- * ```typescript
61
- * // Hardware decode -> software encode pipeline with hwdownload
62
- * const hw = await HardwareContext.auto();
63
- * const decoder = await Decoder.create(stream, { hardware: hw });
64
- * const filter = await FilterAPI.create('hwdownload,format=yuv420p', decoder.getOutputStreamInfo());
65
- * ```
38
+ * @see {@link FilterGraph} For low-level filter graph API
39
+ * @see {@link HardwareContext} For hardware acceleration
40
+ * @see {@link Frame} For frame operations
66
41
  */
67
42
  export declare class FilterAPI implements Disposable {
68
43
  private graph;
@@ -75,135 +50,162 @@ export declare class FilterAPI implements Disposable {
75
50
  private description;
76
51
  private options;
77
52
  /**
78
- * Create a new Filter instance.
79
- *
80
- * @param config - Stream information from input stream
81
- * @param description - Filter graph description
82
- * @param options - Filter options including hardware context
53
+ * @param config - Stream configuration
54
+ * @param description - Filter description string
55
+ * @param options - Filter options
83
56
  * @internal
84
57
  */
85
58
  private constructor();
86
59
  /**
87
- * Create a filter from a filter description string.
88
- *
89
- * Accepts either a Stream (from MediaInput/Decoder) or StreamInfo (for raw data).
90
- * Automatically sets up buffer source and sink filters.
60
+ * Create a filter with specified description and configuration.
91
61
  *
92
- * For hardware input formats: Uses lazy initialization, waits for first frame
93
- * with hw_frames_ctx before configuring the filter graph.
94
- * For software formats: Initializes immediately.
62
+ * Constructs filter graph from description string.
63
+ * Configures input/output buffers and threading.
64
+ * For video filters, uses lazy initialization to detect hardware frames.
95
65
  *
96
- * Hardware context handling:
97
- * - hwupload: Requires hardware context, creates its own hw_frames_ctx
98
- * - hwdownload: Uses hw_frames_ctx propagated from previous filters
99
- * - Other HW filters: Use propagated hw_frames_ctx or hwupload's output
66
+ * Direct mapping to avfilter_graph_parse_ptr() and avfilter_graph_config().
100
67
  *
101
- * @param description - Filter graph description (e.g., "scale=1280:720" or complex chains)
102
- * @param input - Stream or StreamInfo describing the input
103
- * @param options - Optional filter options including hardware context
68
+ * @param description - Filter graph description
69
+ * @param input - Input stream configuration
70
+ * @param options - Filter options
71
+ * @returns Configured filter instance
104
72
  *
105
- * @returns Promise resolving to configured Filter instance
73
+ * @throws {Error} If filter creation or configuration fails
106
74
  *
107
- * @throws {FFmpegError} If filter creation or configuration fails
108
- * @throws {Error} If hardware filter requires hardware context but none provided
75
+ * @throws {FFmpegError} If graph parsing or config fails
109
76
  *
110
77
  * @example
111
78
  * ```typescript
112
- * // Simple filter
113
- * const filter = await FilterAPI.create('scale=640:480', videoStream);
79
+ * // Simple video filter
80
+ * const filter = await FilterAPI.create('scale=640:480', videoInfo);
81
+ * ```
114
82
  *
115
- * // Complex filter chain with hardware
116
- * const hw = await HardwareContext.auto();
117
- * const decoder = await Decoder.create(stream, { hardware: hw });
83
+ * @example
84
+ * ```typescript
85
+ * // Complex filter chain
118
86
  * const filter = await FilterAPI.create(
119
- * 'scale_vt=640:480,hwdownload,format=yuv420p',
120
- * decoder.getOutputStreamInfo(),
121
- * { hardware: hw }
87
+ * 'crop=640:480:0:0,rotate=PI/4',
88
+ * videoInfo
122
89
  * );
90
+ * ```
123
91
  *
124
- * // From StreamInfo (for raw data)
125
- * const filter = await FilterAPI.create('scale=640:480', {
126
- * type: 'video',
127
- * width: 1920,
128
- * height: 1080,
129
- * pixelFormat: AV_PIX_FMT_YUV420P,
130
- * timeBase: { num: 1, den: 30 }
131
- * });
92
+ * @example
93
+ * ```typescript
94
+ * // Audio filter
95
+ * const filter = await FilterAPI.create(
96
+ * 'volume=0.5,aecho=0.8:0.9:1000:0.3',
97
+ * audioInfo
98
+ * );
132
99
  * ```
100
+ *
101
+ * @see {@link process} For frame processing
102
+ * @see {@link FilterOptions} For configuration options
133
103
  */
134
104
  static create(description: string, input: StreamInfo, options?: FilterOptions): Promise<FilterAPI>;
135
105
  /**
136
- * Process a single frame through the filter.
106
+ * Process a frame through the filter.
137
107
  *
138
- * Sends a frame through the filter graph and returns the filtered result.
139
- * May return null if the filter needs more input frames.
108
+ * Applies filter operations to input frame.
109
+ * May buffer frames internally before producing output.
110
+ * For video, performs lazy initialization on first frame.
140
111
  *
141
- * On first frame with hw_frames_ctx, initializes the filter graph (lazy initialization).
142
- * Subsequent frames are processed normally. FFmpeg automatically propagates
143
- * hw_frames_ctx through the filter chain.
112
+ * Direct mapping to av_buffersrc_add_frame() and av_buffersink_get_frame().
144
113
  *
145
- * @param frame - Input frame to filter
114
+ * @param frame - Input frame to process
115
+ * @returns Filtered frame or null if buffered
146
116
  *
147
- * @returns Promise resolving to filtered frame or null if more input needed
117
+ * @throws {Error} If filter not ready
148
118
  *
149
119
  * @throws {FFmpegError} If processing fails
150
- * @throws {Error} If filter not initialized or hardware frame required but not provided
151
120
  *
152
121
  * @example
153
122
  * ```typescript
154
- * const outputFrame = await filter.process(inputFrame);
155
- * if (outputFrame) {
156
- * // Process the filtered frame
123
+ * const output = await filter.process(inputFrame);
124
+ * if (output) {
125
+ * console.log(`Got filtered frame: pts=${output.pts}`);
126
+ * output.free();
127
+ * }
128
+ * ```
129
+ *
130
+ * @example
131
+ * ```typescript
132
+ * // Process and drain
133
+ * const output = await filter.process(frame);
134
+ * if (output) yield output;
135
+ *
136
+ * // Drain buffered frames
137
+ * let buffered;
138
+ * while ((buffered = await filter.receive()) !== null) {
139
+ * yield buffered;
157
140
  * }
158
141
  * ```
142
+ *
143
+ * @see {@link receive} For draining buffered frames
144
+ * @see {@link frames} For stream processing
159
145
  */
160
146
  process(frame: Frame): Promise<Frame | null>;
161
147
  /**
162
- * Process multiple frames through the filter.
148
+ * Process multiple frames at once.
163
149
  *
164
- * Batch processing for better performance.
165
- * Returns all available output frames.
150
+ * Processes batch of frames and drains all output.
151
+ * Useful for filters that buffer multiple frames.
166
152
  *
167
153
  * @param frames - Array of input frames
154
+ * @returns Array of all output frames
168
155
  *
169
- * @returns Promise resolving to array of filtered frames
156
+ * @throws {Error} If filter not ready
170
157
  *
171
158
  * @throws {FFmpegError} If processing fails
172
159
  *
173
160
  * @example
174
161
  * ```typescript
175
- * const outputFrames = await filter.processMultiple(inputFrames);
162
+ * const outputs = await filter.processMultiple([frame1, frame2, frame3]);
163
+ * for (const output of outputs) {
164
+ * console.log(`Output frame: pts=${output.pts}`);
165
+ * output.free();
166
+ * }
176
167
  * ```
168
+ *
169
+ * @see {@link process} For single frame processing
177
170
  */
178
171
  processMultiple(frames: Frame[]): Promise<Frame[]>;
179
172
  /**
180
- * Receive a filtered frame without sending input.
173
+ * Receive buffered frame from filter.
174
+ *
175
+ * Drains frames buffered by the filter.
176
+ * Call repeatedly until null to get all buffered frames.
177
+ *
178
+ * Direct mapping to av_buffersink_get_frame().
181
179
  *
182
- * Used to drain buffered frames from the filter.
183
- * Returns null when no more frames are available.
180
+ * @returns Buffered frame or null if none available
184
181
  *
185
- * @returns Promise resolving to filtered frame or null
182
+ * @throws {Error} If filter not ready
186
183
  *
187
- * @throws {FFmpegError} If receiving fails
184
+ * @throws {FFmpegError} If receive fails
188
185
  *
189
186
  * @example
190
187
  * ```typescript
191
- * // Drain all buffered frames
192
- * while (true) {
193
- * const frame = await filter.receive();
194
- * if (!frame) break;
195
- * // Process frame
188
+ * // Drain buffered frames
189
+ * let frame;
190
+ * while ((frame = await filter.receive()) !== null) {
191
+ * console.log(`Buffered frame: pts=${frame.pts}`);
192
+ * frame.free();
196
193
  * }
197
194
  * ```
195
+ *
196
+ * @see {@link process} For input processing
197
+ * @see {@link flush} For end-of-stream
198
198
  */
199
199
  receive(): Promise<Frame | null>;
200
200
  /**
201
- * Flush the filter by sending null frame.
201
+ * Flush filter and signal end-of-stream.
202
+ *
203
+ * Sends null frame to flush buffered data.
204
+ * Must call receive() to get flushed frames.
202
205
  *
203
- * Signals end of stream to the filter.
204
- * Use receive() to get any remaining frames.
206
+ * Direct mapping to av_buffersrc_add_frame(NULL).
205
207
  *
206
- * @returns Promise resolving when flush is complete
208
+ * @throws {Error} If filter not ready
207
209
  *
208
210
  * @throws {FFmpegError} If flush fails
209
211
  *
@@ -211,155 +213,199 @@ export declare class FilterAPI implements Disposable {
211
213
  * ```typescript
212
214
  * await filter.flush();
213
215
  * // Get remaining frames
214
- * while (true) {
215
- * const frame = await filter.receive();
216
- * if (!frame) break;
217
- * // Process final frames
216
+ * let frame;
217
+ * while ((frame = await filter.receive()) !== null) {
218
+ * frame.free();
218
219
  * }
219
220
  * ```
221
+ *
222
+ * @see {@link flushFrames} For async iteration
223
+ * @see {@link receive} For draining frames
220
224
  */
221
225
  flush(): Promise<void>;
222
226
  /**
223
- * Flush filter and yield all remaining frames as a generator.
227
+ * Flush filter and yield remaining frames.
224
228
  *
225
- * More convenient than calling flush() + receive() in a loop.
226
- * Automatically sends flush signal and yields all buffered frames.
229
+ * Convenient async generator for flushing.
230
+ * Combines flush and receive operations.
227
231
  *
228
- * @returns Async generator of remaining frames
232
+ * @yields Remaining frames from filter
233
+ * @throws {Error} If filter not ready
229
234
  *
230
- * @throws {Error} If filter is not initialized
235
+ * @throws {FFmpegError} If flush fails
231
236
  *
232
237
  * @example
233
238
  * ```typescript
234
- * // Process all remaining frames with generator
235
239
  * for await (const frame of filter.flushFrames()) {
236
- * // Process final frame
237
- * using _ = frame; // Auto cleanup
240
+ * console.log(`Flushed frame: pts=${frame.pts}`);
241
+ * frame.free();
238
242
  * }
239
243
  * ```
244
+ *
245
+ * @see {@link flush} For manual flush
246
+ * @see {@link frames} For complete pipeline
240
247
  */
241
248
  flushFrames(): AsyncGenerator<Frame>;
242
249
  /**
243
- * Process frames as an async generator.
250
+ * Process frame stream through filter.
244
251
  *
245
- * Provides a convenient iterator interface for filtering.
246
- * Automatically handles buffering and draining.
247
- * Input frames are automatically freed after processing.
252
+ * High-level async generator for filtering frame streams.
253
+ * Automatically handles buffering and flushing.
254
+ * Frees input frames after processing.
248
255
  *
249
- * IMPORTANT: The yielded frames MUST be freed by the caller!
250
- * Input frames are automatically freed after processing.
256
+ * @param frames - Async generator of input frames
257
+ * @yields Filtered frames
258
+ * @throws {Error} If filter not ready
251
259
  *
252
- * @param frames - Async generator of input frames (will be freed automatically)
260
+ * @throws {FFmpegError} If processing fails
253
261
  *
254
- * @returns Async generator of filtered frames (ownership transferred to caller)
262
+ * @example
263
+ * ```typescript
264
+ * // Filter decoded frames
265
+ * for await (const frame of filter.frames(decoder.frames(packets))) {
266
+ * await encoder.encode(frame);
267
+ * frame.free();
268
+ * }
269
+ * ```
255
270
  *
256
271
  * @example
257
272
  * ```typescript
258
- * for await (const filtered of filter.frames(decoder.frames())) {
259
- * // Process filtered frame
260
- * using _ = filtered; // Auto cleanup with using statement
273
+ * // Chain filters
274
+ * const filter1 = await FilterAPI.create('scale=640:480', info);
275
+ * const filter2 = await FilterAPI.create('rotate=PI/4', info);
276
+ *
277
+ * for await (const frame of filter2.frames(filter1.frames(input))) {
278
+ * // Process filtered frames
279
+ * frame.free();
261
280
  * }
262
281
  * ```
282
+ *
283
+ * @see {@link process} For single frame processing
284
+ * @see {@link flush} For end-of-stream handling
263
285
  */
264
286
  frames(frames: AsyncGenerator<Frame>): AsyncGenerator<Frame>;
265
287
  /**
266
- * Send a command to a filter in the graph.
288
+ * Send command to filter.
289
+ *
290
+ * Sends runtime command to specific filter in graph.
291
+ * Allows dynamic parameter adjustment.
267
292
  *
268
- * Allows runtime modification of filter parameters without recreating the graph.
269
- * Not all filters support commands - check filter documentation.
293
+ * Direct mapping to avfilter_graph_send_command().
270
294
  *
271
- * @param target - Filter name or "all" to send to all filters
272
- * @param cmd - Command name (e.g., "volume", "hue", "brightness")
273
- * @param arg - Command argument value
274
- * @param flags - Optional command flags
295
+ * @param target - Target filter name
296
+ * @param cmd - Command name
297
+ * @param arg - Command argument
298
+ * @param flags - Command flags
299
+ * @returns Response string from filter
275
300
  *
276
- * @returns Command response
301
+ * @throws {Error} If filter not ready
302
+ *
303
+ * @throws {FFmpegError} If command fails
277
304
  *
278
305
  * @example
279
306
  * ```typescript
280
- * // Change volume dynamically
307
+ * // Change volume at runtime
281
308
  * const response = filter.sendCommand('volume', 'volume', '0.5');
282
- * if (response) {
283
- * console.log('Volume changed successfully');
284
- * }
309
+ * console.log(`Volume changed: ${response}`);
285
310
  * ```
286
311
  *
287
- * @example
288
- * ```typescript
289
- * // Enable/disable all filters at runtime
290
- * filter.sendCommand('all', 'enable', 'expr=gte(t,10)');
291
- * ```
312
+ * @see {@link queueCommand} For delayed commands
292
313
  */
293
314
  sendCommand(target: string, cmd: string, arg: string, flags?: AVFilterCmdFlag): string;
294
315
  /**
295
- * Queue a command to be executed at a specific time.
316
+ * Queue command for later execution.
317
+ *
318
+ * Schedules command to execute at specific timestamp.
319
+ * Useful for synchronized parameter changes.
320
+ *
321
+ * Direct mapping to avfilter_graph_queue_command().
296
322
  *
297
- * Commands are executed when processing frames with matching timestamps.
298
- * Useful for scripted filter changes synchronized with media playback.
323
+ * @param target - Target filter name
324
+ * @param cmd - Command name
325
+ * @param arg - Command argument
326
+ * @param ts - Timestamp for execution
327
+ * @param flags - Command flags
328
+ * @throws {Error} If filter not ready
299
329
  *
300
- * @param target - Filter name or "all" to send to all filters
301
- * @param cmd - Command name (e.g., "volume", "hue", "brightness")
302
- * @param arg - Command argument value
303
- * @param ts - Timestamp when command should execute (in seconds)
304
- * @param flags - Optional command flags
330
+ * @throws {FFmpegError} If queue fails
305
331
  *
306
332
  * @example
307
333
  * ```typescript
308
- * // Schedule volume changes at specific times
309
- * filter.queueCommand('volume', 'volume', '0.5', 5.0); // At 5 seconds
310
- * filter.queueCommand('volume', 'volume', '0.8', 10.0); // At 10 seconds
311
- * filter.queueCommand('volume', 'volume', '0.2', 15.0); // At 15 seconds
334
+ * // Queue volume change at 10 seconds
335
+ * filter.queueCommand('volume', 'volume', '0.8', 10.0);
312
336
  * ```
337
+ *
338
+ * @see {@link sendCommand} For immediate commands
313
339
  */
314
340
  queueCommand(target: string, cmd: string, arg: string, ts: number, flags?: AVFilterCmdFlag): void;
315
341
  /**
316
- * Get the filter graph description.
342
+ * Get filter graph description.
343
+ *
344
+ * Returns human-readable graph structure.
345
+ * Useful for debugging filter chains.
317
346
  *
318
- * Returns a string representation of the filter graph in DOT format.
319
- * Useful for debugging and visualization.
347
+ * Direct mapping to avfilter_graph_dump().
320
348
  *
321
349
  * @returns Graph description or null if not initialized
322
350
  *
323
351
  * @example
324
352
  * ```typescript
325
353
  * const description = filter.getGraphDescription();
326
- * console.log(description);
354
+ * console.log('Filter graph:', description);
327
355
  * ```
328
356
  */
329
357
  getGraphDescription(): string | null;
330
358
  /**
331
- * Check if the filter is initialized and ready.
359
+ * Check if filter is ready for processing.
360
+ *
361
+ * @returns true if initialized and ready
332
362
  *
333
- * @returns true if the filter is ready for processing
363
+ * @example
364
+ * ```typescript
365
+ * if (filter.isReady()) {
366
+ * const output = await filter.process(frame);
367
+ * }
368
+ * ```
334
369
  */
335
370
  isReady(): boolean;
336
371
  /**
337
- * Get the media type of this filter.
372
+ * Get media type of filter.
373
+ *
374
+ * @returns AVMEDIA_TYPE_VIDEO or AVMEDIA_TYPE_AUDIO
338
375
  *
339
- * @returns The media type (video or audio)
376
+ * @example
377
+ * ```typescript
378
+ * if (filter.getMediaType() === AVMEDIA_TYPE_VIDEO) {
379
+ * console.log('Video filter');
380
+ * }
381
+ * ```
340
382
  */
341
383
  getMediaType(): AVMediaType;
342
384
  /**
343
- * Free all filter resources.
385
+ * Free filter resources.
344
386
  *
345
- * Releases the filter graph and all associated filters.
346
- * The filter instance cannot be used after calling this.
387
+ * Releases filter graph and contexts.
388
+ * Safe to call multiple times.
347
389
  *
348
390
  * @example
349
391
  * ```typescript
350
392
  * filter.free();
351
- * // filter is now invalid
352
393
  * ```
394
+ *
395
+ * @see {@link Symbol.dispose} For automatic cleanup
353
396
  */
354
397
  free(): void;
355
398
  /**
356
- * Initialize the filter graph.
399
+ * Initialize filter graph.
400
+ *
401
+ * Creates and configures filter graph components.
402
+ * For video, may use hardware frames context from first frame.
403
+ *
404
+ * @param firstFrame - First frame for hardware detection (video only)
357
405
  *
358
- * Sets up buffer source, buffer sink, and parses the filter description.
359
- * Configures the graph for processing.
406
+ * @throws {Error} If initialization fails
360
407
  *
361
- * For hardware inputs: Uses hw_frames_ctx from first frame
362
- * For software inputs: Initializes without hw_frames_ctx
408
+ * @throws {FFmpegError} If configuration fails
363
409
  *
364
410
  * @internal
365
411
  */
@@ -367,51 +413,69 @@ export declare class FilterAPI implements Disposable {
367
413
  /**
368
414
  * Create buffer source with hardware frames context.
369
415
  *
416
+ * @param frame - Frame with hw_frames_ctx
417
+ *
418
+ * @throws {Error} If creation fails
419
+ *
420
+ * @throws {FFmpegError} If configuration fails
421
+ *
370
422
  * @internal
371
423
  */
372
424
  private createBufferSourceWithHwFrames;
373
425
  /**
374
- * Create and configure the buffer source filter without hw_frames_ctx.
426
+ * Create standard buffer source.
427
+ *
428
+ * @throws {Error} If creation fails
375
429
  *
376
430
  * @internal
377
431
  */
378
432
  private createBufferSource;
379
433
  /**
380
- * Create and configure the buffer sink filter.
434
+ * Create buffer sink.
435
+ *
436
+ * @throws {Error} If creation fails
381
437
  *
382
438
  * @internal
383
439
  */
384
440
  private createBufferSink;
385
441
  /**
386
- * Parse and connect the filter description.
442
+ * Parse filter description and build graph.
443
+ *
444
+ * @param description - Filter description string
445
+ *
446
+ * @throws {Error} If parsing fails
447
+ *
448
+ * @throws {FFmpegError} If graph construction fails
387
449
  *
388
450
  * @internal
389
451
  */
390
452
  private parseFilterDescription;
391
453
  /**
392
- * Check if hardware context is required for the filter chain.
454
+ * Check hardware requirements for filters.
393
455
  *
394
- * Validates that hardware context is provided when needed:
395
- * - hwupload: Always requires hardware context
396
- * - Hardware filters (AVFILTER_FLAG_HWDEVICE): Recommend hardware context
397
- * - hwdownload: Warns if input is not hardware format
456
+ * @param description - Filter description
457
+ * @param options - Filter options
458
+ *
459
+ * @throws {Error} If hardware requirements not met
398
460
  *
399
461
  * @internal
400
462
  */
401
463
  private checkHardwareRequirements;
402
464
  /**
403
- * Dispose of the filter.
465
+ * Dispose of filter.
404
466
  *
405
- * Implements the Disposable interface for automatic cleanup.
467
+ * Implements Disposable interface for automatic cleanup.
406
468
  * Equivalent to calling free().
407
469
  *
408
470
  * @example
409
471
  * ```typescript
410
472
  * {
411
- * using filter = await Filter.create('scale=1280:720', config);
412
- * // ... use filter
413
- * } // Automatically freed when leaving scope
473
+ * using filter = await FilterAPI.create('scale=640:480', info);
474
+ * // Use filter...
475
+ * } // Automatically freed
414
476
  * ```
477
+ *
478
+ * @see {@link free} For manual cleanup
415
479
  */
416
480
  [Symbol.dispose](): void;
417
481
  }