node-av 1.1.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. package/README.md +51 -59
  2. package/dist/api/bitstream-filter.d.ts +183 -123
  3. package/dist/api/bitstream-filter.js +185 -127
  4. package/dist/api/bitstream-filter.js.map +1 -1
  5. package/dist/api/decoder.d.ts +282 -130
  6. package/dist/api/decoder.js +290 -142
  7. package/dist/api/decoder.js.map +1 -1
  8. package/dist/api/encoder.d.ts +249 -160
  9. package/dist/api/encoder.js +276 -207
  10. package/dist/api/encoder.js.map +1 -1
  11. package/dist/api/filter-presets.d.ts +1944 -96
  12. package/dist/api/filter-presets.js +2059 -105
  13. package/dist/api/filter-presets.js.map +1 -1
  14. package/dist/api/filter.d.ts +264 -200
  15. package/dist/api/filter.js +269 -231
  16. package/dist/api/filter.js.map +1 -1
  17. package/dist/api/hardware.d.ts +246 -117
  18. package/dist/api/hardware.js +440 -217
  19. package/dist/api/hardware.js.map +1 -1
  20. package/dist/api/index.d.ts +3 -3
  21. package/dist/api/index.js +1 -1
  22. package/dist/api/index.js.map +1 -1
  23. package/dist/api/io-stream.d.ts +65 -55
  24. package/dist/api/io-stream.js +43 -40
  25. package/dist/api/io-stream.js.map +1 -1
  26. package/dist/api/media-input.d.ts +242 -139
  27. package/dist/api/media-input.js +205 -103
  28. package/dist/api/media-input.js.map +1 -1
  29. package/dist/api/media-output.d.ts +208 -126
  30. package/dist/api/media-output.js +212 -126
  31. package/dist/api/media-output.js.map +1 -1
  32. package/dist/api/pipeline.d.ts +361 -38
  33. package/dist/api/pipeline.js +255 -14
  34. package/dist/api/pipeline.js.map +1 -1
  35. package/dist/api/types.d.ts +26 -187
  36. package/dist/api/utilities/audio-sample.d.ts +0 -8
  37. package/dist/api/utilities/audio-sample.js +0 -8
  38. package/dist/api/utilities/audio-sample.js.map +1 -1
  39. package/dist/api/utilities/channel-layout.d.ts +0 -8
  40. package/dist/api/utilities/channel-layout.js +0 -8
  41. package/dist/api/utilities/channel-layout.js.map +1 -1
  42. package/dist/api/utilities/image.d.ts +0 -8
  43. package/dist/api/utilities/image.js +0 -8
  44. package/dist/api/utilities/image.js.map +1 -1
  45. package/dist/api/utilities/index.d.ts +3 -3
  46. package/dist/api/utilities/index.js +3 -3
  47. package/dist/api/utilities/index.js.map +1 -1
  48. package/dist/api/utilities/media-type.d.ts +1 -9
  49. package/dist/api/utilities/media-type.js +1 -9
  50. package/dist/api/utilities/media-type.js.map +1 -1
  51. package/dist/api/utilities/pixel-format.d.ts +1 -9
  52. package/dist/api/utilities/pixel-format.js +1 -9
  53. package/dist/api/utilities/pixel-format.js.map +1 -1
  54. package/dist/api/utilities/sample-format.d.ts +1 -9
  55. package/dist/api/utilities/sample-format.js +1 -9
  56. package/dist/api/utilities/sample-format.js.map +1 -1
  57. package/dist/api/utilities/streaming.d.ts +0 -8
  58. package/dist/api/utilities/streaming.js +0 -8
  59. package/dist/api/utilities/streaming.js.map +1 -1
  60. package/dist/api/utilities/timestamp.d.ts +0 -8
  61. package/dist/api/utilities/timestamp.js +0 -8
  62. package/dist/api/utilities/timestamp.js.map +1 -1
  63. package/dist/api/utils.d.ts +1 -2
  64. package/dist/api/utils.js +11 -0
  65. package/dist/api/utils.js.map +1 -1
  66. package/dist/constants/constants.d.ts +1 -1
  67. package/dist/constants/constants.js +2 -0
  68. package/dist/constants/constants.js.map +1 -1
  69. package/dist/lib/audio-fifo.d.ts +127 -170
  70. package/dist/lib/audio-fifo.js +130 -173
  71. package/dist/lib/audio-fifo.js.map +1 -1
  72. package/dist/lib/binding.d.ts +1 -0
  73. package/dist/lib/binding.js +7 -0
  74. package/dist/lib/binding.js.map +1 -1
  75. package/dist/lib/bitstream-filter-context.d.ts +139 -184
  76. package/dist/lib/bitstream-filter-context.js +139 -188
  77. package/dist/lib/bitstream-filter-context.js.map +1 -1
  78. package/dist/lib/bitstream-filter.d.ts +68 -54
  79. package/dist/lib/bitstream-filter.js +68 -54
  80. package/dist/lib/bitstream-filter.js.map +1 -1
  81. package/dist/lib/codec-context.d.ts +316 -380
  82. package/dist/lib/codec-context.js +316 -381
  83. package/dist/lib/codec-context.js.map +1 -1
  84. package/dist/lib/codec-parameters.d.ts +160 -170
  85. package/dist/lib/codec-parameters.js +162 -172
  86. package/dist/lib/codec-parameters.js.map +1 -1
  87. package/dist/lib/codec-parser.d.ts +91 -104
  88. package/dist/lib/codec-parser.js +92 -103
  89. package/dist/lib/codec-parser.js.map +1 -1
  90. package/dist/lib/codec.d.ts +266 -283
  91. package/dist/lib/codec.js +270 -287
  92. package/dist/lib/codec.js.map +1 -1
  93. package/dist/lib/dictionary.d.ts +149 -203
  94. package/dist/lib/dictionary.js +158 -212
  95. package/dist/lib/dictionary.js.map +1 -1
  96. package/dist/lib/error.d.ts +96 -130
  97. package/dist/lib/error.js +98 -128
  98. package/dist/lib/error.js.map +1 -1
  99. package/dist/lib/filter-context.d.ts +284 -218
  100. package/dist/lib/filter-context.js +290 -227
  101. package/dist/lib/filter-context.js.map +1 -1
  102. package/dist/lib/filter-graph.d.ts +251 -292
  103. package/dist/lib/filter-graph.js +253 -294
  104. package/dist/lib/filter-graph.js.map +1 -1
  105. package/dist/lib/filter-inout.d.ts +87 -95
  106. package/dist/lib/filter-inout.js +87 -95
  107. package/dist/lib/filter-inout.js.map +1 -1
  108. package/dist/lib/filter.d.ts +93 -111
  109. package/dist/lib/filter.js +93 -111
  110. package/dist/lib/filter.js.map +1 -1
  111. package/dist/lib/format-context.d.ts +320 -428
  112. package/dist/lib/format-context.js +313 -385
  113. package/dist/lib/format-context.js.map +1 -1
  114. package/dist/lib/frame.d.ts +262 -405
  115. package/dist/lib/frame.js +263 -408
  116. package/dist/lib/frame.js.map +1 -1
  117. package/dist/lib/hardware-device-context.d.ts +149 -203
  118. package/dist/lib/hardware-device-context.js +149 -203
  119. package/dist/lib/hardware-device-context.js.map +1 -1
  120. package/dist/lib/hardware-frames-context.d.ts +170 -180
  121. package/dist/lib/hardware-frames-context.js +171 -181
  122. package/dist/lib/hardware-frames-context.js.map +1 -1
  123. package/dist/lib/index.d.ts +3 -2
  124. package/dist/lib/index.js +3 -3
  125. package/dist/lib/index.js.map +1 -1
  126. package/dist/lib/input-format.d.ts +89 -117
  127. package/dist/lib/input-format.js +89 -117
  128. package/dist/lib/input-format.js.map +1 -1
  129. package/dist/lib/io-context.d.ts +209 -241
  130. package/dist/lib/io-context.js +220 -252
  131. package/dist/lib/io-context.js.map +1 -1
  132. package/dist/lib/log.d.ts +85 -119
  133. package/dist/lib/log.js +85 -122
  134. package/dist/lib/log.js.map +1 -1
  135. package/dist/lib/native-types.d.ts +118 -106
  136. package/dist/lib/native-types.js +0 -7
  137. package/dist/lib/native-types.js.map +1 -1
  138. package/dist/lib/option.d.ts +437 -218
  139. package/dist/lib/option.js +462 -226
  140. package/dist/lib/option.js.map +1 -1
  141. package/dist/lib/output-format.d.ts +77 -101
  142. package/dist/lib/output-format.js +77 -101
  143. package/dist/lib/output-format.js.map +1 -1
  144. package/dist/lib/packet.d.ts +172 -240
  145. package/dist/lib/packet.js +172 -241
  146. package/dist/lib/packet.js.map +1 -1
  147. package/dist/lib/rational.d.ts +0 -2
  148. package/dist/lib/rational.js +0 -2
  149. package/dist/lib/rational.js.map +1 -1
  150. package/dist/lib/software-resample-context.d.ts +241 -325
  151. package/dist/lib/software-resample-context.js +242 -326
  152. package/dist/lib/software-resample-context.js.map +1 -1
  153. package/dist/lib/software-scale-context.d.ts +129 -173
  154. package/dist/lib/software-scale-context.js +131 -175
  155. package/dist/lib/software-scale-context.js.map +1 -1
  156. package/dist/lib/stream.d.ts +87 -197
  157. package/dist/lib/stream.js +87 -197
  158. package/dist/lib/stream.js.map +1 -1
  159. package/dist/lib/utilities.d.ts +435 -181
  160. package/dist/lib/utilities.js +438 -182
  161. package/dist/lib/utilities.js.map +1 -1
  162. package/install/check.js +0 -1
  163. package/install/ffmpeg.js +0 -11
  164. package/package.json +25 -18
  165. package/release_notes.md +24 -59
  166. package/CHANGELOG.md +0 -8
