node-av-light 0.0.0-stage → 7.1.0-beta.1

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 (311) hide show
  1. package/LICENSE.md +22 -0
  2. package/README.md +710 -2
  3. package/dist/api/audio-frame-buffer.d.ts +636 -0
  4. package/dist/api/audio-frame-buffer.js +1027 -0
  5. package/dist/api/audio-frame-buffer.js.map +1 -0
  6. package/dist/api/bitstream-filter.d.ts +938 -0
  7. package/dist/api/bitstream-filter.js +1427 -0
  8. package/dist/api/bitstream-filter.js.map +1 -0
  9. package/dist/api/constants.d.ts +44 -0
  10. package/dist/api/constants.js +45 -0
  11. package/dist/api/constants.js.map +1 -0
  12. package/dist/api/data/test_av1.ivf +0 -0
  13. package/dist/api/data/test_h264.h264 +0 -0
  14. package/dist/api/data/test_hevc.h265 +0 -0
  15. package/dist/api/data/test_mjpeg.mjpeg +0 -0
  16. package/dist/api/data/test_vp8.ivf +0 -0
  17. package/dist/api/data/test_vp9.ivf +0 -0
  18. package/dist/api/decoder.d.ts +1413 -0
  19. package/dist/api/decoder.js +2367 -0
  20. package/dist/api/decoder.js.map +1 -0
  21. package/dist/api/demuxer.d.ts +1295 -0
  22. package/dist/api/demuxer.js +2344 -0
  23. package/dist/api/demuxer.js.map +1 -0
  24. package/dist/api/device.d.ts +589 -0
  25. package/dist/api/device.js +964 -0
  26. package/dist/api/device.js.map +1 -0
  27. package/dist/api/encoder-pool.d.ts +262 -0
  28. package/dist/api/encoder-pool.js +397 -0
  29. package/dist/api/encoder-pool.js.map +1 -0
  30. package/dist/api/encoder.d.ts +1509 -0
  31. package/dist/api/encoder.js +2619 -0
  32. package/dist/api/encoder.js.map +1 -0
  33. package/dist/api/filter-complex.d.ts +828 -0
  34. package/dist/api/filter-complex.js +1661 -0
  35. package/dist/api/filter-complex.js.map +1 -0
  36. package/dist/api/filter-presets.d.ts +800 -0
  37. package/dist/api/filter-presets.js +1554 -0
  38. package/dist/api/filter-presets.js.map +1 -0
  39. package/dist/api/filter.d.ts +1339 -0
  40. package/dist/api/filter.js +2075 -0
  41. package/dist/api/filter.js.map +1 -0
  42. package/dist/api/fmp4-stream.d.ts +797 -0
  43. package/dist/api/fmp4-stream.js +1428 -0
  44. package/dist/api/fmp4-stream.js.map +1 -0
  45. package/dist/api/hardware.d.ts +677 -0
  46. package/dist/api/hardware.js +1300 -0
  47. package/dist/api/hardware.js.map +1 -0
  48. package/dist/api/index.d.ts +21 -0
  49. package/dist/api/index.js +38 -0
  50. package/dist/api/index.js.map +1 -0
  51. package/dist/api/io-stream.d.ts +308 -0
  52. package/dist/api/io-stream.js +358 -0
  53. package/dist/api/io-stream.js.map +1 -0
  54. package/dist/api/muxer.d.ts +1311 -0
  55. package/dist/api/muxer.js +2672 -0
  56. package/dist/api/muxer.js.map +1 -0
  57. package/dist/api/pipeline.d.ts +801 -0
  58. package/dist/api/pipeline.js +1344 -0
  59. package/dist/api/pipeline.js.map +1 -0
  60. package/dist/api/probe.d.ts +128 -0
  61. package/dist/api/probe.js +227 -0
  62. package/dist/api/probe.js.map +1 -0
  63. package/dist/api/rtp-stream.d.ts +497 -0
  64. package/dist/api/rtp-stream.js +1131 -0
  65. package/dist/api/rtp-stream.js.map +1 -0
  66. package/dist/api/scaler.d.ts +561 -0
  67. package/dist/api/scaler.js +918 -0
  68. package/dist/api/scaler.js.map +1 -0
  69. package/dist/api/types.d.ts +17 -0
  70. package/dist/api/types.js +2 -0
  71. package/dist/api/types.js.map +1 -0
  72. package/dist/api/utilities/async-queue.d.ts +149 -0
  73. package/dist/api/utilities/async-queue.js +254 -0
  74. package/dist/api/utilities/async-queue.js.map +1 -0
  75. package/dist/api/utilities/audio-sample.d.ts +117 -0
  76. package/dist/api/utilities/audio-sample.js +112 -0
  77. package/dist/api/utilities/audio-sample.js.map +1 -0
  78. package/dist/api/utilities/audio-transcode.d.ts +20 -0
  79. package/dist/api/utilities/audio-transcode.js +27 -0
  80. package/dist/api/utilities/audio-transcode.js.map +1 -0
  81. package/dist/api/utilities/channel-layout.d.ts +76 -0
  82. package/dist/api/utilities/channel-layout.js +80 -0
  83. package/dist/api/utilities/channel-layout.js.map +1 -0
  84. package/dist/api/utilities/codec-format.d.ts +87 -0
  85. package/dist/api/utilities/codec-format.js +117 -0
  86. package/dist/api/utilities/codec-format.js.map +1 -0
  87. package/dist/api/utilities/context-options.d.ts +25 -0
  88. package/dist/api/utilities/context-options.js +23 -0
  89. package/dist/api/utilities/context-options.js.map +1 -0
  90. package/dist/api/utilities/electron-shared-texture.d.ts +368 -0
  91. package/dist/api/utilities/electron-shared-texture.js +540 -0
  92. package/dist/api/utilities/electron-shared-texture.js.map +1 -0
  93. package/dist/api/utilities/image.d.ts +207 -0
  94. package/dist/api/utilities/image.js +213 -0
  95. package/dist/api/utilities/image.js.map +1 -0
  96. package/dist/api/utilities/index.d.ts +14 -0
  97. package/dist/api/utilities/index.js +27 -0
  98. package/dist/api/utilities/index.js.map +1 -0
  99. package/dist/api/utilities/live-decoding.d.ts +15 -0
  100. package/dist/api/utilities/live-decoding.js +32 -0
  101. package/dist/api/utilities/live-decoding.js.map +1 -0
  102. package/dist/api/utilities/media-type.d.ts +49 -0
  103. package/dist/api/utilities/media-type.js +53 -0
  104. package/dist/api/utilities/media-type.js.map +1 -0
  105. package/dist/api/utilities/packet-age-watchdog.d.ts +198 -0
  106. package/dist/api/utilities/packet-age-watchdog.js +594 -0
  107. package/dist/api/utilities/packet-age-watchdog.js.map +1 -0
  108. package/dist/api/utilities/pixel-format.d.ts +89 -0
  109. package/dist/api/utilities/pixel-format.js +97 -0
  110. package/dist/api/utilities/pixel-format.js.map +1 -0
  111. package/dist/api/utilities/sample-format.d.ts +129 -0
  112. package/dist/api/utilities/sample-format.js +141 -0
  113. package/dist/api/utilities/sample-format.js.map +1 -0
  114. package/dist/api/utilities/scale-size.d.ts +51 -0
  115. package/dist/api/utilities/scale-size.js +55 -0
  116. package/dist/api/utilities/scale-size.js.map +1 -0
  117. package/dist/api/utilities/scheduler.d.ts +138 -0
  118. package/dist/api/utilities/scheduler.js +98 -0
  119. package/dist/api/utilities/scheduler.js.map +1 -0
  120. package/dist/api/utilities/streaming.d.ts +186 -0
  121. package/dist/api/utilities/streaming.js +309 -0
  122. package/dist/api/utilities/streaming.js.map +1 -0
  123. package/dist/api/utilities/timestamp.d.ts +193 -0
  124. package/dist/api/utilities/timestamp.js +206 -0
  125. package/dist/api/utilities/timestamp.js.map +1 -0
  126. package/dist/api/utilities/video-transcode.d.ts +218 -0
  127. package/dist/api/utilities/video-transcode.js +624 -0
  128. package/dist/api/utilities/video-transcode.js.map +1 -0
  129. package/dist/api/utilities/whisper-model.d.ts +330 -0
  130. package/dist/api/utilities/whisper-model.js +587 -0
  131. package/dist/api/utilities/whisper-model.js.map +1 -0
  132. package/dist/api/utils.d.ts +19 -0
  133. package/dist/api/utils.js +39 -0
  134. package/dist/api/utils.js.map +1 -0
  135. package/dist/api/webrtc-stream.d.ts +294 -0
  136. package/dist/api/webrtc-stream.js +546 -0
  137. package/dist/api/webrtc-stream.js.map +1 -0
  138. package/dist/api/whisper.d.ts +326 -0
  139. package/dist/api/whisper.js +402 -0
  140. package/dist/api/whisper.js.map +1 -0
  141. package/dist/constants/bsf-options.d.ts +364 -0
  142. package/dist/constants/bsf-options.js +7 -0
  143. package/dist/constants/bsf-options.js.map +1 -0
  144. package/dist/constants/channel-layouts.d.ts +53 -0
  145. package/dist/constants/channel-layouts.js +57 -0
  146. package/dist/constants/channel-layouts.js.map +1 -0
  147. package/dist/constants/constants.d.ts +2435 -0
  148. package/dist/constants/constants.js +1989 -0
  149. package/dist/constants/constants.js.map +1 -0
  150. package/dist/constants/decoders.d.ts +651 -0
  151. package/dist/constants/decoders.js +641 -0
  152. package/dist/constants/decoders.js.map +1 -0
  153. package/dist/constants/encoders.d.ts +314 -0
  154. package/dist/constants/encoders.js +309 -0
  155. package/dist/constants/encoders.js.map +1 -0
  156. package/dist/constants/filter-options.d.ts +12099 -0
  157. package/dist/constants/filter-options.js +7 -0
  158. package/dist/constants/filter-options.js.map +1 -0
  159. package/dist/constants/format-options.d.ts +4319 -0
  160. package/dist/constants/format-options.js +7 -0
  161. package/dist/constants/format-options.js.map +1 -0
  162. package/dist/constants/formats.d.ts +18 -0
  163. package/dist/constants/formats.js +7 -0
  164. package/dist/constants/formats.js.map +1 -0
  165. package/dist/constants/hardware.d.ts +26 -0
  166. package/dist/constants/hardware.js +27 -0
  167. package/dist/constants/hardware.js.map +1 -0
  168. package/dist/constants/index.d.ts +10 -0
  169. package/dist/constants/index.js +6 -0
  170. package/dist/constants/index.js.map +1 -0
  171. package/dist/constants/options.d.ts +6217 -0
  172. package/dist/constants/options.js +7 -0
  173. package/dist/constants/options.js.map +1 -0
  174. package/dist/ffmpeg/index.d.ts +101 -0
  175. package/dist/ffmpeg/index.js +161 -0
  176. package/dist/ffmpeg/index.js.map +1 -0
  177. package/dist/ffmpeg/version.d.ts +6 -0
  178. package/dist/ffmpeg/version.js +7 -0
  179. package/dist/ffmpeg/version.js.map +1 -0
  180. package/dist/index.d.ts +4 -0
  181. package/dist/index.js +9 -0
  182. package/dist/index.js.map +1 -0
  183. package/dist/lib/audio-fifo.d.ts +399 -0
  184. package/dist/lib/audio-fifo.js +431 -0
  185. package/dist/lib/audio-fifo.js.map +1 -0
  186. package/dist/lib/binding.d.ts +242 -0
  187. package/dist/lib/binding.js +102 -0
  188. package/dist/lib/binding.js.map +1 -0
  189. package/dist/lib/bitstream-filter-context.d.ts +381 -0
  190. package/dist/lib/bitstream-filter-context.js +443 -0
  191. package/dist/lib/bitstream-filter-context.js.map +1 -0
  192. package/dist/lib/bitstream-filter.d.ts +140 -0
  193. package/dist/lib/bitstream-filter.js +154 -0
  194. package/dist/lib/bitstream-filter.js.map +1 -0
  195. package/dist/lib/codec-context.d.ts +1069 -0
  196. package/dist/lib/codec-context.js +1336 -0
  197. package/dist/lib/codec-context.js.map +1 -0
  198. package/dist/lib/codec-parameters.d.ts +664 -0
  199. package/dist/lib/codec-parameters.js +813 -0
  200. package/dist/lib/codec-parameters.js.map +1 -0
  201. package/dist/lib/codec-parser.d.ts +201 -0
  202. package/dist/lib/codec-parser.js +213 -0
  203. package/dist/lib/codec-parser.js.map +1 -0
  204. package/dist/lib/codec.d.ts +617 -0
  205. package/dist/lib/codec.js +746 -0
  206. package/dist/lib/codec.js.map +1 -0
  207. package/dist/lib/device.d.ts +294 -0
  208. package/dist/lib/device.js +326 -0
  209. package/dist/lib/device.js.map +1 -0
  210. package/dist/lib/dictionary.d.ts +333 -0
  211. package/dist/lib/dictionary.js +372 -0
  212. package/dist/lib/dictionary.js.map +1 -0
  213. package/dist/lib/error.d.ts +311 -0
  214. package/dist/lib/error.js +395 -0
  215. package/dist/lib/error.js.map +1 -0
  216. package/dist/lib/fifo.d.ts +416 -0
  217. package/dist/lib/fifo.js +453 -0
  218. package/dist/lib/fifo.js.map +1 -0
  219. package/dist/lib/filter-context.d.ts +714 -0
  220. package/dist/lib/filter-context.js +783 -0
  221. package/dist/lib/filter-context.js.map +1 -0
  222. package/dist/lib/filter-graph-segment.d.ts +161 -0
  223. package/dist/lib/filter-graph-segment.js +172 -0
  224. package/dist/lib/filter-graph-segment.js.map +1 -0
  225. package/dist/lib/filter-graph.d.ts +641 -0
  226. package/dist/lib/filter-graph.js +704 -0
  227. package/dist/lib/filter-graph.js.map +1 -0
  228. package/dist/lib/filter-inout.d.ts +202 -0
  229. package/dist/lib/filter-inout.js +261 -0
  230. package/dist/lib/filter-inout.js.map +1 -0
  231. package/dist/lib/filter.d.ts +243 -0
  232. package/dist/lib/filter.js +272 -0
  233. package/dist/lib/filter.js.map +1 -0
  234. package/dist/lib/format-context.d.ts +1335 -0
  235. package/dist/lib/format-context.js +1455 -0
  236. package/dist/lib/format-context.js.map +1 -0
  237. package/dist/lib/frame-utils.d.ts +116 -0
  238. package/dist/lib/frame-utils.js +98 -0
  239. package/dist/lib/frame-utils.js.map +1 -0
  240. package/dist/lib/frame.d.ts +1315 -0
  241. package/dist/lib/frame.js +1535 -0
  242. package/dist/lib/frame.js.map +1 -0
  243. package/dist/lib/hardware-device-context.d.ts +362 -0
  244. package/dist/lib/hardware-device-context.js +383 -0
  245. package/dist/lib/hardware-device-context.js.map +1 -0
  246. package/dist/lib/hardware-frames-context.d.ts +418 -0
  247. package/dist/lib/hardware-frames-context.js +471 -0
  248. package/dist/lib/hardware-frames-context.js.map +1 -0
  249. package/dist/lib/index.d.ts +35 -0
  250. package/dist/lib/index.js +60 -0
  251. package/dist/lib/index.js.map +1 -0
  252. package/dist/lib/input-format.d.ts +249 -0
  253. package/dist/lib/input-format.js +306 -0
  254. package/dist/lib/input-format.js.map +1 -0
  255. package/dist/lib/io-context.d.ts +698 -0
  256. package/dist/lib/io-context.js +771 -0
  257. package/dist/lib/io-context.js.map +1 -0
  258. package/dist/lib/log.d.ts +174 -0
  259. package/dist/lib/log.js +184 -0
  260. package/dist/lib/log.js.map +1 -0
  261. package/dist/lib/native-types.d.ts +1024 -0
  262. package/dist/lib/native-types.js +2 -0
  263. package/dist/lib/native-types.js.map +1 -0
  264. package/dist/lib/option.d.ts +953 -0
  265. package/dist/lib/option.js +1607 -0
  266. package/dist/lib/option.js.map +1 -0
  267. package/dist/lib/output-format.d.ts +222 -0
  268. package/dist/lib/output-format.js +259 -0
  269. package/dist/lib/output-format.js.map +1 -0
  270. package/dist/lib/packet.d.ts +521 -0
  271. package/dist/lib/packet.js +613 -0
  272. package/dist/lib/packet.js.map +1 -0
  273. package/dist/lib/rational.d.ts +251 -0
  274. package/dist/lib/rational.js +278 -0
  275. package/dist/lib/rational.js.map +1 -0
  276. package/dist/lib/software-resample-context.d.ts +552 -0
  277. package/dist/lib/software-resample-context.js +592 -0
  278. package/dist/lib/software-resample-context.js.map +1 -0
  279. package/dist/lib/software-scale-context.d.ts +344 -0
  280. package/dist/lib/software-scale-context.js +366 -0
  281. package/dist/lib/software-scale-context.js.map +1 -0
  282. package/dist/lib/stream.d.ts +383 -0
  283. package/dist/lib/stream.js +524 -0
  284. package/dist/lib/stream.js.map +1 -0
  285. package/dist/lib/sync-queue.d.ts +179 -0
  286. package/dist/lib/sync-queue.js +197 -0
  287. package/dist/lib/sync-queue.js.map +1 -0
  288. package/dist/lib/types.d.ts +34 -0
  289. package/dist/lib/types.js +2 -0
  290. package/dist/lib/types.js.map +1 -0
  291. package/dist/lib/utilities.d.ts +1198 -0
  292. package/dist/lib/utilities.js +1302 -0
  293. package/dist/lib/utilities.js.map +1 -0
  294. package/dist/utils/electron.d.ts +49 -0
  295. package/dist/utils/electron.js +63 -0
  296. package/dist/utils/electron.js.map +1 -0
  297. package/dist/utils/index.d.ts +6 -0
  298. package/dist/utils/index.js +7 -0
  299. package/dist/utils/index.js.map +1 -0
  300. package/dist/utils/libc.d.ts +11 -0
  301. package/dist/utils/libc.js +35 -0
  302. package/dist/utils/libc.js.map +1 -0
  303. package/dist/utils/variant.d.ts +26 -0
  304. package/dist/utils/variant.js +31 -0
  305. package/dist/utils/variant.js.map +1 -0
  306. package/dist/webrtc/index.d.ts +4 -0
  307. package/dist/webrtc/index.js +7 -0
  308. package/dist/webrtc/index.js.map +1 -0
  309. package/install/check.js +124 -0
  310. package/install/ffmpeg.js +66 -0
  311. package/package.json +167 -4
