node-av-lgpl 0.0.0 → 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 +711 -0
  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 +165 -3
@@ -0,0 +1,1339 @@
1
+ import { FilterGraph } from '../lib/filter-graph.js';
2
+ import { Frame } from '../lib/frame.js';
3
+ import { Scheduler } from './utilities/scheduler.js';
4
+ import type { AVColorRange, AVColorSpace, AVFilterCmdFlag, AVPixelFormat, AVSampleFormat, EOFSignal } from '../constants/index.js';
5
+ import type { FilterContext } from '../lib/filter-context.js';
6
+ import type { ChannelLayout, IDimension, IRational } from '../lib/types.js';
7
+ import type { Encoder } from './encoder.js';
8
+ import type { HardwareContext } from './hardware.js';
9
+ import type { ContextOptions } from './utilities/context-options.js';
10
+ /**
11
+ * Options for creating a filter instance.
12
+ */
13
+ export interface FilterOptions {
14
+ /**
15
+ * Number of threads for parallel processing.
16
+ *
17
+ * Controls the number of threads used for filter processing.
18
+ * Set to 0 to auto-detect based on CPU cores.
19
+ *
20
+ * @default 0 (auto-detect)
21
+ *
22
+ * @deprecated Use the {@link FilterOptions.graph} option instead, e.g. `graph: { nbThreads: 4 }`.
23
+ */
24
+ threads?: number;
25
+ /**
26
+ * Software scaler options for video filters.
27
+ *
28
+ * Options passed to libswscale when scaling video within filters.
29
+ * Maps to AVFilterGraph->scale_sws_opts.
30
+ *
31
+ * @deprecated Use the {@link FilterOptions.graph} option instead, e.g. `graph: { scaleSwsOpts: 'flags=bicubic' }`.
32
+ */
33
+ scaleSwsOpts?: string;
34
+ /**
35
+ * Audio resampler options for audio filters.
36
+ *
37
+ * Options passed to libswresample when resampling audio within filters.
38
+ * Maps to AVFilterGraph->aresample_swr_opts.
39
+ *
40
+ * @deprecated Use the {@link FilterOptions.graph} option instead, e.g. `graph: { aresampleSwrOpts: 'cutoff=0.8' }`.
41
+ */
42
+ audioResampleOpts?: string;
43
+ /**
44
+ * Hardware acceleration context.
45
+ *
46
+ * Pass a HardwareContext instance to enable hardware-accelerated filtering.
47
+ * Set to null to disable hardware acceleration.
48
+ */
49
+ hardware?: HardwareContext | null;
50
+ /**
51
+ * Number of extra hardware frames to allocate.
52
+ *
53
+ * Useful for hardware filters requiring additional frame buffering.
54
+ * Some hardware filters need extra frames for look-ahead or reference.
55
+ */
56
+ extraHWFrames?: number;
57
+ /**
58
+ * Force constant framerate mode (CFR).
59
+ *
60
+ * When true, timeBase is automatically set to 1/framerate (like FFmpeg CLI -fps_mode cfr).
61
+ * When false (default), timeBase is taken from frame.timeBase (VFR mode).
62
+ *
63
+ * Maps to FFmpeg's IFILTER_FLAG_CFR.
64
+ * Requires `framerate` to be set when enabled.
65
+ *
66
+ * @default false (VFR mode)
67
+ */
68
+ cfr?: boolean;
69
+ /**
70
+ * Framerate for CFR mode or as hint for buffer source.
71
+ *
72
+ * Required when `cfr=true` to calculate timeBase = 1/framerate.
73
+ * Also passed to AVBufferSrcParameters->frame_rate.
74
+ *
75
+ * Maps to FFmpeg's InputFilterOptions->framerate.
76
+ */
77
+ framerate?: IRational;
78
+ /**
79
+ * Drop frames on format/parameter changes instead of reinitializing filtergraph.
80
+ *
81
+ * When true, frames with changed properties (resolution, format, etc.) are dropped
82
+ * instead of triggering filtergraph reinitialization. Useful for live streams
83
+ * with unstable properties.
84
+ *
85
+ * Maps to FFmpeg's IFILTER_FLAG_DROPCHANGED.
86
+ *
87
+ * @default false
88
+ */
89
+ dropOnChange?: boolean;
90
+ /**
91
+ * Allow filtergraph reinitialization when frame parameters change.
92
+ *
93
+ * When false, parameter changes (resolution, format) will cause errors
94
+ * instead of reinitializing the filtergraph.
95
+ * When true (default), filtergraph is reinitialized on parameter changes.
96
+ *
97
+ * Maps to FFmpeg's IFILTER_FLAG_REINIT.
98
+ *
99
+ * @default true
100
+ */
101
+ allowReinit?: boolean;
102
+ /**
103
+ * Fields to set on the underlying filter graph.
104
+ *
105
+ * A typed, declarative bag for any writable {@link FilterGraph} field that has
106
+ * no dedicated option — e.g. `nbThreads`, `scaleSwsOpts`, `aresampleSwrOpts`.
107
+ * Applied after the buffer source/sink and filter description are set up and
108
+ * immediately before `avfilter_graph_config` (and again on every filtergraph
109
+ * reinitialization). The allowed keys are derived from the class, so every
110
+ * writable field is available and correctly typed.
111
+ *
112
+ * @example
113
+ * ```typescript
114
+ * FilterAPI.create('scale=1280:720', {
115
+ * graph: {
116
+ * nbThreads: 4,
117
+ * },
118
+ * });
119
+ * ```
120
+ */
121
+ graph?: ContextOptions<FilterGraph>;
122
+ /**
123
+ * Configure the underlying filter graph just before it is configured.
124
+ *
125
+ * The imperative escape hatch for cases the {@link FilterOptions.graph} bag
126
+ * cannot express: methods or conditional logic. Called with the
127
+ * {@link FilterGraph} after `graph` is applied and immediately before
128
+ * `avfilter_graph_config`. Runs again on every filtergraph reinitialization.
129
+ *
130
+ * @example
131
+ * ```typescript
132
+ * FilterAPI.create('scale=1280:720', {
133
+ * configure: (graph) => {
134
+ * graph.nbThreads = 4;
135
+ * },
136
+ * });
137
+ * ```
138
+ */
139
+ configure?: (graph: FilterGraph) => void;
140
+ /**
141
+ * AbortSignal for cancellation.
142
+ *
143
+ * When aborted, async generators stop yielding and async methods throw AbortError.
144
+ */
145
+ signal?: AbortSignal;
146
+ }
147
+ /**
148
+ * High-level filter API for audio and video processing.
149
+ *
150
+ * Provides simplified interface for applying FFmpeg filters to frames.
151
+ * Handles filter graph construction, frame buffering, and command control.
152
+ * Supports both software and hardware-accelerated filtering operations.
153
+ * Essential component for effects, transformations, and format conversions.
154
+ *
155
+ * @example
156
+ * ```typescript
157
+ * import { FilterAPI } from 'node-av/api';
158
+ *
159
+ * // Create video filter - initializes on first frame
160
+ * const filter = FilterAPI.create('scale=1280:720', {
161
+ * timeBase: video.timeBase,
162
+ * });
163
+ *
164
+ * // Process frame - first frame configures filter graph
165
+ * const output = await filter.process(inputFrame);
166
+ * if (output) {
167
+ * console.log(`Filtered frame: ${output.width}x${output.height}`);
168
+ * output.free();
169
+ * }
170
+ * ```
171
+ *
172
+ * @example
173
+ * ```typescript
174
+ * // Hardware-accelerated filtering - hw context detected from frame
175
+ * const filter = FilterAPI.create('hwupload,scale_cuda=1920:1080,hwdownload', {
176
+ * timeBase: video.timeBase,
177
+ * });
178
+ * // Hardware frames context will be automatically detected from first frame
179
+ * ```
180
+ *
181
+ * @see {@link FilterGraph} For low-level filter graph API
182
+ * @see {@link Frame} For frame operations
183
+ */
184
+ export declare class FilterAPI implements Disposable {
185
+ private graph;
186
+ private description;
187
+ private options;
188
+ private buffersrcCtx;
189
+ private buffersinkCtx;
190
+ private frame;
191
+ private initializePromise;
192
+ private initialized;
193
+ private isClosed;
194
+ private calculatedTimeBase;
195
+ private lastFrameProps;
196
+ private inputQueue;
197
+ private outputQueue;
198
+ private workerPromise;
199
+ private nextComponent;
200
+ private signal?;
201
+ private pipeToPromise;
202
+ /**
203
+ * @param graph - Filter graph instance
204
+ *
205
+ * @param description - Filter description string, or a function building it from a frame
206
+ *
207
+ * @param options - Filter options
208
+ *
209
+ * @internal
210
+ */
211
+ private constructor();
212
+ /**
213
+ * Create a filter with specified description and configuration.
214
+ *
215
+ * Direct mapping to avfilter_graph_parse_ptr() and avfilter_graph_config().
216
+ *
217
+ * @param description - Filter graph description, or a function that builds it from the
218
+ * first frame. The function runs again whenever the graph is rebuilt for a frame with
219
+ * other properties, so the graph can follow what the frames turn out to be, e.g.
220
+ * hardware frames or software frames after a decoder fell back. When its graph fails to
221
+ * configure, the function is asked once more with the error and can return another one,
222
+ * e.g. without a device filter the driver refused.
223
+ *
224
+ * @param options - Filter options
225
+ *
226
+ * @returns Configured filter instance
227
+ *
228
+ * @throws {Error} If cfr=true but framerate is not set
229
+ *
230
+ * @example
231
+ * ```typescript
232
+ * // Simple video filter (VFR mode, auto timeBase)
233
+ * const filter = FilterAPI.create('scale=640:480');
234
+ * ```
235
+ *
236
+ * @example
237
+ * ```typescript
238
+ * // CFR mode with constant framerate
239
+ * const filter = FilterAPI.create('scale=1920:1080', {
240
+ * cfr: true,
241
+ * framerate: { num: 25, den: 1 }
242
+ * });
243
+ * ```
244
+ *
245
+ * @example
246
+ * ```typescript
247
+ * // Audio filter with resampling
248
+ * const filter = FilterAPI.create('aformat=sample_fmts=s16:sample_rates=44100', {
249
+ * audioResampleOpts: 'async=1'
250
+ * });
251
+ * ```
252
+ *
253
+ * @example
254
+ * ```typescript
255
+ * // Graph chosen by the frames: download hardware frames, pass software ones
256
+ * const filter = FilterAPI.create((frame) => (frame.isHwFrame() ? 'hwdownload,format=nv12' : 'null'));
257
+ * ```
258
+ *
259
+ * @example
260
+ * ```typescript
261
+ * // Scale on the device, in software if the device filter fails
262
+ * const filter = FilterAPI.create((frame, failure) => (failure ? 'hwdownload,format=nv12,scale=640:-2' : 'scale_vaapi=640:-2'), { hardware });
263
+ * ```
264
+ *
265
+ * @see {@link process} For frame processing
266
+ * @see {@link FilterOptions} For configuration options
267
+ */
268
+ static create(description: string | ((frame: Frame, failure?: Error) => string), options?: FilterOptions): FilterAPI;
269
+ /**
270
+ * Check if filter is open.
271
+ *
272
+ * @example
273
+ * ```typescript
274
+ * if (filter.isFilterOpen) {
275
+ * const output = await filter.process(frame);
276
+ * }
277
+ * ```
278
+ */
279
+ get isFilterOpen(): boolean;
280
+ /**
281
+ * Check if filter has been initialized.
282
+ *
283
+ * Returns true after first frame has been processed and filter graph configured.
284
+ * Useful for checking if filter has received frame properties.
285
+ *
286
+ * @returns true if filter graph has been built from first frame
287
+ *
288
+ * @example
289
+ * ```typescript
290
+ * if (!filter.isFilterInitialized) {
291
+ * console.log('Filter will initialize on first frame');
292
+ * }
293
+ * ```
294
+ */
295
+ get isFilterInitialized(): boolean;
296
+ /**
297
+ * Get buffersink filter context.
298
+ *
299
+ * Provides access to the buffersink filter context for advanced operations.
300
+ * Returns null if filter is not initialized.
301
+ *
302
+ * @returns Buffersink context or null
303
+ *
304
+ * @example
305
+ * ```typescript
306
+ * const sink = filter.buffersink;
307
+ * if (sink) {
308
+ * const fr = sink.buffersinkGetFrameRate();
309
+ * console.log(`Output frame rate: ${fr.num}/${fr.den}`);
310
+ * }
311
+ * ```
312
+ */
313
+ get buffersink(): FilterContext | null;
314
+ /**
315
+ * Output frame rate from filter graph.
316
+ *
317
+ * Returns the frame rate determined by the filter graph output.
318
+ * Returns null if filter is not initialized or frame rate is not set.
319
+ *
320
+ * Direct mapping to av_buffersink_get_frame_rate().
321
+ *
322
+ * @returns Frame rate or null if not available
323
+ *
324
+ * @example
325
+ * ```typescript
326
+ * const frameRate = filter.frameRate;
327
+ * if (frameRate) {
328
+ * console.log(`Filter output: ${frameRate.num}/${frameRate.den} fps`);
329
+ * }
330
+ * ```
331
+ *
332
+ * @see {@link timeBase} For output timebase
333
+ */
334
+ get frameRate(): IRational | null;
335
+ /**
336
+ * Output time base from filter graph.
337
+ *
338
+ * Returns the time base of the buffersink output.
339
+ * Matches FFmpeg CLI's av_buffersink_get_time_base() behavior.
340
+ *
341
+ * Direct mapping to av_buffersink_get_time_base().
342
+ *
343
+ * @returns Time base or null if not initialized
344
+ *
345
+ * @example
346
+ * ```typescript
347
+ * const timeBase = filter.timeBase;
348
+ * if (timeBase) {
349
+ * console.log(`Filter timebase: ${timeBase.num}/${timeBase.den}`);
350
+ * }
351
+ * ```
352
+ *
353
+ * @see {@link frameRate} For output frame rate
354
+ */
355
+ get timeBase(): IRational | null;
356
+ /**
357
+ * Output format from filter graph.
358
+ *
359
+ * Returns the pixel format (video) or sample format (audio) of the buffersink output.
360
+ * Matches FFmpeg CLI's av_buffersink_get_format() behavior.
361
+ *
362
+ * Direct mapping to av_buffersink_get_format().
363
+ *
364
+ * @returns Pixel format or sample format, or null if not initialized
365
+ *
366
+ * @example
367
+ * ```typescript
368
+ * const format = filter.format;
369
+ * if (format !== null) {
370
+ * console.log(`Filter output format: ${format}`);
371
+ * }
372
+ * ```
373
+ */
374
+ get format(): AVPixelFormat | AVSampleFormat | null;
375
+ /**
376
+ * Output dimensions from filter graph (video only).
377
+ *
378
+ * Returns the width and height of the buffersink output.
379
+ * Matches FFmpeg CLI's av_buffersink_get_w() and av_buffersink_get_h() behavior.
380
+ * Only meaningful for video filters.
381
+ *
382
+ * Direct mapping to av_buffersink_get_w() and av_buffersink_get_h().
383
+ *
384
+ * @returns Dimensions object or null if not initialized
385
+ *
386
+ * @example
387
+ * ```typescript
388
+ * const dims = filter.dimensions;
389
+ * if (dims) {
390
+ * console.log(`Filter output: ${dims.width}x${dims.height}`);
391
+ * }
392
+ * ```
393
+ */
394
+ get dimensions(): IDimension | null;
395
+ /**
396
+ * Output sample rate from filter graph (audio only).
397
+ *
398
+ * Returns the sample rate of the buffersink output.
399
+ * Matches FFmpeg CLI's av_buffersink_get_sample_rate() behavior.
400
+ * Only meaningful for audio filters.
401
+ *
402
+ * Direct mapping to av_buffersink_get_sample_rate().
403
+ *
404
+ * @returns Sample rate or null if not initialized
405
+ *
406
+ * @example
407
+ * ```typescript
408
+ * const sampleRate = filter.sampleRate;
409
+ * if (sampleRate) {
410
+ * console.log(`Filter output sample rate: ${sampleRate} Hz`);
411
+ * }
412
+ * ```
413
+ */
414
+ get sampleRate(): number | null;
415
+ /**
416
+ * Output channel layout from filter graph (audio only).
417
+ *
418
+ * Returns the channel layout of the buffersink output.
419
+ * Matches FFmpeg CLI's av_buffersink_get_ch_layout() behavior.
420
+ * Only meaningful for audio filters.
421
+ *
422
+ * Direct mapping to av_buffersink_get_ch_layout().
423
+ *
424
+ * @returns Channel layout or null if not initialized
425
+ *
426
+ * @example
427
+ * ```typescript
428
+ * const layout = filter.channelLayout;
429
+ * if (layout) {
430
+ * console.log(`Filter output channels: ${layout.nbChannels}`);
431
+ * }
432
+ * ```
433
+ */
434
+ get channelLayout(): ChannelLayout | null;
435
+ /**
436
+ * Output color space from filter graph (video only).
437
+ *
438
+ * Returns the color space of the buffersink output.
439
+ * Matches FFmpeg CLI's av_buffersink_get_colorspace() behavior.
440
+ * Only meaningful for video filters.
441
+ *
442
+ * Direct mapping to av_buffersink_get_colorspace().
443
+ *
444
+ * @returns Color space or null if not initialized
445
+ *
446
+ * @example
447
+ * ```typescript
448
+ * const colorSpace = filter.colorSpace;
449
+ * if (colorSpace !== null) {
450
+ * console.log(`Filter output color space: ${colorSpace}`);
451
+ * }
452
+ * ```
453
+ */
454
+ get colorSpace(): AVColorSpace | null;
455
+ /**
456
+ * Output color range from filter graph (video only).
457
+ *
458
+ * Returns the color range of the buffersink output.
459
+ * Matches FFmpeg CLI's av_buffersink_get_color_range() behavior.
460
+ * Only meaningful for video filters.
461
+ *
462
+ * Direct mapping to av_buffersink_get_color_range().
463
+ *
464
+ * @returns Color range or null if not initialized
465
+ *
466
+ * @example
467
+ * ```typescript
468
+ * const colorRange = filter.colorRange;
469
+ * if (colorRange !== null) {
470
+ * console.log(`Filter output color range: ${colorRange}`);
471
+ * }
472
+ * ```
473
+ */
474
+ get colorRange(): AVColorRange | null;
475
+ /**
476
+ * Output sample aspect ratio from filter graph (video only).
477
+ *
478
+ * Returns the sample aspect ratio of the buffersink output.
479
+ * Matches FFmpeg CLI's av_buffersink_get_sample_aspect_ratio() behavior.
480
+ * Only meaningful for video filters.
481
+ *
482
+ * Direct mapping to av_buffersink_get_sample_aspect_ratio().
483
+ *
484
+ * @returns Sample aspect ratio or null if not initialized
485
+ *
486
+ * @example
487
+ * ```typescript
488
+ * const sar = filter.sampleAspectRatio;
489
+ * if (sar) {
490
+ * console.log(`Filter output SAR: ${sar.num}:${sar.den}`);
491
+ * }
492
+ * ```
493
+ */
494
+ get sampleAspectRatio(): IRational | null;
495
+ /**
496
+ * Check if filter is ready for processing.
497
+ *
498
+ * @returns true if initialized and ready
499
+ *
500
+ * @example
501
+ * ```typescript
502
+ * if (filter.isReady()) {
503
+ * const output = await filter.process(frame);
504
+ * }
505
+ * ```
506
+ */
507
+ isReady(): boolean;
508
+ /**
509
+ * Get filter graph description.
510
+ *
511
+ * Returns human-readable graph structure.
512
+ * Useful for debugging filter chains.
513
+ *
514
+ * Direct mapping to avfilter_graph_dump().
515
+ *
516
+ * @returns Graph description or null if closed
517
+ *
518
+ * @example
519
+ * ```typescript
520
+ * const description = filter.getGraphDescription();
521
+ * console.log('Filter graph:', description);
522
+ * ```
523
+ */
524
+ getGraphDescription(): string | null;
525
+ /**
526
+ * Send a frame to the filter.
527
+ *
528
+ * Sends a frame to the filter for processing.
529
+ * Does not return filtered frames - use {@link receive} to retrieve frames.
530
+ * On first frame, automatically builds filter graph with frame properties.
531
+ * A single input frame can produce zero, one, or multiple output frames.
532
+ *
533
+ * **Important**: This method only SENDS the frame to the filter.
534
+ * You must call {@link receive} separately (potentially multiple times) to get filtered frames.
535
+ *
536
+ * Direct mapping to av_buffersrc_add_frame().
537
+ *
538
+ * @param frame - Input frame to send to filter, or null to flush
539
+ *
540
+ * @throws {Error} If filter could not be initialized
541
+ *
542
+ * @throws {FFmpegError} If sending frame fails
543
+ *
544
+ * @example
545
+ * ```typescript
546
+ * // Send frame and receive filtered frames
547
+ * await filter.process(inputFrame);
548
+ *
549
+ * // Receive all available filtered frames
550
+ * while (true) {
551
+ * const output = await filter.receive();
552
+ * if (!output) break;
553
+ * console.log(`Got filtered frame: pts=${output.pts}`);
554
+ * output.free();
555
+ * }
556
+ * ```
557
+ *
558
+ * @example
559
+ * ```typescript
560
+ * for await (const frame of decoder.frames(input.packets())) {
561
+ * // Send frame
562
+ * await filter.process(frame);
563
+ *
564
+ * // Receive available filtered frames
565
+ * let output;
566
+ * while ((output = await filter.receive())) {
567
+ * await encoder.encode(output);
568
+ * output.free();
569
+ * }
570
+ * frame.free();
571
+ * }
572
+ * ```
573
+ *
574
+ * @see {@link receive} For receiving filtered frames
575
+ * @see {@link processAll} For combined send+receive operation
576
+ * @see {@link frames} For processing frame streams
577
+ * @see {@link flush} For end-of-stream handling
578
+ * @see {@link processSync} For synchronous version
579
+ */
580
+ process(frame: Frame | null): Promise<void>;
581
+ /**
582
+ * Send a frame to the filter synchronously.
583
+ * Synchronous version of process.
584
+ *
585
+ * Sends a frame to the filter for processing.
586
+ * Does not return filtered frames - use {@link receiveSync} to retrieve frames.
587
+ * On first frame, automatically builds filter graph with frame properties.
588
+ * A single input frame can produce zero, one, or multiple output frames.
589
+ *
590
+ * **Important**: This method only SENDS the frame to the filter.
591
+ * You must call {@link receiveSync} separately (potentially multiple times) to get filtered frames.
592
+ *
593
+ * Direct mapping to av_buffersrc_add_frame().
594
+ *
595
+ * @param frame - Input frame to send to filter, or null to flush
596
+ *
597
+ * @throws {Error} If filter could not be initialized
598
+ *
599
+ * @throws {FFmpegError} If sending frame fails
600
+ *
601
+ * @example
602
+ * ```typescript
603
+ * // Send frame and receive filtered frames
604
+ * filter.processSync(inputFrame);
605
+ *
606
+ * // Receive all available filtered frames
607
+ * let output;
608
+ * while ((output = filter.receiveSync())) {
609
+ * console.log(`Got filtered frame: pts=${output.pts}`);
610
+ * output.free();
611
+ * }
612
+ * ```
613
+ *
614
+ * @see {@link receiveSync} For receiving filtered frames
615
+ * @see {@link processAllSync} For combined send+receive operation
616
+ * @see {@link framesSync} For processing frame streams
617
+ * @see {@link flushSync} For end-of-stream handling
618
+ * @see {@link process} For async version
619
+ */
620
+ processSync(frame: Frame | null): void;
621
+ /**
622
+ * Process a frame through the filter.
623
+ *
624
+ * Applies filter operations to input frame and receives all available output frames.
625
+ * Returns array of frames - may be empty if filter needs more input.
626
+ * On first frame, automatically builds filter graph with frame properties.
627
+ * One input frame can produce zero, one, or multiple output frames depending on filter.
628
+ * Hardware frames context is automatically detected from frame.
629
+ *
630
+ * Direct mapping to av_buffersrc_add_frame() and av_buffersink_get_frame().
631
+ *
632
+ * @param frame - Input frame to process
633
+ *
634
+ * @returns Array of filtered frames (empty if buffered or filter closed)
635
+ *
636
+ * @throws {Error} If filter could not be initialized
637
+ *
638
+ * @throws {FFmpegError} If processing fails
639
+ *
640
+ * @example
641
+ * ```typescript
642
+ * const frames = await filter.processAll(inputFrame);
643
+ * for (const output of frames) {
644
+ * console.log(`Got filtered frame: pts=${output.pts}`);
645
+ * output.free();
646
+ * }
647
+ * ```
648
+ *
649
+ * @example
650
+ * ```typescript
651
+ * // Process frame - may return multiple frames (e.g. fps filter)
652
+ * const frames = await filter.processAll(frame);
653
+ * for (const output of frames) {
654
+ * yield output;
655
+ * }
656
+ * ```
657
+ *
658
+ * @see {@link process} For single frame processing
659
+ * @see {@link frames} For processing frame streams
660
+ * @see {@link flush} For end-of-stream handling
661
+ * @see {@link processAllSync} For synchronous version
662
+ */
663
+ processAll(frame: Frame | null): Promise<Frame[]>;
664
+ /**
665
+ * Process a frame through the filter synchronously.
666
+ * Synchronous version of processAll.
667
+ *
668
+ * Applies filter operations to input frame and receives all available output frames.
669
+ * Returns array of frames - may be empty if filter needs more input.
670
+ * On first frame, automatically builds filter graph with frame properties.
671
+ * One input frame can produce zero, one, or multiple output frames depending on filter.
672
+ * Hardware frames context is automatically detected from frame.
673
+ *
674
+ * Direct mapping to av_buffersrc_add_frame() and av_buffersink_get_frame().
675
+ *
676
+ * @param frame - Input frame to process
677
+ *
678
+ * @returns Array of filtered frames (empty if buffered or filter closed)
679
+ *
680
+ * @throws {Error} If filter could not be initialized
681
+ *
682
+ * @throws {FFmpegError} If processing fails
683
+ *
684
+ * @example
685
+ * ```typescript
686
+ * const outputs = filter.processAllSync(inputFrame);
687
+ * for (const output of outputs) {
688
+ * console.log(`Got filtered frame: pts=${output.pts}`);
689
+ * output.free();
690
+ * }
691
+ * ```
692
+ *
693
+ * @example
694
+ * ```typescript
695
+ * // Process frame - may return multiple frames (e.g. fps filter)
696
+ * const outputs = filter.processAllSync(frame);
697
+ * for (const output of outputs) {
698
+ * yield output;
699
+ * }
700
+ * ```
701
+ *
702
+ * @see {@link processSync} For single frame processing
703
+ * @see {@link framesSync} For processing frame streams
704
+ * @see {@link flushSync} For end-of-stream handling
705
+ * @see {@link process} For async version
706
+ */
707
+ processAllSync(frame: Frame): Frame[];
708
+ /**
709
+ * Process frame stream through filter.
710
+ *
711
+ * High-level async generator for filtering frame streams.
712
+ * Filter is only flushed when EOF (null) signal is explicitly received.
713
+ * Primary interface for stream-based filtering.
714
+ *
715
+ * **EOF Handling:**
716
+ * - Send null to flush filter and get remaining buffered frames
717
+ * - Generator yields null after flushing when null is received
718
+ * - No automatic flushing - filter stays open until EOF or close()
719
+ *
720
+ * @param frames - Async iterable of frames, single frame, or null to flush
721
+ *
722
+ * @yields {Frame | null} Filtered frames, followed by null when explicitly flushed
723
+ *
724
+ * @throws {Error} If filter not ready
725
+ *
726
+ * @throws {FFmpegError} If processing fails
727
+ *
728
+ * @example
729
+ * ```typescript
730
+ * // Stream of frames with automatic EOF propagation
731
+ * for await (const frame of filter.frames(decoder.frames(packets))) {
732
+ * if (frame === null) {
733
+ * console.log('Filter flushed');
734
+ * break;
735
+ * }
736
+ * await encoder.encode(frame);
737
+ * frame.free();
738
+ * }
739
+ * ```
740
+ *
741
+ * @example
742
+ * ```typescript
743
+ * // Single frame - no automatic flush
744
+ * for await (const frame of filter.frames(singleFrame)) {
745
+ * await encoder.encode(frame);
746
+ * frame.free();
747
+ * }
748
+ * // Filter remains open, buffered frames not flushed
749
+ * ```
750
+ *
751
+ * @example
752
+ * ```typescript
753
+ * // Explicit flush with EOF
754
+ * for await (const frame of filter.frames(null)) {
755
+ * if (frame === null) {
756
+ * console.log('All buffered frames flushed');
757
+ * break;
758
+ * }
759
+ * console.log('Buffered frame:', frame.pts);
760
+ * frame.free();
761
+ * }
762
+ * ```
763
+ *
764
+ * @see {@link process} For single frame processing
765
+ * @see {@link Decoder.frames} For frames source
766
+ * @see {@link framesSync} For sync version
767
+ */
768
+ frames(frames: AsyncIterable<Frame | null> | Frame | null): AsyncGenerator<Frame | null>;
769
+ /**
770
+ * Process frame stream through filter synchronously.
771
+ * Synchronous version of frames.
772
+ *
773
+ * High-level sync generator for filtering frame streams.
774
+ * Filter is only flushed when EOF (null) signal is explicitly received.
775
+ * Primary interface for stream-based filtering.
776
+ *
777
+ * **EOF Handling:**
778
+ * - Send null to flush filter and get remaining buffered frames
779
+ * - Generator yields null after flushing when null is received
780
+ * - No automatic flushing - filter stays open until EOF or close()
781
+ *
782
+ * @param frames - Iterable of frames, single frame, or null to flush
783
+ *
784
+ * @yields {Frame | null} Filtered frames, followed by null when explicitly flushed
785
+ *
786
+ * @throws {Error} If filter not ready
787
+ *
788
+ * @throws {FFmpegError} If processing fails
789
+ *
790
+ * @example
791
+ * ```typescript
792
+ * // Stream of frames with automatic EOF propagation
793
+ * for (const frame of filter.framesSync(decoder.framesSync(packets))) {
794
+ * if (frame === null) {
795
+ * console.log('Filter flushed');
796
+ * break;
797
+ * }
798
+ * encoder.encodeSync(frame);
799
+ * frame.free();
800
+ * }
801
+ * ```
802
+ *
803
+ * @example
804
+ * ```typescript
805
+ * // Single frame - no automatic flush
806
+ * for (const frame of filter.framesSync(singleFrame)) {
807
+ * encoder.encodeSync(frame);
808
+ * frame.free();
809
+ * }
810
+ * // Filter remains open, buffered frames not flushed
811
+ * ```
812
+ *
813
+ * @example
814
+ * ```typescript
815
+ * // Explicit flush with EOF
816
+ * for (const frame of filter.framesSync(null)) {
817
+ * if (frame === null) {
818
+ * console.log('All buffered frames flushed');
819
+ * break;
820
+ * }
821
+ * console.log('Buffered frame:', frame.pts);
822
+ * frame.free();
823
+ * }
824
+ * ```
825
+ *
826
+ * @see {@link processSync} For single frame processing
827
+ * @see {@link Decoder.framesSync} For frames source
828
+ * @see {@link frames} For async version
829
+ */
830
+ framesSync(frames: Iterable<Frame | null> | Frame | null): Generator<Frame | null>;
831
+ /**
832
+ * Flush filter and signal end-of-stream.
833
+ *
834
+ * Sends null frame to flush buffered data.
835
+ * Must call receive() to get flushed frames.
836
+ * Does nothing if filter is closed or was never initialized.
837
+ *
838
+ * Direct mapping to av_buffersrc_add_frame(NULL).
839
+ *
840
+ * @throws {FFmpegError} If flush fails
841
+ *
842
+ * @example
843
+ * ```typescript
844
+ * await filter.flush();
845
+ * // Get remaining frames
846
+ * let frame;
847
+ * while ((frame = await filter.receive()) !== null) {
848
+ * frame.free();
849
+ * }
850
+ * ```
851
+ *
852
+ * @see {@link flushFrames} For async iteration
853
+ * @see {@link receive} For getting flushed frames
854
+ * @see {@link flushSync} For synchronous version
855
+ */
856
+ flush(): Promise<void>;
857
+ /**
858
+ * Flush filter and signal end-of-stream synchronously.
859
+ * Synchronous version of flush.
860
+ *
861
+ * Sends null frame to flush buffered data.
862
+ * Must call receiveSync() to get flushed frames.
863
+ * Does nothing if filter is closed or was never initialized.
864
+ *
865
+ * Direct mapping to av_buffersrc_add_frame(NULL).
866
+ *
867
+ * @throws {FFmpegError} If flush fails
868
+ *
869
+ * @example
870
+ * ```typescript
871
+ * filter.flushSync();
872
+ * // Get remaining frames
873
+ * let frame;
874
+ * while ((frame = filter.receiveSync()) !== null) {
875
+ * frame.free();
876
+ * }
877
+ * ```
878
+ *
879
+ * @see {@link flushFramesSync} For sync iteration
880
+ * @see {@link receiveSync} For getting flushed frames
881
+ * @see {@link flush} For async version
882
+ */
883
+ flushSync(): void;
884
+ /**
885
+ * Flush filter and yield remaining frames.
886
+ *
887
+ * Convenient async generator for flushing.
888
+ * Combines flush and receive operations.
889
+ * Returns immediately if filter is closed or was never initialized.
890
+ *
891
+ * @yields {Frame} Remaining frames from filter
892
+ *
893
+ * @throws {FFmpegError} If flush fails
894
+ *
895
+ * @example
896
+ * ```typescript
897
+ * for await (const frame of filter.flushFrames()) {
898
+ * console.log(`Flushed frame: pts=${frame.pts}`);
899
+ * frame.free();
900
+ * }
901
+ * ```
902
+ *
903
+ * @see {@link process} For frame processing
904
+ * @see {@link flush} For manual flush
905
+ * @see {@link flushFramesSync} For sync version
906
+ */
907
+ flushFrames(): AsyncGenerator<Frame>;
908
+ /**
909
+ * Flush filter and yield remaining frames synchronously.
910
+ * Synchronous version of flushFrames.
911
+ *
912
+ * Convenient sync generator for flushing.
913
+ * Combines flush and receive operations.
914
+ * Returns immediately if filter is closed or was never initialized.
915
+ *
916
+ * @yields {Frame} Remaining frames from filter
917
+ *
918
+ * @throws {FFmpegError} If flush fails
919
+ *
920
+ * @example
921
+ * ```typescript
922
+ * for (const frame of filter.flushFramesSync()) {
923
+ * console.log(`Flushed frame: pts=${frame.pts}`);
924
+ * frame.free();
925
+ * }
926
+ * ```
927
+ *
928
+ * @see {@link processSync} For frame processing
929
+ * @see {@link flushSync} For manual flush
930
+ * @see {@link flushFrames} For async version
931
+ */
932
+ flushFramesSync(): Generator<Frame>;
933
+ /**
934
+ * Receive buffered frame from filter.
935
+ *
936
+ * Drains frames buffered by the filter.
937
+ * Call repeatedly until null or EOF to get all buffered frames.
938
+ * Implements FFmpeg's send/receive pattern.
939
+ *
940
+ * **Return Values:**
941
+ * - `Frame` - Successfully received frame (AVERROR >= 0)
942
+ * - `null` - Need more input data (AVERROR_EAGAIN), or filter not initialized
943
+ * - `undefined` - End of stream reached (AVERROR_EOF), or filter is closed
944
+ *
945
+ * Direct mapping to av_buffersink_get_frame().
946
+ *
947
+ * @returns Buffered frame, null if need more data, or undefined if stream ended
948
+ *
949
+ * @throws {FFmpegError} If receiving fails
950
+ *
951
+ * @throws {Error} If frame cloning fails (out of memory)
952
+ *
953
+ * @example
954
+ * ```typescript
955
+ * // Process all buffered frames
956
+ * while (true) {
957
+ * const frame = await filter.receive();
958
+ * if (!frame) break; // Stop on EAGAIN or EOF
959
+ * console.log(`Received frame: pts=${frame.pts}`);
960
+ * frame.free();
961
+ * }
962
+ * ```
963
+ *
964
+ * @example
965
+ * ```typescript
966
+ * // Handle each return value explicitly
967
+ * const frame = await filter.receive();
968
+ * if (frame === EOF) {
969
+ * console.log('Filter stream ended');
970
+ * } else if (frame === null) {
971
+ * console.log('Need more input data');
972
+ * } else {
973
+ * console.log(`Got frame: pts=${frame.pts}`);
974
+ * frame.free();
975
+ * }
976
+ * ```
977
+ *
978
+ * @see {@link process} For frame processing
979
+ * @see {@link flush} For flushing filter
980
+ * @see {@link receiveSync} For synchronous version
981
+ * @see {@link EOF} For end-of-stream signal
982
+ */
983
+ receive(): Promise<Frame | EOFSignal | null>;
984
+ /**
985
+ * Receive buffered frame from filter synchronously.
986
+ * Synchronous version of receive.
987
+ *
988
+ * Drains frames buffered by the filter.
989
+ * Call repeatedly until null or EOF to get all buffered frames.
990
+ * Implements FFmpeg's send/receive pattern.
991
+ *
992
+ * **Return Values:**
993
+ * - `Frame` - Successfully received frame (AVERROR >= 0)
994
+ * - `null` - Need more input data (AVERROR_EAGAIN), or filter not initialized
995
+ * - `undefined` - End of stream reached (AVERROR_EOF), or filter is closed
996
+ *
997
+ * Direct mapping to av_buffersink_get_frame().
998
+ *
999
+ * @returns Buffered frame, null if need more data, or undefined if stream ended
1000
+ *
1001
+ * @throws {FFmpegError} If receiving fails
1002
+ *
1003
+ * @throws {Error} If frame cloning fails (out of memory)
1004
+ *
1005
+ * @example
1006
+ * ```typescript
1007
+ * // Process all buffered frames
1008
+ * while (true) {
1009
+ * const frame = filter.receiveSync();
1010
+ * if (!frame) break; // Stop on EAGAIN or EOF
1011
+ * console.log(`Received frame: pts=${frame.pts}`);
1012
+ * frame.free();
1013
+ * }
1014
+ * ```
1015
+ *
1016
+ * @example
1017
+ * ```typescript
1018
+ * // Handle each return value explicitly
1019
+ * const frame = filter.receiveSync();
1020
+ * if (frame === EOF) {
1021
+ * console.log('Filter stream ended');
1022
+ * } else if (frame === null) {
1023
+ * console.log('Need more input data');
1024
+ * } else {
1025
+ * console.log(`Got frame: pts=${frame.pts}`);
1026
+ * frame.free();
1027
+ * }
1028
+ * ```
1029
+ *
1030
+ * @see {@link processSync} For frame processing
1031
+ * @see {@link flushSync} For flushing filter
1032
+ * @see {@link receive} For async version
1033
+ * @see {@link EOF} For end-of-stream signal
1034
+ */
1035
+ receiveSync(): Frame | EOFSignal | null;
1036
+ /**
1037
+ * Send command to filter.
1038
+ *
1039
+ * Sends runtime command to specific filter in graph.
1040
+ * Allows dynamic parameter adjustment.
1041
+ *
1042
+ * Direct mapping to avfilter_graph_send_command().
1043
+ *
1044
+ * @param target - Target filter name
1045
+ *
1046
+ * @param cmd - Command name
1047
+ *
1048
+ * @param arg - Command argument
1049
+ *
1050
+ * @param flags - Command flags
1051
+ *
1052
+ * @returns Response string from filter
1053
+ *
1054
+ * @throws {Error} If filter not ready
1055
+ *
1056
+ * @throws {FFmpegError} If command fails
1057
+ *
1058
+ * @example
1059
+ * ```typescript
1060
+ * // Change volume at runtime
1061
+ * const response = filter.sendCommand('volume', 'volume', '0.5');
1062
+ * console.log(`Volume changed: ${response}`);
1063
+ * ```
1064
+ *
1065
+ * @see {@link queueCommand} For delayed commands
1066
+ */
1067
+ sendCommand(target: string, cmd: string, arg: string, flags?: AVFilterCmdFlag): string;
1068
+ /**
1069
+ * Queue command for later execution.
1070
+ *
1071
+ * Schedules command to execute at specific timestamp.
1072
+ * Useful for synchronized parameter changes.
1073
+ *
1074
+ * Direct mapping to avfilter_graph_queue_command().
1075
+ *
1076
+ * @param target - Target filter name
1077
+ *
1078
+ * @param cmd - Command name
1079
+ *
1080
+ * @param arg - Command argument
1081
+ *
1082
+ * @param ts - Timestamp for execution
1083
+ *
1084
+ * @param flags - Command flags
1085
+ *
1086
+ * @throws {Error} If filter not ready
1087
+ *
1088
+ * @throws {FFmpegError} If queue fails
1089
+ *
1090
+ * @example
1091
+ * ```typescript
1092
+ * // Queue volume change at 10 seconds
1093
+ * filter.queueCommand('volume', 'volume', '0.8', 10.0);
1094
+ * ```
1095
+ *
1096
+ * @see {@link sendCommand} For immediate commands
1097
+ */
1098
+ queueCommand(target: string, cmd: string, arg: string, ts: number, flags?: AVFilterCmdFlag): void;
1099
+ /**
1100
+ * Pipe decoded frames to a filter component or encoder.
1101
+ *
1102
+ * @param target - Filter to receive frames or encoder to encode frames
1103
+ *
1104
+ * @returns Scheduler for continued chaining
1105
+ *
1106
+ * @example
1107
+ * ```typescript
1108
+ * decoder.pipeTo(filter).pipeTo(encoder)
1109
+ * ```
1110
+ */
1111
+ pipeTo(target: FilterAPI): Scheduler<Frame>;
1112
+ pipeTo(target: Encoder): Scheduler<Frame>;
1113
+ /**
1114
+ * Free filter resources.
1115
+ *
1116
+ * Releases filter graph and contexts.
1117
+ * Safe to call multiple times.
1118
+ *
1119
+ * @example
1120
+ * ```typescript
1121
+ * filter.close();
1122
+ * ```
1123
+ *
1124
+ * @see {@link Symbol.dispose} For automatic cleanup
1125
+ */
1126
+ close(): void;
1127
+ /**
1128
+ * Worker loop for push-based processing.
1129
+ *
1130
+ * @internal
1131
+ */
1132
+ private runWorker;
1133
+ /**
1134
+ * Send frame to input queue or flush the pipeline.
1135
+ *
1136
+ * When frame is provided, queues it for filtering.
1137
+ * When null is provided, triggers flush sequence:
1138
+ * - Closes input queue
1139
+ * - Waits for worker completion
1140
+ * - Flushes filter and sends remaining frames to output queue
1141
+ * - Closes output queue
1142
+ * - Waits for pipeTo task completion
1143
+ * - Propagates flush to next component (if any)
1144
+ *
1145
+ * Used by scheduler system for pipeline control.
1146
+ *
1147
+ * @param frame - Frame to send, or null to flush
1148
+ *
1149
+ * @internal
1150
+ */
1151
+ private sendToQueue;
1152
+ /**
1153
+ * Receive frame from output queue.
1154
+ *
1155
+ * @returns Frame from output queue or null if closed
1156
+ *
1157
+ * @internal
1158
+ */
1159
+ private receiveFrame;
1160
+ /**
1161
+ * Initialize filter graph from first frame.
1162
+ *
1163
+ * Creates and configures filter graph components.
1164
+ * Sets buffer source parameters from frame properties.
1165
+ * Automatically configures hardware frames context if present.
1166
+ *
1167
+ * @param frame - First frame to process, provides format and hw context
1168
+ *
1169
+ * @throws {Error} If initialization fails
1170
+ *
1171
+ * @throws {FFmpegError} If configuration fails
1172
+ *
1173
+ * @internal
1174
+ */
1175
+ private initialize;
1176
+ /**
1177
+ * Initialize filter graph from first frame synchronously.
1178
+ * Synchronous version of initialize.
1179
+ *
1180
+ * Creates and configures filter graph components.
1181
+ * Sets buffer source parameters from frame properties.
1182
+ * Automatically configures hardware frames context if present.
1183
+ *
1184
+ * @param frame - First frame to process, provides format and hw context
1185
+ *
1186
+ * @throws {Error} If initialization fails
1187
+ *
1188
+ * @throws {FFmpegError} If configuration fails
1189
+ *
1190
+ * @internal
1191
+ *
1192
+ * @see {@link initialize} For async version
1193
+ */
1194
+ private initializeSync;
1195
+ /**
1196
+ * Build and configure the graph for a frame.
1197
+ *
1198
+ * Sets the graph options, creates the buffer source and sink and parses the
1199
+ * description between them.
1200
+ *
1201
+ * @param frame - Frame the graph is built for
1202
+ *
1203
+ * @param failure - Why the previous graph for this frame failed, passed to a description function
1204
+ *
1205
+ * @throws {Error} If building fails
1206
+ *
1207
+ * @throws {FFmpegError} If configuration fails
1208
+ *
1209
+ * @internal
1210
+ */
1211
+ private buildGraph;
1212
+ /**
1213
+ * Build and configure the graph for a frame synchronously.
1214
+ * Synchronous version of buildGraph.
1215
+ *
1216
+ * @param frame - Frame the graph is built for
1217
+ *
1218
+ * @param failure - Why the previous graph for this frame failed, passed to a description function
1219
+ *
1220
+ * @throws {Error} If building fails
1221
+ *
1222
+ * @throws {FFmpegError} If configuration fails
1223
+ *
1224
+ * @internal
1225
+ *
1226
+ * @see {@link buildGraph} For async version
1227
+ */
1228
+ private buildGraphSync;
1229
+ /**
1230
+ * Replace the graph with a new, empty one.
1231
+ *
1232
+ * @internal
1233
+ */
1234
+ private resetGraph;
1235
+ /**
1236
+ * Check if frame properties changed and handle according to dropOnChange/allowReinit options.
1237
+ *
1238
+ * Implements FFmpeg's IFILTER_FLAG_DROPCHANGED and IFILTER_FLAG_REINIT logic
1239
+ *
1240
+ * @param frame - Frame to check
1241
+ *
1242
+ * @returns true if frame should be processed, false if frame should be dropped
1243
+ *
1244
+ * @throws {Error} If format changed and allowReinit is false
1245
+ *
1246
+ * @internal
1247
+ */
1248
+ private checkFramePropertiesChanged;
1249
+ /**
1250
+ * Calculate timeBase from frame based on media type and CFR option.
1251
+ *
1252
+ * Implements FFmpeg's ifilter_parameters_from_frame logic:
1253
+ * - Audio: Always { 1, sample_rate }
1254
+ * - Video CFR: 1/framerate (inverse of framerate)
1255
+ * - Video VFR: Use frame.timeBase
1256
+ *
1257
+ * @param frame - Input frame
1258
+ *
1259
+ * @returns Calculated timeBase
1260
+ *
1261
+ * @internal
1262
+ */
1263
+ private calculateTimeBase;
1264
+ /**
1265
+ * Post-process output frame from buffersink.
1266
+ *
1267
+ * Applies FFmpeg's fg_output_step() behavior:
1268
+ * 1. Sets frame.timeBase from buffersink (filters can change timeBase, e.g., aresample)
1269
+ * 2. Calculates video frame duration from frame rate if not set
1270
+ *
1271
+ * This must be called AFTER buffersinkGetFrame() for every output frame.
1272
+ *
1273
+ * @param frame - Output frame from buffersink
1274
+ *
1275
+ * @throws {Error} If buffersink context not available
1276
+ *
1277
+ * @internal
1278
+ */
1279
+ private postProcessOutputFrame;
1280
+ /**
1281
+ * Create buffer source with frame parameters.
1282
+ *
1283
+ * Configures buffer source with frame properties including hardware context.
1284
+ * Automatically detects video/audio and sets appropriate parameters.
1285
+ *
1286
+ * @param frame - Frame providing format, dimensions, and hw_frames_ctx
1287
+ *
1288
+ * @throws {Error} If creation fails
1289
+ *
1290
+ * @throws {FFmpegError} If configuration fails
1291
+ *
1292
+ * @internal
1293
+ */
1294
+ private createBufferSource;
1295
+ /**
1296
+ * Create buffer sink.
1297
+ *
1298
+ * @param frame - Frame
1299
+ *
1300
+ * @throws {Error} If creation fails
1301
+ *
1302
+ * @internal
1303
+ */
1304
+ private createBufferSink;
1305
+ /**
1306
+ * Parse filter description and build graph.
1307
+ *
1308
+ * Uses the Segment API to parse filters, which allows setting hw_device_ctx
1309
+ * before filter initialization when needed. Works for both hardware and software filters.
1310
+ *
1311
+ * @param frame - First frame to process, provides hw_frames_ctx if any
1312
+ *
1313
+ * @param failure - Why the previous graph for this frame failed, passed to a description function
1314
+ *
1315
+ * @throws {Error} If parsing fails
1316
+ *
1317
+ * @throws {FFmpegError} If graph construction fails
1318
+ *
1319
+ * @internal
1320
+ */
1321
+ private parseFilterDescription;
1322
+ /**
1323
+ * Dispose of filter.
1324
+ *
1325
+ * Implements Disposable interface for automatic cleanup.
1326
+ * Equivalent to calling close().
1327
+ *
1328
+ * @example
1329
+ * ```typescript
1330
+ * {
1331
+ * using filter = FilterAPI.create('scale=640:480', { ... });
1332
+ * // Use filter...
1333
+ * } // Automatically freed
1334
+ * ```
1335
+ *
1336
+ * @see {@link close} For manual cleanup
1337
+ */
1338
+ [Symbol.dispose](): void;
1339
+ }