@@ -1,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,2135 @@ 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
+ * @example
59
+ * ```typescript
60
+ * presets.scale(1920, 1080) // Scale to Full HD
61
+ * presets.scale(640, 480, { flags: 'lanczos' }) // With specific algorithm
62
+ * ```
63
+ *
64
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#scale | FFmpeg scale filter}
40
65
  */
41
66
  scale(width: number, height: number, options?: Record<string, any>): string | null;
42
67
  /**
43
- * Crop video to specified dimensions.
68
+ * Creates a crop filter string.
69
+ *
70
+ * @param width - Width of the cropped area
71
+ * @param height - Height of the cropped area
72
+ * @param x - X coordinate of top-left corner (default: 0)
73
+ * @param y - Y coordinate of top-left corner (default: 0)
74
+ * @returns Filter string or null if not supported
75
+ *
76
+ * @example
77
+ * ```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
80
+ * ```
81
+ *
82
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#crop | FFmpeg crop filter}
44
83
  */
45
84
  crop(width: number, height: number, x?: number, y?: number): string | null;
46
85
  /**
47
- * Change frame rate.
86
+ * Creates an FPS filter string to change frame rate.
87
+ *
88
+ * @param fps - Target frames per second
89
+ * @returns Filter string or null if not supported
90
+ *
91
+ * @example
92
+ * ```typescript
93
+ * presets.fps(30) // Convert to 30 FPS
94
+ * presets.fps(23.976) // Film frame rate
95
+ * ```
96
+ *
97
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#fps | FFmpeg fps filter}
48
98
  */
49
99
  fps(fps: number): string | null;
50
100
  /**
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,...
101
+ * Creates a format filter string to convert pixel format.
102
+ *
103
+ * @param pixelFormat - Target pixel format(s) - can be string, AVPixelFormat enum, or array
104
+ * @returns Filter string or null if not supported
105
+ *
106
+ * @example
107
+ * ```typescript
108
+ * // Single format
109
+ * presets.format('yuv420p');
110
+ * presets.format(AV_PIX_FMT_YUV420P);
111
+ *
112
+ * // Multiple formats (creates a chain)
113
+ * presets.format(['yuv420p', 'rgb24']);
114
+ * ```
115
+ *
116
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#format | FFmpeg format filter}
54
117
  */
55
118
  format(pixelFormat: string | AVPixelFormat | (string | AVPixelFormat)[]): string | null;
56
119
  /**
57
- * Rotate video by angle.
120
+ * Creates a rotate filter string.
121
+ *
122
+ * @param angle - Rotation angle in degrees
123
+ * @returns Filter string or null if not supported
124
+ *
125
+ * @example
126
+ * ```typescript
127
+ * presets.rotate(90) // Rotate 90 degrees clockwise
128
+ * presets.rotate(-45) // Rotate 45 degrees counter-clockwise
129
+ * ```
130
+ *
131
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#rotate | FFmpeg rotate filter}
58
132
  */
