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,828 @@
1
+ import { Frame } from '../lib/frame.js';
2
+ import type { AVMediaType, EOFSignal } from '../constants/index.js';
3
+ import type { IRational } from '../lib/types.js';
4
+ import type { FilterComplexGraph } from './filter-presets.js';
5
+ import type { FilterOptions } from './filter.js';
6
+ /**
7
+ * Input configuration for FilterComplexAPI.
8
+ */
9
+ export interface FilterComplexInput {
10
+ /**
11
+ * Input label identifier.
12
+ *
13
+ * Matches labels in filter_complex description (e.g., '0:v', '1:v', '0:a').
14
+ * Used to identify which buffersrc filter to send frames to via process() method.
15
+ */
16
+ label: string;
17
+ }
18
+ /**
19
+ * Output configuration for FilterComplexAPI.
20
+ */
21
+ export interface FilterComplexOutput {
22
+ /**
23
+ * Output label identifier.
24
+ *
25
+ * Matches labels in filter_complex description (e.g., 'out', 'thumb', 'main').
26
+ * Used to identify which buffersink to read from via output() method.
27
+ */
28
+ label: string;
29
+ /**
30
+ * Media type for this output.
31
+ *
32
+ * If not specified, defaults to the media type of the first input.
33
+ * Set to 'AVMEDIA_TYPE_VIDEO' or 'AVMEDIA_TYPE_AUDIO' explicitly if needed (e.g., for audio extraction filters).
34
+ *
35
+ * @default Inferred from first input
36
+ */
37
+ mediaType?: AVMediaType;
38
+ }
39
+ /**
40
+ * Options for creating a complex filter graph.
41
+ */
42
+ export interface FilterComplexOptions extends FilterOptions {
43
+ /**
44
+ * Input sources for the filter graph.
45
+ *
46
+ * Array of labeled frame sources that feed into the filter graph.
47
+ * Labels must match those referenced in the description string.
48
+ */
49
+ inputs: FilterComplexInput[];
50
+ /**
51
+ * Output labels from the filter graph.
52
+ *
53
+ * Array of output identifiers that can be consumed via output() method.
54
+ * Labels must match those defined in the description string.
55
+ */
56
+ outputs: FilterComplexOutput[];
57
+ }
58
+ /**
59
+ * High-level filter_complex API for multi-input/output filtering.
60
+ *
61
+ * Provides simplified interface for complex FFmpeg filter graphs with multiple inputs and outputs.
62
+ * Supports both high-level generator API and low-level manual control.
63
+ *
64
+ * @example
65
+ * ```typescript
66
+ * // High-level API: Simple overlay with frames() generator
67
+ * using complex = FilterComplexAPI.create('[0:v][1:v]overlay=x=100:y=50[out]', {
68
+ * inputs: [{ label: '0:v' }, { label: '1:v' }],
69
+ * outputs: [{ label: 'out' }]
70
+ * });
71
+ *
72
+ * // Process multiple input streams automatically
73
+ * for await (using frame of complex.frames('out', {
74
+ * '0:v': decoder1.frames(packets1),
75
+ * '1:v': decoder2.frames(packets2)
76
+ * })) {
77
+ * await encoder.encode(frame);
78
+ * }
79
+ * ```
80
+ *
81
+ * @see {@link FilterAPI} For simple single-input/output filtering
82
+ * @see {@link FilterGraph} For low-level filter graph API
83
+ * @see {@link frames} For high-level stream processing
84
+ * @see {@link process} For low-level manual frame sending
85
+ * @see {@link receive} For low-level manual frame receiving
86
+ */
87
+ export declare class FilterComplexAPI implements Disposable {
88
+ private graph;
89
+ private description;
90
+ private options;
91
+ private inputs;
92
+ private outputs;
93
+ private initialized;
94
+ private isClosed;
95
+ private initializePromise;
96
+ private frame;
97
+ /**
98
+ * @param graph - Filter graph instance
99
+ *
100
+ * @param description - Filter description string
101
+ *
102
+ * @param options - Filter complex options
103
+ *
104
+ * @internal
105
+ */
106
+ private constructor();
107
+ /**
108
+ * Create a complex filter with specified configuration.
109
+ *
110
+ * Direct mapping to avfilter_graph_segment_parse() and avfilter_graph_config().
111
+ *
112
+ * @param description - Filter description string (e.g., '[0:v][1:v]overlay[out]')
113
+ *
114
+ * @param options - Filter complex configuration including inputs and outputs
115
+ *
116
+ * @returns Filter complex instance ready to process frames
117
+ *
118
+ * @throws {Error} If configuration is invalid (duplicate labels, no inputs/outputs)
119
+ *
120
+ * @example
121
+ * ```typescript
122
+ * // Simple overlay example
123
+ * using complex = FilterComplexAPI.create(
124
+ * '[0:v][1:v]overlay=x=100:y=50[out]',
125
+ * {
126
+ * inputs: [
127
+ * { label: '0:v' }, // Base video
128
+ * { label: '1:v' } // Overlay video
129
+ * ],
130
+ * outputs: [{ label: 'out' }]
131
+ * }
132
+ * );
133
+ *
134
+ * // Send frames manually
135
+ * await complex.process('0:v', baseFrame);
136
+ * await complex.process('1:v', overlayFrame);
137
+ * using outFrame = await complex.receive('out');
138
+ * ```
139
+ *
140
+ * @see {@link process} For sending frames to inputs
141
+ * @see {@link receive} For getting frames from outputs
142
+ */
143
+ static create(description: string | FilterComplexGraph, options: FilterComplexOptions): FilterComplexAPI;
144
+ /**
145
+ * Check if filter complex is open.
146
+ *
147
+ * @returns true if not closed
148
+ *
149
+ * @example
150
+ * ```typescript
151
+ * if (complex.isOpen) {
152
+ * // Can still consume frames
153
+ * }
154
+ * ```
155
+ */
156
+ get isOpen(): boolean;
157
+ /**
158
+ * Check if filter complex has been initialized.
159
+ *
160
+ * Returns true after first frame set has been processed from all inputs.
161
+ *
162
+ * @returns true if filter graph has been configured
163
+ *
164
+ * @example
165
+ * ```typescript
166
+ * if (!complex.isInitialized) {
167
+ * console.log('Filter will initialize on first frame set');
168
+ * }
169
+ * ```
170
+ */
171
+ get isInitialized(): boolean;
172
+ /**
173
+ * Get output frame rate.
174
+ *
175
+ * Returns frame rate from the first output's buffersink.
176
+ * Returns null if not initialized or frame rate is not set.
177
+ *
178
+ * @returns Frame rate as rational number or null
179
+ *
180
+ * @example
181
+ * ```typescript
182
+ * const frameRate = complex.frameRate;
183
+ * if (frameRate) {
184
+ * console.log(`Output: ${frameRate.num}/${frameRate.den} fps`);
185
+ * }
186
+ * ```
187
+ *
188
+ * @see {@link FilterAPI.frameRate} For single-output filter frame rate
189
+ */
190
+ get frameRate(): IRational | null;
191
+ /**
192
+ * Get output time base.
193
+ *
194
+ * Returns time base from the first output's buffersink.
195
+ * Returns null if not initialized.
196
+ *
197
+ * @returns Time base as rational number or null
198
+ *
199
+ * @example
200
+ * ```typescript
201
+ * const timeBase = complex.timeBase;
202
+ * if (timeBase) {
203
+ * console.log(`Output timeBase: ${timeBase.num}/${timeBase.den}`);
204
+ * }
205
+ * ```
206
+ *
207
+ * @see {@link FilterAPI.timeBase} For single-output filter time base
208
+ */
209
+ get timeBase(): IRational | null;
210
+ /**
211
+ * Process frame by sending to specified input.
212
+ *
213
+ * Sends a frame to the buffersrc of the specified input label.
214
+ * Automatically rescales timestamps to the input's calculated timeBase (CFR/VFR).
215
+ * Pass null to signal end-of-stream for that input.
216
+ *
217
+ * Direct mapping to av_buffersrc_add_frame().
218
+ *
219
+ * @param inLabel - Input label to send frame to
220
+ *
221
+ * @param frame - Frame to process
222
+ *
223
+ * @throws {Error} If input label not found or filter closed
224
+ *
225
+ * @throws {FFmpegError} If processing fails
226
+ *
227
+ * @example
228
+ * ```typescript
229
+ * // Process frames one at a time
230
+ * await complex.process('0:v', frame1);
231
+ * await complex.process('1:v', frame2);
232
+ * const outFrame = await complex.receive('out');
233
+ * ```
234
+ *
235
+ * @see {@link receive} For receiving output frames
236
+ * @see {@link flush} For flushing inputs
237
+ * @see {@link processSync} For synchronous version
238
+ */
239
+ process(inLabel: string, frame: Frame): Promise<void>;
240
+ /**
241
+ * Process frame by sending to specified input synchronously.
242
+ * Synchronous version of process.
243
+ *
244
+ * Sends a frame to the buffersrc of the specified input label.
245
+ * Automatically rescales timestamps to the input's calculated timeBase (CFR/VFR).
246
+ * Pass null to signal end-of-stream for that input.
247
+ *
248
+ * Direct mapping to av_buffersrc_add_frame().
249
+ *
250
+ * @param inLabel - Input label to send frame to
251
+ *
252
+ * @param frame - Frame to process
253
+ *
254
+ * @throws {Error} If input label not found or filter closed
255
+ *
256
+ * @throws {FFmpegError} If processing fails
257
+ *
258
+ * @example
259
+ * ```typescript
260
+ * // Process frames one at a time
261
+ * complex.processSync('0:v', frame1);
262
+ * complex.processSync('1:v', frame2);
263
+ * const outFrame = complex.receiveSync('out');
264
+ * ```
265
+ *
266
+ * @see {@link receiveSync} For receiving output frames
267
+ * @see {@link flushSync} For flushing inputs
268
+ * @see {@link process} For async version
269
+ */
270
+ processSync(inLabel: string, frame: Frame): void;
271
+ /**
272
+ * Process frame streams from multiple inputs and yield frames from specified output.
273
+ *
274
+ * High-level async generator for multi-input filtering.
275
+ * Inputs may end at different times - shorter inputs are flushed individually
276
+ * while the remaining inputs keep flowing, matching ffmpeg CLI behaviour.
277
+ *
278
+ * **EOF Handling:**
279
+ * - EOF (null) from one input flushes only that input; the others continue.
280
+ * The filter decides what happens (e.g. overlay's `eof_action`, default
281
+ * `repeat`, keeps compositing the last overlay frame)
282
+ * - When ALL inputs have ended and at least one signaled EOF, the graph is
283
+ * finalized and the generator yields null
284
+ * - Iterator completion without null does not trigger a flush - the filter
285
+ * stays open until EOF or close()
286
+ *
287
+ * @param outLabel - Output label to receive frames from
288
+ *
289
+ * @param inputs - Record mapping input labels to frame sources (AsyncIterable, single Frame, or null)
290
+ *
291
+ * @yields {Frame | null} Filtered frames from output, followed by null when flushed
292
+ *
293
+ * @throws {Error} If input label not found
294
+ *
295
+ * @throws {FFmpegError} If processing fails
296
+ *
297
+ * @example
298
+ * ```typescript
299
+ * // Stream processing: 2 inputs, 1 output
300
+ * using complex = FilterComplexAPI.create('[0:v][1:v]overlay[out]', {
301
+ * inputs: [{ label: '0:v' }, { label: '1:v' }],
302
+ * outputs: [{ label: 'out' }]
303
+ * });
304
+ *
305
+ * for await (using frame of complex.frames('out', {
306
+ * '0:v': decoder1.frames(packets1),
307
+ * '1:v': decoder2.frames(packets2)
308
+ * })) {
309
+ * await encoder.encode(frame);
310
+ * }
311
+ * ```
312
+ *
313
+ * @example
314
+ * ```typescript
315
+ * // Single frames - no automatic flush
316
+ * for await (using frame of complex.frames('out', {
317
+ * '0:v': frame1,
318
+ * '1:v': frame2
319
+ * })) {
320
+ * await encoder.encode(frame);
321
+ * }
322
+ * // Filter remains open, buffered frames not flushed
323
+ * ```
324
+ *
325
+ * @example
326
+ * ```typescript
327
+ * // Explicit flush with null
328
+ * for await (using frame of complex.frames('out', {
329
+ * '0:v': null,
330
+ * '1:v': null
331
+ * })) {
332
+ * await encoder.encode(frame);
333
+ * }
334
+ * ```
335
+ *
336
+ * @example
337
+ * ```typescript
338
+ * // Mixed: stream + single frame
339
+ * for await (using frame of complex.frames('out', {
340
+ * '0:v': decoder.frames(packets), // Stream
341
+ * '1:v': watermarkFrame // Single frame (used for all)
342
+ * })) {
343
+ * await encoder.encode(frame);
344
+ * }
345
+ * ```
346
+ *
347
+ * @see {@link process} For manual frame sending
348
+ * @see {@link receive} For manual frame receiving
349
+ * @see {@link framesSync} For sync version
350
+ */
351
+ frames(outLabel: string, inputs: Record<string, AsyncIterable<Frame | null> | Frame | null>): AsyncGenerator<Frame | null>;
352
+ /**
353
+ * Process frame streams from multiple inputs and yield frames from specified output synchronously.
354
+ * Synchronous version of frames.
355
+ *
356
+ * High-level sync generator for multi-input filtering.
357
+ * Inputs may end at different times - shorter inputs are flushed individually
358
+ * while the remaining inputs keep flowing, matching ffmpeg CLI behaviour.
359
+ *
360
+ * **EOF Handling:**
361
+ * - EOF (null) from one input flushes only that input; the others continue
362
+ * - When ALL inputs have ended and at least one signaled EOF, the graph is
363
+ * finalized and the generator yields null
364
+ * - Iterator completion without null does not trigger a flush - the filter
365
+ * stays open until EOF or close()
366
+ *
367
+ * @param outLabel - Output label to receive frames from
368
+ *
369
+ * @param inputs - Record mapping input labels to frame sources (Iterable, single Frame, or null)
370
+ *
371
+ * @yields {Frame | null} Filtered frames from output, followed by null when flushed
372
+ *
373
+ * @throws {Error} If input label not found or filter not initialized
374
+ *
375
+ * @throws {FFmpegError} If processing fails
376
+ *
377
+ * @example
378
+ * ```typescript
379
+ * // Stream processing: 2 inputs, 1 output
380
+ * using complex = FilterComplexAPI.create('[0:v][1:v]overlay[out]', {
381
+ * inputs: [{ label: '0:v' }, { label: '1:v' }],
382
+ * outputs: [{ label: 'out' }]
383
+ * });
384
+ *
385
+ * // Note: Sync version requires async initialization first
386
+ * await complex.process('0:v', firstFrame1);
387
+ * await complex.process('1:v', firstFrame2);
388
+ *
389
+ * for (using frame of complex.framesSync('out', {
390
+ * '0:v': decoder1.framesSync(packets1),
391
+ * '1:v': decoder2.framesSync(packets2)
392
+ * })) {
393
+ * encoder.encodeSync(frame);
394
+ * }
395
+ * ```
396
+ *
397
+ * @example
398
+ * ```typescript
399
+ * // Single frames
400
+ * for (using frame of complex.framesSync('out', {
401
+ * '0:v': frame1,
402
+ * '1:v': frame2
403
+ * })) {
404
+ * encoder.encodeSync(frame);
405
+ * }
406
+ * ```
407
+ *
408
+ * @example
409
+ * ```typescript
410
+ * // Explicit flush
411
+ * for (using frame of complex.framesSync('out', {
412
+ * '0:v': null,
413
+ * '1:v': null
414
+ * })) {
415
+ * encoder.encodeSync(frame);
416
+ * }
417
+ * ```
418
+ *
419
+ * @see {@link processSync} For manual frame sending
420
+ * @see {@link receiveSync} For manual frame receiving
421
+ * @see {@link frames} For async version with lazy initialization
422
+ */
423
+ framesSync(outLabel: string, inputs: Record<string, Iterable<Frame | null> | Frame | null>): Generator<Frame | null>;
424
+ /**
425
+ * Flush input(s) and signal end-of-stream.
426
+ *
427
+ * Sends null frame to buffersrc filter(s) to flush buffered data.
428
+ * Must call receive() on outputs to get flushed frames.
429
+ * Does nothing if filter is closed or was never initialized.
430
+ *
431
+ * Direct mapping to av_buffersrc_add_frame(NULL).
432
+ *
433
+ * @param inLabel - Input label to flush. If not specified, flushes all inputs.
434
+ *
435
+ * @throws {Error} If input label not found
436
+ *
437
+ * @throws {FFmpegError} If flush fails
438
+ *
439
+ * @example
440
+ * ```typescript
441
+ * // Flush specific input
442
+ * await complex.flush('0:v');
443
+ *
444
+ * // Flush all inputs
445
+ * await complex.flush();
446
+ *
447
+ * // Get remaining frames from output
448
+ * let frame;
449
+ * while ((frame = await complex.receive('out')) !== null) {
450
+ * frame.free();
451
+ * }
452
+ * ```
453
+ *
454
+ * @see {@link flushFrames} For async iteration
455
+ * @see {@link receive} For getting flushed frames
456
+ * @see {@link flushSync} For synchronous version
457
+ */
458
+ flush(inLabel?: string): Promise<void>;
459
+ /**
460
+ * Flush input(s) and signal end-of-stream synchronously.
461
+ * Synchronous version of flush.
462
+ *
463
+ * Sends null frame to buffersrc filter(s) to flush buffered data.
464
+ * Must call receiveSync() on outputs to get flushed frames.
465
+ * Does nothing if filter is closed or was never initialized.
466
+ *
467
+ * Direct mapping to av_buffersrc_add_frame(NULL).
468
+ *
469
+ * @param inLabel - Input label to flush. If not specified, flushes all inputs.
470
+ *
471
+ * @throws {Error} If input label not found
472
+ *
473
+ * @throws {FFmpegError} If flush fails
474
+ *
475
+ * @example
476
+ * ```typescript
477
+ * // Flush specific input
478
+ * complex.flushSync('0:v');
479
+ *
480
+ * // Flush all inputs
481
+ * complex.flushSync();
482
+ *
483
+ * // Get remaining frames from output
484
+ * let frame;
485
+ * while ((frame = complex.receiveSync('out')) !== null) {
486
+ * frame.free();
487
+ * }
488
+ * ```
489
+ *
490
+ * @see {@link flushFramesSync} For sync iteration
491
+ * @see {@link receiveSync} For getting flushed frames
492
+ * @see {@link flush} For async version
493
+ */
494
+ flushSync(inLabel?: string): void;
495
+ /**
496
+ * Flush all inputs and yield remaining frames from specified output.
497
+ *
498
+ * Convenience method that:
499
+ * 1. Calls flush() to send EOF to all inputs
500
+ * 2. Yields all remaining frames from the specified output
501
+ * 3. Continues until EOF is reached
502
+ *
503
+ * Automatically frees yielded frames after use (using declaration).
504
+ *
505
+ * @param outLabel - Output label to receive flushed frames from
506
+ *
507
+ * @yields {Frame} Remaining frames from filter after flush
508
+ *
509
+ * @throws {Error} If output label not found or filter not initialized
510
+ *
511
+ * @throws {FFmpegError} If flushing or receiving fails
512
+ *
513
+ * @example
514
+ * ```typescript
515
+ * // Process all frames, then flush
516
+ * for await (using frame of inputFrames) {
517
+ * await complex.process('0:v', frame);
518
+ * }
519
+ *
520
+ * // Get all remaining frames
521
+ * for await (using frame of complex.flushFrames('out')) {
522
+ * await encoder.encode(frame);
523
+ * }
524
+ * ```
525
+ *
526
+ * @see {@link flush} For flushing without iteration
527
+ * @see {@link receive} For manual frame retrieval
528
+ * @see {@link flushFramesSync} For synchronous version
529
+ */
530
+ flushFrames(outLabel: string): AsyncGenerator<Frame>;
531
+ /**
532
+ * Flush all inputs and yield remaining frames from specified output synchronously.
533
+ * Synchronous version of flushFrames.
534
+ *
535
+ * Convenience method that:
536
+ * 1. Calls flushSync() to send EOF to all inputs
537
+ * 2. Yields all remaining frames from the specified output
538
+ * 3. Continues until EOF is reached
539
+ *
540
+ * Automatically frees yielded frames after use (using declaration).
541
+ *
542
+ * @param outLabel - Output label to receive flushed frames from
543
+ *
544
+ * @yields {Frame} Remaining frames from filter after flush
545
+ *
546
+ * @throws {Error} If output label not found or filter not initialized
547
+ *
548
+ * @throws {FFmpegError} If flushing or receiving fails
549
+ *
550
+ * @example
551
+ * ```typescript
552
+ * // Process all frames, then flush
553
+ * for (using frame of inputFrames) {
554
+ * complex.processSync('0:v', frame);
555
+ * }
556
+ *
557
+ * // Get all remaining frames
558
+ * for (using frame of complex.flushFramesSync('out')) {
559
+ * encoder.encodeSync(frame);
560
+ * }
561
+ * ```
562
+ *
563
+ * @see {@link flushSync} For flushing without iteration
564
+ * @see {@link receiveSync} For manual frame retrieval
565
+ * @see {@link flushFrames} For async version
566
+ */
567
+ flushFramesSync(outLabel: string): Generator<Frame>;
568
+ /**
569
+ * Receive filtered frame from specified output.
570
+ *
571
+ * Pulls a single frame from the buffersink of the specified output.
572
+ * Automatically post-processes frame (sets timeBase, calculates duration).
573
+ * Returns cloned frame - caller must free it.
574
+ *
575
+ * Return values:
576
+ * - Frame: Successfully received frame (caller must free)
577
+ * - null: Need more input (AVERROR_EAGAIN) - call process() to send more frames
578
+ * - EOF: End of stream reached
579
+ *
580
+ * Direct mapping to av_buffersink_get_frame().
581
+ *
582
+ * @param outLabel - Output label to receive from
583
+ *
584
+ * @returns Frame on success, null if need more input, EOF if finished
585
+ *
586
+ * @throws {Error} If output label not found or filter not initialized
587
+ *
588
+ * @throws {FFmpegError} If receive fails with unexpected error
589
+ *
590
+ * @example
591
+ * ```typescript
592
+ * // Process frames one at a time
593
+ * await complex.process('0:v', frame1);
594
+ * const outFrame = await complex.receive('out');
595
+ * if (outFrame && outFrame !== EOF) {
596
+ * // Use frame
597
+ * outFrame.free();
598
+ * }
599
+ * ```
600
+ *
601
+ * @see {@link process} For sending input frames
602
+ * @see {@link flush} For flushing after all input
603
+ * @see {@link receiveSync} For synchronous version
604
+ */
605
+ receive(outLabel: string): Promise<Frame | EOFSignal | null>;
606
+ /**
607
+ * Receive filtered frame from specified output synchronously.
608
+ * Synchronous version of receive.
609
+ *
610
+ * Pulls a single frame from the buffersink of the specified output.
611
+ * Automatically post-processes frame (sets timeBase, calculates duration).
612
+ * Returns cloned frame - caller must free it.
613
+ *
614
+ * Return values:
615
+ * - Frame: Successfully received frame (caller must free)
616
+ * - null: Need more input (AVERROR_EAGAIN) - call processSync() to send more frames
617
+ * - EOF: End of stream reached
618
+ *
619
+ * Direct mapping to av_buffersink_get_frame().
620
+ *
621
+ * @param outLabel - Output label to receive from
622
+ *
623
+ * @returns Frame on success, null if need more input, EOF if finished
624
+ *
625
+ * @throws {Error} If output label not found or filter not initialized
626
+ *
627
+ * @throws {FFmpegError} If receive fails with unexpected error
628
+ *
629
+ * @example
630
+ * ```typescript
631
+ * // Process frames one at a time
632
+ * complex.processSync('0:v', frame1);
633
+ * const outFrame = complex.receiveSync('out');
634
+ * if (outFrame && outFrame !== EOF) {
635
+ * // Use frame
636
+ * outFrame.free();
637
+ * }
638
+ * ```
639
+ *
640
+ * @see {@link processSync} For sending input frames
641
+ * @see {@link flushSync} For flushing after all input
642
+ * @see {@link receive} For async version
643
+ */
644
+ receiveSync(outLabel: string): Frame | EOFSignal | null;
645
+ /**
646
+ * Check if all inputs have received at least one frame (have format information).
647
+ *
648
+ * @returns true if all inputs have format info (first frame received)
649
+ *
650
+ * @internal
651
+ */
652
+ private hasAllInputFormats;
653
+ /**
654
+ * Initialize filter graph from queued frames.
655
+ *
656
+ * Implements FFmpeg's configure_filtergraph() logic:
657
+ * 1. Create buffersrc filters from first queued frame of each input
658
+ * 2. Parse filter description
659
+ * 3. Create buffersink filters
660
+ * 4. Configure graph with avfilter_graph_config()
661
+ * 5. Send all queued frames to buffersrc
662
+ *
663
+ * @throws {Error} If initialization fails
664
+ *
665
+ * @throws {FFmpegError} If configuration fails
666
+ *
667
+ * @internal
668
+ */
669
+ private initializeFromQueuedFrames;
670
+ /**
671
+ * Initialize filter graph from queued frames synchronously.
672
+ * Synchronous version of initializeFromQueuedFrames.
673
+ *
674
+ * @throws {Error} If closed or inputs have no queued frames
675
+ *
676
+ * @throws {FFmpegError} If graph configuration or frame processing fails
677
+ *
678
+ * @internal
679
+ */
680
+ private initializeFromQueuedFramesSync;
681
+ /**
682
+ * Calculate timeBase from frame based on media type and CFR option.
683
+ *
684
+ * Implements FFmpeg's ifilter_parameters_from_frame logic:
685
+ * - Audio: Always { 1, sample_rate }
686
+ * - Video CFR: 1/framerate (inverse of framerate)
687
+ * - Video VFR: Use frame.timeBase
688
+ *
689
+ * @param frame - Input frame
690
+ *
691
+ * @returns Calculated timeBase
692
+ *
693
+ * @internal
694
+ */
695
+ private calculateTimeBase;
696
+ /**
697
+ * Rescale frame timestamps to calculated timeBase.
698
+ *
699
+ * Helper to avoid code duplication when rescaling timestamps.
700
+ * Modifies the frame in-place.
701
+ *
702
+ * @param frame - Frame to rescale
703
+ *
704
+ * @param calculatedTimeBase - Target timeBase
705
+ *
706
+ * @internal
707
+ */
708
+ private rescaleFrameTimestamps;
709
+ /**
710
+ * Create buffer source for an input.
711
+ *
712
+ * @param label - Input label
713
+ *
714
+ * @param frame - First frame from this input
715
+ *
716
+ * @param timeBase - Calculated timeBase for this input (from calculateTimeBase)
717
+ *
718
+ * @returns BufferSrc filter context
719
+ *
720
+ * @throws {Error} If creation fails
721
+ *
722
+ * @internal
723
+ */
724
+ private createBufferSource;
725
+ /**
726
+ * Create buffer sink for an output.
727
+ *
728
+ * @param label - Output label
729
+ *
730
+ * @param isVideo - Whether this is a video output
731
+ *
732
+ * @returns BufferSink filter context
733
+ *
734
+ * @throws {Error} If creation fails
735
+ *
736
+ * @internal
737
+ */
738
+ private createBufferSink;
739
+ /**
740
+ * Parse filter description and build graph using segment API.
741
+ *
742
+ * @throws {Error} If parsing fails
743
+ *
744
+ * @throws {FFmpegError} If graph construction fails
745
+ *
746
+ * @internal
747
+ */
748
+ private parseFilterDescription;
749
+ /**
750
+ * Link buffersrc filters to segment inputs.
751
+ *
752
+ * Iterates through FilterInOut chain and links by label.
753
+ *
754
+ * @param inputs - FilterInOut chain of segment inputs
755
+ *
756
+ * @throws {Error} If linking fails
757
+ *
758
+ * @internal
759
+ */
760
+ private linkBufferSources;
761
+ /**
762
+ * Link segment outputs to buffersink filters.
763
+ *
764
+ * Iterates through FilterInOut chain and links by label.
765
+ *
766
+ * @param outputs - FilterInOut chain of segment outputs
767
+ *
768
+ * @throws {Error} If linking fails
769
+ *
770
+ * @internal
771
+ */
772
+ private linkBufferSinks;
773
+ /**
774
+ * Post-process output frame from buffersink.
775
+ *
776
+ * Applies FFmpeg's fg_output_step() behavior:
777
+ * 1. Sets frame.timeBase from buffersink (filters can change timeBase)
778
+ * 2. Calculates video frame duration from frame rate if not set
779
+ *
780
+ * This must be called AFTER buffersinkGetFrame() for every output frame.
781
+ *
782
+ * @param frame - Output frame from buffersink
783
+ *
784
+ * @param buffersink - The buffersink context
785
+ *
786
+ * @internal
787
+ */
788
+ private postProcessOutputFrame;
789
+ /**
790
+ * Close filter complex and release resources.
791
+ *
792
+ * Frees queued frames, filter graph and all filter contexts.
793
+ * Safe to call multiple times.
794
+ *
795
+ * @example
796
+ * ```typescript
797
+ * complex.close();
798
+ * ```
799
+ *
800
+ * @example
801
+ * ```typescript
802
+ * // Automatic cleanup with using
803
+ * {
804
+ * using complex = FilterComplexAPI.create('[0:v]scale=640:480[out]', { ... });
805
+ * // Use complex...
806
+ * } // Automatically freed
807
+ * ```
808
+ *
809
+ * @see {@link Symbol.dispose} For automatic cleanup
810
+ */
811
+ close(): void;
812
+ /**
813
+ * Dispose of filter complex.
814
+ *
815
+ * Implements Disposable interface for automatic cleanup.
816
+ *
817
+ * @example
818
+ * ```typescript
819
+ * {
820
+ * using complex = FilterComplexAPI.create('[0:v]scale=640:480[out]', { ... });
821
+ * // Use complex...
822
+ * } // Automatically freed
823
+ * ```
824
+ *
825
+ * @see {@link close} For manual cleanup
826
+ */
827
+ [Symbol.dispose](): void;
828
+ }