node-av 1.0.3 → 1.2.0

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