59
133
  rotate(angle: number): string | null;
60
134
  /**
61
- * Flip video horizontally.
135
+ * Creates a horizontal flip filter string.
136
+ *
137
+ * @returns Filter string or null if not supported
138
+ *
139
+ * @example
140
+ * ```typescript
141
+ * presets.hflip() // Mirror horizontally
142
+ * ```
143
+ *
144
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#hflip | FFmpeg hflip filter}
62
145
  */
63
146
  hflip(): string | null;
64
147
  /**
65
- * Flip video vertically.
148
+ * Creates a vertical flip filter string.
149
+ *
150
+ * @returns Filter string or null if not supported
151
+ *
152
+ * @example
153
+ * ```typescript
154
+ * presets.vflip() // Flip upside down
155
+ * ```
156
+ *
157
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#vflip | FFmpeg vflip filter}
66
158
  */
67
159
  vflip(): string | null;
68
160
  /**
69
- * Apply fade effect.
161
+ * Creates a fade filter string for video.
162
+ *
163
+ * @param type - Fade type ('in' or 'out')
164
+ * @param start - Start time in seconds
165
+ * @param duration - Fade duration in seconds
166
+ * @returns Filter string or null if not supported
167
+ *
168
+ * @example
169
+ * ```typescript
170
+ * presets.fade('in', 0, 2) // 2-second fade in from start
171
+ * presets.fade('out', 10, 1) // 1-second fade out at 10 seconds
172
+ * ```
173
+ *
174
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#fade | FFmpeg fade filter}
70
175
  */
71
176
  fade(type: 'in' | 'out', start: number, duration: number): string | null;
72
177
  /**
73
- * Overlay one video on another.
178
+ * Creates an overlay filter string to composite two video streams.
179
+ *
180
+ * @param x - X position for overlay (default: 0)
181
+ * @param y - Y position for overlay (default: 0)
182
+ * @param options - Additional overlay options
183
+ * @returns Filter string or null if not supported
184
+ *
185
+ * @example
186
+ * ```typescript
187
+ * // Basic overlay at position
188
+ * presets.overlay(100, 50);
189
+ *
190
+ * // With additional options
191
+ * presets.overlay(0, 0, { format: 'yuv420' });
192
+ * ```
193
+ *
194
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#overlay | FFmpeg overlay filter}
74
195
  */
75
196
  overlay(x?: number, y?: number, options?: Record<string, string>): string | null;
76
197
  /**
77
- * Adjust audio volume.
198
+ * Creates a volume filter string for audio.
199
+ *
200
+ * @param factor - Volume multiplication factor (1.0 = unchanged, 2.0 = double)
201
+ * @returns Filter string or null if not supported
202
+ *
203
+ * @example
204
+ * ```typescript
205
+ * presets.volume(0.5) // Reduce volume by 50%
206
+ * presets.volume(1.5) // Increase volume by 50%
207
+ * ```
208
+ *
209
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#volume | FFmpeg volume filter}
78
210
  */
79
211
  volume(factor: number): string | null;
80
212
  /**
81
- * Convert audio sample format.
213
+ * Creates an audio format filter string.
214
+ *
215
+ * @param sampleFormat - Target sample format (e.g., 's16', 'fltp')
216
+ * @param sampleRate - Target sample rate in Hz (optional)
217
+ * @param channelLayout - Target channel layout (optional)
218
+ * @returns Filter string or null if not supported
219
+ *
220
+ * @example
221
+ * ```typescript
222
+ * // Change sample format only
223
+ * presets.aformat('s16');
224
+ *
225
+ * // Change format and sample rate
226
+ * presets.aformat('fltp', 48000);
227
+ *
228
+ * // Full conversion
229
+ * presets.aformat('s16', 44100, 'stereo');
230
+ * ```
231
+ *
232
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#aformat | FFmpeg aformat filter}
82
233
  */
83
234
  aformat(sampleFormat: string | AVSampleFormat, sampleRate?: number, channelLayout?: string): string | null;
84
235
  /**
85
- * Change audio tempo without changing pitch.
236
+ * Creates an asetnsamples filter string to set the number of samples per frame.
237
+ * This is crucial for encoders like Opus that require specific frame sizes.
238
+ *
239
+ * @param samples - Number of samples per frame
240
+ * @param padding - Whether to pad or drop samples (default: true)
241
+ * @returns Filter string or null if not supported
242
+ *
243
+ * @example
244
+ * ```typescript
245
+ * // For Opus encoder (requires 960 samples)
246
+ * presets.asetnsamples(960);
247
+ *
248
+ * // Drop samples instead of padding
249
+ * presets.asetnsamples(1024, false);
250
+ * ```
251
+ *
252
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#asetnsamples | FFmpeg asetnsamples filter}
253
+ */
254
+ asetnsamples(samples: number, padding?: boolean): string | null;
255
+ /**
256
+ * Creates an atempo filter string to change audio playback speed.
257
+ * Factor must be between 0.5 and 2.0. For larger changes, chain multiple atempo filters.
258
+ *
259
+ * @param factor - Tempo factor (0.5 = half speed, 2.0 = double speed)
260
+ * @returns Filter string or null if not supported
261
+ *
262
+ * @example
263
+ * ```typescript
264
+ * presets.atempo(1.5) // 1.5x speed
265
+ * presets.atempo(0.8) // Slow down to 80% speed
266
+ * ```
267
+ *
268
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#atempo | FFmpeg atempo filter}
86
269
  */
87
270
  atempo(factor: number): string | null;
88
271
  /**
89
- * Apply audio fade.
272
+ * Creates an audio fade filter string.
273
+ *
274
+ * @param type - Fade type ('in' or 'out')
275
+ * @param start - Start time in seconds
276
+ * @param duration - Fade duration in seconds
277
+ * @returns Filter string or null if not supported
278
+ *
279
+ * @example
280
+ * ```typescript
281
+ * presets.afade('in', 0, 3) // 3-second audio fade in
282
+ * presets.afade('out', 20, 2) // 2-second fade out at 20s
283
+ * ```
284
+ *
285
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#afade | FFmpeg afade filter}
90
286
  */
91
287
  afade(type: 'in' | 'out', start: number, duration: number): string | null;
