node-av 1.3.0 → 2.1.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 (127) hide show
  1. package/README.md +47 -40
  2. package/binding.gyp +12 -0
  3. package/dist/api/bitstream-filter.d.ts +134 -2
  4. package/dist/api/bitstream-filter.js +200 -2
  5. package/dist/api/bitstream-filter.js.map +1 -1
  6. package/dist/api/decoder.d.ts +261 -105
  7. package/dist/api/decoder.js +384 -171
  8. package/dist/api/decoder.js.map +1 -1
  9. package/dist/api/encoder.d.ts +338 -74
  10. package/dist/api/encoder.js +546 -188
  11. package/dist/api/encoder.js.map +1 -1
  12. package/dist/api/filter-presets.d.ts +479 -1513
  13. package/dist/api/filter-presets.js +1044 -2005
  14. package/dist/api/filter-presets.js.map +1 -1
  15. package/dist/api/filter.d.ts +370 -150
  16. package/dist/api/filter.js +647 -364
  17. package/dist/api/filter.js.map +1 -1
  18. package/dist/api/hardware.d.ts +25 -31
  19. package/dist/api/hardware.js +36 -70
  20. package/dist/api/hardware.js.map +1 -1
  21. package/dist/api/index.d.ts +1 -1
  22. package/dist/api/index.js +1 -1
  23. package/dist/api/index.js.map +1 -1
  24. package/dist/api/io-stream.d.ts +6 -0
  25. package/dist/api/io-stream.js +2 -0
  26. package/dist/api/io-stream.js.map +1 -1
  27. package/dist/api/media-input.d.ts +208 -2
  28. package/dist/api/media-input.js +356 -8
  29. package/dist/api/media-input.js.map +1 -1
  30. package/dist/api/media-output.d.ts +142 -104
  31. package/dist/api/media-output.js +446 -179
  32. package/dist/api/media-output.js.map +1 -1
  33. package/dist/api/pipeline.d.ts +82 -17
  34. package/dist/api/pipeline.js +80 -42
  35. package/dist/api/pipeline.js.map +1 -1
  36. package/dist/api/types.d.ts +24 -57
  37. package/dist/api/utils.js +2 -0
  38. package/dist/api/utils.js.map +1 -1
  39. package/dist/lib/audio-fifo.d.ts +103 -0
  40. package/dist/lib/audio-fifo.js +109 -0
  41. package/dist/lib/audio-fifo.js.map +1 -1
  42. package/dist/lib/binding.d.ts +1 -0
  43. package/dist/lib/binding.js.map +1 -1
  44. package/dist/lib/bitstream-filter-context.d.ts +79 -0
  45. package/dist/lib/bitstream-filter-context.js +83 -0
  46. package/dist/lib/bitstream-filter-context.js.map +1 -1
  47. package/dist/lib/bitstream-filter.d.ts +2 -0
  48. package/dist/lib/bitstream-filter.js +2 -0
  49. package/dist/lib/bitstream-filter.js.map +1 -1
  50. package/dist/lib/codec-context.d.ts +168 -0
  51. package/dist/lib/codec-context.js +178 -0
  52. package/dist/lib/codec-context.js.map +1 -1
  53. package/dist/lib/codec-parameters.d.ts +3 -0
  54. package/dist/lib/codec-parameters.js +3 -0
  55. package/dist/lib/codec-parameters.js.map +1 -1
  56. package/dist/lib/codec-parser.d.ts +6 -0
  57. package/dist/lib/codec-parser.js +6 -0
  58. package/dist/lib/codec-parser.js.map +1 -1
  59. package/dist/lib/codec.d.ts +12 -0
  60. package/dist/lib/codec.js +12 -0
  61. package/dist/lib/codec.js.map +1 -1
  62. package/dist/lib/dictionary.d.ts +18 -2
  63. package/dist/lib/dictionary.js +18 -2
  64. package/dist/lib/dictionary.js.map +1 -1
  65. package/dist/lib/error.d.ts +8 -0
  66. package/dist/lib/error.js +9 -0
  67. package/dist/lib/error.js.map +1 -1
  68. package/dist/lib/filter-context.d.ts +119 -2
  69. package/dist/lib/filter-context.js +119 -0
  70. package/dist/lib/filter-context.js.map +1 -1
  71. package/dist/lib/filter-graph.d.ts +80 -0
  72. package/dist/lib/filter-graph.js +84 -0
  73. package/dist/lib/filter-graph.js.map +1 -1
  74. package/dist/lib/filter-inout.d.ts +1 -0
  75. package/dist/lib/filter-inout.js +1 -0
  76. package/dist/lib/filter-inout.js.map +1 -1
  77. package/dist/lib/filter.d.ts +2 -0
  78. package/dist/lib/filter.js +2 -0
  79. package/dist/lib/filter.js.map +1 -1
  80. package/dist/lib/format-context.d.ts +356 -20
  81. package/dist/lib/format-context.js +375 -23
  82. package/dist/lib/format-context.js.map +1 -1
  83. package/dist/lib/frame.d.ts +84 -1
  84. package/dist/lib/frame.js +96 -0
  85. package/dist/lib/frame.js.map +1 -1
  86. package/dist/lib/hardware-device-context.d.ts +8 -0
  87. package/dist/lib/hardware-device-context.js +8 -0
  88. package/dist/lib/hardware-device-context.js.map +1 -1
  89. package/dist/lib/hardware-frames-context.d.ts +55 -0
  90. package/dist/lib/hardware-frames-context.js +57 -0
  91. package/dist/lib/hardware-frames-context.js.map +1 -1
  92. package/dist/lib/input-format.d.ts +43 -3
  93. package/dist/lib/input-format.js +48 -0
  94. package/dist/lib/input-format.js.map +1 -1
  95. package/dist/lib/io-context.d.ts +212 -0
  96. package/dist/lib/io-context.js +228 -0
  97. package/dist/lib/io-context.js.map +1 -1
  98. package/dist/lib/log.d.ts +2 -0
  99. package/dist/lib/log.js +2 -0
  100. package/dist/lib/log.js.map +1 -1
  101. package/dist/lib/native-types.d.ts +39 -1
  102. package/dist/lib/option.d.ts +90 -0
  103. package/dist/lib/option.js +97 -0
  104. package/dist/lib/option.js.map +1 -1
  105. package/dist/lib/output-format.d.ts +4 -0
  106. package/dist/lib/output-format.js +4 -0
  107. package/dist/lib/output-format.js.map +1 -1
  108. package/dist/lib/packet.d.ts +7 -0
  109. package/dist/lib/packet.js +7 -0
  110. package/dist/lib/packet.js.map +1 -1
  111. package/dist/lib/rational.d.ts +1 -0
  112. package/dist/lib/rational.js +1 -0
  113. package/dist/lib/rational.js.map +1 -1
  114. package/dist/lib/software-resample-context.d.ts +64 -0
  115. package/dist/lib/software-resample-context.js +66 -0
  116. package/dist/lib/software-resample-context.js.map +1 -1
  117. package/dist/lib/software-scale-context.d.ts +98 -0
  118. package/dist/lib/software-scale-context.js +102 -0
  119. package/dist/lib/software-scale-context.js.map +1 -1
  120. package/dist/lib/stream.d.ts +1 -0
  121. package/dist/lib/stream.js +1 -0
  122. package/dist/lib/stream.js.map +1 -1
  123. package/dist/lib/utilities.d.ts +60 -0
  124. package/dist/lib/utilities.js +60 -0
  125. package/dist/lib/utilities.js.map +1 -1
  126. package/package.json +18 -18
  127. package/release_notes.md +0 -29
@@ -1,4 +1,5 @@
1
- import type { AVHWDeviceType, AVPixelFormat, AVSampleFormat } from '../constants/constants.js';
1
+ import type { AVPixelFormat, AVSampleFormat } from '../constants/constants.js';
2
+ import type { HardwareContext } from './hardware.js';
2
3
  /**
3
4
  * Hardware filter capabilities for different platforms.
4
5
  * Maps hardware types to their supported filter operations.
@@ -13,7 +14,7 @@ import type { AVHWDeviceType, AVPixelFormat, AVSampleFormat } from '../constants
13
14
  * - Vulkan: Cross-platform with growing filter support
14
15
  * - OpenCL: Cross-platform compute-based filtering
15
16
  */