@@ -0,0 +1,800 @@
1
+ import type { AVPixelFormat, AVSampleFormat, FilterOptionsMap } from '../constants/index.js';
2
+ import type { HardwareContext } from './hardware.js';
3
+ /**
4
+ * Hardware filter capabilities for different platforms.
5
+ * Maps hardware types to their supported filter operations.
6
+ * Each capability indicates whether a specific filter operation is supported
7
+ * by the hardware acceleration type.
8
+ *
9
+ * Support varies significantly between hardware types:
10
+ * - CUDA: Comprehensive filter support with custom kernels
11
+ * - VAAPI: Good Linux support with Intel/AMD GPUs
12
+ * - QSV: Intel Quick Sync with basic filtering
13
+ * - VideoToolbox: macOS/iOS with CoreImage filters
14
+ * - Vulkan: Cross-platform with growing filter support
15
+ * - OpenCL: Cross-platform compute-based filtering
16
+ */
17
+ export interface FilterSupport {
18
+ scale: boolean;
19
+ overlay: boolean;
20
+ transpose: boolean;
21
+ tonemap: boolean;
22
+ deinterlace: boolean;
23
+ denoise: boolean;
24
+ flip: boolean;
25
+ blur: boolean;
26
+ sharpen: boolean;
27
+ sobel: boolean;
28
+ chromakey: boolean;
29
+ colorspace: boolean;
30
+ pad: boolean;
31
+ stack: boolean;
32
+ }
33
+ /**
34
+ * Filter preset builder for composing filter chains.
35
+ * Supports both software and hardware-accelerated filters.
36
+ * Automatically selects appropriate filter implementations based on hardware context.
37
+ * Uses fluent interface pattern for chaining multiple filters.
38
+ *
39
+ * @example
40
+ * ```typescript
41
+ * // Software filter chain
42
+ * const filter = FilterPreset.chain()
43
+ * .scale(1920, 1080)
44
+ * .filter('fps', { fps: 30 })
45
+ * .filter('fade', { type: 'in', start_time: 0, duration: 2 })
46
+ * .build();
47
+ *
48
+ * // Hardware-accelerated filter chain
49
+ * const hw = HardwareContext.auto();
50
+ * const hwFilter = FilterPreset.chain(hw)
51
+ * .scale(1920, 1080)
52
+ * .blur('gaussian', 5)
53
+ * .build();
54
+ * ```
55
+ */
56
+ export declare class FilterPreset {
57
+ private hardware?;
58
+ private filters;
59
+ private support;
60
+ private constructor();
61
+ /**
62
+ * Checks if a filter is hardware-accelerated.
63
+ *
64
+ * @param filterName - Name of the filter to check
65
+ *
66
+ * @returns True if the filter uses hardware acceleration
67
+ *
68
+ * @example
69
+ * ```typescript
70
+ * if (FilterPreset.isHardwareFilter('scale_cuda')) {
71
+ * console.log('Hardware accelerated scaling');
72
+ * }
73
+ * ```
74
+ */
75
+ static isHardwareFilter(filterName: string): boolean;
76
+ /**
77
+ * Creates a new filter chain builder.
78
+ *
79
+ * @param hardware - Optional hardware context for hardware-accelerated filters
80
+ *
81
+ * @returns A new FilterPreset instance for chaining
82
+ *
83
+ * @example
84
+ * ```typescript
85
+ * // Software filter chain
86
+ * const filter = FilterPreset.chain()
87
+ * .scale(1280, 720)
88
+ * .filter('fps', { fps: 30 })
89
+ * .build();
90
+ * ```
91
+ *
92
+ * @example
93
+ * ```typescript
94
+ * // Hardware filter chain
95
+ * const hw = HardwareContext.auto();
96
+ * const filter = FilterPreset.chain(hw)
97
+ * .scale(1280, 720)
98
+ * .deinterlace()
99
+ * .build();
100
+ * ```
101
+ */
102
+ static chain(hardware?: HardwareContext | null): FilterPreset;
103
+ /**
104
+ * Checks if an operation is available for this chain's hardware.
105
+ *
106
+ * Operations the hardware has no filter for (e.g. scaling on MediaCodec) are
107
+ * skipped when added, so check first where skipping would be wrong and fall
108
+ * back to software, e.g. by scaling in the decoder.
109
+ *
110
+ * @param operation - Operation to check
111
+ *
112
+ * @returns True if the operation is applied; always true without hardware
113
+ *
114
+ * @example
115
+ * ```typescript
116
+ * const chain = FilterPreset.chain(hw);
117
+ * if (chain.supports('scale')) {
118
+ * chain.scale(1280, 720);
119
+ * } else {
120
+ * // e.g. Decoder.create(stream, { hardware: hw, rescale: { width: 1280, height: 720 } })
121
+ * }
122
+ * ```
123
+ */
124
+ supports(operation: keyof FilterSupport): boolean;
125
+ /**
126
+ * Adds a custom filter string to the chain.
127
+ *
128
+ * @param filter - Custom filter string
129
+ *
130
+ * @returns This instance for chaining
131
+ *
132
+ * @example
133
+ * ```typescript
134
+ * chain.custom('myfilter=param1:param2')
135
+ * ```
136
+ */
137
+ custom(filter?: string): this;
138
+ /**
139
+ * Adds any FFmpeg filter to the chain with type-safe options.
140
+ *
141
+ * Provides autocomplete for every available filter name and its options
142
+ * (generated from FFmpeg's AVOption metadata). Prefer the dedicated methods
143
+ * (e.g. {@link scale}) when hardware-aware selection or automatic mapping is
144
+ * needed; use {@link custom} for raw filter strings.
145
+ *
146
+ * @param name - Filter name (autocompleted from all available filters)
147
+ *
148
+ * @param options - Filter-specific options, typed to the chosen filter
149
+ *
150
+ * @returns This instance for chaining
151
+ *
152
+ * @example
153
+ * ```typescript
154
+ * chain
155
+ * .filter('drawtext', { text: 'hello', fontsize: 24 })
156
+ * .filter('hue', { s: 0 });
157
+ * // "drawtext=text=hello:fontsize=24,hue=s=0"
158
+ * ```
159
+ */
160
+ filter<N extends keyof FilterOptionsMap>(name: N, options?: FilterOptionsMap[N]): this;
161
+ /**
162
+ * Builds the final filter string.
163
+ *
164
+ * @param separator - Separator between filters (default: ',')
165
+ *
166
+ * @returns Combined filter string
167
+ *
168
+ * @example
169
+ * ```typescript
170
+ * const filterString = chain.build() // "scale=1920:1080,fps=30"
171
+ * ```
172
+ */
173
+ build(separator?: string): string;
174
+ /**
175
+ * Returns the filters as an array.
176
+ *
177
+ * @returns Array of filter strings
178
+ *
179
+ * @example
180
+ * ```typescript
181
+ * const filters = chain.toArray() // ["scale=1920:1080", "fps=30"]
182
+ * ```
183
+ */
184
+ toArray(): string[];
185
+ /**
186
+ * Adds a scale filter to the chain.
187
+ * Automatically selects hardware-specific scaler if hardware context is set.
188
+ *
189
+ * @param width - Target width in pixels
190
+ *
191
+ * @param height - Target height in pixels
192
+ *
193
+ * @param options - Additional scaling options (e.g., flags for algorithm)
194
+ *
195
+ * @returns This instance for chaining (unchanged if the hardware has no scaler, see {@link supports})
196
+ *
197
+ * @example
198
+ * ```typescript
199
+ * chain.scale(1920, 1080) // Scale to Full HD
200
+ * chain.scale(640, 480, { flags: 'lanczos' }) // With specific algorithm
201
+ * ```
202
+ *
203
+ * @example
204
+ * ```typescript
205
+ * // Hardware crop + scale (VAAPI, CUDA, QSV, VideoToolbox)
206
+ * chain.crop(100, 100, 50, 50) // Sets AVFrame crop fields
207
+ * .scale(1920, 1080) // Hardware scaler reads crop fields
208
+ * ```
209
+ *
210
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#scale | FFmpeg scale filter}
211
+ */
212
+ scale(width: number, height: number, options?: Record<string, any>): FilterPreset;
213
+ /**
214
+ * Adds a GPU format conversion filter without scaling.
215
+ * Only available for hardware contexts. Uses hardware-specific scale filter with format parameter.
216
+ * Skipped without hardware; on hardware without a scaler (see {@link supports}) the
217
+ * graph fails to build.
218
+ *
219
+ * @param format - Target pixel format (e.g., 'nv12', 'p010')
220
+ *
221
+ * @returns This instance for chaining
222
+ *
223
+ * @example
224
+ * ```typescript
225
+ * // Convert to NV12 on GPU without scaling
226
+ * chain.scaleFormat('nv12')
227
+ * // Generates: scale_vt=format=nv12 (VideoToolbox)
228
+ * // or: scale_cuda=format=nv12 (CUDA)
229
+ * // or: scale_opencl=format=nv12 (OpenCL)
230
+ * ```
231
+ *
232
+ * @example
233
+ * ```typescript
234
+ * // Convert P010 → NV12 on GPU
235
+ * const hw = await HardwareContext.auto();
236
+ * const filter = FilterPreset.chain(hw)
237
+ * .scaleFormat('nv12')
238
+ * .build();
239
+ * ```
240
+ *
241
+ * @example
242
+ * ```typescript
243
+ * // Scale then convert format (two separate GPU operations)
244
+ * chain.scale(1920, 1080)
245
+ * .scaleFormat('p010')
246
+ * // Generates: scale_vt=1920:1080,scale_vt=format=p010
247
+ * ```
248
+ */
249
+ scaleFormat(format: string | AVPixelFormat): FilterPreset;
250
+ /**
251
+ * Adds a crop filter to the chain.
252
+ *
253
+ * @param width - Width of the cropped area
254
+ *
255
+ * @param height - Height of the cropped area
256
+ *
257
+ * @param x - X coordinate of top-left corner (default: 0)
258
+ *
259
+ * @param y - Y coordinate of top-left corner (default: 0)
260
+ *
261
+ * @returns This instance for chaining
262
+ *
263
+ * @example
264
+ * ```typescript
265
+ * chain.crop(640, 480, 100, 100) // Crop 640x480 area starting at (100,100)
266
+ * chain.crop(1280, 720) // Crop from top-left corner
267
+ * ```
268
+ *
269
+ * @example
270
+ * ```typescript
271
+ * // Hardware crop + scale
272
+ * chain.crop(100, 100, 50, 50)
273
+ * .scale(1920, 1080)
274
+ * ```
275
+ *
276
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#crop | FFmpeg crop filter}
277
+ */
278
+ crop(width: number, height: number, x?: number, y?: number): FilterPreset;
279
+ /**
280
+ * Adds a blur filter to the chain (hardware-specific).
281
+ * Only available for hardware presets that support blur
282
+ *
283
+ * @param type - Blur type (default: 'avg')
284
+ *
285
+ * @param radius - Blur radius (optional)
286
+ *
287
+ * @returns This instance for chaining
288
+ *
289
+ * @example
290
+ * ```typescript
291
+ * const chain = FilterPresets.chain()
292
+ * .blur('gaussian', 5)
293
+ * .build();
294
+ * ```
295
+ *
296
+ * @example
297
+ * ```typescript
298
+ * const chain = FilterPresets.chain()
299
+ * .blur('box')
300
+ * .build();
301
+ * ```
302
+ */
303
+ blur(type?: 'avg' | 'gaussian' | 'box', radius?: number): FilterPreset;
304
+ /**
305
+ * Adds a sharpen filter to the chain (hardware-specific).
306
+ * Only available for hardware presets that support sharpening
307
+ *
308
+ * @param amount - Sharpen amount (optional)
309
+ *
310
+ * @returns This instance for chaining
311
+ *
312
+ * @example
313
+ * ```typescript
314
+ * const chain = FilterPresets.chain()
315
+ * .sharpen(1.5)
316
+ * .build();
317
+ * ```
318
+ *
319
+ * @example
320
+ * ```typescript
321
+ * const chain = FilterPresets.chain()
322
+ * .sharpen()
323
+ * .build();
324
+ * ```
325
+ */
326
+ sharpen(amount?: number): FilterPreset;
327
+ /**
328
+ * Adds a Sobel edge detection filter.
329
+ *
330
+ * Applies Sobel operator to detect edges in images.
331
+ * Supports hardware acceleration with OpenCL.
332
+ * Useful for computer vision and artistic effects.
333
+ *
334
+ * @param planes - Planes to process (1-15, default: 15 for all)
335
+ *
336
+ * @param scale - Scale factor for result (default: 1.0)
337
+ *
338
+ * @returns This instance for chaining
339
+ *
340
+ * @example
341
+ * ```typescript
342
+ * const chain = FilterPresets.chain()
343
+ * .sobel()
344
+ * .build();
345
+ * ```
346
+ *
347
+ * @example
348
+ * ```typescript
349
+ * const chain = FilterPresets.chain()
350
+ * .sobel(15, 2.0) // All planes, 2x scale
351
+ * .build();
352
+ * ```
353
+ */
354
+ sobel(planes?: number, scale?: number): FilterPreset;
355
+ /**
356
+ * Adds a format filter to convert pixel format.
357
+ *
358
+ * @param pixelFormat - Target pixel format(s) - AVPixelFormat enum, or array
359
+ *
360
+ * @returns This instance for chaining
361
+ *
362
+ * @example
363
+ * ```typescript
364
+ * // Single format
365
+ * chain.format(AV_PIX_FMT_YUV420P);
366
+ *
367
+ * // Multiple formats (tries formats in order)
368
+ * chain.format([AV_PIX_FMT_YUV420P, AV_PIX_FMT_RGB24]);
369
+ * ```
370
+ *
371
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#format | FFmpeg format filter}
372
+ */
373
+ format(pixelFormat: AVPixelFormat | AVPixelFormat[]): FilterPreset;
374
+ /**
375
+ * Adds a flip filter to the chain (hardware-specific).
376
+ * Falls back to hflip/vflip if hardware flip not available
377
+ *
378
+ * @param direction - Flip direction ('h' or 'v')
379
+ *
380
+ * @returns This instance for chaining
381
+ *
382
+ * @example
383
+ * ```typescript
384
+ * const chain = FilterPresets.chain()
385
+ * .flip('h')
386
+ * .build();
387
+ * ```
388
+ *
389
+ * @example
390
+ * ```typescript
391
+ * const chain = FilterPresets.chain()
392
+ * .flip('v')
393
+ * .build();
394
+ * ```
395
+ */
396
+ flip(direction: 'h' | 'v'): FilterPreset;
397
+ /**
398
+ * Adds a stack filter to the chain (hardware-specific).
399
+ * Only available for hardware presets that support stacking
400
+ *
401
+ * @param type - Stack type ('h' for horizontal, 'v' for vertical, 'x' for grid)
402
+ *
403
+ * @param inputs - Number of inputs (default: 2)
404
+ *
405
+ * @returns This instance for chaining
406
+ *
407
+ * @example
408
+ * ```typescript
409
+ * const chain = FilterPresets.chain()
410
+ * .stack('h', 2)
411
+ * .build();
412
+ * ```
413
+ *
414
+ * @example
415
+ * ```typescript
416
+ * const chain = FilterPresets.chain()
417
+ * .stack('x', 4)
418
+ * .build();
419
+ * ```
420
+ */
421
+ stack(type: 'h' | 'v' | 'x', inputs?: number): FilterPreset;
422
+ /**
423
+ * Creates a tonemap filter.
424
+ * Used for HDR to SDR conversion with hardware acceleration.
425
+ *
426
+ * @param alg - Tonemapping algorithm (e.g., 'hable', 'reinhard', 'mobius', etc.)
427
+ *
428
+ * @param options - Tonemapping options
429
+ *
430
+ * @returns Hardware tonemap filter string or null if not supported
431
+ *
432
+ * @example
433
+ * ```typescript
434
+ * const filter = hwPresets.tonemap();
435
+ * ```
436
+ *
437
+ * @example
438
+ * ```typescript
439
+ * const filter = hwPresets.tonemap({ tonemap: 'hable', desat: '0' });
440
+ * ```
441
+ */
442
+ tonemap(alg: string, options: Record<string, string | number>): FilterPreset;
443
+ /**
444
+ * Creates an overlay filter string to composite two video streams.
445
+ *
446
+ * @param x - X position for overlay (default: 0)
447
+ *
448
+ * @param y - Y position for overlay (default: 0)
449
+ *
450
+ * @param options - Additional overlay options
451
+ *
452
+ * @returns Filter string or null if not supported
453
+ *
454
+ * @example
455
+ * ```typescript
456
+ * // Basic overlay at position
457
+ * presets.overlay(100, 50);
458
+ *
459
+ * // With additional options
460
+ * presets.overlay(0, 0, { format: 'yuv420' });
461
+ * ```
462
+ *
463
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#overlay | FFmpeg overlay filter}
464
+ */
465
+ overlay(x?: number, y?: number, options?: Record<string, string>): FilterPreset;
466
+ /**
467
+ * Creates an audio format filter string.
468
+ *
469
+ * @param sampleFormat - Target sample format (e.g., 's16', 'fltp')
470
+ *
471
+ * @param sampleRate - Target sample rate in Hz (optional)
472
+ *
473
+ * @param channelLayout - Target channel layout (optional)
474
+ *
475
+ * @returns Filter string or null if not supported
476
+ *
477
+ * @example
478
+ * ```typescript
479
+ * // Change sample format only
480
+ * presets.aformat('s16');
481
+ *
482
+ * // Change format and sample rate
483
+ * presets.aformat('fltp', 48000);
484
+ *
485
+ * // Full conversion
486
+ * presets.aformat('s16', 44100, 'stereo');
487
+ * ```
488
+ *
489
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#aformat | FFmpeg aformat filter}
490
+ */
491
+ aformat(sampleFormat: AVSampleFormat | AVSampleFormat[], sampleRate?: number, channelLayout?: string): FilterPreset;
492
+ /**
493
+ * Adds a pad filter to add padding to video.
494
+ * Essential for aspect ratio adjustments and letterboxing.
495
+ *
496
+ * @param width - Output width (can use expressions like 'iw+100')
497
+ *
498
+ * @param height - Output height (can use expressions like 'ih+100')
499
+ *
500
+ * @param x - X position of input video (default: '(ow-iw)/2' for center)
501
+ *
502
+ * @param y - Y position of input video (default: '(oh-ih)/2' for center)
503
+ *
504
+ * @param color - Padding color (default: 'black')
505
+ *
506
+ * @returns This instance for chaining
507
+ *
508
+ * @example
509
+ * ```typescript
510
+ * // Add black bars for 16:9 aspect ratio
511
+ * chain.pad('iw', 'iw*9/16');
512
+ *
513
+ * // Add 50px padding on all sides
514
+ * chain.pad('iw+100', 'ih+100');
515
+ * ```
516
+ *
517
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#pad | FFmpeg pad filter}
518
+ */
519
+ pad(width: string | number, height: string | number, x?: string, y?: string, color?: string): FilterPreset;
520
+ /**
521
+ * Creates a transpose filter string for rotation/flipping.
522
+ * More efficient than rotate for 90-degree rotations.
523
+ *
524
+ * @param mode - Transpose mode (0-3, or named constants)
525
+ *
526
+ * @returns Filter string or null if not supported
527
+ *
528
+ * @example
529
+ * ```typescript
530
+ * presets.transpose(1) // Rotate 90 degrees clockwise
531
+ * presets.transpose('cclock') // Rotate 90 degrees counter-clockwise
532
+ * ```
533
+ *
534
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#transpose | FFmpeg transpose filter}
535
+ */
536
+ transpose(mode: number | 'clock' | 'cclock' | 'clock_flip' | 'cclock_flip'): FilterPreset;
537
+ /**
538
+ * Creates a deinterlace filter string.
539
+ * Essential for processing interlaced content.
540
+ *
541
+ * @param mode - Deinterlace mode (default: 'yadif')
542
+ *
543
+ * @param options - Additional options for the filter
544
+ *
545
+ * @returns Filter string or null if not supported
546
+ *
547
+ * @example
548
+ * ```typescript
549
+ * presets.deinterlace('yadif') // Standard deinterlacing
550
+ * presets.deinterlace('bwdif') // Bob Weaver deinterlacing
551
+ * ```
552
+ *
553
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#yadif | FFmpeg yadif filter}
554
+ */
555
+ deinterlace(mode?: 'yadif' | 'bwdif' | 'w3fdif', options?: Record<string, any>): FilterPreset;
556
+ /**
557
+ * Adds a whisper filter for audio transcription using whisper.cpp.
558
+ * Transcribes audio and adds metadata to frames (lavfi.whisper.text, lavfi.whisper.duration).
559
+ *
560
+ * @param options - Whisper transcription options
561
+ *
562
+ * @param options.model - Path to whisper.cpp model file
563
+ *
564
+ * @param options.language - Language for transcription (default: 'auto')
565
+ *
566
+ * @param options.queue - Audio queue size in seconds (default: 3)
567
+ *
568
+ * @param options.useGpu - Use GPU for processing (default: true)
569
+ *
570
+ * @param options.gpuDevice - GPU device to use (default: 0)
571
+ *
572
+ * @param options.destination - Output destination for transcripts
573
+ *
574
+ * @param options.format - Output format: text|srt|json (default: 'text')
575
+ *
576
+ * @param options.vadModel - Path to VAD model file (optional)
577
+ *
578
+ * @param options.vadThreshold - VAD threshold 0.0-1.0 (default: 0.5)
579
+ *
580
+ * @param options.vadMinSpeechDuration - Minimum speech duration for VAD in seconds (default: 0.1)
581
+ *
582
+ * @param options.vadMinSilenceDuration - Minimum silence duration for VAD in seconds (default: 0.5)
583
+ *
584
+ * @returns This instance for chaining
585
+ *
586
+ * @example
587
+ * ```typescript
588
+ * // Basic transcription
589
+ * chain.whisper({
590
+ * model: '/path/to/ggml-base.bin'
591
+ * });
592
+ *
593
+ * // With language and output
594
+ * chain.whisper({
595
+ * model: '/path/to/ggml-base.bin',
596
+ * language: 'en',
597
+ * destination: 'output.srt',
598
+ * format: 'srt'
599
+ * });
600
+ *
601
+ * // With VAD model
602
+ * chain.whisper({
603
+ * model: '/path/to/ggml-base.bin',
604
+ * vadModel: '/path/to/ggml-silero-v5.1.2.bin',
605
+ * vadThreshold: 0.5
606
+ * });
607
+ * ```
608
+ *
609
+ * @see {@link https://ffmpeg.org/ffmpeg-filters.html#whisper | FFmpeg whisper filter}
610
+ */
611
+ whisper(options: {
612
+ model: string;
613
+ language?: string;
614
+ queue?: number;
615
+ useGpu?: boolean;
616
+ gpuDevice?: number;
617
+ destination?: string;
618
+ format?: 'text' | 'srt' | 'json';
619
+ vadModel?: string;
620
+ vadThreshold?: number;
621
+ vadMinSpeechDuration?: number;
622
+ vadMinSilenceDuration?: number;
623
+ }): FilterPreset;
624
+ /**
625
+ * Adds a hwupload filter to upload frames to hardware.
626
+ * Only applied if hardware acceleration is configured.
627
+ *
628
+ * @returns This instance for chaining
629
+ *
630
+ * @example
631
+ * ```typescript
632
+ * const chain = FilterPresets.chain()
633
+ * .hwupload()
634
+ * .scale(1920, 1080)
635
+ * .build();
636
+ * ```
637
+ */
638
+ hwupload(): FilterPreset;
639
+ /**
640
+ * Adds a hwdownload filter to download frames from hardware.
641
+ * Only applied if hardware acceleration is configured.
642
+ *
643
+ * @returns This instance for chaining
644
+ *
645
+ * @example
646
+ * ```typescript
647
+ * const chain = FilterPresets.chain()
648
+ * .scale(1920, 1080)
649
+ * .hwdownload()
650
+ * .build();
651
+ * ```
652
+ */
653
+ hwdownload(): FilterPreset;
654
+ /**
655
+ * Adds a filter to the chain.
656
+ *
657
+ * @param filter - Filter string to add (ignored if null/undefined)
658
+ *
659
+ * @param unshift - If true, adds to the start instead of the end (default: false)
660
+ *
661
+ * @returns This instance for chaining
662
+ *
663
+ * @example
664
+ * ```typescript
665
+ * chain.add('scale=1920:1080')
666
+ * ```
667
+ *
668
+ * @internal
669
+ */
670
+ private add;
671
+ /**
672
+ * Determines filter support for the hardware type.
673
+ *
674
+ * @returns Hardware filter support configuration
675
+ *
676
+ * @internal
677
+ */
678
+ private getSupport;
679
+ }
680
+ /**
681
+ * Label specification for a filter-complex chain (input or output pads).
682
+ *
683
+ * A single label like `'0:v'` or `'out'`, or several labels. Labels are wrapped
684
+ * in `[...]` automatically when the graph string is built.
685
+ */
686
+ export type FilterComplexLabels = string | string[];
687
+ /**
688
+ * Type-safe builder for `filter_complex` graph strings.
689
+ *
690
+ * Composes one or more labeled filter chains - each with optional input/output
691
+ * pad labels and a sequence of type-safe {@link FilterPreset.filter} calls - and
692
+ * renders them to the description string consumed by
693
+ * {@link FilterComplexAPI.create}. Provides the same autocomplete and enum
694
+ * validation as {@link FilterPreset}, but for multi-input/output graphs.
695
+ *
696
+ * @example
697
+ * ```typescript
698
+ * const graph = FilterComplexGraph.create()
699
+ * .chain({ inputs: ['0:v', '1:v'], outputs: 'tmp' }, (c) => c.filter('overlay', { x: 100, y: 50 }))
700
+ * .chain({ inputs: 'tmp', outputs: 'out' }, (c) => c.filter('hue', { s: 0 }))
701
+ * .build();
702
+ * // "[0:v][1:v]overlay=x=100:y=50[tmp];[tmp]hue=s=0[out]"
703
+ *
704
+ * using complex = FilterComplexAPI.create(graph, {
705
+ * inputs: [{ label: '0:v' }, { label: '1:v' }],
706
+ * outputs: [{ label: 'out' }],
707
+ * });
708
+ * ```
709
+ */
710
+ export declare class FilterComplexGraph {
711
+ private chains;
712
+ private hardware?;
713
+ /**
714
+ * Create a new filter-complex graph builder.
715
+ *
716
+ * @param hardware - Optional hardware context. Each {@link chain} then builds
717
+ * with hardware-aware filter selection (e.g. `scale` → `scale_vaapi`,
718
+ * `overlay` → `overlay_vaapi`), like {@link FilterPreset.chain}.
719
+ *
720
+ * @returns A new builder instance
721
+ *
722
+ * @example
723
+ * ```typescript
724
+ * const graph = FilterComplexGraph.create();
725
+ * ```
726
+ *
727
+ * @example
728
+ * ```typescript
729
+ * // Hardware-aware graph (scale_vaapi / overlay_vaapi etc.)
730
+ * const hw = HardwareContext.auto();
731
+ * const graph = FilterComplexGraph.create(hw)
732
+ * .chain({ inputs: '1:v', outputs: 'pip' }, (c) => c.scale(320, 240))
733
+ * .chain({ inputs: ['0:v', 'pip'], outputs: 'out' }, (c) => c.overlay(10, 10));
734
+ * ```
735
+ */
736
+ static create(hardware?: HardwareContext | null): FilterComplexGraph;
737
+ /**
738
+ * Add a labeled filter chain to the graph.
739
+ *
740
+ * The chain's filters are built via a callback that receives a
741
+ * {@link FilterPreset} for type-safe `filter()` composition.
742
+ *
743
+ * @param labels - Optional input and output pad labels
744
+ *
745
+ * @param labels.inputs - Input pad label(s) prepended to the chain
746
+ *
747
+ * @param labels.outputs - Output pad label(s) appended to the chain
748
+ *
749
+ * @param build - Callback composing the chain's filters
750
+ *
751
+ * @returns This instance for chaining
752
+ *
753
+ * @example
754
+ * ```typescript
755
+ * graph.chain({ inputs: ['0:v', '1:v'], outputs: 'out' }, (c) =>
756
+ * c.filter('overlay', { x: 0, y: 0 }).filter('hue', { s: 0 }),
757
+ * );
758
+ * ```
759
+ */
760
+ chain(labels: {
761
+ inputs?: FilterComplexLabels;
762
+ outputs?: FilterComplexLabels;
763
+ }, build: (chain: FilterPreset) => FilterPreset): this;
764
+ /**
765
+ * Add a raw chain segment to the graph.
766
+ *
767
+ * Escape hatch for graph syntax not expressible through {@link chain}.
768
+ *
769
+ * @param segment - Raw chain string (e.g. `'[0:v]split[a][b]'`)
770
+ *
771
+ * @returns This instance for chaining
772
+ *
773
+ * @example
774
+ * ```typescript
775
+ * graph.custom('[0:v]split[a][b]');
776
+ * ```
777
+ */
778
+ custom(segment: string): this;
779
+ /**
780
+ * Build the final filter-complex description string.
781
+ *
782
+ * @returns The graph description (chains joined by `;`)
783
+ *
784
+ * @example
785
+ * ```typescript
786
+ * const description = graph.build();
787
+ * ```
788
+ */
789
+ build(): string;
790
+ /**
791
+ * Wrap pad labels in `[...]`.
792
+ *
793
+ * @param labels - A single label, an array of labels, or undefined
794
+ *
795
+ * @returns The bracketed label string (empty when no labels)
796
+ *
797
+ * @internal
798
+ */
799
+ private renderLabels;
800
+ }