92
288
  /**
93
- * Mix multiple audio streams.
289
+ * Creates an amix filter string to mix multiple audio streams.
290
+ *
291
+ * @param inputs - Number of input streams to mix (default: 2)
292
+ * @param duration - How to determine output duration (default: 'longest')
293
+ * @returns Filter string or null if not supported
294
+ *
295
+ * @example
296
+ * ```typescript
297
+ * presets.amix(3, 'longest') // Mix 3 audio streams
298
+ * presets.amix(2, 'first') // Mix 2 streams, use first's duration
299
+ * ```
300
+ *
301
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#amix | FFmpeg amix filter}
94
302
  */
95
303
  amix(inputs?: number, duration?: 'first' | 'longest' | 'shortest'): string | null;
304
+ /**
305
+ * Creates a pad filter string to add padding to video.
306
+ * Essential for aspect ratio adjustments and letterboxing.
307
+ *
308
+ * @param width - Output width (can use expressions like 'iw+100')
309
+ * @param height - Output height (can use expressions like 'ih+100')
310
+ * @param x - X position of input video (default: '(ow-iw)/2' for center)
311
+ * @param y - Y position of input video (default: '(oh-ih)/2' for center)
312
+ * @param color - Padding color (default: 'black')
313
+ * @returns Filter string or null if not supported
314
+ *
315
+ * @example
316
+ * ```typescript
317
+ * // Add black bars for 16:9 aspect ratio
318
+ * presets.pad('iw', 'iw*9/16');
319
+ *
320
+ * // Add 50px padding on all sides
321
+ * presets.pad('iw+100', 'ih+100');
322
+ * ```
323
+ *
324
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#pad | FFmpeg pad filter}
325
+ */
326
+ pad(width: string | number, height: string | number, x?: string, y?: string, color?: string): string | null;
327
+ /**
328
+ * Creates a trim filter string to cut a portion of the stream.
329
+ * Crucial for cutting segments from media.
330
+ *
331
+ * @param start - Start time in seconds
332
+ * @param end - End time in seconds (optional)
333
+ * @param duration - Duration in seconds (optional, alternative to end)
334
+ * @returns Filter string or null if not supported
335
+ *
336
+ * @example
337
+ * ```typescript
338
+ * presets.trim(10, 30) // Extract from 10s to 30s
339
+ * presets.trim(5, undefined, 10) // Extract 10s starting at 5s
340
+ * ```
341
+ *
342
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#trim | FFmpeg trim filter}
343
+ */
344
+ trim(start: number, end?: number, duration?: number): string | null;
345
+ /**
346
+ * Creates a setpts filter string to change presentation timestamps.
347
+ * Essential for speed changes and timestamp manipulation.
348
+ *
349
+ * @param expression - PTS expression (e.g., 'PTS*2' for half speed, 'PTS/2' for double speed)
350
+ * @returns Filter string or null if not supported
351
+ *
352
+ * @example
353
+ * ```typescript
354
+ * // Double speed
355
+ * presets.setpts('PTS/2');
356
+ *
357
+ * // Half speed
358
+ * presets.setpts('PTS*2');
359
+ *
360
+ * // Reset timestamps
361
+ * presets.setpts('PTS-STARTPTS');
362
+ * ```
363
+ *
364
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#setpts | FFmpeg setpts filter}
365
+ */
366
+ setpts(expression: string): string | null;
367
+ /**
368
+ * Creates an asetpts filter string for audio timestamp manipulation.
369
+ *
370
+ * @param expression - PTS expression
371
+ * @returns Filter string or null if not supported
372
+ *
373
+ * @example
374
+ * ```typescript
375
+ * presets.asetpts('PTS-STARTPTS') // Reset timestamps to start from 0
376
+ * ```
377
+ *
378
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#asetpts | FFmpeg asetpts filter}
379
+ */
380
+ asetpts(expression: string): string | null;
381
+ /**
382
+ * Creates a transpose filter string for rotation/flipping.
383
+ * More efficient than rotate for 90-degree rotations.
384
+ *
385
+ * @param mode - Transpose mode (0-3, or named constants)
386
+ * @returns Filter string or null if not supported
387
+ *
388
+ * @example
389
+ * ```typescript
390
+ * presets.transpose(1) // Rotate 90 degrees clockwise
391
+ * presets.transpose('cclock') // Rotate 90 degrees counter-clockwise
392
+ * ```
393
+ *
394
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#transpose | FFmpeg transpose filter}
395
+ */
396
+ transpose(mode: number | 'clock' | 'cclock' | 'clock_flip' | 'cclock_flip'): string | null;
397
+ /**
398
+ * Creates a setsar filter string to set sample aspect ratio.
399
+ * Important for correcting aspect ratio issues.
400
+ *
401
+ * @param ratio - Aspect ratio (e.g., '1:1', '16:9', or number)
402
+ * @returns Filter string or null if not supported
403
+ *
404
+ * @example
405
+ * ```typescript
406
+ * presets.setsar('1:1') // Square pixels
407
+ * presets.setsar(1.333) // 4:3 aspect ratio
408
+ * ```
409
+ *
410
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#setsar | FFmpeg setsar/setdar filter}
411
+ */
412
+ setsar(ratio: string | number): string | null;
413
+ /**
414
+ * Creates a setdar filter string to set display aspect ratio.
415
+ *
416
+ * @param ratio - Aspect ratio (e.g., '16:9', '4:3')
417
+ * @returns Filter string or null if not supported
418
+ *
419
+ * @example
420
+ * ```typescript
421
+ * presets.setdar('16:9') // Widescreen
422
+ * presets.setdar('4:3') // Traditional TV aspect
423
+ * ```
424
+ *
425
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#setsar | FFmpeg setsar/setdar filter}
426
+ */
427
+ setdar(ratio: string | number): string | null;
428
+ /**
429
+ * Creates an apad filter string to add audio padding.
430
+ * Useful for ensuring minimum audio duration.
431
+ *
432
+ * @param wholeDuration - Minimum duration in seconds (optional)
433
+ * @param padDuration - Amount of padding to add in seconds (optional)
434
+ * @returns Filter string or null if not supported
435
+ *
436
+ * @example
437
+ * ```typescript
438
+ * presets.apad(30) // Ensure at least 30 seconds total
439
+ * presets.apad(undefined, 5) // Add 5 seconds of padding
440
+ * ```
441
+ *
442
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#apad | FFmpeg apad filter}
443
+ */
444
+ apad(wholeDuration?: number, padDuration?: number): string | null;
445
+ /**
446
+ * Creates a deinterlace filter string.
447
+ * Essential for processing interlaced content.
448
+ *
449
+ * @param mode - Deinterlace mode (default: 'yadif')
450
+ * @returns Filter string or null if not supported
451
+ *
452
+ * @example
453
+ * ```typescript
454
+ * presets.deinterlace('yadif') // Standard deinterlacing
455
+ * presets.deinterlace('bwdif') // Bob Weaver deinterlacing
456
+ * ```
457
+ *
458
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#yadif | FFmpeg yadif filter}
459
+ */
460
+ deinterlace(mode?: 'yadif' | 'bwdif' | 'w3fdif'): string | null;
461
+ /**
462
+ * Creates a select filter string to select specific frames.
463
+ * Powerful for extracting keyframes, specific frame types, etc.
464
+ *
465
+ * @param expression - Selection expression
466
+ * @returns Filter string or null if not supported
467
+ *
468
+ * @example
469
+ * ```typescript
470
+ * presets.select('eq(pict_type,I)') // Select only keyframes
471
+ * presets.select('not(mod(n,10))') // Select every 10th frame
472
+ * ```
473
+ *
474
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#select | FFmpeg select filter}
475
+ */
476
+ select(expression: string): string | null;
477
+ /**
478
+ * Creates an aselect filter string for audio selection.
479
+ *
480
+ * @param expression - Selection expression
481
+ * @returns Filter string or null if not supported
482
+ *
483
+ * @example
484
+ * ```typescript
485
+ * presets.aselect('between(t,10,20)') // Select audio between 10-20 seconds
486
+ * ```
487
+ *
488
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#aselect | FFmpeg aselect filter}
489
+ */
490
+ aselect(expression: string): string | null;
491
+ /**
492
+ * Creates a concat filter string to concatenate multiple inputs.
493
+ * Essential for joining multiple video/audio segments.
494
+ *
495
+ * @param n - Number of input segments
496
+ * @param v - Number of output video streams (0 or 1)
497
+ * @param a - Number of output audio streams (0 or 1)
498
+ * @returns Filter string or null if not supported
499
+ *
500
+ * @example
501
+ * ```typescript
502
+ * presets.concat(3, 1, 1) // Join 3 segments with video and audio
503
+ * presets.concat(2, 1, 0) // Join 2 video-only segments
504
+ * ```
505
+ *
506
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#concat | FFmpeg concat filter}
507
+ */
508
+ concat(n: number, v?: number, a?: number): string | null;
509
+ /**
510
+ * Creates an amerge filter string to merge multiple audio streams into one.
511
+ * Different from amix - this creates multi-channel output.
512
+ *
513
+ * @param inputs - Number of input streams
514
+ * @returns Filter string or null if not supported
515
+ *
516
+ * @example
517
+ * ```typescript
518
+ * presets.amerge(2) // Merge 2 mono streams to stereo
519
+ * presets.amerge(6) // Merge 6 channels for 5.1 surround
520
+ * ```
521
+ *
522
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#amerge | FFmpeg amerge filter}
523
+ */
524
+ amerge(inputs?: number): string | null;
525
+ /**
526
+ * Creates a channelmap filter string to remap audio channels.
527
+ * Critical for audio channel manipulation.
528
+ *
529
+ * @param map - Channel mapping (e.g., '0-0|1-1' or 'FL-FR|FR-FL' to swap stereo)
530
+ * @returns Filter string or null if not supported
531
+ *
532
+ * @example
533
+ * ```typescript
534
+ * presets.channelmap('FL-FR|FR-FL') // Swap left and right channels
535
+ * presets.channelmap('0-0|0-1') // Duplicate mono to stereo
536
+ * ```
537
+ *
538
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#channelmap | FFmpeg channelmap filter}
539
+ */
540
+ channelmap(map: string): string | null;
541
+ /**
542
+ * Creates a channelsplit filter string to split audio channels.
543
+ *
544
+ * @param channelLayout - Channel layout to split (optional)
545
+ * @returns Filter string or null if not supported
546
+ *
547
+ * @example
548
+ * ```typescript
549
+ * presets.channelsplit('stereo') // Split stereo to 2 mono
550
+ * presets.channelsplit('5.1') // Split 5.1 to individual channels
551
+ * ```
552
+ *
553
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#channelsplit | FFmpeg channelsplit filter}
554
+ */
555
+ channelsplit(channelLayout?: string): string | null;
556
+ /**
557
+ * Creates a loudnorm filter string for loudness normalization.
558
+ * Essential for broadcast compliance and consistent audio levels.
559
+ *
560
+ * @param I - Integrated loudness target (default: -24 LUFS)
561
+ * @param TP - True peak (default: -2 dBTP)
562
+ * @param LRA - Loudness range (default: 7 LU)
563
+ * @returns Filter string or null if not supported
564
+ *
565
+ * @example
566
+ * ```typescript
567
+ * presets.loudnorm(-23, -1, 7) // EBU R128 broadcast standard
568
+ * presets.loudnorm(-16, -1.5, 11) // Streaming platforms standard
569
+ * ```
570
+ *
571
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#loudnorm | FFmpeg loudnorm filter}
572
+ */
573
+ loudnorm(I?: number, TP?: number, LRA?: number): string | null;
574
+ /**
575
+ * Creates a compand filter string for audio compression/expansion.
576
+ * Important for dynamic range control.
577
+ *
578
+ * @param attacks - Attack times
579
+ * @param decays - Decay times
580
+ * @param points - Transfer function points
581
+ * @param gain - Output gain
582
+ * @returns Filter string or null if not supported
583
+ *
584
+ * @example
585
+ * ```typescript
586
+ * presets.compand('0.3|0.3', '1|1', '-90/-60|-60/-40|-40/-30|-20/-20', 6)
587
+ * ```
588
+ *
589
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#compand | FFmpeg compand filter}
590
+ */
591
+ compand(attacks: string, decays: string, points: string, gain?: number): string | null;
96
592
  }