16
- export interface HardwareFilterSupport {
17
+ export interface FilterSupport {
17
18
  scale: boolean;
18
19
  overlay: boolean;
19
20
  transpose: boolean;
@@ -29,140 +30,333 @@ export interface HardwareFilterSupport {
29
30
  stack: boolean;
30
31
  }
31
32
  /**
32
- * Base class for filter preset implementations.
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.
33
+ * Filter preset builder for composing filter chains.
34
+ * Supports both software and hardware-accelerated filters.
35
+ * Automatically selects appropriate filter implementations based on hardware context.
36
+ * Uses fluent interface pattern for chaining multiple filters.
39
37
  *
40
38
  * @example
41
39
  * ```typescript
42
- * class CustomPresets extends FilterPresetBase {
43
- * override scale(width: number, height: number): string | null {
44
- * return `custom_scale=${width}:${height}`;
45
- * }
46
- * }
40
+ * // Software filter chain
41
+ * const filter = FilterPreset.chain()
42
+ * .scale(1920, 1080)
43
+ * .fps(30)
44
+ * .fade('in', 0, 2)
45
+ * .build();
46
+ *
47
+ * // Hardware-accelerated filter chain
48
+ * const hw = HardwareContext.auto();
49
+ * const hwFilter = FilterPreset.chain(hw)
50
+ * .scale(1920, 1080)
51
+ * .blur('gaussian', 5)
52
+ * .build();
47
53
  * ```
48
54
  */
49
- export declare abstract class FilterPresetBase {
55
+ export declare class FilterPreset {
56
+ private hardware?;
57
+ private filters;
58
+ private support;
59
+ private constructor();
60
+ /**
61
+ * Checks if a filter is hardware-accelerated.
62
+ *
63
+ * @param filterName - Name of the filter to check
64
+ *
65
+ * @returns True if the filter uses hardware acceleration
66
+ *
67
+ * @example
68
+ * ```typescript
69
+ * if (FilterPreset.isHardwareFilter('scale_cuda')) {
70
+ * console.log('Hardware accelerated scaling');
71
+ * }
72
+ * ```
73
+ */
74
+ static isHardwareFilter(filterName: string): boolean;
75
+ /**
76
+ * Creates a new filter chain builder.
77
+ *
78
+ * @param hardware - Optional hardware context for hardware-accelerated filters
79
+ *
80
+ * @returns A new FilterPreset instance for chaining
81
+ *
82
+ * @example
83
+ * ```typescript
84
+ * // Software filter chain
85
+ * const filter = FilterPreset.chain()
86
+ * .scale(1280, 720)
87
+ * .fps(30)
88
+ * .build();
89
+ * ```
90
+ *
91
+ * @example
92
+ * ```typescript
93
+ * // Hardware filter chain
94
+ * const hw = HardwareContext.auto();
95
+ * const filter = FilterPreset.chain(hw)
96
+ * .scale(1280, 720)
97
+ * .deinterlace()
98
+ * .build();
99
+ * ```
100
+ */
101
+ static chain(hardware?: HardwareContext | null): FilterPreset;
102
+ /**
103
+ * Adds a custom filter string to the chain.
104
+ *
105
+ * @param filter - Custom filter string
106
+ *
107
+ * @returns This instance for chaining
108
+ *
109
+ * @example
110
+ * ```typescript
111
+ * chain.custom('myfilter=param1:param2')
112
+ * ```
113
+ */
114
+ custom(filter: string): this;
115
+ /**
116
+ * Builds the final filter string.
117
+ *
118
+ * @param separator - Separator between filters (default: ',')
119
+ *
120
+ * @returns Combined filter string
121
+ *
122
+ * @example
123
+ * ```typescript
124
+ * const filterString = chain.build() // "scale=1920:1080,fps=30"
125
+ * ```
126
+ */
127
+ build(separator?: string): string;
128
+ /**
129
+ * Returns the filters as an array.
130
+ *
131
+ * @returns Array of filter strings
132
+ *
133
+ * @example
134
+ * ```typescript
135
+ * const filters = chain.toArray() // ["scale=1920:1080", "fps=30"]
136
+ * ```
137
+ */
138
+ toArray(): string[];
50
139
  /**
51
- * Creates a scale filter string.
140
+ * Adds a scale filter to the chain.
141
+ * Automatically selects hardware-specific scaler if hardware context is set.
52
142
  *
53
143
  * @param width - Target width in pixels
144
+ *
54
145
  * @param height - Target height in pixels
55
- * @param options - Additional scaling options (e.g., flags for algorithm)
56
- * @returns Filter string or null if not supported
146
+ *
147
+ * @param options - Additional scaling options (e.g., flags for algorithm, npp for CUDA)
148
+ *
149
+ * @returns This instance for chaining
57
150
  *
58
151
  * @example
59
152
  * ```typescript
60
- * presets.scale(1920, 1080) // Scale to Full HD
61
- * presets.scale(640, 480, { flags: 'lanczos' }) // With specific algorithm
153
+ * chain.scale(1920, 1080) // Scale to Full HD
154
+ * chain.scale(640, 480, { flags: 'lanczos' }) // With specific algorithm
155
+ * chain.scale(1920, 1080, { npp: true }) // Use NPP for CUDA
62
156
  * ```
63
157
  *
64
158
  * @see {@link https://ffmpeg.org/ffmpeg-filters.html#scale | FFmpeg scale filter}
65
159
  */
66
- scale(width: number, height: number, options?: Record<string, any>): string | null;
160
+ scale(width: number, height: number, options?: Record<string, any>): FilterPreset;
67
161
  /**
68
- * Creates a crop filter string.
162
+ * Adds a crop filter to the chain.
69
163
  *
70
164
  * @param width - Width of the cropped area
165
+ *
71
166
  * @param height - Height of the cropped area
167
+ *
72
168
  * @param x - X coordinate of top-left corner (default: 0)
169
+ *
73
170
  * @param y - Y coordinate of top-left corner (default: 0)
74
- * @returns Filter string or null if not supported
171
+ *
172
+ * @returns This instance for chaining
75
173
  *
76
174
  * @example
77
175
  * ```typescript
78
- * presets.crop(640, 480, 100, 100) // Crop 640x480 area starting at (100,100)
79
- * presets.crop(1280, 720) // Crop from top-left corner
176
+ * chain.crop(640, 480, 100, 100) // Crop 640x480 area starting at (100,100)
177
+ * chain.crop(1280, 720) // Crop from top-left corner
80
178
  * ```
81
179
  *
82
180
  * @see {@link https://ffmpeg.org/ffmpeg-filters.html#crop | FFmpeg crop filter}
83
181
  */
84
- crop(width: number, height: number, x?: number, y?: number): string | null;
182
+ crop(width: number, height: number, x?: number, y?: number): FilterPreset;
183
+ /**
184
+ * Adds a blur filter to the chain (hardware-specific).
185
+ * Only available for hardware presets that support blur
186
+ *
187
+ * @param type - Blur type (default: 'avg')
188
+ *
189
+ * @param radius - Blur radius (optional)
190
+ *
191
+ * @returns This instance for chaining
192
+ *
193
+ * @example
194
+ * ```typescript
195
+ * const chain = FilterPresets.chain()
196
+ * .blur('gaussian', 5)
197
+ * .build();
198
+ * ```
199
+ *
200
+ * @example
201
+ * ```typescript
202
+ * const chain = FilterPresets.chain()
203
+ * .blur('box')
204
+ * .build();
205
+ * ```
206
+ */
207
+ blur(type?: 'avg' | 'gaussian' | 'box', radius?: number): FilterPreset;
208
+ /**
209
+ * Adds a sharpen filter to the chain (hardware-specific).
210
+ * Only available for hardware presets that support sharpening
211
+ *
212
+ * @param amount - Sharpen amount (optional)
213
+ *
214
+ * @returns This instance for chaining
215
+ *
216
+ * @example
217
+ * ```typescript
218
+ * const chain = FilterPresets.chain()
219
+ * .sharpen(1.5)
220
+ * .build();
221
+ * ```
222
+ *
223
+ * @example
224
+ * ```typescript
225
+ * const chain = FilterPresets.chain()
226
+ * .sharpen()
227
+ * .build();
228
+ * ```
229
+ */
230
+ sharpen(amount?: number): FilterPreset;
85
231
  /**
86
- * Creates an FPS filter string to change frame rate.
232
+ * Adds an FPS filter to change frame rate.
87
233
  *
88
234
  * @param fps - Target frames per second
89
- * @returns Filter string or null if not supported
235
+ *
236
+ * @returns This instance for chaining
90
237
  *
91
238
  * @example
92
239
  * ```typescript
93
- * presets.fps(30) // Convert to 30 FPS
94
- * presets.fps(23.976) // Film frame rate
240
+ * chain.fps(30) // Convert to 30 FPS
241
+ * chain.fps(23.976) // Film frame rate
95
242
  * ```
96
243
  *
97
244
  * @see {@link https://ffmpeg.org/ffmpeg-filters.html#fps | FFmpeg fps filter}
98
245
  */
99
- fps(fps: number): string | null;
246
+ fps(fps: number): FilterPreset;
100
247
  /**
101
- * Creates a format filter string to convert pixel format.
248
+ * Adds a format filter to convert pixel format.
102
249
  *
103
- * @param pixelFormat - Target pixel format(s) - can be string, AVPixelFormat enum, or array
104
- * @returns Filter string or null if not supported
250
+ * @param pixelFormat - Target pixel format(s) - AVPixelFormat enum, or array
251
+ *
252
+ * @returns This instance for chaining
105
253
  *
106
254
  * @example
107
255
  * ```typescript
108
256
  * // Single format
109
- * presets.format('yuv420p');
110
- * presets.format(AV_PIX_FMT_YUV420P);
257
+ * chain.format(AV_PIX_FMT_YUV420P);
111
258
  *
112
- * // Multiple formats (creates a chain)
113
- * presets.format(['yuv420p', 'rgb24']);
259
+ * // Multiple formats (tries formats in order)
260
+ * chain.format([AV_PIX_FMT_YUV420P, AV_PIX_FMT_RGB24]);
114
261
  * ```
115
262
  *
116
263
  * @see {@link https://ffmpeg.org/ffmpeg-filters.html#format | FFmpeg format filter}
117
264
  */
118
- format(pixelFormat: string | AVPixelFormat | (string | AVPixelFormat)[]): string | null;
265
+ format(pixelFormat: AVPixelFormat | AVPixelFormat[]): FilterPreset;
119
266
  /**
120
- * Creates a rotate filter string.
267
+ * Adds a rotate filter to the chain.
121
268
  *
122
269
  * @param angle - Rotation angle in degrees
123
- * @returns Filter string or null if not supported
270
+ *
271
+ * @returns This instance for chaining
124
272
  *
125
273
  * @example
126
274
  * ```typescript
127
- * presets.rotate(90) // Rotate 90 degrees clockwise
128
- * presets.rotate(-45) // Rotate 45 degrees counter-clockwise
275
+ * chain.rotate(90) // Rotate 90 degrees clockwise
276
+ * chain.rotate(-45) // Rotate 45 degrees counter-clockwise
129
277
  * ```
130
278
  *
131
279
  * @see {@link https://ffmpeg.org/ffmpeg-filters.html#rotate | FFmpeg rotate filter}
132
280
  */
133
- rotate(angle: number): string | null;
281
+ rotate(angle: number): FilterPreset;
134
282
  /**
135
- * Creates a horizontal flip filter string.
283
+ * Adds a flip filter to the chain (hardware-specific).
284
+ * Falls back to hflip/vflip if hardware flip not available
136
285
  *
137
- * @returns Filter string or null if not supported
286
+ * @param direction - Flip direction ('h' or 'v')
287
+ *
288
+ * @returns This instance for chaining
289
+ *
290
+ * @example
291
+ * ```typescript
292
+ * const chain = FilterPresets.chain()
293
+ * .flip('h')
294
+ * .build();
295
+ * ```
296
+ *
297
+ * @example
298
+ * ```typescript
299
+ * const chain = FilterPresets.chain()
300
+ * .flip('v')
301
+ * .build();
302
+ * ```
303
+ */
304
+ flip(direction: 'h' | 'v'): FilterPreset;
305
+ /**
306
+ * Adds a stack filter to the chain (hardware-specific).
307
+ * Only available for hardware presets that support stacking
308
+ *
309
+ * @param type - Stack type ('h' for horizontal, 'v' for vertical, 'x' for grid)
310
+ *
311
+ * @param inputs - Number of inputs (default: 2)
312
+ *
313
+ * @returns This instance for chaining
138
314
  *
139
315
  * @example
140
316
  * ```typescript
141
- * presets.hflip() // Mirror horizontally
317
+ * const chain = FilterPresets.chain()
318
+ * .stack('h', 2)
319
+ * .build();
142
320
  * ```
143
321
  *
144
- * @see {@link https://ffmpeg.org/ffmpeg-filters.html#hflip | FFmpeg hflip filter}
322
+ * @example
323
+ * ```typescript
324
+ * const chain = FilterPresets.chain()
325
+ * .stack('x', 4)
326
+ * .build();
327
+ * ```
145
328
  */
146
- hflip(): string | null;
329
+ stack(type: 'h' | 'v' | 'x', inputs?: number): FilterPreset;
147
330
  /**
148
- * Creates a vertical flip filter string.
331
+ * Creates a tonemap filter.
332
+ * Used for HDR to SDR conversion with hardware acceleration.
149
333
  *
150
- * @returns Filter string or null if not supported
334
+ * @param alg - Tonemapping algorithm (e.g., 'hable', 'reinhard', 'mobius', etc.)
335
+ *
336
+ * @param options - Tonemapping options
337
+ *
338
+ * @returns Hardware tonemap filter string or null if not supported
151
339
  *
152
340
  * @example
153
341
  * ```typescript
154
- * presets.vflip() // Flip upside down
342
+ * const filter = hwPresets.tonemap();
155
343
  * ```
156
344
  *
157
- * @see {@link https://ffmpeg.org/ffmpeg-filters.html#vflip | FFmpeg vflip filter}
345
+ * @example
346
+ * ```typescript
347
+ * const filter = hwPresets.tonemap({ tonemap: 'hable', desat: '0' });
348
+ * ```
158
349
  */
159
- vflip(): string | null;
350
+ tonemap(alg: string, options: Record<string, string | number>): FilterPreset;
160
351
  /**
161
352
  * Creates a fade filter string for video.
162
353
  *
163
354
  * @param type - Fade type ('in' or 'out')
355
+ *
164
356
  * @param start - Start time in seconds
357
+ *
165
358
  * @param duration - Fade duration in seconds
359
+ *
166
360
  * @returns Filter string or null if not supported
167
361
  *
168
362
  * @example
@@ -173,13 +367,16 @@ export declare abstract class FilterPresetBase {
173
367
  *
174
368
  * @see {@link https://ffmpeg.org/ffmpeg-filters.html#fade | FFmpeg fade filter}
175
369
  */
176
- fade(type: 'in' | 'out', start: number, duration: number): string | null;
370
+ fade(type: 'in' | 'out', start: number, duration: number): FilterPreset;
177
371
  /**
178
372
  * Creates an overlay filter string to composite two video streams.
179
373
  *
180
374
  * @param x - X position for overlay (default: 0)
375
+ *
181
376
  * @param y - Y position for overlay (default: 0)
377
+ *
182
378
  * @param options - Additional overlay options
379
+ *
183
380
  * @returns Filter string or null if not supported
184
381
  *
185
382
  * @example
@@ -193,11 +390,12 @@ export declare abstract class FilterPresetBase {
193
390
  *
194
391
  * @see {@link https://ffmpeg.org/ffmpeg-filters.html#overlay | FFmpeg overlay filter}
195
392
  */
196
- overlay(x?: number, y?: number, options?: Record<string, string>): string | null;
393
+ overlay(x?: number, y?: number, options?: Record<string, string>): FilterPreset;
197
394
  /**
198
395
  * Creates a volume filter string for audio.
199
396
  *
200
397
  * @param factor - Volume multiplication factor (1.0 = unchanged, 2.0 = double)
398
+ *
201
399
  * @returns Filter string or null if not supported
202
400
  *
203
401
  * @example
@@ -208,13 +406,16 @@ export declare abstract class FilterPresetBase {
208
406
  *
209
407
  * @see {@link https://ffmpeg.org/ffmpeg-filters.html#volume | FFmpeg volume filter}
210
408
  */
211
- volume(factor: number): string | null;
409
+ volume(factor: number): FilterPreset;
212
410
  /**
213
411
  * Creates an audio format filter string.
214
412
  *
215
413
  * @param sampleFormat - Target sample format (e.g., 's16', 'fltp')
414
+ *
216
415
  * @param sampleRate - Target sample rate in Hz (optional)
416
+ *
217
417
  * @param channelLayout - Target channel layout (optional)
418
+ *
218
419
  * @returns Filter string or null if not supported
219
420
  *
220
421
  * @example
@@ -231,122 +432,155 @@ export declare abstract class FilterPresetBase {
231
432
  *
232
433
  * @see {@link https://ffmpeg.org/ffmpeg-filters.html#aformat | FFmpeg aformat filter}
233
434
  */
234
- aformat(sampleFormat: string | AVSampleFormat, sampleRate?: number, channelLayout?: string): string | null;
435
+ aformat(sampleFormat: AVSampleFormat | AVSampleFormat[], sampleRate?: number, channelLayout?: string): FilterPreset;
235
436
  /**
236
- * Creates an asetnsamples filter string to set the number of samples per frame.
437
+ * Adds an asetnsamples filter to set the number of samples per frame.
237
438
  * This is crucial for encoders like Opus that require specific frame sizes.
238
439
  *
239
440
  * @param samples - Number of samples per frame
441
+ *
240
442
  * @param padding - Whether to pad or drop samples (default: true)
241
- * @returns Filter string or null if not supported
443
+ *
444
+ * @returns This instance for chaining
242
445
  *
243
446
  * @example
244
447
  * ```typescript
245
448
  * // For Opus encoder (requires 960 samples)
246
- * presets.asetnsamples(960);
449
+ * chain.asetnsamples(960);
247
450
  *
248
451
  * // Drop samples instead of padding
249
- * presets.asetnsamples(1024, false);
452
+ * chain.asetnsamples(1024, false);
250
453
  * ```
251
454
  *
252
455
  * @see {@link https://ffmpeg.org/ffmpeg-filters.html#asetnsamples | FFmpeg asetnsamples filter}
253
456
  */
254
- asetnsamples(samples: number, padding?: boolean): string | null;
457
+ asetnsamples(samples: number, padding?: boolean): FilterPreset;
458
+ /**
459
+ * Adds an aresample filter to change audio sample rate.
460
+ *
461
+ * @param rate - Target sample rate in Hz
462
+ *
463
+ * @returns This instance for chaining
464
+ *
465
+ * @example
466
+ * ```typescript
467
+ * chain.aresample(44100) // Convert to 44.1 kHz
468
+ * chain.aresample(48000) // Convert to 48 kHz
469
+ * ```
470
+ *
471
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#aresample | FFmpeg aresample filter}
472
+ */
473
+ aresample(rate: number): FilterPreset;
255
474
  /**
256
- * Creates an atempo filter string to change audio playback speed.
475
+ * Adds an atempo filter to change audio playback speed.
257
476
  * Factor must be between 0.5 and 2.0. For larger changes, chain multiple atempo filters.
258
477
  *
259
478
  * @param factor - Tempo factor (0.5 = half speed, 2.0 = double speed)
260
- * @returns Filter string or null if not supported
479
+ *
480
+ * @returns This instance for chaining
261
481
  *
262
482
  * @example
263
483
  * ```typescript
264
- * presets.atempo(1.5) // 1.5x speed
265
- * presets.atempo(0.8) // Slow down to 80% speed
484
+ * chain.atempo(1.5) // 1.5x speed
485
+ * chain.atempo(0.8) // Slow down to 80% speed
266
486
  * ```
267
487
  *
268
488
  * @see {@link https://ffmpeg.org/ffmpeg-filters.html#atempo | FFmpeg atempo filter}
269
489
  */
270
- atempo(factor: number): string | null;
490
+ atempo(factor: number): FilterPreset;
271
491
  /**
272
- * Creates an audio fade filter string.
492
+ * Adds an audio fade filter.
273
493
  *
274
494
  * @param type - Fade type ('in' or 'out')
495
+ *
275
496
  * @param start - Start time in seconds
497
+ *
276
498
  * @param duration - Fade duration in seconds
277
- * @returns Filter string or null if not supported
499
+ *
500
+ * @returns This instance for chaining
278
501
  *
279
502
  * @example
280
503
  * ```typescript
281
- * presets.afade('in', 0, 3) // 3-second audio fade in
282
- * presets.afade('out', 20, 2) // 2-second fade out at 20s
504
+ * chain.afade('in', 0, 3) // 3-second audio fade in
505
+ * chain.afade('out', 20, 2) // 2-second fade out at 20s
283
506
  * ```
284
507
  *
285
508
  * @see {@link https://ffmpeg.org/ffmpeg-filters.html#afade | FFmpeg afade filter}
286
509
  */
287
- afade(type: 'in' | 'out', start: number, duration: number): string | null;
510
+ afade(type: 'in' | 'out', start: number, duration: number): FilterPreset;
288
511
  /**
289
- * Creates an amix filter string to mix multiple audio streams.
512
+ * Adds an amix filter to mix multiple audio streams.
290
513
  *
291
514
  * @param inputs - Number of input streams to mix (default: 2)
515
+ *
292
516
  * @param duration - How to determine output duration (default: 'longest')
293
- * @returns Filter string or null if not supported
517
+ *
518
+ * @returns This instance for chaining
294
519
  *
295
520
  * @example
296
521
  * ```typescript
297
- * presets.amix(3, 'longest') // Mix 3 audio streams
298
- * presets.amix(2, 'first') // Mix 2 streams, use first's duration
522
+ * chain.amix(3, 'longest') // Mix 3 audio streams
523
+ * chain.amix(2, 'first') // Mix 2 streams, use first's duration
299
524
  * ```
300
525
  *
301
526
  * @see {@link https://ffmpeg.org/ffmpeg-filters.html#amix | FFmpeg amix filter}
302
527
  */
303
- amix(inputs?: number, duration?: 'first' | 'longest' | 'shortest'): string | null;
528
+ amix(inputs?: number, duration?: 'first' | 'longest' | 'shortest'): FilterPreset;
304
529
  /**
305
- * Creates a pad filter string to add padding to video.
530
+ * Adds a pad filter to add padding to video.
306
531
  * Essential for aspect ratio adjustments and letterboxing.
307
532
  *
308
533
  * @param width - Output width (can use expressions like 'iw+100')
534
+ *
309
535
  * @param height - Output height (can use expressions like 'ih+100')
536
+ *
310
537
  * @param x - X position of input video (default: '(ow-iw)/2' for center)
538
+ *
311
539
  * @param y - Y position of input video (default: '(oh-ih)/2' for center)
540
+ *
312
541
  * @param color - Padding color (default: 'black')
313
- * @returns Filter string or null if not supported
542
+ *
543
+ * @returns This instance for chaining
314
544
  *
315
545
  * @example
316
546
  * ```typescript
317
547
  * // Add black bars for 16:9 aspect ratio
318
- * presets.pad('iw', 'iw*9/16');
548
+ * chain.pad('iw', 'iw*9/16');
319
549
  *
320
550
  * // Add 50px padding on all sides
321
- * presets.pad('iw+100', 'ih+100');
551
+ * chain.pad('iw+100', 'ih+100');
322
552
  * ```
323
553
  *
324
554
  * @see {@link https://ffmpeg.org/ffmpeg-filters.html#pad | FFmpeg pad filter}
325
555
  */
326
- pad(width: string | number, height: string | number, x?: string, y?: string, color?: string): string | null;
556
+ pad(width: string | number, height: string | number, x?: string, y?: string, color?: string): FilterPreset;
327
557
  /**
328
- * Creates a trim filter string to cut a portion of the stream.
558
+ * Adds a trim filter to cut a portion of the stream.
329
559
  * Crucial for cutting segments from media.
330
560
  *
331
561
  * @param start - Start time in seconds
562
+ *
332
563
  * @param end - End time in seconds (optional)
564
+ *
333
565
  * @param duration - Duration in seconds (optional, alternative to end)
334
- * @returns Filter string or null if not supported
566
+ *
567
+ * @returns This instance for chaining
335
568
  *
336
569
  * @example
337
570
  * ```typescript
338
- * presets.trim(10, 30) // Extract from 10s to 30s
339
- * presets.trim(5, undefined, 10) // Extract 10s starting at 5s
571
+ * chain.trim(10, 30) // Extract from 10s to 30s
572
+ * chain.trim(5, undefined, 10) // Extract 10s starting at 5s
340
573
  * ```
341
574
  *
342
575
  * @see {@link https://ffmpeg.org/ffmpeg-filters.html#trim | FFmpeg trim filter}
343
576
  */
344
- trim(start: number, end?: number, duration?: number): string | null;
577
+ trim(start: number, end?: number, duration?: number): FilterPreset;
345
578
  /**
346
579
  * Creates a setpts filter string to change presentation timestamps.
347
580
  * Essential for speed changes and timestamp manipulation.
348
581
  *
349
582
  * @param expression - PTS expression (e.g., 'PTS*2' for half speed, 'PTS/2' for double speed)
583
+ *
350
584
  * @returns Filter string or null if not supported
351
585
  *
352
586
  * @example
@@ -363,11 +597,12 @@ export declare abstract class FilterPresetBase {
363
597
  *
364
598
  * @see {@link https://ffmpeg.org/ffmpeg-filters.html#setpts | FFmpeg setpts filter}
365
599
  */
366
- setpts(expression: string): string | null;
600
+ setpts(expression: string): FilterPreset;
367
601
  /**
368
602
  * Creates an asetpts filter string for audio timestamp manipulation.
369
603
  *
370
604
  * @param expression - PTS expression
605
+ *
371
606
  * @returns Filter string or null if not supported
372
607
  *
373
608
  * @example
@@ -377,12 +612,13 @@ export declare abstract class FilterPresetBase {
377
612
  *
378
613
  * @see {@link https://ffmpeg.org/ffmpeg-filters.html#asetpts | FFmpeg asetpts filter}
379
614
  */
380
- asetpts(expression: string): string | null;
615
+ asetpts(expression: string): FilterPreset;
381
616
  /**
382
617
  * Creates a transpose filter string for rotation/flipping.
383
618
  * More efficient than rotate for 90-degree rotations.
384
619
  *
385
620
  * @param mode - Transpose mode (0-3, or named constants)
621
+ *
386
622
  * @returns Filter string or null if not supported
387
623
  *
388
624
  * @example
@@ -393,12 +629,13 @@ export declare abstract class FilterPresetBase {
393
629
  *
394
630
  * @see {@link https://ffmpeg.org/ffmpeg-filters.html#transpose | FFmpeg transpose filter}
395
631
  */
396
- transpose(mode: number | 'clock' | 'cclock' | 'clock_flip' | 'cclock_flip'): string | null;
632
+ transpose(mode: number | 'clock' | 'cclock' | 'clock_flip' | 'cclock_flip'): FilterPreset;
397
633
  /**
398
634
  * Creates a setsar filter string to set sample aspect ratio.
399
635
  * Important for correcting aspect ratio issues.
400
636
  *
401
637
  * @param ratio - Aspect ratio (e.g., '1:1', '16:9', or number)
638
+ *
402
639
  * @returns Filter string or null if not supported
403
640
  *
404
641
  * @example
@@ -409,11 +646,12 @@ export declare abstract class FilterPresetBase {
409
646
  *
410
647
  * @see {@link https://ffmpeg.org/ffmpeg-filters.html#setsar | FFmpeg setsar/setdar filter}
411
648
  */
412
- setsar(ratio: string | number): string | null;
649
+ setsar(ratio: string | number): FilterPreset;
413
650
  /**
414
651
  * Creates a setdar filter string to set display aspect ratio.
415
652
  *
416
653
  * @param ratio - Aspect ratio (e.g., '16:9', '4:3')
654
+ *
417
655
  * @returns Filter string or null if not supported
418
656
  *
419
657
  * @example
@@ -424,30 +662,35 @@ export declare abstract class FilterPresetBase {
424
662
  *
425
663
  * @see {@link https://ffmpeg.org/ffmpeg-filters.html#setsar | FFmpeg setsar/setdar filter}
426
664
  */
427
- setdar(ratio: string | number): string | null;
665
+ setdar(ratio: string | number): FilterPreset;
428
666
  /**
429
- * Creates an apad filter string to add audio padding.
667
+ * Adds an apad filter to add audio padding.
430
668
  * Useful for ensuring minimum audio duration.
431
669
  *
432
670
  * @param wholeDuration - Minimum duration in seconds (optional)
671
+ *
433
672
  * @param padDuration - Amount of padding to add in seconds (optional)
434
- * @returns Filter string or null if not supported
673
+ *
674
+ * @returns This instance for chaining
435
675
  *
436
676
  * @example
437
677
  * ```typescript
438
- * presets.apad(30) // Ensure at least 30 seconds total
439
- * presets.apad(undefined, 5) // Add 5 seconds of padding
678
+ * chain.apad(30) // Ensure at least 30 seconds total
679
+ * chain.apad(undefined, 5) // Add 5 seconds of padding
440
680
  * ```
441
681
  *
442
682
  * @see {@link https://ffmpeg.org/ffmpeg-filters.html#apad | FFmpeg apad filter}
443
683
  */
444
- apad(wholeDuration?: number, padDuration?: number): string | null;
684
+ apad(wholeDuration?: number, padDuration?: number): FilterPreset;
445
685
  /**
446
686
  * Creates a deinterlace filter string.
447
687
  * Essential for processing interlaced content.
448
688
  *
449
689
  * @param mode - Deinterlace mode (default: 'yadif')
450
- * @returns Filter string or null if not supported
690
+ *
691
+ * @param options - Additional options for the filter
692
+ *
693
+ * @returns Filter string or null if not supported
451
694
  *
452
695
  * @example
453
696
  * ```typescript
@@ -457,12 +700,13 @@ export declare abstract class FilterPresetBase {
457
700
  *
458
701
  * @see {@link https://ffmpeg.org/ffmpeg-filters.html#yadif | FFmpeg yadif filter}
459
702
  */
460
- deinterlace(mode?: 'yadif' | 'bwdif' | 'w3fdif'): string | null;
703
+ deinterlace(mode?: 'yadif' | 'bwdif' | 'w3fdif', options?: Record<string, any>): FilterPreset;
461
704
  /**
462
705
  * Creates a select filter string to select specific frames.
463
706
  * Powerful for extracting keyframes, specific frame types, etc.
464
707
  *
465
708
  * @param expression - Selection expression
709
+ *
466
710
  * @returns Filter string or null if not supported
467
711
  *
468
712
  * @example
@@ -473,11 +717,12 @@ export declare abstract class FilterPresetBase {
473
717
  *
474
718
  * @see {@link https://ffmpeg.org/ffmpeg-filters.html#select | FFmpeg select filter}
475
719
  */
476
- select(expression: string): string | null;
720
+ select(expression: string): FilterPreset;
477
721
  /**
478
722
  * Creates an aselect filter string for audio selection.
479
723
  *
480
724
  * @param expression - Selection expression
725
+ *
481
726
  * @returns Filter string or null if not supported
482
727
  *
483
728
  * @example
@@ -487,14 +732,17 @@ export declare abstract class FilterPresetBase {
487
732
  *
488
733
  * @see {@link https://ffmpeg.org/ffmpeg-filters.html#aselect | FFmpeg aselect filter}
489
734
  */
490
- aselect(expression: string): string | null;
735
+ aselect(expression: string): FilterPreset;
491
736
  /**
492
737
  * Creates a concat filter string to concatenate multiple inputs.
493
738
  * Essential for joining multiple video/audio segments.
494
739
  *
495
740
  * @param n - Number of input segments
741
+ *
496
742
  * @param v - Number of output video streams (0 or 1)
743
+ *
497
744
  * @param a - Number of output audio streams (0 or 1)
745
+ *
498
746
  * @returns Filter string or null if not supported
499
747
  *
500
748
  * @example
@@ -505,12 +753,13 @@ export declare abstract class FilterPresetBase {
505
753
  *
506
754
  * @see {@link https://ffmpeg.org/ffmpeg-filters.html#concat | FFmpeg concat filter}
507
755
  */
508
- concat(n: number, v?: number, a?: number): string | null;
756
+ concat(n: number, v?: number, a?: number): FilterPreset;
509
757
  /**
510
758
  * Creates an amerge filter string to merge multiple audio streams into one.
511
759
  * Different from amix - this creates multi-channel output.
512
760
  *
513
761
  * @param inputs - Number of input streams
762
+ *
514
763
  * @returns Filter string or null if not supported
515
764
  *
516
765
  * @example
@@ -521,12 +770,13 @@ export declare abstract class FilterPresetBase {
521
770
  *
522
771
  * @see {@link https://ffmpeg.org/ffmpeg-filters.html#amerge | FFmpeg amerge filter}
523
772
  */
524
- amerge(inputs?: number): string | null;
773
+ amerge(inputs?: number): FilterPreset;
525
774
  /**
526
775
  * Creates a channelmap filter string to remap audio channels.
527
776
  * Critical for audio channel manipulation.
528
777
  *
529
778
  * @param map - Channel mapping (e.g., '0-0|1-1' or 'FL-FR|FR-FL' to swap stereo)
779
+ *
530
780
  * @returns Filter string or null if not supported
531
781
  *
532
782
  * @example
@@ -537,11 +787,12 @@ export declare abstract class FilterPresetBase {
537
787
  *
538
788
  * @see {@link https://ffmpeg.org/ffmpeg-filters.html#channelmap | FFmpeg channelmap filter}
539
789
  */
540
- channelmap(map: string): string | null;
790
+ channelmap(map: string): FilterPreset;
541
791
  /**
542
792
  * Creates a channelsplit filter string to split audio channels.
543
793
  *
544
794
  * @param channelLayout - Channel layout to split (optional)
795
+ *
545
796
  * @returns Filter string or null if not supported
546
797
  *
547
798
  * @example
@@ -552,14 +803,17 @@ export declare abstract class FilterPresetBase {
552
803
  *
553
804
  * @see {@link https://ffmpeg.org/ffmpeg-filters.html#channelsplit | FFmpeg channelsplit filter}
554
805
  */
555
- channelsplit(channelLayout?: string): string | null;
806
+ channelsplit(channelLayout?: string): FilterPreset;
556
807
  /**
557
808
  * Creates a loudnorm filter string for loudness normalization.
558
809
  * Essential for broadcast compliance and consistent audio levels.
559
810
  *
560
811
  * @param I - Integrated loudness target (default: -24 LUFS)
812
+ *
561
813
  * @param TP - True peak (default: -2 dBTP)
814
+ *
562
815
  * @param LRA - Loudness range (default: 7 LU)
816
+ *
563
817
  * @returns Filter string or null if not supported
564
818
  *
565
819
  * @example
@@ -570,15 +824,19 @@ export declare abstract class FilterPresetBase {
570
824
  *
571
825
  * @see {@link https://ffmpeg.org/ffmpeg-filters.html#loudnorm | FFmpeg loudnorm filter}
572
826
  */
573
- loudnorm(I?: number, TP?: number, LRA?: number): string | null;
827
+ loudnorm(I?: number, TP?: number, LRA?: number): FilterPreset;
574
828
  /**
575
829
  * Creates a compand filter string for audio compression/expansion.
576
830
  * Important for dynamic range control.
577
831
  *
578
832
  * @param attacks - Attack times
833
+ *
579
834
  * @param decays - Decay times
835
+ *
580
836
  * @param points - Transfer function points
837
+ *
581
838
  * @param gain - Output gain
839
+ *
582
840
  * @returns Filter string or null if not supported
583
841
  *
584
842
  * @example
@@ -588,1577 +846,285 @@ export declare abstract class FilterPresetBase {
588
846
  *
589
847
  * @see {@link https://ffmpeg.org/ffmpeg-filters.html#compand | FFmpeg compand filter}
590
848
  */
591
- compand(attacks: string, decays: string, points: string, gain?: number): string | null;
592
- }
593
- /**
594
- * Filter chain builder for composing multiple filters.
595
- * Allows fluent API for building complex filter graphs by chaining filter operations.
596
- *
597
- * @example
598
- * ```typescript
599
- * const chain = new FilterChain()
600
- * .add('scale=1920:1080')
601
- * .add('fps=30')
602
- * .custom('rotate=45*PI/180')
603
- * .build();
604
- * // Result: "scale=1920:1080,fps=30,rotate=45*PI/180"
605
- * ```
606
- */
607
- export declare class FilterChain {
608
- private filters;
849
+ compand(attacks: string, decays: string, points: string, gain?: number): FilterPreset;
609
850
  /**
610
- * Adds a filter to the chain.
851
+ * Adds a drawtext filter to overlay text on video.
611
852
  *
612
- * @param filter - Filter string to add (ignored if null/undefined)
613
- * @returns This instance for chaining
853
+ * @param text - Text to display
614
854
  *
615
- * @example
616
- * ```typescript
617
- * chain.add('scale=1920:1080')
618
- * ```
619
- */
620
- add(filter: string | null | undefined): this;
621
- /**
622
- * Adds a custom filter string to the chain.
855
+ * @param options - Text rendering options
623
856
  *
624
- * @param filter - Custom filter string
625
857
  * @returns This instance for chaining
626
858
  *
627
859
  * @example
628
860
  * ```typescript
629
- * chain.custom('myfilter=param1:param2')
630
- * ```
631
- */
632
- custom(filter: string): this;
633
- /**
634
- * Builds the final filter string.
635
- *
636
- * @param separator - Separator between filters (default: ',')
637
- * @returns Combined filter string
638
- *
639
- * @example
640
- * ```typescript
641
- * const filterString = chain.build() // "scale=1920:1080,fps=30"
861
+ * chain.drawtext('Hello World', { x: 10, y: 10, fontsize: 24 })
862
+ * chain.drawtext('Timestamp', {
863
+ * x: 10,
864
+ * y: 10,
865
+ * fontsize: 24,
866
+ * fontcolor: 'white',
867
+ * fontfile: '/path/to/font.ttf'
868
+ * })
642
869
  * ```
643
- */
644
- build(separator?: string): string;
645
- /**
646
- * Returns the filters as an array.
647
- *
648
- * @returns Array of filter strings
649
870
  *
650
- * @example
651
- * ```typescript
652
- * const filters = chain.toArray() // ["scale=1920:1080", "fps=30"]
653
- * ```
654
- */
655
- toArray(): string[];
656
- }
657
- /**
658
- * Base chain builder with common filter methods.
659
- * Provides a fluent API for building filter chains using preset methods.
660
- *
661
- * @template T The preset type this builder uses
662
- *
663
- * @example
664
- * ```typescript
665
- * const chain = new ChainBuilderBase(presets)
666
- * .scale(1920, 1080)
667
- * .fps(30)
668
- * .fade('in', 0, 2)
669
- * .build();
670
- * ```
671
- */
672
- export declare abstract class ChainBuilderBase<T extends FilterPresetBase> extends FilterChain {
673
- protected readonly presets: T;
674
- /**
675
- * @param presets - The filter presets to use
676
- * @internal
871
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#drawtext | FFmpeg drawtext filter}
677
872
  */
678
- constructor(presets: T);
873
+ drawtext(text: string, options: Record<string, any>): FilterPreset;
679
874
  /**
680
- * Adds a scale filter to the chain.
875
+ * Adds a split filter to duplicate a video stream.
681
876
  *
682
- * @param width - Target width
683
- * @param height - Target height
684
- * @param options - Additional scaling options
877
+ * @param outputs - Number of output streams (default: 2)
685
878
  *
686
879
  * @returns This instance for chaining
687
880
  *
688
881
  * @example
689
882
  * ```typescript
690
- * const chain = FilterPresets.chain()
691
- * .scale(1920, 1080)
692
- * .build();
693
- * ```
694
- *
695
- * @example
696
- * ```typescript
697
- * const chain = FilterPresets.chain()
698
- * .scale(1280, 720, { flags: 'lanczos' })
699
- * .build();
883
+ * chain.split() // Split into 2 outputs
884
+ * chain.split(3) // Split into 3 outputs
700
885
  * ```
701
886
  *
702
- * @see {@link FilterPresetBase.scale}
887
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#split | FFmpeg split filter}
703
888
  */
704
- scale(width: number, height: number, options?: Record<string, any>): this;
889
+ split(outputs?: number): FilterPreset;
705
890
  /**
706
- * Adds a crop filter to the chain.
891
+ * Adds an asplit filter to duplicate an audio stream.
707
892
  *
708
- * @param width - Crop width
709
- * @param height - Crop height
710
- * @param x - X position (default: 0)
711
- * @param y - Y position (default: 0)
893
+ * @param outputs - Number of output streams (default: 2)
712
894
  *
713
895
  * @returns This instance for chaining
714
896
  *
715
897
  * @example
716
898
  * ```typescript
717
- * const chain = FilterPresets.chain()
718
- * .crop(640, 480)
719
- * .build();
720
- * ```
721
- *
722
- * @example
723
- * ```typescript
724
- * const chain = FilterPresets.chain()
725
- * .crop(1920, 1080, 100, 50)
726
- * .build();
899
+ * chain.asplit() // Split into 2 outputs
900
+ * chain.asplit(3) // Split into 3 outputs
727
901
  * ```
728
902
  *
729
- * @see {@link FilterPresetBase.crop}
903
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#asplit | FFmpeg asplit filter}
730
904
  */
731
- crop(width: number, height: number, x?: number, y?: number): this;
905
+ asplit(outputs?: number): FilterPreset;
732
906
  /**
733
- * Adds an FPS filter to the chain.
907
+ * Adds an adelay filter to delay audio by specified milliseconds.
734
908
  *
735
- * @param fps - Target frame rate
909
+ * @param delays - Delay in milliseconds (single value or array for multiple channels)
736
910
  *
737
911
  * @returns This instance for chaining
738
912
  *
739
913
  * @example
740
914
  * ```typescript
741
- * const chain = FilterPresets.chain()
742
- * .fps(30)
743
- * .build();
744
- * ```
745
- *
746
- * @example
747
- * ```typescript
748
- * const chain = FilterPresets.chain()
749
- * .fps(23.976)
750
- * .build();
915
+ * chain.adelay(100) // Delay all channels by 100ms
916
+ * chain.adelay([100, 200]) // Delay first channel by 100ms, second by 200ms
751
917
  * ```
752
918
  *
753
- * @see {@link FilterPresetBase.fps}
919
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#adelay | FFmpeg adelay filter}
754
920
  */
755
- fps(fps: number): this;
921
+ adelay(delays: number | number[]): FilterPreset;
756
922
  /**
757
- * Adds a format filter to the chain.
758
- *
759
- * @param pixelFormat - Target pixel format(s)
760
- *
761
- * @returns This instance for chaining
923
+ * Adds an aecho filter for audio echo effect.
762
924
  *
763
- * @example
764
- * ```typescript
765
- * const chain = FilterPresets.chain()
766
- * .format('yuv420p')
767
- * .build();
768
- * ```
925
+ * @param in_gain - Input gain (0-1)
769
926
  *
770
- * @example
771
- * ```typescript
772
- * const chain = FilterPresets.chain()
773
- * .format(AV_PIX_FMT_RGB24)
774
- * .build();
775
- * ```
927
+ * @param out_gain - Output gain (0-1)
776
928
  *
777
- * @see {@link FilterPresetBase.format}
778
- */
779
- format(pixelFormat: string | AVPixelFormat | (string | AVPixelFormat)[]): this;
780
- /**
781
- * Adds a rotate filter to the chain.
929
+ * @param delays - Delay in milliseconds
782
930
  *
783
- * @param angle - Rotation angle in degrees
931
+ * @param decays - Decay factor (0-1)
784
932
  *
785
933
  * @returns This instance for chaining
786
934
  *
787
935
  * @example
788
936
  * ```typescript
789
- * const chain = FilterPresets.chain()
790
- * .rotate(45)
791
- * .build();
792
- * ```
793
- *
794
- * @example
795
- * ```typescript
796
- * const chain = FilterPresets.chain()
797
- * .rotate(-90)
798
- * .build();
937
+ * chain.aecho(0.8, 0.9, 1000, 0.3) // Echo with 1 second delay
799
938
  * ```
800
939
  *
801
- * @see {@link FilterPresetBase.rotate}
940
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#aecho | FFmpeg aecho filter}
802
941
  */
803
- rotate(angle: number): this;
942
+ aecho(in_gain: number, out_gain: number, delays: number, decays: number): FilterPreset;
804
943
  /**
805
- * Adds a horizontal flip filter to the chain.
806
- *
807
- * @returns This instance for chaining
944
+ * Adds a highpass filter to remove low frequencies.
808
945
  *
809
- * @example
810
- * ```typescript
811
- * const chain = FilterPresets.chain()
812
- * .hflip()
813
- * .build();
814
- * ```
946
+ * @param frequency - Cutoff frequency in Hz
815
947
  *
816
- * @see {@link FilterPresetBase.hflip}
817
- */
818
- hflip(): this;
819
- /**
820
- * Adds a vertical flip filter to the chain.
948
+ * @param options - Additional filter options
821
949
  *
822
950
  * @returns This instance for chaining
823
951
  *
824
952
  * @example
825
953
  * ```typescript
826
- * const chain = FilterPresets.chain()
827
- * .vflip()
828
- * .build();
954
+ * chain.highpass(200) // Remove frequencies below 200Hz
955
+ * chain.highpass(200, { width_type: 'q', width: 1 })
829
956
  * ```
830
957
  *
831
- * @see {@link FilterPresetBase.vflip}
958
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#highpass | FFmpeg highpass filter}
832
959
  */
833
- vflip(): this;
960
+ highpass(frequency: number, options?: Record<string, any>): FilterPreset;
834
961
  /**
835
- * Adds a fade filter to the chain.
962
+ * Adds a lowpass filter to remove high frequencies.
836
963
  *
837
- * @param type - Fade type ('in' or 'out')
838
- * @param start - Start time in seconds
839
- * @param duration - Fade duration in seconds
964
+ * @param frequency - Cutoff frequency in Hz
840
965
  *
841
- * @returns This instance for chaining
966
+ * @param options - Additional filter options
842
967
  *
843
- * @example
844
- * ```typescript
845
- * const chain = FilterPresets.chain()
846
- * .fade('in', 0, 2)
847
- * .build();
848
- * ```
968
+ * @returns This instance for chaining
849
969
  *
850
970
  * @example
851
971
  * ```typescript
852
- * const chain = FilterPresets.chain()
853
- * .fade('out', 10, 1.5)
854
- * .build();
972
+ * chain.lowpass(5000) // Remove frequencies above 5000Hz
855
973
  * ```
856
974
  *
857
- * @see {@link FilterPresetBase.fade}
975
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#lowpass | FFmpeg lowpass filter}
858
976
  */
859
- fade(type: 'in' | 'out', start: number, duration: number): this;
977
+ lowpass(frequency: number, options?: Record<string, any>): FilterPreset;
860
978
  /**
861
- * Adds an overlay filter to the chain.
979
+ * Adds a bandpass filter to keep only a frequency band.
862
980
  *
863
- * @param x - X position (default: 0)
864
- * @param y - Y position (default: 0)
865
- * @param options - Additional overlay options
981
+ * @param frequency - Center frequency in Hz
866
982
  *
867
- * @returns This instance for chaining
983
+ * @param options - Additional filter options
868
984
  *
869
- * @example
870
- * ```typescript
871
- * const chain = FilterPresets.chain()
872
- * .overlay(100, 50)
873
- * .build();
874
- * ```
985
+ * @returns This instance for chaining
875
986
  *
876
987
  * @example
877
988
  * ```typescript
878
- * const chain = FilterPresets.chain()
879
- * .overlay(10, 10, { enable: 'between(t,5,10)' })
880
- * .build();
989
+ * chain.bandpass(1000) // Keep frequencies around 1000Hz
881
990
  * ```
882
991
  *
883
- * @see {@link FilterPresetBase.overlay}
992
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#bandpass | FFmpeg bandpass filter}
884
993
  */
885
- overlay(x?: number, y?: number, options?: Record<string, string>): this;
994
+ bandpass(frequency: number, options?: Record<string, any>): FilterPreset;
886
995
  /**
887
- * Adds a volume filter to the chain.
996
+ * Adds an equalizer filter for frequency band adjustment.
888
997
  *
889
- * @param factor - Volume factor
998
+ * @param frequency - Center frequency in Hz
890
999
  *
891
- * @returns This instance for chaining
1000
+ * @param width - Band width
892
1001
  *
893
- * @example
894
- * ```typescript
895
- * const chain = FilterPresets.chain()
896
- * .volume(0.5)
897
- * .build();
898
- * ```
1002
+ * @param gain - Gain in dB
1003
+ *
1004
+ * @param width_type - Width type (optional)
1005
+ *
1006
+ * @returns This instance for chaining
899
1007
  *
900
1008
  * @example
901
1009
  * ```typescript
902
- * const chain = FilterPresets.chain()
903
- * .volume(2.0)
904
- * .build();
1010
+ * chain.equalizer(1000, 2, 5) // Boost 1000Hz by 5dB
1011
+ * chain.equalizer(1000, 2, 5, 'q') // Use Q factor for width
905
1012
  * ```
906
1013
  *
907
- * @see {@link FilterPresetBase.volume}
1014
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#equalizer | FFmpeg equalizer filter}
908
1015
  */
909
- volume(factor: number): this;
1016
+ equalizer(frequency: number, width: number, gain: number, width_type?: string): FilterPreset;
910
1017
  /**
911
- * Adds an audio format filter to the chain.
1018
+ * Adds a compressor filter for dynamic range compression.
912
1019
  *
913
- * @param sampleFormat - Target sample format
914
- * @param sampleRate - Target sample rate (optional)
915
- * @param channelLayout - Target channel layout (optional)
1020
+ * @param options - Compressor parameters
916
1021
  *
917
1022
  * @returns This instance for chaining
918
1023
  *
919
1024
  * @example
920
1025
  * ```typescript
921
- * const chain = FilterPresets.chain()
922
- * .aformat(AV_SAMPLE_FMT_FLT, 48000, 'stereo')
923
- * .build();
924
- * ```
925
- *
926
- * @example
927
- * ```typescript
928
- * const chain = FilterPresets.chain()
929
- * .aformat('s16', 44100)
930
- * .build();
1026
+ * chain.compressor() // Default compression
1027
+ * chain.compressor({
1028
+ * threshold: 0.5,
1029
+ * ratio: 4,
1030
+ * attack: 5,
1031
+ * release: 50
1032
+ * })
931
1033
  * ```
932
1034
  *
933
- * @see {@link FilterPresetBase.aformat}
1035
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#acompressor | FFmpeg acompressor filter}
934
1036
  */
935
- aformat(sampleFormat: string | AVSampleFormat, sampleRate?: number, channelLayout?: string): this;
1037
+ compressor(options?: Record<string, any>): FilterPreset;
936
1038
  /**
937
- * Adds an asetnsamples filter to the chain.
1039
+ * Adds an atrim filter to trim audio.
938
1040
  *
939
- * @param samples - Number of samples per frame
940
- * @param padding - Whether to pad or drop samples (default: true)
1041
+ * @param start - Start time in seconds
941
1042
  *
942
- * @returns This instance for chaining
1043
+ * @param end - End time in seconds (optional)
943
1044
  *
944
- * @example
945
- * ```typescript
946
- * const chain = FilterPresets.chain()
947
- * .asetnsamples(960)
948
- * .build();
949
- * ```
1045
+ * @param duration - Duration in seconds (optional)
1046
+ *
1047
+ * @returns This instance for chaining
950
1048
  *
951
1049
  * @example
952
1050
  * ```typescript
953
- * const chain = FilterPresets.chain()
954
- * .asetnsamples(1024, false)
955
- * .build();
1051
+ * chain.atrim(10, 20) // Extract audio from 10s to 20s
956
1052
  * ```
957
1053
  *
958
- * @see {@link FilterPresetBase.asetnsamples}
1054
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#atrim | FFmpeg atrim filter}
959
1055
  */
960
- asetnsamples(samples: number, padding?: boolean): this;
1056
+ atrim(start: number, end?: number, duration?: number): FilterPreset;
961
1057
  /**
962
- * Adds an atempo filter to the chain.
963
- *
964
- * @param factor - Tempo factor (0.5 to 2.0)
1058
+ * Adds a hwupload filter to upload frames to hardware.
965
1059
  *
966
1060
  * @returns This instance for chaining
967
1061
  *
968
1062
  * @example
969
1063
  * ```typescript
970
1064
  * const chain = FilterPresets.chain()
971
- * .atempo(1.5)
972
- * .build();
973
- * ```
974
- *
975
- * @example
976
- * ```typescript
977
- * const chain = FilterPresets.chain()
978
- * .atempo(0.8)
1065
+ * .hwupload()
1066
+ * .scale(1920, 1080)
979
1067
  * .build();
980
1068
  * ```
981
- *
982
- * @see {@link FilterPresetBase.atempo}
983
1069
  */
984
- atempo(factor: number): this;
1070
+ hwupload(): FilterPreset;
985
1071
  /**
986
- * Adds an audio fade filter to the chain.
987
- *
988
- * @param type - Fade type ('in' or 'out')
989
- * @param start - Start time in seconds
990
- * @param duration - Fade duration in seconds
1072
+ * Adds a hwdownload filter to download frames from hardware.
991
1073
  *
992
1074
  * @returns This instance for chaining
993
1075
  *
994
1076
  * @example
995
1077
  * ```typescript
996
1078
  * const chain = FilterPresets.chain()
997
- * .afade('in', 0, 3)
998
- * .build();
999
- * ```
1000
- *
1001
- * @example
1002
- * ```typescript
1003
- * const chain = FilterPresets.chain()
1004
- * .afade('out', 25, 2)
1079
+ * .scale(1920, 1080)
1080
+ * .hwdownload()
1005
1081
  * .build();
1006
1082
  * ```
1007
- *
1008
- * @see {@link FilterPresetBase.afade}
1009
1083
  */
1010
- afade(type: 'in' | 'out', start: number, duration: number): this;
1084
+ hwdownload(): FilterPreset;
1011
1085
  /**
1012
- * Adds an amix filter to the chain.
1086
+ * Adds a hwmap filter to map frames between hardware devices.
1013
1087
  *
1014
- * @param inputs - Number of inputs (default: 2)
1015
- * @param duration - Duration mode (default: 'longest')
1088
+ * @param derive - Device to derive from (optional)
1016
1089
  *
1017
1090
  * @returns This instance for chaining
1018
1091
  *
1019
1092
  * @example
1020
1093
  * ```typescript
1021
1094
  * const chain = FilterPresets.chain()
1022
- * .amix(3, 'longest')
1095
+ * .hwmap('cuda')
1023
1096
  * .build();
1024
1097
  * ```
1025
1098
  *
1026
1099
  * @example
1027
1100
  * ```typescript
1028
1101
  * const chain = FilterPresets.chain()
1029
- * .amix(2, 'first')
1102
+ * .hwmap()
1030
1103
  * .build();
1031
1104
  * ```
1032
- *
1033
- * @see {@link FilterPresetBase.amix}
1034
- */
1035
- amix(inputs?: number, duration?: 'first' | 'longest' | 'shortest'): this;
1036
- /**
1037
- * Adds a pad filter to the chain.
1038
- *
1039
- * @param width - Target width
1040
- * @param height - Target height
1041
- * @param x - X position of input
1042
- * @param y - Y position of input
1043
- * @param color - Padding color
1044
- *
1045
- * @returns This instance for chaining
1046
- *
1047
- * @example
1048
- * ```typescript
1049
- * chain.pad('iw*2', 'ih*2') // Double the canvas size
1050
- * ```
1051
- *
1052
- * @see {@link FilterPresetBase.pad}
1053
1105
  */
1054
- pad(width: string | number, height: string | number, x?: string, y?: string, color?: string): this;
1106
+ hwmap(derive?: string): FilterPreset;
1055
1107
  /**
1056
- * Adds a trim filter to the chain.
1108
+ * Adds a filter to the chain.
1057
1109
  *
1058
- * @param start - Start time in seconds
1059
- * @param end - End time in seconds
1060
- * @param duration - Duration in seconds
1110
+ * @param filter - Filter string to add (ignored if null/undefined)
1061
1111
  *
1062
1112
  * @returns This instance for chaining
1063
1113
  *
1064
1114
  * @example
1065
1115
  * ```typescript
1066
- * chain.trim(10, 20) // Extract 10 seconds from t=10 to t=20
1116
+ * chain.add('scale=1920:1080')
1067
1117
  * ```
1068
1118
  *
1069
- * @see {@link FilterPresetBase.trim}
1119
+ * @internal
1070
1120
  */
1071
- trim(start: number, end?: number, duration?: number): this;
1121
+ private add;
1072
1122
  /**
1073
- * Adds a setpts filter to the chain.
1074
- *
1075
- * @param expression - PTS expression
1076
- *
1077
- * @returns This instance for chaining
1123
+ * Determines filter support for the hardware type.
1078
1124
  *
1079
- * @example
1080
- * ```typescript
1081
- * chain.setpts('PTS/2') // Double playback speed
1082
- * ```
1125
+ * @returns Hardware filter support configuration
1083
1126
  *
1084
- * @see {@link FilterPresetBase.setpts}
1085
- */
1086
- setpts(expression: string): this;
1087
- /**
1088
- * Adds an asetpts filter to the chain.
1089
- *
1090
- * @param expression - PTS expression
1091
- *
1092
- * @returns This instance for chaining
1093
- *
1094
- * @example
1095
- * ```typescript
1096
- * chain.asetpts('PTS-STARTPTS') // Reset audio timestamps
1097
- * ```
1098
- *
1099
- * @see {@link FilterPresetBase.asetpts}
1100
- */
1101
- asetpts(expression: string): this;
1102
- /**
1103
- * Adds a setsar filter to the chain.
1104
- *
1105
- * @param ratio - Sample aspect ratio
1106
- *
1107
- * @returns This instance for chaining
1108
- *
1109
- * @example
1110
- * ```typescript
1111
- * chain.setsar('1:1') // Square pixels
1112
- * ```
1113
- *
1114
- * @see {@link FilterPresetBase.setsar}
1115
- */
1116
- setsar(ratio: string | number): this;
1117
- /**
1118
- * Adds a setdar filter to the chain.
1119
- *
1120
- * @param ratio - Display aspect ratio
1121
- *
1122
- * @returns This instance for chaining
1123
- *
1124
- * @example
1125
- * ```typescript
1126
- * chain.setdar('16:9') // Set widescreen aspect
1127
- * ```
1128
- *
1129
- * @see {@link FilterPresetBase.setdar}
1130
- */
1131
- setdar(ratio: string | number): this;
1132
- /**
1133
- * Adds an apad filter to the chain.
1134
- *
1135
- * @param wholeDuration - Minimum total duration
1136
- * @param padDuration - Padding duration to add
1137
- *
1138
- * @returns This instance for chaining
1139
- *
1140
- * @example
1141
- * ```typescript
1142
- * chain.apad(10) // Ensure at least 10 seconds of audio
1143
- * ```
1144
- *
1145
- * @see {@link FilterPresetBase.apad}
1146
- */
1147
- apad(wholeDuration?: number, padDuration?: number): this;
1148
- /**
1149
- * Adds a select filter to the chain.
1150
- *
1151
- * @param expression - Selection expression
1152
- *
1153
- * @returns This instance for chaining
1154
- *
1155
- * @example
1156
- * ```typescript
1157
- * chain.select('eq(pict_type,I)') // Select only I-frames
1158
- * ```
1159
- *
1160
- * @see {@link FilterPresetBase.select}
1161
- */
1162
- select(expression: string): this;
1163
- /**
1164
- * Adds an aselect filter to the chain.
1165
- *
1166
- * @param expression - Selection expression
1167
- *
1168
- * @returns This instance for chaining
1169
- *
1170
- * @example
1171
- * ```typescript
1172
- * chain.aselect('between(t,10,20)') // Select audio between 10-20s
1173
- * ```
1174
- *
1175
- * @see {@link FilterPresetBase.aselect}
1176
- */
1177
- aselect(expression: string): this;
1178
- /**
1179
- * Adds a concat filter to the chain.
1180
- *
1181
- * @param n - Number of input segments
1182
- * @param v - Number of video streams
1183
- * @param a - Number of audio streams
1184
- *
1185
- * @returns This instance for chaining
1186
- *
1187
- * @example
1188
- * ```typescript
1189
- * chain.concat(3, 1, 1) // Concatenate 3 segments with video and audio
1190
- * ```
1191
- *
1192
- * @see {@link FilterPresetBase.concat}
1193
- */
1194
- concat(n: number, v?: number, a?: number): this;
1195
- /**
1196
- * Adds an amerge filter to the chain.
1197
- *
1198
- * @param inputs - Number of input streams
1199
- *
1200
- * @returns This instance for chaining
1201
- *
1202
- * @example
1203
- * ```typescript
1204
- * chain.amerge(2) // Merge 2 audio streams
1205
- * ```
1206
- *
1207
- * @see {@link FilterPresetBase.amerge}
1208
- */
1209
- amerge(inputs?: number): this;
1210
- /**
1211
- * Adds a channelmap filter to the chain.
1212
- *
1213
- * @param map - Channel mapping string
1214
- *
1215
- * @returns This instance for chaining
1216
- *
1217
- * @example
1218
- * ```typescript
1219
- * chain.channelmap('FL-FR|FR-FL') // Swap stereo channels
1220
- * ```
1221
- *
1222
- * @see {@link FilterPresetBase.channelmap}
1223
- */
1224
- channelmap(map: string): this;
1225
- /**
1226
- * Adds a channelsplit filter to the chain.
1227
- *
1228
- * @param channelLayout - Channel layout to split
1229
- *
1230
- * @returns This instance for chaining
1231
- *
1232
- * @example
1233
- * ```typescript
1234
- * chain.channelsplit('stereo') // Split stereo into two mono streams
1235
- * ```
1236
- *
1237
- * @see {@link FilterPresetBase.channelsplit}
1238
- */
1239
- channelsplit(channelLayout?: string): this;
1240
- /**
1241
- * Adds a loudnorm filter to the chain.
1242
- *
1243
- * @param I - Integrated loudness target (LUFS)
1244
- * @param TP - True peak (dBTP)
1245
- * @param LRA - Loudness range (LU)
1246
- *
1247
- * @returns This instance for chaining
1248
- *
1249
- * @example
1250
- * ```typescript
1251
- * chain.loudnorm(-16, -1.5, 11) // Streaming loudness standard
1252
- * ```
1253
- *
1254
- * @see {@link FilterPresetBase.loudnorm}
1255
- */
1256
- loudnorm(I?: number, TP?: number, LRA?: number): this;
1257
- /**
1258
- * Adds a compand filter to the chain.
1259
- *
1260
- * @param attacks - Attack times
1261
- * @param decays - Decay times
1262
- * @param points - Transfer function points
1263
- * @param gain - Output gain
1264
- *
1265
- * @returns This instance for chaining
1266
- *
1267
- * @example
1268
- * ```typescript
1269
- * chain.compand('0.3|0.3', '1|1', '-90/-60|-60/-40|-40/-30|-20/-20', 6)
1270
- * ```
1271
- *
1272
- * @see {@link FilterPresetBase.compand}
1273
- */
1274
- compand(attacks: string, decays: string, points: string, gain?: number): this;
1275
- /**
1276
- * Adds a transpose filter to the chain (hardware-specific).
1277
- * Only available for hardware presets that support transpose
1278
- *
1279
- * @param mode - Transpose mode (number or string)
1280
- *
1281
- * @returns This instance for chaining
1282
- *
1283
- * @example
1284
- * ```typescript
1285
- * const chain = FilterPresets.chain()
1286
- * .transpose('clock')
1287
- * .build();
1288
- * ```
1289
- *
1290
- * @example
1291
- * ```typescript
1292
- * const chain = FilterPresets.chain()
1293
- * .transpose('cclock_flip')
1294
- * .build();
1295
- * ```
1296
- */
1297
- transpose(mode?: number | 'clock' | 'cclock' | 'clock_flip' | 'cclock_flip'): this;
1298
- /**
1299
- * Adds a tonemap filter to the chain (hardware-specific).
1300
- * Only available for hardware presets that support tonemapping
1301
- *
1302
- * @param options - Tonemapping options
1303
- *
1304
- * @returns This instance for chaining
1305
- *
1306
- * @example
1307
- * ```typescript
1308
- * const chain = FilterPresets.chain()
1309
- * .tonemap()
1310
- * .build();
1311
- * ```
1312
- *
1313
- * @example
1314
- * ```typescript
1315
- * const chain = FilterPresets.chain()
1316
- * .tonemap({ tonemap: 'hable', desat: '0' })
1317
- * .build();
1318
- * ```
1319
- */
1320
- tonemap(options?: Record<string, string>): this;
1321
- /**
1322
- * Adds a deinterlace filter to the chain (hardware-specific).
1323
- * Only available for hardware presets that support deinterlacing
1324
- *
1325
- * @param mode - Deinterlace mode (optional)
1326
- *
1327
- * @returns This instance for chaining
1328
- *
1329
- * @example
1330
- * ```typescript
1331
- * const chain = FilterPresets.chain()
1332
- * .deinterlace()
1333
- * .build();
1334
- * ```
1335
- *
1336
- * @example
1337
- * ```typescript
1338
- * const chain = FilterPresets.chain()
1339
- * .deinterlace('yadif')
1340
- * .build();
1341
- * ```
1342
- */
1343
- deinterlace(mode?: string): this;
1344
- /**
1345
- * Adds a flip filter to the chain (hardware-specific).
1346
- * Falls back to hflip/vflip if hardware flip not available
1347
- *
1348
- * @param direction - Flip direction ('h' or 'v')
1349
- *
1350
- * @returns This instance for chaining
1351
- *
1352
- * @example
1353
- * ```typescript
1354
- * const chain = FilterPresets.chain()
1355
- * .flip('h')
1356
- * .build();
1357
- * ```
1358
- *
1359
- * @example
1360
- * ```typescript
1361
- * const chain = FilterPresets.chain()
1362
- * .flip('v')
1363
- * .build();
1364
- * ```
1365
- */
1366
- flip(direction: 'h' | 'v'): this;
1367
- /**
1368
- * Adds a blur filter to the chain (hardware-specific).
1369
- * Only available for hardware presets that support blur
1370
- *
1371
- * @param type - Blur type (default: 'avg')
1372
- * @param radius - Blur radius (optional)
1373
- *
1374
- * @returns This instance for chaining
1375
- *
1376
- * @example
1377
- * ```typescript
1378
- * const chain = FilterPresets.chain()
1379
- * .blur('gaussian', 5)
1380
- * .build();
1381
- * ```
1382
- *
1383
- * @example
1384
- * ```typescript
1385
- * const chain = FilterPresets.chain()
1386
- * .blur('box')
1387
- * .build();
1388
- * ```
1389
- */
1390
- blur(type?: 'avg' | 'gaussian' | 'box', radius?: number): this;
1391
- /**
1392
- * Adds a sharpen filter to the chain (hardware-specific).
1393
- * Only available for hardware presets that support sharpening
1394
- *
1395
- * @param amount - Sharpen amount (optional)
1396
- *
1397
- * @returns This instance for chaining
1398
- *
1399
- * @example
1400
- * ```typescript
1401
- * const chain = FilterPresets.chain()
1402
- * .sharpen(1.5)
1403
- * .build();
1404
- * ```
1405
- *
1406
- * @example
1407
- * ```typescript
1408
- * const chain = FilterPresets.chain()
1409
- * .sharpen()
1410
- * .build();
1411
- * ```
1412
- */
1413
- sharpen(amount?: number): this;
1414
- /**
1415
- * Adds a stack filter to the chain (hardware-specific).
1416
- * Only available for hardware presets that support stacking
1417
- *
1418
- * @param type - Stack type ('h' for horizontal, 'v' for vertical, 'x' for grid)
1419
- * @param inputs - Number of inputs (default: 2)
1420
- *
1421
- * @returns This instance for chaining
1422
- *
1423
- * @example
1424
- * ```typescript
1425
- * const chain = FilterPresets.chain()
1426
- * .stack('h', 2)
1427
- * .build();
1428
- * ```
1429
- *
1430
- * @example
1431
- * ```typescript
1432
- * const chain = FilterPresets.chain()
1433
- * .stack('x', 4)
1434
- * .build();
1435
- * ```
1436
- */
1437
- stack(type: 'h' | 'v' | 'x', inputs?: number): this;
1438
- /**
1439
- * Adds a hwupload filter to upload frames to hardware.
1440
- *
1441
- * @returns This instance for chaining
1442
- *
1443
- * @example
1444
- * ```typescript
1445
- * const chain = FilterPresets.chain()
1446
- * .hwupload()
1447
- * .scale(1920, 1080)
1448
- * .build();
1449
- * ```
1450
- */
1451
- hwupload(): this;
1452
- /**
1453
- * Adds a hwdownload filter to download frames from hardware.
1454
- *
1455
- * @returns This instance for chaining
1456
- *
1457
- * @example
1458
- * ```typescript
1459
- * const chain = FilterPresets.chain()
1460
- * .scale(1920, 1080)
1461
- * .hwdownload()
1462
- * .build();
1463
- * ```
1464
- */
1465
- hwdownload(): this;
1466
- /**
1467
- * Adds a hwmap filter to map frames between hardware devices.
1468
- *
1469
- * @param derive - Device to derive from (optional)
1470
- *
1471
- * @returns This instance for chaining
1472
- *
1473
- * @example
1474
- * ```typescript
1475
- * const chain = FilterPresets.chain()
1476
- * .hwmap('cuda')
1477
- * .build();
1478
- * ```
1479
- *
1480
- * @example
1481
- * ```typescript
1482
- * const chain = FilterPresets.chain()
1483
- * .hwmap()
1484
- * .build();
1485
- * ```
1486
- */
1487
- hwmap(derive?: string): this;
1488
- }
1489
- /**
1490
- * Fluent filter chain builder with preset methods.
1491
- * Provides a convenient API for building filter chains using standard presets.
1492
- *
1493
- * @example
1494
- * ```typescript
1495
- * const filter = FilterPresets.chain()
1496
- * .scale(1920, 1080)
1497
- * .fps(30)
1498
- * .fade('in', 0, 2)
1499
- * .format('yuv420p')
1500
- * .build();
1501
- * ```
1502
- */
1503
- export declare class FilterChainBuilder extends ChainBuilderBase<FilterPresets> {
1504
- }
1505
- /**
1506
- * Standard filter presets for software filtering.
1507
- * Provides static methods for creating common filter strings and
1508
- * a chain builder for composing complex filter graphs.
1509
- *
1510
- * @example
1511
- * ```typescript
1512
- * // Static methods for individual filters
1513
- * const scaleFilter = FilterPresets.scale(1920, 1080);
1514
- * const fpsFilter = FilterPresets.fps(30);
1515
- *
1516
- * // Chain builder for complex graphs
1517
- * const chain = FilterPresets.chain()
1518
- * .scale(1920, 1080)
1519
- * .fps(30)
1520
- * .fade('in', 0, 2)
1521
- * .build();
1522
- * ```
1523
- */
1524
- export declare class FilterPresets extends FilterPresetBase {
1525
- private static instance;
1526
- /**
1527
- * Creates a new filter chain builder.
1528
- *
1529
- * @returns A new FilterChainBuilder instance
1530
- *
1531
- * @example
1532
- * ```typescript
1533
- * const filter = FilterPresets.chain()
1534
- * .scale(1280, 720)
1535
- * .fps(30)
1536
- * .build();
1537
- * ```
1538
- */
1539
- static chain(): FilterChainBuilder;
1540
- /**
1541
- * Creates a scale filter string.
1542
- *
1543
- * @param width - Target width
1544
- * @param height - Target height
1545
- * @param flags - Scaling algorithm flags (optional)
1546
- *
1547
- * @returns Scale filter string
1548
- *
1549
- * @example
1550
- * ```typescript
1551
- * const filter = FilterPresets.scale(1920, 1080);
1552
- * ```
1553
- *
1554
- * @example
1555
- * ```typescript
1556
- * const filter = FilterPresets.scale(1280, 720, 'lanczos');
1557
- * ```
1558
- */
1559
- static scale(width: number, height: number, flags?: string): string;
1560
- /**
1561
- * Creates a crop filter string.
1562
- *
1563
- * @param width - Crop width
1564
- * @param height - Crop height
1565
- * @param x - X position (default: 0)
1566
- * @param y - Y position (default: 0)
1567
- *
1568
- * @returns Crop filter string
1569
- *
1570
- * @example
1571
- * ```typescript
1572
- * const filter = FilterPresets.crop(640, 480);
1573
- * ```
1574
- *
1575
- * @example
1576
- * ```typescript
1577
- * const filter = FilterPresets.crop(1920, 1080, 100, 50);
1578
- * ```
1579
- */
1580
- static crop(width: number, height: number, x?: number, y?: number): string;
1581
- /**
1582
- * Creates an FPS filter string.
1583
- *
1584
- * @param fps - Target frame rate
1585
- *
1586
- * @returns FPS filter string
1587
- *
1588
- * @example
1589
- * ```typescript
1590
- * const filter = FilterPresets.fps(30);
1591
- * ```
1592
- *
1593
- * @example
1594
- * ```typescript
1595
- * const filter = FilterPresets.fps(23.976);
1596
- * ```
1597
- */
1598
- static fps(fps: number): string;
1599
- /**
1600
- * Creates a format filter string.
1601
- *
1602
- * @param pixelFormat - Target pixel format(s)
1603
- *
1604
- * @returns Format filter string
1605
- *
1606
- * @example
1607
- * ```typescript
1608
- * const filter = FilterPresets.format('yuv420p');
1609
- * ```
1610
- *
1611
- * @example
1612
- * ```typescript
1613
- * const filter = FilterPresets.format(AV_PIX_FMT_RGB24);
1614
- * ```
1615
- */
1616
- static format(pixelFormat: string | AVPixelFormat | (string | AVPixelFormat)[]): string;
1617
- /**
1618
- * Creates a rotate filter string.
1619
- *
1620
- * @param angle - Rotation angle in degrees
1621
- *
1622
- * @returns Rotate filter string
1623
- *
1624
- * @example
1625
- * ```typescript
1626
- * const filter = FilterPresets.rotate(45);
1627
- * ```
1628
- *
1629
- * @example
1630
- * ```typescript
1631
- * const filter = FilterPresets.rotate(-90);
1632
- * ```
1633
- */
1634
- static rotate(angle: number): string;
1635
- /**
1636
- * Creates a horizontal flip filter string.
1637
- *
1638
- * @returns Horizontal flip filter string
1639
- *
1640
- * @example
1641
- * ```typescript
1642
- * const filter = FilterPresets.hflip();
1643
- * ```
1644
- */
1645
- static hflip(): string;
1646
- /**
1647
- * Creates a vertical flip filter string.
1648
- *
1649
- * @returns Vertical flip filter string
1650
- *
1651
- * @example
1652
- * ```typescript
1653
- * const filter = FilterPresets.vflip();
1654
- * ```
1655
- */
1656
- static vflip(): string;
1657
- /**
1658
- * Creates a fade filter string.
1659
- *
1660
- * @param type - Fade type ('in' or 'out')
1661
- * @param start - Start time in seconds
1662
- * @param duration - Fade duration in seconds
1663
- *
1664
- * @returns Fade filter string
1665
- *
1666
- * @example
1667
- * ```typescript
1668
- * const filter = FilterPresets.fade('in', 0, 2);
1669
- * ```
1670
- *
1671
- * @example
1672
- * ```typescript
1673
- * const filter = FilterPresets.fade('out', 10, 1.5);
1674
- * ```
1675
- */
1676
- static fade(type: 'in' | 'out', start: number, duration: number): string;
1677
- /**
1678
- * Creates an overlay filter string.
1679
- *
1680
- * @param x - X position (default: 0)
1681
- * @param y - Y position (default: 0)
1682
- *
1683
- * @returns Overlay filter string
1684
- *
1685
- * @example
1686
- * ```typescript
1687
- * const filter = FilterPresets.overlay(100, 50);
1688
- * ```
1689
- *
1690
- * @example
1691
- * ```typescript
1692
- * const filter = FilterPresets.overlay();
1693
- * ```
1694
- */
1695
- static overlay(x?: number, y?: number): string;
1696
- /**
1697
- * Creates a volume filter string.
1698
- *
1699
- * @param factor - Volume multiplication factor
1700
- *
1701
- * @returns Volume filter string
1702
- *
1703
- * @example
1704
- * ```typescript
1705
- * const filter = FilterPresets.volume(0.5);
1706
- * ```
1707
- *
1708
- * @example
1709
- * ```typescript
1710
- * const filter = FilterPresets.volume(2.0);
1711
- * ```
1712
- */
1713
- static volume(factor: number): string;
1714
- /**
1715
- * Creates an audio format filter string.
1716
- *
1717
- * @param sampleFormat - Target sample format
1718
- * @param sampleRate - Target sample rate (optional)
1719
- * @param channelLayout - Target channel layout (optional)
1720
- *
1721
- * @returns Audio format filter string
1722
- *
1723
- * @example
1724
- * ```typescript
1725
- * const filter = FilterPresets.aformat(AV_SAMPLE_FMT_FLT, 48000, 'stereo');
1726
- * ```
1727
- *
1728
- * @example
1729
- * ```typescript
1730
- * const filter = FilterPresets.aformat('s16', 44100);
1731
- * ```
1732
- */
1733
- static aformat(sampleFormat: string | AVSampleFormat, sampleRate?: number, channelLayout?: string): string;
1734
- /**
1735
- * Creates an asetnsamples filter string.
1736
- *
1737
- * @param samples - Number of samples per frame
1738
- * @param padding - Whether to pad or drop samples (default: true)
1739
- *
1740
- * @returns Asetnsamples filter string
1741
- *
1742
- * @example
1743
- * ```typescript
1744
- * const filter = FilterPresets.asetnsamples(960);
1745
- * ```
1746
- *
1747
- * @example
1748
- * ```typescript
1749
- * const filter = FilterPresets.asetnsamples(1024, false);
1750
- * ```
1751
- */
1752
- static asetnsamples(samples: number, padding?: boolean): string;
1753
- /**
1754
- * Creates an atempo filter string.
1755
- *
1756
- * @param factor - Tempo factor (0.5 to 2.0)
1757
- *
1758
- * @returns Atempo filter string
1759
- *
1760
- * @example
1761
- * ```typescript
1762
- * const filter = FilterPresets.atempo(1.5);
1763
- * ```
1764
- *
1765
- * @example
1766
- * ```typescript
1767
- * const filter = FilterPresets.atempo(0.8);
1768
- * ```
1769
- */
1770
- static atempo(factor: number): string;
1771
- /**
1772
- * Creates an audio fade filter string.
1773
- *
1774
- * @param type - Fade type ('in' or 'out')
1775
- * @param start - Start time in seconds
1776
- * @param duration - Fade duration in seconds
1777
- *
1778
- * @returns Audio fade filter string
1779
- *
1780
- * @example
1781
- * ```typescript
1782
- * const filter = FilterPresets.afade('in', 0, 3);
1783
- * ```
1784
- *
1785
- * @example
1786
- * ```typescript
1787
- * const filter = FilterPresets.afade('out', 25, 2);
1788
- * ```
1789
- */
1790
- static afade(type: 'in' | 'out', start: number, duration: number): string;
1791
- /**
1792
- * Creates an amix filter string.
1793
- *
1794
- * @param inputs - Number of inputs (default: 2)
1795
- * @param duration - Duration mode (default: 'longest')
1796
- *
1797
- * @returns Amix filter string
1798
- *
1799
- * @example
1800
- * ```typescript
1801
- * const filter = FilterPresets.amix(3, 'longest');
1802
- * ```
1803
- *
1804
- * @example
1805
- * ```typescript
1806
- * const filter = FilterPresets.amix(2, 'first');
1807
- * ```
1808
- */
1809
- static amix(inputs?: number, duration?: 'first' | 'longest' | 'shortest'): string;
1810
- }
1811
- /**
1812
- * Hardware-accelerated filter presets.
1813
- * Provides optimized filter implementations for specific hardware types,
1814
- * with automatic fallback when operations aren't supported.
1815
- *
1816
- * @example
1817
- * ```typescript
1818
- * // Create hardware presets for CUDA
1819
- * const hw = new HardwareFilterPresets(AV_HWDEVICE_TYPE_CUDA);
1820
- *
1821
- * // Check capabilities
1822
- * if (hw.support.scale) {
1823
- * const scaleFilter = hw.scale(1920, 1080);
1824
- * }
1825
- *
1826
- * // Use chain builder
1827
- * const chain = hw.chain()
1828
- * .hwupload()
1829
- * .scale(1920, 1080)
1830
- * .tonemap()
1831
- * .hwdownload()
1832
- * .build();
1833
- * ```
1834
- */
1835
- export declare class HardwareFilterPresets extends FilterPresetBase {
1836
- private readonly deviceType;
1837
- private readonly deviceTypeName;
1838
- readonly support: HardwareFilterSupport;
1839
- /**
1840
- * @param deviceType - Hardware device type enum
1841
- * @param deviceTypeName - Optional hardware device type name (e.g., 'cuda', 'vaapi')
1842
- */
1843
- constructor(deviceType: AVHWDeviceType, deviceTypeName?: string);
1844
- /**
1845
- * Checks if a filter is hardware-accelerated.
1846
- *
1847
- * @param filterName - Name of the filter to check
1848
- * @returns True if the filter uses hardware acceleration
1849
- *
1850
- * @example
1851
- * ```typescript
1852
- * if (HardwareFilterPresets.isHardwareFilter('scale_cuda')) {
1853
- * console.log('Hardware accelerated scaling');
1854
- * }
1855
- * ```
1856
- */
1857
- static isHardwareFilter(filterName: string): boolean;
1858
- /**
1859
- * Creates a hardware filter chain builder.
1860
- *
1861
- * @returns A new HardwareFilterChainBuilder instance
1862
- *
1863
- * @example
1864
- * ```typescript
1865
- * const filter = hw.chain()
1866
- * .hwupload()
1867
- * .scale(1920, 1080)
1868
- * .hwdownload()
1869
- * .build();
1870
- * ```
1871
- */
1872
- chain(): HardwareFilterChainBuilder;
1873
- /**
1874
- * Creates a hardware-accelerated scale filter.
1875
- *
1876
- * Different hardware types use different scale filters:
1877
- * - CUDA: scale_cuda or scale_npp (with npp option)
1878
- * - VAAPI: scale_vaapi
1879
- * - QSV: scale_qsv
1880
- * - VideoToolbox: scale_vt
1881
- * - RKMPP: scale_rkrga
1882
- *
1883
- * @param width - Target width
1884
- * @param height - Target height
1885
- * @param options - Hardware-specific scaling options
1886
- *
1887
- * @returns Hardware scale filter string or null if not supported
1888
- *
1889
- * @example
1890
- * ```typescript
1891
- * const filter = hwPresets.scale(1920, 1080);
1892
- * ```
1893
- *
1894
- * @example
1895
- * ```typescript
1896
- * const filter = hwPresets.scale(1280, 720, { npp: true });
1897
- * ```
1898
- *
1899
- * @see {@link https://ffmpeg.org/ffmpeg-filters.html#scale_005fcuda | FFmpeg scale_cuda filter}
1900
- */
1901
- scale(width: number, height: number, options?: Record<string, any>): string | null;
1902
- /**
1903
- * Creates a hardware-accelerated overlay filter.
1904
- *
1905
- * @param x - X position (default: 0)
1906
- * @param y - Y position (default: 0)
1907
- * @param options - Hardware-specific overlay options
1908
- *
1909
- * @returns Hardware overlay filter string or null if not supported
1910
- *
1911
- * @example
1912
- * ```typescript
1913
- * const filter = hwPresets.overlay(100, 50);
1914
- * ```
1915
- *
1916
- * @example
1917
- * ```typescript
1918
- * const filter = hwPresets.overlay(0, 0, { eof_action: 'pass' });
1919
- * ```
1920
- *
1921
- * @see {@link https://ffmpeg.org/ffmpeg-filters.html#overlay_005fcuda | FFmpeg overlay_cuda filter}
1922
- */
1923
- overlay(x?: number, y?: number, options?: Record<string, string>): string | null;
1924
- /**
1925
- * Creates a hardware-accelerated transpose filter.
1926
- *
1927
- * Direction values:
1928
- * - 0: 90 degrees counter-clockwise and vertical flip
1929
- * - 1 / 'clock': 90 degrees clockwise
1930
- * - 2 / 'cclock': 90 degrees counter-clockwise
1931
- * - 3 / 'clock_flip': 90 degrees clockwise and vertical flip
1932
- *
1933
- * @param mode - Transpose mode (number or string)
1934
- *
1935
- * @returns Hardware transpose filter string or null if not supported
1936
- *
1937
- * @example
1938
- * ```typescript
1939
- * const filter = hwPresets.transpose('clock');
1940
- * ```
1941
- *
1942
- * @example
1943
- * ```typescript
1944
- * const filter = hwPresets.transpose(2);
1945
- * ```
1946
- */
1947
- transpose(mode: number | 'clock' | 'cclock' | 'clock_flip' | 'cclock_flip'): string | null;
1948
- /**
1949
- * Creates a hardware-accelerated tonemap filter.
1950
- * Used for HDR to SDR conversion with hardware acceleration.
1951
- *
1952
- * @param options - Tonemapping options (algorithm, parameters)
1953
- *
1954
- * @returns Hardware tonemap filter string or null if not supported
1955
- *
1956
- * @example
1957
- * ```typescript
1958
- * const filter = hwPresets.tonemap();
1959
- * ```
1960
- *
1961
- * @example
1962
- * ```typescript
1963
- * const filter = hwPresets.tonemap({ tonemap: 'hable', desat: '0' });
1964
- * ```
1965
- */
1966
- tonemap(options?: Record<string, string>): string | null;
1967
- /**
1968
- * Creates a hardware-accelerated deinterlace filter.
1969
- *
1970
- * Different hardware types use different deinterlacers:
1971
- * - CUDA: yadif_cuda
1972
- * - VAAPI: deinterlace_vaapi
1973
- * - QSV: deinterlace_qsv
1974
- * - Vulkan: bwdif_vulkan
1975
- * - VideoToolbox: yadif_videotoolbox
1976
- *
1977
- * @param mode - Deinterlacing mode (optional)
1978
- *
1979
- * @returns Hardware deinterlace filter string or null if not supported
1980
- *
1981
- * @example
1982
- * ```typescript
1983
- * const filter = hwPresets.deinterlace();
1984
- * ```
1985
- *
1986
- * @example
1987
- * ```typescript
1988
- * const filter = hwPresets.deinterlace('send_field');
1989
- * ```
1990
- */
1991
- deinterlace(mode?: string): string | null;
1992
- /**
1993
- * Creates a hardware-accelerated flip filter.
1994
- * Currently only Vulkan supports hardware flip filters.
1995
- *
1996
- * @param direction - Flip direction ('h' for horizontal, 'v' for vertical)
1997
- *
1998
- * @returns Hardware flip filter string or null if not supported
1999
- *
2000
- * @example
2001
- * ```typescript
2002
- * const filter = hwPresets.flip('h');
2003
- * ```
2004
- *
2005
- * @example
2006
- * ```typescript
2007
- * const filter = hwPresets.flip('v');
2008
- * ```
2009
- */
2010
- flip(direction: 'h' | 'v'): string | null;
2011
- /**
2012
- * Creates a hardware-accelerated blur filter.
2013
- *
2014
- * Different hardware types support different blur filters:
2015
- * - CUDA: bilateral_cuda
2016
- * - Vulkan: avgblur_vulkan, gblur_vulkan
2017
- * - OpenCL: avgblur_opencl, boxblur_opencl
2018
- *
2019
- * @param type - Blur type ('avg', 'gaussian', or 'box', default: 'avg')
2020
- * @param radius - Blur radius (optional)
2021
- *
2022
- * @returns Hardware blur filter string or null if not supported
2023
- *
2024
- * @example
2025
- * ```typescript
2026
- * const filter = hwPresets.blur('gaussian', 5);
2027
- * ```
2028
- *
2029
- * @example
2030
- * ```typescript
2031
- * const filter = hwPresets.blur('avg');
2032
- * ```
2033
- */
2034
- blur(type?: 'avg' | 'gaussian' | 'box', radius?: number): string | null;
2035
- /**
2036
- * Creates a hardware-accelerated sharpen filter.
2037
- *
2038
- * Hardware sharpening support:
2039
- * - VAAPI: sharpness_vaapi
2040
- * - OpenCL: unsharp_opencl
2041
- * - CUDA: sharpen_npp (NPP-based)
2042
- *
2043
- * @param amount - Sharpening amount (optional)
2044
- *
2045
- * @returns Hardware sharpen filter string or null if not supported
2046
- *
2047
- * @example
2048
- * ```typescript
2049
- * const filter = hwPresets.sharpen(1.5);
2050
- * ```
2051
- *
2052
- * @example
2053
- * ```typescript
2054
- * const filter = hwPresets.sharpen();
2055
- * ```
2056
- */
2057
- sharpen(amount?: number): string | null;
2058
- /**
2059
- * Creates a hardware-accelerated stack filter.
2060
- * Only VAAPI and QSV support hardware stacking.
2061
- *
2062
- * @param type - Stack type ('h' for horizontal, 'v' for vertical, 'x' for grid)
2063
- * @param inputs - Number of inputs to stack (default: 2)
2064
- *
2065
- * @returns Hardware stack filter string or null if not supported
2066
- *
2067
- * @example
2068
- * ```typescript
2069
- * const filter = hwPresets.stack('h', 2);
2070
- * ```
2071
- *
2072
- * @example
2073
- * ```typescript
2074
- * const filter = hwPresets.stack('x', 4);
2075
- * ```
2076
- */
2077
- stack(type: 'h' | 'v' | 'x', inputs?: number): string | null;
2078
- /**
2079
- * Creates a hwupload filter to upload frames to hardware memory.
2080
- * CUDA uses hwupload_cuda, others use generic hwupload.
2081
- *
2082
- * @returns Hardware upload filter string
2083
- *
2084
- * @example
2085
- * ```typescript
2086
- * const filter = hwPresets.hwupload();
2087
- * ```
2088
- *
2089
- * @see {@link https://ffmpeg.org/ffmpeg-filters.html#hwupload | FFmpeg hwupload filter}
2090
- */
2091
- hwupload(): string | null;
2092
- /**
2093
- * Creates a hwdownload filter to download frames from hardware memory.
2094
- *
2095
- * @returns Hardware download filter string
2096
- *
2097
- * @example
2098
- * ```typescript
2099
- * const filter = hwPresets.hwdownload();
2100
- * ```
2101
- *
2102
- * @see {@link https://ffmpeg.org/ffmpeg-filters.html#hwdownload | FFmpeg hwdownload filter}
2103
- */
2104
- hwdownload(): string | null;
2105
- /**
2106
- * Creates a hwmap filter to map frames between hardware devices.
2107
- *
2108
- * @param derive - Device to derive from (optional)
2109
- *
2110
- * @returns Hardware map filter string
2111
- *
2112
- * @example
2113
- * ```typescript
2114
- * const filter = hwPresets.hwmap('cuda');
2115
- * ```
2116
- *
2117
- * @example
2118
- * ```typescript
2119
- * const filter = hwPresets.hwmap();
2120
- * ```
2121
- *
2122
- * @see {@link https://ffmpeg.org/ffmpeg-filters.html#hwmap | FFmpeg hwmap filter}
2123
- */
2124
- hwmap(derive?: string): string | null;
2125
- /**
2126
- * Gets the filter capabilities for this hardware type.
2127
- *
2128
- * @returns Object describing which filters are supported
2129
- *
2130
- * @example
2131
- * ```typescript
2132
- * const caps = hw.getCapabilities();
2133
- * if (caps.scale && caps.overlay) {
2134
- * console.log('Hardware supports scaling and overlay');
2135
- * }
2136
- * ```
2137
- */
2138
- getCapabilities(): HardwareFilterSupport;
2139
- /**
2140
- * Determines filter support for the hardware type.
2141
- *
2142
- * @returns Hardware filter support configuration
2143
- *
2144
- * @internal
1127
+ * @internal
2145
1128
  */
2146
1129
  private getSupport;
2147
1130
  }
2148
- /**
2149
- * Hardware filter chain builder with fluent API.
2150
- * Automatically skips unsupported filters (returns null) allowing graceful fallback.
2151
- *
2152
- * @example
2153
- * ```typescript
2154
- * const hw = new HardwareFilterPresets(AV_HWDEVICE_TYPE_CUDA, 'cuda');
2155
- * const chain = hw.chain()
2156
- * .hwupload()
2157
- * .scale(1920, 1080)
2158
- * .tonemap() // Skipped if not supported
2159
- * .hwdownload()
2160
- * .build();
2161
- * ```
2162
- */
2163
- export declare class HardwareFilterChainBuilder extends ChainBuilderBase<HardwareFilterPresets> {
2164
- }