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
@@ -1,18 +1,17 @@
1
- /**
2
- * FilterPresets - Pre-defined filter configurations
3
- *
4
- * Provides convenient filter string builders for common operations.
5
- * Includes both software and hardware-accelerated filter presets.
6
- *
7
- * Simplifies filter creation with type-safe parameter handling.
8
- * Supports platform-specific hardware acceleration capabilities.
9
- *
10
- * @module api/filter-presets
11
- */
12
1
  import type { AVHWDeviceType, AVPixelFormat, AVSampleFormat } from '../constants/constants.js';
13
2
  /**
14
3
  * Hardware filter capabilities for different platforms.
15
4
  * Maps hardware types to their supported filter operations.
5
+ * Each capability indicates whether a specific filter operation is supported
6
+ * by the hardware acceleration type.
7
+ *
8
+ * Support varies significantly between hardware types:
9
+ * - CUDA: Comprehensive filter support with NPP integration
10
+ * - VAAPI: Good Linux support with Intel/AMD GPUs
11
+ * - QSV: Intel Quick Sync with basic filtering
12
+ * - VideoToolbox: macOS/iOS with CoreImage filters
13
+ * - Vulkan: Cross-platform with growing filter support
14
+ * - OpenCL: Cross-platform compute-based filtering
16
15
  */