97
593
  /**
98
594
  * Filter chain builder for composing multiple filters.
99
- * Allows fluent API for building complex filter graphs.
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
+ * ```
100
606
  */
101
607
  export declare class FilterChain {
102
608
  private filters;
103
609
  /**
104
- * Add a filter to the chain.
105
- * @param filter - Filter string or null/undefined (will be skipped)
610
+ * Adds a filter to the chain.
611
+ *
612
+ * @param filter - Filter string to add (ignored if null/undefined)
613
+ * @returns This instance for chaining
614
+ *
615
+ * @example
616
+ * ```typescript
617
+ * chain.add('scale=1920:1080')
618
+ * ```
106
619
  */
107
620
  add(filter: string | null | undefined): this;
108
621
  /**
109
- * Add a custom filter string.
622
+ * Adds a custom filter string to the chain.
623
+ *
624
+ * @param filter - Custom filter string
625
+ * @returns This instance for chaining
626
+ *
627
+ * @example
628
+ * ```typescript
629
+ * chain.custom('myfilter=param1:param2')
630
+ * ```
110
631
  */
111
632
  custom(filter: string): this;
112
633
  /**
113
- * Build the filter chain string.
634
+ * Builds the final filter string.
635
+ *
114
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"
642
+ * ```
115
643
  */
116
644
  build(separator?: string): string;
117
645
  /**
118
- * Get the filter array.
646
+ * Returns the filters as an array.
647
+ *
648
+ * @returns Array of filter strings
649
+ *
650
+ * @example
651
+ * ```typescript
652
+ * const filters = chain.toArray() // ["scale=1920:1080", "fps=30"]
653
+ * ```
119
654
  */
120
655
  toArray(): string[];
121
656
  }
122
657
  /**
123
658
  * Base chain builder with common filter methods.
659
+ * Provides a fluent API for building filter chains using preset methods.
660
+ *
124
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
+ * ```
125
671
  */
126
672
  export declare abstract class ChainBuilderBase<T extends FilterPresetBase> extends FilterChain {
127
673
  protected readonly presets: T;
674
+ /**
675
+ * @param presets - The filter presets to use
676
+ * @internal
677
+ */
128
678
  constructor(presets: T);
679
+ /**
680
+ * Adds a scale filter to the chain.
681
+ *
682
+ * @param width - Target width
683
+ * @param height - Target height
684
+ * @param options - Additional scaling options
685
+ *
686
+ * @returns This instance for chaining
687
+ *
688
+ * @example
689
+ * ```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();
700
+ * ```
701
+ *
702
+ * @see {@link FilterPresetBase.scale}
703
+ */
129
704
  scale(width: number, height: number, options?: Record<string, any>): this;
705
+ /**
706
+ * Adds a crop filter to the chain.
707
+ *
708
+ * @param width - Crop width
709
+ * @param height - Crop height
710
+ * @param x - X position (default: 0)
711
+ * @param y - Y position (default: 0)
712
+ *
713
+ * @returns This instance for chaining
714
+ *
715
+ * @example
716
+ * ```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();
727
+ * ```
728
+ *
729
+ * @see {@link FilterPresetBase.crop}
730
+ */
130
731
  crop(width: number, height: number, x?: number, y?: number): this;
732
+ /**
733
+ * Adds an FPS filter to the chain.
734
+ *
735
+ * @param fps - Target frame rate
736
+ *
737
+ * @returns This instance for chaining
738
+ *
739
+ * @example
740
+ * ```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();
751
+ * ```
752
+ *
753
+ * @see {@link FilterPresetBase.fps}
754
+ */
131
755
  fps(fps: number): this;
756
+ /**
757
+ * Adds a format filter to the chain.
758
+ *
759
+ * @param pixelFormat - Target pixel format(s)
760
+ *
761
+ * @returns This instance for chaining
762
+ *
763
+ * @example
764
+ * ```typescript
765
+ * const chain = FilterPresets.chain()
766
+ * .format('yuv420p')
767
+ * .build();
768
+ * ```
769
+ *
770
+ * @example
771
+ * ```typescript
772
+ * const chain = FilterPresets.chain()
773
+ * .format(AV_PIX_FMT_RGB24)
774
+ * .build();
775
+ * ```
776
+ *
777
+ * @see {@link FilterPresetBase.format}
778
+ */
132
779
  format(pixelFormat: string | AVPixelFormat | (string | AVPixelFormat)[]): this;
780
+ /**
781
+ * Adds a rotate filter to the chain.
782
+ *
783
+ * @param angle - Rotation angle in degrees
784
+ *
785
+ * @returns This instance for chaining
786
+ *
787
+ * @example
788
+ * ```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();
799
+ * ```
800
+ *
801
+ * @see {@link FilterPresetBase.rotate}
802
+ */
133
803
  rotate(angle: number): this;
804
+ /**
805
+ * Adds a horizontal flip filter to the chain.
806
+ *
807
+ * @returns This instance for chaining
808
+ *
809
+ * @example
810
+ * ```typescript
811
+ * const chain = FilterPresets.chain()
812
+ * .hflip()
813
+ * .build();
814
+ * ```
815
+ *
816
+ * @see {@link FilterPresetBase.hflip}
817
+ */
134
818
  hflip(): this;
819
+ /**
820
+ * Adds a vertical flip filter to the chain.
821
+ *
822
+ * @returns This instance for chaining
823
+ *
824
+ * @example
825
+ * ```typescript
826
+ * const chain = FilterPresets.chain()
827
+ * .vflip()
828
+ * .build();
829
+ * ```
830
+ *
831
+ * @see {@link FilterPresetBase.vflip}
832
+ */
135
833
  vflip(): this;
834
+ /**
835
+ * Adds a fade filter to the chain.
836
+ *
837
+ * @param type - Fade type ('in' or 'out')
838
+ * @param start - Start time in seconds
839
+ * @param duration - Fade duration in seconds
840
+ *
841
+ * @returns This instance for chaining
842
+ *
843
+ * @example
844
+ * ```typescript
845
+ * const chain = FilterPresets.chain()
846
+ * .fade('in', 0, 2)
847
+ * .build();
848
+ * ```
849
+ *
850
+ * @example
851
+ * ```typescript
852
+ * const chain = FilterPresets.chain()
853
+ * .fade('out', 10, 1.5)
854
+ * .build();
855
+ * ```
856
+ *
857
+ * @see {@link FilterPresetBase.fade}
858
+ */
136
859
  fade(type: 'in' | 'out', start: number, duration: number): this;
860
+ /**
861
+ * Adds an overlay filter to the chain.
862
+ *
863
+ * @param x - X position (default: 0)
864
+ * @param y - Y position (default: 0)
865
+ * @param options - Additional overlay options
866
+ *
867
+ * @returns This instance for chaining
868
+ *
869
+ * @example
870
+ * ```typescript
871
+ * const chain = FilterPresets.chain()
872
+ * .overlay(100, 50)
873
+ * .build();
874
+ * ```
875
+ *
876
+ * @example
877
+ * ```typescript
878
+ * const chain = FilterPresets.chain()
879
+ * .overlay(10, 10, { enable: 'between(t,5,10)' })
880
+ * .build();
881
+ * ```
882
+ *
883
+ * @see {@link FilterPresetBase.overlay}
884
+ */
137
885
  overlay(x?: number, y?: number, options?: Record<string, string>): this;
886
+ /**
887
+ * Adds a volume filter to the chain.
888
+ *
889
+ * @param factor - Volume factor
890
+ *
891
+ * @returns This instance for chaining
892
+ *
893
+ * @example
894
+ * ```typescript
895
+ * const chain = FilterPresets.chain()
896
+ * .volume(0.5)
897
+ * .build();
898
+ * ```
899
+ *
900
+ * @example
901
+ * ```typescript
902
+ * const chain = FilterPresets.chain()
903
+ * .volume(2.0)
904
+ * .build();
905
+ * ```
906
+ *
907
+ * @see {@link FilterPresetBase.volume}
908
+ */
138
909
  volume(factor: number): this;
910
+ /**
911
+ * Adds an audio format filter to the chain.
912
+ *
913
+ * @param sampleFormat - Target sample format
914
+ * @param sampleRate - Target sample rate (optional)
915
+ * @param channelLayout - Target channel layout (optional)
916
+ *
917
+ * @returns This instance for chaining
918
+ *
919
+ * @example
920
+ * ```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();
931
+ * ```
932
+ *
933
+ * @see {@link FilterPresetBase.aformat}
934
+ */
139
935
  aformat(sampleFormat: string | AVSampleFormat, sampleRate?: number, channelLayout?: string): this;
936
+ /**
937
+ * Adds an asetnsamples filter to the chain.
938
+ *
939
+ * @param samples - Number of samples per frame
940
+ * @param padding - Whether to pad or drop samples (default: true)
941
+ *
942
+ * @returns This instance for chaining
943
+ *
944
+ * @example
945
+ * ```typescript
946
+ * const chain = FilterPresets.chain()
947
+ * .asetnsamples(960)
948
+ * .build();
949
+ * ```
950
+ *
951
+ * @example
952
+ * ```typescript
953
+ * const chain = FilterPresets.chain()
954
+ * .asetnsamples(1024, false)
955
+ * .build();
956
+ * ```
957
+ *
958
+ * @see {@link FilterPresetBase.asetnsamples}
959
+ */
960
+ asetnsamples(samples: number, padding?: boolean): this;
961
+ /**
962
+ * Adds an atempo filter to the chain.
963
+ *
964
+ * @param factor - Tempo factor (0.5 to 2.0)
965
+ *
966
+ * @returns This instance for chaining
967
+ *
968
+ * @example
969
+ * ```typescript
970
+ * 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)
979
+ * .build();
980
+ * ```
981
+ *
982
+ * @see {@link FilterPresetBase.atempo}
983
+ */
140
984
  atempo(factor: number): this;
985
+ /**
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
991
+ *
992
+ * @returns This instance for chaining
993
+ *
994
+ * @example
995
+ * ```typescript
996
+ * 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)
1005
+ * .build();
1006
+ * ```
1007
+ *
1008
+ * @see {@link FilterPresetBase.afade}
1009
+ */
141
1010
  afade(type: 'in' | 'out', start: number, duration: number): this;
1011
+ /**
1012
+ * Adds an amix filter to the chain.
1013
+ *
1014
+ * @param inputs - Number of inputs (default: 2)
1015
+ * @param duration - Duration mode (default: 'longest')
1016
+ *
1017
+ * @returns This instance for chaining
1018
+ *
1019
+ * @example
1020
+ * ```typescript
1021
+ * const chain = FilterPresets.chain()
1022
+ * .amix(3, 'longest')
1023
+ * .build();
1024
+ * ```
1025
+ *
1026
+ * @example
1027
+ * ```typescript
1028
+ * const chain = FilterPresets.chain()
1029
+ * .amix(2, 'first')
1030
+ * .build();
1031
+ * ```
1032
+ *
1033
+ * @see {@link FilterPresetBase.amix}
1034
+ */
142
1035
  amix(inputs?: number, duration?: 'first' | 'longest' | 'shortest'): this;
143
- transpose(dir?: number): 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
+ */
1054
+ pad(width: string | number, height: string | number, x?: string, y?: string, color?: string): this;
1055
+ /**
1056
+ * Adds a trim filter to the chain.
1057
+ *
1058
+ * @param start - Start time in seconds
1059
+ * @param end - End time in seconds
1060
+ * @param duration - Duration in seconds
1061
+ *
1062
+ * @returns This instance for chaining
1063
+ *
1064
+ * @example
1065
+ * ```typescript
1066
+ * chain.trim(10, 20) // Extract 10 seconds from t=10 to t=20
1067
+ * ```
1068
+ *
1069
+ * @see {@link FilterPresetBase.trim}
1070
+ */
1071
+ trim(start: number, end?: number, duration?: number): this;
1072
+ /**
1073
+ * Adds a setpts filter to the chain.
1074
+ *
1075
+ * @param expression - PTS expression
1076
+ *
1077
+ * @returns This instance for chaining
1078
+ *
1079
+ * @example
1080
+ * ```typescript
1081
+ * chain.setpts('PTS/2') // Double playback speed
1082
+ * ```
1083
+ *
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
+ */
144
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
+ */
145
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
+ */
146
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
+ */
147
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
+ */
148
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
+ */
149
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
+ */
150
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
+ */
151
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
+ */
152
1487
  hwmap(derive?: string): this;
153
1488
  }