17
16
  export interface HardwareFilterSupport {
18
17
  scale: boolean;
@@ -31,286 +30,883 @@ export interface HardwareFilterSupport {
31
30
  }
32
31
  /**
33
32
  * Base class for filter preset implementations.
34
- * Provides common filter building methods that can be overridden.
33
+ * Provides common filter building methods that can be overridden by hardware-specific implementations.
34
+ *
35
+ * This class defines the standard filter operations available in FFmpeg,
36
+ * with each method returning a filter string that can be used in a filter graph.
37
+ * Hardware-specific implementations may override these methods to use optimized
38
+ * hardware filters instead of software implementations.
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * class CustomPresets extends FilterPresetBase {
43
+ * override scale(width: number, height: number): string | null {
44
+ * return `custom_scale=${width}:${height}`;
45
+ * }
46
+ * }
47
+ * ```
35
48
  */
36
49
  export declare abstract class FilterPresetBase {
37
50
  /**
38
- * Scale video to specified dimensions.
51
+ * Creates a scale filter string.
52
+ *
53
+ * @param width - Target width in pixels
54
+ * @param height - Target height in pixels
55
+ * @param options - Additional scaling options (e.g., flags for algorithm)
39
56
  * @returns Filter string or null if not supported
57
+ *
58
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#scale | FFmpeg scale filter}
40
59
  */
41
60
  scale(width: number, height: number, options?: Record<string, any>): string | null;
42
61
  /**
43
- * Crop video to specified dimensions.
62
+ * Creates a crop filter string.
63
+ *
64
+ * @param width - Width of the cropped area
65
+ * @param height - Height of the cropped area
66
+ * @param x - X coordinate of top-left corner (default: 0)
67
+ * @param y - Y coordinate of top-left corner (default: 0)
68
+ * @returns Filter string or null if not supported
69
+ *
70
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#crop | FFmpeg crop filter}
44
71
  */
45
72
  crop(width: number, height: number, x?: number, y?: number): string | null;
46
73
  /**
47
- * Change frame rate.
74
+ * Creates an FPS filter string to change frame rate.
75
+ *
76
+ * @param fps - Target frames per second
77
+ * @returns Filter string or null if not supported
78
+ *
79
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#fps | FFmpeg fps filter}
48
80
  */
49
81
  fps(fps: number): string | null;
50
82
  /**
51
- * Convert pixel format.
52
- * Can accept a single format or an array of formats for fallback.
53
- * Multiple formats will create a chain: format=fmt1,format=fmt2,...
83
+ * Creates a format filter string to convert pixel format.
84
+ *
85
+ * @param pixelFormat - Target pixel format(s) - can be string, AVPixelFormat enum, or array
86
+ * @returns Filter string or null if not supported
87
+ *
88
+ * @example
89
+ * ```typescript
90
+ * // Single format
91
+ * presets.format('yuv420p');
92
+ * presets.format(AV_PIX_FMT_YUV420P);
93
+ *
94
+ * // Multiple formats (creates a chain)
95
+ * presets.format(['yuv420p', 'rgb24']);
96
+ * ```
97
+ *
98
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#format | FFmpeg format filter}
54
99
  */
55
100
  format(pixelFormat: string | AVPixelFormat | (string | AVPixelFormat)[]): string | null;
56
101
  /**
57
- * Rotate video by angle.
102
+ * Creates a rotate filter string.
103
+ *
104
+ * @param angle - Rotation angle in degrees
105
+ * @returns Filter string or null if not supported
106
+ *
107
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#rotate | FFmpeg rotate filter}
58
108
  */
59
109
  rotate(angle: number): string | null;
60
110
  /**
61
- * Flip video horizontally.
111
+ * Creates a horizontal flip filter string.
112
+ *
113
+ * @returns Filter string or null if not supported
114
+ *
115
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#hflip | FFmpeg hflip filter}
62
116
  */
63
117
  hflip(): string | null;
64
118
  /**
65
- * Flip video vertically.
119
+ * Creates a vertical flip filter string.
120
+ *
121
+ * @returns Filter string or null if not supported
122
+ *
123
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#vflip | FFmpeg vflip filter}
66
124
  */
67
125
  vflip(): string | null;
68
126
  /**
69
- * Apply fade effect.
127
+ * Creates a fade filter string for video.
128
+ *
129
+ * @param type - Fade type ('in' or 'out')
130
+ * @param start - Start time in seconds
131
+ * @param duration - Fade duration in seconds
132
+ * @returns Filter string or null if not supported
133
+ *
134
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#fade | FFmpeg fade filter}
70
135
  */
71
136
  fade(type: 'in' | 'out', start: number, duration: number): string | null;
72
137
  /**
73
- * Overlay one video on another.
138
+ * Creates an overlay filter string to composite two video streams.
139
+ *
140
+ * @param x - X position for overlay (default: 0)
141
+ * @param y - Y position for overlay (default: 0)
142
+ * @param options - Additional overlay options
143
+ * @returns Filter string or null if not supported
144
+ *
145
+ * @example
146
+ * ```typescript
147
+ * // Basic overlay at position
148
+ * presets.overlay(100, 50);
149
+ *
150
+ * // With additional options
151
+ * presets.overlay(0, 0, { format: 'yuv420' });
152
+ * ```
153
+ *
154
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#overlay | FFmpeg overlay filter}
74
155
  */
75
156
  overlay(x?: number, y?: number, options?: Record<string, string>): string | null;
76
157
  /**
77
- * Adjust audio volume.
158
+ * Creates a volume filter string for audio.
159
+ *
160
+ * @param factor - Volume multiplication factor (1.0 = unchanged, 2.0 = double)
161
+ * @returns Filter string or null if not supported
162
+ *
163
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#volume | FFmpeg volume filter}
78
164
  */
79
165
  volume(factor: number): string | null;
80
166
  /**
81
- * Convert audio sample format.
167
+ * Creates an audio format filter string.
168
+ *
169
+ * @param sampleFormat - Target sample format (e.g., 's16', 'fltp')
170
+ * @param sampleRate - Target sample rate in Hz (optional)
171
+ * @param channelLayout - Target channel layout (optional)
172
+ * @returns Filter string or null if not supported
173
+ *
174
+ * @example
175
+ * ```typescript
176
+ * // Change sample format only
177
+ * presets.aformat('s16');
178
+ *
179
+ * // Change format and sample rate
180
+ * presets.aformat('fltp', 48000);
181
+ *
182
+ * // Full conversion
183
+ * presets.aformat('s16', 44100, 'stereo');
184
+ * ```
185
+ *
186
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#aformat | FFmpeg aformat filter}
82
187
  */
83
188
  aformat(sampleFormat: string | AVSampleFormat, sampleRate?: number, channelLayout?: string): string | null;
84
189
  /**
85
- * Change audio tempo without changing pitch.
190
+ * Creates an atempo filter string to change audio playback speed.
191
+ * Factor must be between 0.5 and 2.0. For larger changes, chain multiple atempo filters.
192
+ *
193
+ * @param factor - Tempo factor (0.5 = half speed, 2.0 = double speed)
194
+ * @returns Filter string or null if not supported
195
+ *
196
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#atempo | FFmpeg atempo filter}
86
197
  */
87
198
  atempo(factor: number): string | null;
88
199
  /**
89
- * Apply audio fade.
200
+ * Creates an audio fade filter string.
201
+ *
202
+ * @param type - Fade type ('in' or 'out')
203
+ * @param start - Start time in seconds
204
+ * @param duration - Fade duration in seconds
205
+ * @returns Filter string or null if not supported
206
+ *
207
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#afade | FFmpeg afade filter}
90
208
  */
91
209
  afade(type: 'in' | 'out', start: number, duration: number): string | null;
92
210
  /**
93
- * Mix multiple audio streams.
211
+ * Creates an amix filter string to mix multiple audio streams.
212
+ *
213
+ * @param inputs - Number of input streams to mix (default: 2)
214
+ * @param duration - How to determine output duration (default: 'longest')
215
+ * @returns Filter string or null if not supported
216
+ *
217
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#amix | FFmpeg amix filter}
94
218
  */
95
219
  amix(inputs?: number, duration?: 'first' | 'longest' | 'shortest'): string | null;
96
220
  }
97
221
  /**
98
222
  * Filter chain builder for composing multiple filters.
99
- * Allows fluent API for building complex filter graphs.
223
+ * Allows fluent API for building complex filter graphs by chaining filter operations.
224
+ *
225
+ * @example
226
+ * ```typescript
227
+ * const chain = new FilterChain()
228
+ * .add('scale=1920:1080')
229
+ * .add('fps=30')
230
+ * .custom('rotate=45*PI/180')
231
+ * .build();
232
+ * // Result: "scale=1920:1080,fps=30,rotate=45*PI/180"
233
+ * ```
100
234
  */
101
235
  export declare class FilterChain {
102
236
  private filters;
103
237
  /**
104
- * Add a filter to the chain.
105
- * @param filter - Filter string or null/undefined (will be skipped)
238
+ * Adds a filter to the chain.
239
+ *
240
+ * @param filter - Filter string to add (ignored if null/undefined)
241
+ * @returns This instance for chaining
106
242
  */
107
243
  add(filter: string | null | undefined): this;
108
244
  /**
109
- * Add a custom filter string.
245
+ * Adds a custom filter string to the chain.
246
+ *
247
+ * @param filter - Custom filter string
248
+ * @returns This instance for chaining
110
249
  */
111
250
  custom(filter: string): this;
112
251
  /**
113
- * Build the filter chain string.
252
+ * Builds the final filter string.
253
+ *
114
254
  * @param separator - Separator between filters (default: ',')
255
+ * @returns Combined filter string
115
256
  */
116
257
  build(separator?: string): string;
117
258
  /**
118
- * Get the filter array.
259
+ * Returns the filters as an array.
260
+ *
261
+ * @returns Array of filter strings
119
262
  */
120
263
  toArray(): string[];
121
264
  }
122
265
  /**
123
266
  * Base chain builder with common filter methods.
267
+ * Provides a fluent API for building filter chains using preset methods.
268
+ *
124
269
  * @template T The preset type this builder uses
270
+ *
271
+ * @example
272
+ * ```typescript
273
+ * const chain = new ChainBuilderBase(presets)
274
+ * .scale(1920, 1080)
275
+ * .fps(30)
276
+ * .fade('in', 0, 2)
277
+ * .build();
278
+ * ```
125
279
  */
126
280
  export declare abstract class ChainBuilderBase<T extends FilterPresetBase> extends FilterChain {
127
281
  protected readonly presets: T;
282
+ /**
283
+ * @param presets - The filter presets to use
284
+ * @internal
285
+ */
128
286
  constructor(presets: T);
287
+ /**
288
+ * Adds a scale filter to the chain.
289
+ *
290
+ * @param width - Target width
291
+ * @param height - Target height
292
+ * @param options - Additional scaling options
293
+ * @returns This instance for chaining
294
+ *
295
+ * @see {@link FilterPresetBase.scale}
296
+ */
129
297
  scale(width: number, height: number, options?: Record<string, any>): this;
298
+ /**
299
+ * Adds a crop filter to the chain.
300
+ *
301
+ * @param width - Crop width
302
+ * @param height - Crop height
303
+ * @param x - X position (default: 0)
304
+ * @param y - Y position (default: 0)
305
+ * @returns This instance for chaining
306
+ *
307
+ * @see {@link FilterPresetBase.crop}
308
+ */
130
309
  crop(width: number, height: number, x?: number, y?: number): this;
310
+ /**
311
+ * Adds an FPS filter to the chain.
312
+ *
313
+ * @param fps - Target frame rate
314
+ * @returns This instance for chaining
315
+ *
316
+ * @see {@link FilterPresetBase.fps}
317
+ */
131
318
  fps(fps: number): this;
319
+ /**
320
+ * Adds a format filter to the chain.
321
+ *
322
+ * @param pixelFormat - Target pixel format(s)
323
+ * @returns This instance for chaining
324
+ *
325
+ * @see {@link FilterPresetBase.format}
326
+ */
132
327
  format(pixelFormat: string | AVPixelFormat | (string | AVPixelFormat)[]): this;
328
+ /**
329
+ * Adds a rotate filter to the chain.
330
+ *
331
+ * @param angle - Rotation angle in degrees
332
+ * @returns This instance for chaining
333
+ *
334
+ * @see {@link FilterPresetBase.rotate}
335
+ */
133
336
  rotate(angle: number): this;
337
+ /**
338
+ * Adds a horizontal flip filter to the chain.
339
+ *
340
+ * @returns This instance for chaining
341
+ *
342
+ * @see {@link FilterPresetBase.hflip}
343
+ */
134
344
  hflip(): this;
345
+ /**
346
+ * Adds a vertical flip filter to the chain.
347
+ *
348
+ * @returns This instance for chaining
349
+ *
350
+ * @see {@link FilterPresetBase.vflip}
351
+ */
135
352
  vflip(): this;
353
+ /**
354
+ * Adds a fade filter to the chain.
355
+ *
356
+ * @param type - Fade type ('in' or 'out')
357
+ * @param start - Start time in seconds
358
+ * @param duration - Fade duration in seconds
359
+ * @returns This instance for chaining
360
+ *
361
+ * @see {@link FilterPresetBase.fade}
362
+ */
136
363
  fade(type: 'in' | 'out', start: number, duration: number): this;
364
+ /**
365
+ * Adds an overlay filter to the chain.
366
+ *
367
+ * @param x - X position (default: 0)
368
+ * @param y - Y position (default: 0)
369
+ * @param options - Additional overlay options
370
+ * @returns This instance for chaining
371
+ *
372
+ * @see {@link FilterPresetBase.overlay}
373
+ */
137
374
  overlay(x?: number, y?: number, options?: Record<string, string>): this;
375
+ /**
376
+ * Adds a volume filter to the chain.
377
+ *
378
+ * @param factor - Volume factor
379
+ * @returns This instance for chaining
380
+ *
381
+ * @see {@link FilterPresetBase.volume}
382
+ */
138
383
  volume(factor: number): this;
384
+ /**
385
+ * Adds an audio format filter to the chain.
386
+ *
387
+ * @param sampleFormat - Target sample format
388
+ * @param sampleRate - Target sample rate (optional)
389
+ * @param channelLayout - Target channel layout (optional)
390
+ * @returns This instance for chaining
391
+ *
392
+ * @see {@link FilterPresetBase.aformat}
393
+ */
139
394
  aformat(sampleFormat: string | AVSampleFormat, sampleRate?: number, channelLayout?: string): this;
395
+ /**
396
+ * Adds an atempo filter to the chain.
397
+ *
398
+ * @param factor - Tempo factor (0.5 to 2.0)
399
+ * @returns This instance for chaining
400
+ *
401
+ * @see {@link FilterPresetBase.atempo}
402
+ */
140
403
  atempo(factor: number): this;
404
+ /**
405
+ * Adds an audio fade filter to the chain.
406
+ *
407
+ * @param type - Fade type ('in' or 'out')
408
+ * @param start - Start time in seconds
409
+ * @param duration - Fade duration in seconds
410
+ * @returns This instance for chaining
411
+ *
412
+ * @see {@link FilterPresetBase.afade}
413
+ */
141
414
  afade(type: 'in' | 'out', start: number, duration: number): this;
415
+ /**
416
+ * Adds an amix filter to the chain.
417
+ *
418
+ * @param inputs - Number of inputs (default: 2)
419
+ * @param duration - Duration mode (default: 'longest')
420
+ * @returns This instance for chaining
421
+ *
422
+ * @see {@link FilterPresetBase.amix}
423
+ */
142
424
  amix(inputs?: number, duration?: 'first' | 'longest' | 'shortest'): this;
425
+ /**
426
+ * Adds a transpose filter to the chain (hardware-specific).
427
+ * Only available for hardware presets that support transpose
428
+ *
429
+ * @param dir - Transpose direction (default: 0)
430
+ * @returns This instance for chaining
431
+ *
432
+ */
143
433
  transpose(dir?: number): this;
434
+ /**
435
+ * Adds a tonemap filter to the chain (hardware-specific).
436
+ * Only available for hardware presets that support tonemapping
437
+ *
438
+ * @param options - Tonemapping options
439
+ * @returns This instance for chaining
440
+ *
441
+ */
144
442
  tonemap(options?: Record<string, string>): this;
443
+ /**
444
+ * Adds a deinterlace filter to the chain (hardware-specific).
445
+ * Only available for hardware presets that support deinterlacing
446
+ *
447
+ * @param mode - Deinterlace mode (optional)
448
+ * @returns This instance for chaining
449
+ *
450
+ */
145
451
  deinterlace(mode?: string): this;
452
+ /**
453
+ * Adds a flip filter to the chain (hardware-specific).
454
+ * Falls back to hflip/vflip if hardware flip not available
455
+ *
456
+ * @param direction - Flip direction ('h' or 'v')
457
+ * @returns This instance for chaining
458
+ *
459
+ */
146
460
  flip(direction: 'h' | 'v'): this;
461
+ /**
462
+ * Adds a blur filter to the chain (hardware-specific).
463
+ * Only available for hardware presets that support blur
464
+ *
465
+ * @param type - Blur type (default: 'avg')
466
+ * @param radius - Blur radius (optional)
467
+ * @returns This instance for chaining
468
+ *
469
+ */
147
470
  blur(type?: 'avg' | 'gaussian' | 'box', radius?: number): this;
471
+ /**
472
+ * Adds a sharpen filter to the chain (hardware-specific).
473
+ * Only available for hardware presets that support sharpening
474
+ *
475
+ * @param amount - Sharpen amount (optional)
476
+ * @returns This instance for chaining
477
+ *
478
+ */
148
479
  sharpen(amount?: number): this;
480
+ /**
481
+ * Adds a stack filter to the chain (hardware-specific).
482
+ * Only available for hardware presets that support stacking
483
+ *
484
+ * @param type - Stack type ('h' for horizontal, 'v' for vertical, 'x' for grid)
485
+ * @param inputs - Number of inputs (default: 2)
486
+ * @returns This instance for chaining
487
+ *
488
+ */
149
489
  stack(type: 'h' | 'v' | 'x', inputs?: number): this;
490
+ /**
491
+ * Adds a hwupload filter to upload frames to hardware.
492
+ *
493
+ * @returns This instance for chaining
494
+ */
150
495
  hwupload(): this;
496
+ /**
497
+ * Adds a hwdownload filter to download frames from hardware.
498
+ *
499
+ * @returns This instance for chaining
500
+ */
151
501
  hwdownload(): this;
502
+ /**
503
+ * Adds a hwmap filter to map frames between hardware devices.
504
+ *
505
+ * @param derive - Device to derive from (optional)
506
+ * @returns This instance for chaining
507
+ */
152
508
  hwmap(derive?: string): this;
153
509
  }
154
510
  /**
155
511
  * Fluent filter chain builder with preset methods.
512
+ * Provides a convenient API for building filter chains using standard presets.
513
+ *
514
+ * @example
515
+ * ```typescript
516
+ * const filter = FilterPresets.chain()
517
+ * .scale(1920, 1080)
518
+ * .fps(30)
519
+ * .fade('in', 0, 2)
520
+ * .format('yuv420p')
521
+ * .build();
522
+ * ```
156
523
  */
157
524
  export declare class FilterChainBuilder extends ChainBuilderBase<FilterPresets> {
158
525
  }
159
526
  /**
160
- * Common filter presets for convenience.
161
- *
162
- * Provides pre-defined filter strings for common operations.
163
- * Can be used with Filter.create() for quick setup.
527
+ * Standard filter presets for software filtering.
528
+ * Provides static methods for creating common filter strings and
529
+ * a chain builder for composing complex filter graphs.
164
530
  *
165
531
  * @example
166
532
  * ```typescript
167
- * const filter = await Filter.create(
168
- * FilterPresets.scale(1280, 720),
169
- * config
170
- * );
533
+ * // Static methods for individual filters
534
+ * const scaleFilter = FilterPresets.scale(1920, 1080);
535
+ * const fpsFilter = FilterPresets.fps(30);
171
536
  *
172
- * // Using chain builder
537
+ * // Chain builder for complex graphs
173
538
  * const chain = FilterPresets.chain()
174
539
  * .scale(1920, 1080)
175
- * .format('yuv420p')
176
- * .custom('unsharp=5:5:1.0')
540
+ * .fps(30)
541
+ * .fade('in', 0, 2)
177
542
  * .build();
178
543
  * ```
179
544
  */
180
545
  export declare class FilterPresets extends FilterPresetBase {
181
546
  private static instance;
182
547
  /**
183
- * Create a new filter chain builder.
548
+ * Creates a new filter chain builder.
549
+ *
550
+ * @returns A new FilterChainBuilder instance
551
+ *
552
+ * @example
553
+ * ```typescript
554
+ * const filter = FilterPresets.chain()
555
+ * .scale(1280, 720)
556
+ * .fps(30)
557
+ * .build();
558
+ * ```
184
559
  */
185
560
  static chain(): FilterChainBuilder;
561
+ /**
562
+ * Creates a scale filter string.
563
+ *
564
+ * @param width - Target width
565
+ * @param height - Target height
566
+ * @param flags - Scaling algorithm flags (optional)
567
+ * @returns Scale filter string
568
+ */
186
569
  static scale(width: number, height: number, flags?: string): string;
570
+ /**
571
+ * Creates a crop filter string.
572
+ *
573
+ * @param width - Crop width
574
+ * @param height - Crop height
575
+ * @param x - X position (default: 0)
576
+ * @param y - Y position (default: 0)
577
+ * @returns Crop filter string
578
+ */
187
579
  static crop(width: number, height: number, x?: number, y?: number): string;
580
+ /**
581
+ * Creates an FPS filter string.
582
+ *
583
+ * @param fps - Target frame rate
584
+ * @returns FPS filter string
585
+ */
188
586
  static fps(fps: number): string;
587
+ /**
588
+ * Creates a format filter string.
589
+ *
590
+ * @param pixelFormat - Target pixel format(s)
591
+ * @returns Format filter string
592
+ */
189
593
  static format(pixelFormat: string | AVPixelFormat | (string | AVPixelFormat)[]): string;
594
+ /**
595
+ * Creates a rotate filter string.
596
+ *
597
+ * @param angle - Rotation angle in degrees
598
+ * @returns Rotate filter string
599
+ */
190
600
  static rotate(angle: number): string;
601
+ /**
602
+ * Creates a horizontal flip filter string.
603
+ *
604
+ * @returns Horizontal flip filter string
605
+ */
191
606
  static hflip(): string;
607
+ /**
608
+ * Creates a vertical flip filter string.
609
+ *
610
+ * @returns Vertical flip filter string
611
+ */
192
612
  static vflip(): string;
613
+ /**
614
+ * Creates a fade filter string.
615
+ *
616
+ * @param type - Fade type ('in' or 'out')
617
+ * @param start - Start time in seconds
618
+ * @param duration - Fade duration in seconds
619
+ * @returns Fade filter string
620
+ */
193
621
  static fade(type: 'in' | 'out', start: number, duration: number): string;
622
+ /**
623
+ * Creates an overlay filter string.
624
+ *
625
+ * @param x - X position (default: 0)
626
+ * @param y - Y position (default: 0)
627
+ * @returns Overlay filter string
628
+ */
194
629
  static overlay(x?: number, y?: number): string;
630
+ /**
631
+ * Creates a volume filter string.
632
+ *
633
+ * @param factor - Volume multiplication factor
634
+ * @returns Volume filter string
635
+ */
195
636
  static volume(factor: number): string;
637
+ /**
638
+ * Creates an audio format filter string.
639
+ *
640
+ * @param sampleFormat - Target sample format
641
+ * @param sampleRate - Target sample rate (optional)
642
+ * @param channelLayout - Target channel layout (optional)
643
+ * @returns Audio format filter string
644
+ */
196
645
  static aformat(sampleFormat: string | AVSampleFormat, sampleRate?: number, channelLayout?: string): string;
646
+ /**
647
+ * Creates an atempo filter string.
648
+ *
649
+ * @param factor - Tempo factor (0.5 to 2.0)
650
+ * @returns Atempo filter string
651
+ */
197
652
  static atempo(factor: number): string;
653
+ /**
654
+ * Creates an audio fade filter string.
655
+ *
656
+ * @param type - Fade type ('in' or 'out')
657
+ * @param start - Start time in seconds
658
+ * @param duration - Fade duration in seconds
659
+ * @returns Audio fade filter string
660
+ */
198
661
  static afade(type: 'in' | 'out', start: number, duration: number): string;
662
+ /**
663
+ * Creates an amix filter string.
664
+ *
665
+ * @param inputs - Number of inputs (default: 2)
666
+ * @param duration - Duration mode (default: 'longest')
667
+ * @returns Amix filter string
668
+ */
199
669
  static amix(inputs?: number, duration?: 'first' | 'longest' | 'shortest'): string;
200
670
  }
201
671
  /**
202
672
  * Hardware-accelerated filter presets.
203
- *
204
- * Provides hardware-specific filter strings for accelerated processing.
205
- * Created and managed by HardwareContext for type-safe hardware operations.
673
+ * Provides optimized filter implementations for specific hardware types,
674
+ * with automatic fallback when operations aren't supported.
206
675
  *
207
676
  * @example
208
677
  * ```typescript
209
- * const hw = await HardwareContext.auto();
210
- * if (hw) {
211
- * // Get hardware-specific scale filter (returns null if unsupported)
212
- * const scaleFilter = hw.filterPresets.scale(1920, 1080);
678
+ * // Create hardware presets for CUDA
679
+ * const hw = new HardwareFilterPresets(AV_HWDEVICE_TYPE_CUDA, 'cuda');
213
680
  *
214
- * // Build a filter chain (unsupported filters are skipped)
215
- * const chain = hw.filterPresets.chain()
216
- * .hwupload()
217
- * .scale(1920, 1080)
218
- * .tonemap() // Skipped if not supported
219
- * .custom('unsharp=5:5:1.0')
220
- * .hwdownload()
221
- * .build();
681
+ * // Check capabilities
682
+ * if (hw.support.scale) {
683
+ * const scaleFilter = hw.scale(1920, 1080);
222
684
  * }
685
+ *
686
+ * // Use chain builder
687
+ * const chain = hw.chain()
688
+ * .hwupload()
689
+ * .scale(1920, 1080)
690
+ * .tonemap()
691
+ * .hwdownload()
692
+ * .build();
223
693
  * ```
224
694
  */
225
695
  export declare class HardwareFilterPresets extends FilterPresetBase {
226
696
  private readonly deviceType;
227
- private readonly deviceName;
697
+ private readonly deviceTypeName;
228
698
  readonly support: HardwareFilterSupport;
229
699
  /**
230
- * Create hardware filter presets for a specific device type.
231
- * @internal Used by HardwareContext
700
+ * @param deviceType - Hardware device type enum
701
+ * @param deviceTypeName - Hardware device type name (e.g., 'cuda', 'vaapi')
232
702
  */
233
- constructor(deviceType: AVHWDeviceType, deviceName?: string | null);
703
+ constructor(deviceType: AVHWDeviceType, deviceTypeName: string);
234
704
  /**
235
- * Check if a filter name is a hardware-accelerated filter.
236
- * Uses FFmpeg's AVFILTER_FLAG_HWDEVICE flag to determine if a filter is hardware-accelerated.
237
- * @param filterName - The filter name to check
238
- * @returns True if it's a hardware filter, false otherwise
705
+ * Checks if a filter is hardware-accelerated.
706
+ *
707
+ * @param filterName - Name of the filter to check
708
+ * @returns True if the filter uses hardware acceleration
709
+ *
710
+ * @example
711
+ * ```typescript
712
+ * if (HardwareFilterPresets.isHardwareFilter('scale_cuda')) {
713
+ * console.log('Hardware accelerated scaling');
714
+ * }
715
+ * ```
239
716
  */
240
717
  static isHardwareFilter(filterName: string): boolean;
241
718
  /**
242
- * Create a new hardware filter chain builder.
719
+ * Creates a hardware filter chain builder.
720
+ *
721
+ * @returns A new HardwareFilterChainBuilder instance
722
+ *
723
+ * @example
724
+ * ```typescript
725
+ * const filter = hw.chain()
726
+ * .hwupload()
727
+ * .scale(1920, 1080)
728
+ * .hwdownload()
729
+ * .build();
730
+ * ```
243
731
  */
244
732
  chain(): HardwareFilterChainBuilder;
245
733
  /**
246
- * Hardware-accelerated scale filter.
247
- * @returns Filter string or null if not supported
734
+ * Creates a hardware-accelerated scale filter.
735
+ *
736
+ * Different hardware types use different scale filters:
737
+ * - CUDA: scale_cuda or scale_npp (with npp option)
738
+ * - VAAPI: scale_vaapi
739
+ * - QSV: scale_qsv
740
+ * - VideoToolbox: scale_vt
741
+ * - RKMPP: scale_rkrga
742
+ *
743
+ * @param width - Target width
744
+ * @param height - Target height
745
+ * @param options - Hardware-specific scaling options
746
+ * @returns Hardware scale filter string or null if not supported
747
+ *
748
+ *
749
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#scale_005fcuda | FFmpeg scale_cuda filter}
248
750
  */
249
751
  scale(width: number, height: number, options?: Record<string, any>): string | null;
250
752
  /**
251
- * Hardware-accelerated overlay filter.
252
- * @returns Filter string or null if not supported
753
+ * Creates a hardware-accelerated overlay filter.
754
+ *
755
+ * @param x - X position (default: 0)
756
+ * @param y - Y position (default: 0)
757
+ * @param options - Hardware-specific overlay options
758
+ * @returns Hardware overlay filter string or null if not supported
759
+ *
760
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#overlay_005fcuda | FFmpeg overlay_cuda filter}
253
761
  */
254
762
  overlay(x?: number, y?: number, options?: Record<string, string>): string | null;
255
763
  /**
256
- * Hardware-accelerated transpose filter.
257
- * @returns Filter string or null if not supported
764
+ * Creates a hardware-accelerated transpose filter.
765
+ *
766
+ * Direction values:
767
+ * - 0: 90 degrees counter-clockwise and vertical flip
768
+ * - 1: 90 degrees clockwise
769
+ * - 2: 90 degrees counter-clockwise
770
+ * - 3: 90 degrees clockwise and vertical flip
771
+ *
772
+ * @param dir - Transpose direction (default: 0)
773
+ * @returns Hardware transpose filter string or null if not supported
774
+ *
258
775
  */
259
776
  transpose(dir?: number): string | null;
260
777
  /**
261
- * Hardware-accelerated tonemap filter.
262
- * @returns Filter string or null if not supported
778
+ * Creates a hardware-accelerated tonemap filter.
779
+ * Used for HDR to SDR conversion with hardware acceleration.
780
+ *
781
+ * @param options - Tonemapping options (algorithm, parameters)
782
+ * @returns Hardware tonemap filter string or null if not supported
783
+ *
263
784
  */
264
785
  tonemap(options?: Record<string, string>): string | null;
265
786
  /**
266
- * Hardware-accelerated deinterlace filter.
267
- * @returns Filter string or null if not supported
787
+ * Creates a hardware-accelerated deinterlace filter.
788
+ *
789
+ * Different hardware types use different deinterlacers:
790
+ * - CUDA: yadif_cuda
791
+ * - VAAPI: deinterlace_vaapi
792
+ * - QSV: deinterlace_qsv
793
+ * - Vulkan: bwdif_vulkan
794
+ * - VideoToolbox: yadif_videotoolbox
795
+ *
796
+ * @param mode - Deinterlacing mode (optional)
797
+ * @returns Hardware deinterlace filter string or null if not supported
798
+ *
268
799
  */
269
800
  deinterlace(mode?: string): string | null;
270
801
  /**
271
- * Hardware-accelerated flip filter.
272
- * @returns Filter string or null if not supported
802
+ * Creates a hardware-accelerated flip filter.
803
+ * Currently only Vulkan supports hardware flip filters.
804
+ *
805
+ * @param direction - Flip direction ('h' for horizontal, 'v' for vertical)
806
+ * @returns Hardware flip filter string or null if not supported
807
+ *
273
808
  */
274
809
  flip(direction: 'h' | 'v'): string | null;
275
810
  /**
276
- * Hardware-accelerated blur filter.
277
- * @returns Filter string or null if not supported
811
+ * Creates a hardware-accelerated blur filter.
812
+ *
813
+ * Different hardware types support different blur filters:
814
+ * - CUDA: bilateral_cuda
815
+ * - Vulkan: avgblur_vulkan, gblur_vulkan
816
+ * - OpenCL: avgblur_opencl, boxblur_opencl
817
+ *
818
+ * @param type - Blur type ('avg', 'gaussian', or 'box', default: 'avg')
819
+ * @param radius - Blur radius (optional)
820
+ * @returns Hardware blur filter string or null if not supported
821
+ *
278
822
  */
279
823
  blur(type?: 'avg' | 'gaussian' | 'box', radius?: number): string | null;
280
824
  /**
281
- * Hardware-accelerated sharpen filter.
282
- * @returns Filter string or null if not supported
825
+ * Creates a hardware-accelerated sharpen filter.
826
+ *
827
+ * Hardware sharpening support:
828
+ * - VAAPI: sharpness_vaapi
829
+ * - OpenCL: unsharp_opencl
830
+ * - CUDA: sharpen_npp (NPP-based)
831
+ *
832
+ * @param amount - Sharpening amount (optional)
833
+ * @returns Hardware sharpen filter string or null if not supported
834
+ *
283
835
  */
284
836
  sharpen(amount?: number): string | null;
285
837
  /**
286
- * Hardware-accelerated stack filters (hstack, vstack, xstack).
287
- * @returns Filter string or null if not supported
838
+ * Creates a hardware-accelerated stack filter.
839
+ * Only VAAPI and QSV support hardware stacking.
840
+ *
841
+ * @param type - Stack type ('h' for horizontal, 'v' for vertical, 'x' for grid)
842
+ * @param inputs - Number of inputs to stack (default: 2)
843
+ * @returns Hardware stack filter string or null if not supported
844
+ *
288
845
  */
289
846
  stack(type: 'h' | 'v' | 'x', inputs?: number): string | null;
290
847
  /**
291
- * Hardware upload filter to transfer frames to GPU.
848
+ * Creates a hwupload filter to upload frames to hardware memory.
849
+ * CUDA uses hwupload_cuda, others use generic hwupload.
850
+ *
851
+ * @returns Hardware upload filter string
852
+ *
853
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#hwupload | FFmpeg hwupload filter}
292
854
  */
293
855
  hwupload(): string | null;
294
856
  /**
295
- * Hardware download filter to transfer frames from GPU.
857
+ * Creates a hwdownload filter to download frames from hardware memory.
858
+ *
859
+ * @returns Hardware download filter string
860
+ *
861
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#hwdownload | FFmpeg hwdownload filter}
296
862
  */
297
863
  hwdownload(): string | null;
298
864
  /**
299
- * Format conversion for hardware frames.
865
+ * Creates a hwmap filter to map frames between hardware devices.
866
+ *
867
+ * @param derive - Device to derive from (optional)
868
+ * @returns Hardware map filter string
869
+ *
870
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#hwmap | FFmpeg hwmap filter}
300
871
  */
301
872
  hwmap(derive?: string): string | null;
302
873
  /**
303
- * Get capabilities for this hardware type.
874
+ * Gets the filter capabilities for this hardware type.
875
+ *
876
+ * @returns Object describing which filters are supported
877
+ *
878
+ * @example
879
+ * ```typescript
880
+ * const caps = hw.getCapabilities();
881
+ * if (caps.scale && caps.overlay) {
882
+ * console.log('Hardware supports scaling and overlay');
883
+ * }
884
+ * ```
304
885
  */
305
886
  getCapabilities(): HardwareFilterSupport;
306
887
  /**
307
- * Get supported filters for this hardware type.
888
+ * Determines filter support for the hardware type.
889
+ *
890
+ * @returns Hardware filter support configuration
891
+ *
892
+ * @internal
308
893
  */
309
894
  private getSupport;
310
895
  }
311
896
  /**
312
897
  * Hardware filter chain builder with fluent API.
313
- * Automatically skips unsupported filters (returns null).
898
+ * Automatically skips unsupported filters (returns null) allowing graceful fallback.
899
+ *
900
+ * @example
901
+ * ```typescript
902
+ * const hw = new HardwareFilterPresets(AV_HWDEVICE_TYPE_CUDA, 'cuda');
903
+ * const chain = hw.chain()
904
+ * .hwupload()
905
+ * .scale(1920, 1080)
906
+ * .tonemap() // Skipped if not supported
907
+ * .hwdownload()
908
+ * .build();
909
+ * ```
314
910
  */
315
911
  export declare class HardwareFilterChainBuilder extends ChainBuilderBase<HardwareFilterPresets> {
316
912
  }