154
1489
  /**
155
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
+ * ```
156
1502
  */
157
1503
  export declare class FilterChainBuilder extends ChainBuilderBase<FilterPresets> {
158
1504
  }
159
1505
  /**
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.
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.
164
1509
  *
165
1510
  * @example
166
1511
  * ```typescript
167
- * const filter = await Filter.create(
168
- * FilterPresets.scale(1280, 720),
169
- * config
170
- * );
1512
+ * // Static methods for individual filters
1513
+ * const scaleFilter = FilterPresets.scale(1920, 1080);
1514
+ * const fpsFilter = FilterPresets.fps(30);
171
1515
  *
172
- * // Using chain builder
1516
+ * // Chain builder for complex graphs
173
1517
  * const chain = FilterPresets.chain()
174
1518
  * .scale(1920, 1080)
175
- * .format('yuv420p')
176
- * .custom('unsharp=5:5:1.0')
1519
+ * .fps(30)
1520
+ * .fade('in', 0, 2)
177
1521
  * .build();
178
1522
  * ```
179
1523
  */
180
1524
  export declare class FilterPresets extends FilterPresetBase {
181
1525
  private static instance;
182
1526
  /**
183
- * Create a new filter chain builder.
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
+ * ```
184
1538
  */
185
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
+ */
186
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
+ */
187
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
+ */
188
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
+ */
189
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
+ */
190
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
+ */
191
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
+ */
192
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
+ */
193
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
+ */
194
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
+ */
195
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
+ */
196
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
+ */
197
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
+ */
198
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
+ */
199
1809
  static amix(inputs?: number, duration?: 'first' | 'longest' | 'shortest'): string;
200
1810
  }
201
1811
  /**
202
1812
  * 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.
1813
+ * Provides optimized filter implementations for specific hardware types,
1814
+ * with automatic fallback when operations aren't supported.
206
1815
  *
207
1816
  * @example
208
1817
  * ```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);
1818
+ * // Create hardware presets for CUDA
1819
+ * const hw = new HardwareFilterPresets(AV_HWDEVICE_TYPE_CUDA);
213
1820
  *
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();
1821
+ * // Check capabilities
1822
+ * if (hw.support.scale) {
1823
+ * const scaleFilter = hw.scale(1920, 1080);
222
1824
  * }
1825
+ *
1826
+ * // Use chain builder
1827
+ * const chain = hw.chain()
1828
+ * .hwupload()
1829
+ * .scale(1920, 1080)
1830
+ * .tonemap()
1831
+ * .hwdownload()
1832
+ * .build();
223
1833
  * ```
224
1834
  */
225
1835
  export declare class HardwareFilterPresets extends FilterPresetBase {
226
1836
  private readonly deviceType;
227
- private readonly deviceName;
1837
+ private readonly deviceTypeName;
228
1838
  readonly support: HardwareFilterSupport;
229
1839
  /**
230
- * Create hardware filter presets for a specific device type.
231
- * @internal Used by HardwareContext
1840
+ * @param deviceType - Hardware device type enum
1841
+ * @param deviceTypeName - Optional hardware device type name (e.g., 'cuda', 'vaapi')
232
1842
  */
233
- constructor(deviceType: AVHWDeviceType, deviceName?: string | null);
1843
+ constructor(deviceType: AVHWDeviceType, deviceTypeName?: string);
234
1844
  /**
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
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
+ * ```
239
1856
  */
240
1857
  static isHardwareFilter(filterName: string): boolean;
241
1858
  /**
242
- * Create a new hardware filter chain builder.
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
+ * ```
243
1871
  */
244
1872
  chain(): HardwareFilterChainBuilder;
245
1873
  /**
246
- * Hardware-accelerated scale filter.
247
- * @returns Filter string or null if not supported
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}
248
1900
  */
249
1901
  scale(width: number, height: number, options?: Record<string, any>): string | null;
250
1902
  /**
251
- * Hardware-accelerated overlay filter.
252
- * @returns Filter string or null if not supported
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}
253
1922
  */
254
1923
  overlay(x?: number, y?: number, options?: Record<string, string>): string | null;
255
1924
  /**
256
- * Hardware-accelerated transpose filter.
257
- * @returns Filter string or null if not supported
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
+ * ```
258
1946
  */
259
- transpose(dir?: number): string | null;
1947
+ transpose(mode: number | 'clock' | 'cclock' | 'clock_flip' | 'cclock_flip'): string | null;
260
1948
  /**
261
- * Hardware-accelerated tonemap filter.
262
- * @returns Filter string or null if not supported
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
+ * ```
263
1965
  */
264
1966
  tonemap(options?: Record<string, string>): string | null;
265
1967
  /**
266
- * Hardware-accelerated deinterlace filter.
267
- * @returns Filter string or null if not supported
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
+ * ```
268
1990
  */
269
1991
  deinterlace(mode?: string): string | null;
270
1992
  /**
271
- * Hardware-accelerated flip filter.
272
- * @returns Filter string or null if not supported
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
+ * ```
273
2009
  */
274
2010
  flip(direction: 'h' | 'v'): string | null;
275
2011
  /**
276
- * Hardware-accelerated blur filter.
277
- * @returns Filter string or null if not supported
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
+ * ```
278
2033
  */
279
2034
  blur(type?: 'avg' | 'gaussian' | 'box', radius?: number): string | null;
280
2035
  /**
281
- * Hardware-accelerated sharpen filter.
282
- * @returns Filter string or null if not supported
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
+ * ```
283
2056
  */
284
2057
  sharpen(amount?: number): string | null;
285
2058
  /**
286
- * Hardware-accelerated stack filters (hstack, vstack, xstack).
287
- * @returns Filter string or null if not supported
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
+ * ```
288
2076
  */
289
2077
  stack(type: 'h' | 'v' | 'x', inputs?: number): string | null;
290
2078
  /**
291
- * Hardware upload filter to transfer frames to GPU.
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}
292
2090
  */
293
2091
  hwupload(): string | null;
294
2092
  /**
295
- * Hardware download filter to transfer frames from GPU.
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}
296
2103
  */
297
2104
  hwdownload(): string | null;
298
2105
  /**
299
- * Format conversion for hardware frames.
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}
300
2123
  */
301
2124
  hwmap(derive?: string): string | null;
302
2125
  /**
303
- * Get capabilities for this hardware type.
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
+ * ```
304
2137
  */
305
2138
  getCapabilities(): HardwareFilterSupport;
306
2139
  /**
307
- * Get supported filters for this hardware type.
2140
+ * Determines filter support for the hardware type.
2141
+ *
2142
+ * @returns Hardware filter support configuration
2143
+ *
2144
+ * @internal
308
2145
  */
309
2146
  private getSupport;
310
2147
  }
311
2148
  /**
312
2149
  * Hardware filter chain builder with fluent API.
313
- * Automatically skips unsupported filters (returns null).
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
+ * ```
314
2162
  */
315
2163
  export declare class HardwareFilterChainBuilder extends ChainBuilderBase<HardwareFilterPresets> {
316
2164
  }