node-av-light 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,783 @@
1
+ import { Filter } from './filter.js';
2
+ import { HardwareDeviceContext } from './hardware-device-context.js';
3
+ import { OptionMember } from './option.js';
4
+ import { Rational } from './rational.js';
5
+ /**
6
+ * Filter instance in a filter graph.
7
+ *
8
+ * Represents an instantiated filter within a filter graph. Each context contains
9
+ * a specific filter configuration with its parameters, connections to other filters,
10
+ * and input/output pads. Supports both software and hardware filtering operations.
11
+ * Essential for building complex filter chains for audio/video processing.
12
+ *
13
+ * A filter context belongs to its filter graph. Once that graph is freed, the context
14
+ * reads its defaults (e.g. name null), ignores writes and its frame operations fail.
15
+ *
16
+ * Direct mapping to FFmpeg's AVFilterContext.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * import { FilterContext, FilterGraph, Filter, FFmpegError } from 'node-av';
21
+ *
22
+ * // Create filter context in a graph
23
+ * const graph = new FilterGraph();
24
+ * const filter = Filter.getByName('scale');
25
+ * const context = graph.createFilter(filter, 'scaler');
26
+ *
27
+ * // Initialize with parameters
28
+ * const ret = context.initStr('640:480');
29
+ * FFmpegError.throwIfError(ret, 'initStr');
30
+ *
31
+ * // Link filters together
32
+ * const ret2 = source.link(0, context, 0);
33
+ * FFmpegError.throwIfError(ret2, 'link');
34
+ *
35
+ * // For buffer source/sink
36
+ * const ret3 = await bufferSrc.buffersrcAddFrame(frame);
37
+ * FFmpegError.throwIfError(ret3, 'buffersrcAddFrame');
38
+ * ```
39
+ *
40
+ * @see [AVFilterContext](https://ffmpeg.org/doxygen/trunk/structAVFilterContext.html) - FFmpeg Doxygen
41
+ * @see {@link FilterGraph} For managing filter graphs
42
+ * @see {@link Filter} For filter descriptors
43
+ */
44
+ export class FilterContext extends OptionMember {
45
+ /**
46
+ * @param native - The native filter context instance
47
+ *
48
+ * @internal
49
+ */
50
+ constructor(native) {
51
+ super(native);
52
+ }
53
+ /**
54
+ * Filter instance name.
55
+ *
56
+ * User-assigned name for this filter instance in the graph.
57
+ * Used for identification and debugging.
58
+ *
59
+ * Direct mapping to AVFilterContext->name.
60
+ */
61
+ get name() {
62
+ return this.native.name;
63
+ }
64
+ set name(value) {
65
+ this.native.name = value;
66
+ }
67
+ /**
68
+ * Filter descriptor.
69
+ *
70
+ * Reference to the filter type this context instantiates.
71
+ *
72
+ * Direct mapping to AVFilterContext->filter.
73
+ */
74
+ get filter() {
75
+ const native = this.native.filter;
76
+ return native ? new Filter(native) : null;
77
+ }
78
+ /**
79
+ * Parent filter graph.
80
+ *
81
+ * Reference to the graph containing this filter context.
82
+ *
83
+ * Direct mapping to AVFilterContext->graph.
84
+ */
85
+ get graph() {
86
+ return this.native.graph;
87
+ }
88
+ /**
89
+ * Number of input pads.
90
+ *
91
+ * Total number of input connections this filter can accept.
92
+ *
93
+ * Direct mapping to AVFilterContext->nb_inputs.
94
+ */
95
+ get nbInputs() {
96
+ return this.native.nbInputs;
97
+ }
98
+ /**
99
+ * Number of output pads.
100
+ *
101
+ * Total number of output connections this filter can provide.
102
+ *
103
+ * Direct mapping to AVFilterContext->nb_outputs.
104
+ */
105
+ get nbOutputs() {
106
+ return this.native.nbOutputs;
107
+ }
108
+ /**
109
+ * Hardware device context.
110
+ *
111
+ * Hardware acceleration context for GPU-based filtering.
112
+ * Set to enable hardware-accelerated filter operations.
113
+ *
114
+ * Direct mapping to AVFilterContext->hw_device_ctx.
115
+ */
116
+ get hwDeviceCtx() {
117
+ // Not cached: the native getter returns a fresh object per access, so an
118
+ // identity-based cache can never hit
119
+ const native = this.native.hwDeviceCtx;
120
+ if (!native) {
121
+ return null;
122
+ }
123
+ const device = Object.create(HardwareDeviceContext.prototype);
124
+ device.native = native;
125
+ return device;
126
+ }
127
+ set hwDeviceCtx(value) {
128
+ this.native.hwDeviceCtx = value?.getNative() ?? null;
129
+ }
130
+ /**
131
+ * Number of extra hardware frames to allocate.
132
+ *
133
+ * Specifies additional hardware frame buffers for filters that need them.
134
+ * Useful for deinterlacing or other filters requiring frame buffering.
135
+ *
136
+ * Direct mapping to AVFilterContext->extra_hw_frames.
137
+ */
138
+ get extraHWFrames() {
139
+ return this.native.extraHWFrames;
140
+ }
141
+ set extraHWFrames(value) {
142
+ this.native.extraHWFrames = value;
143
+ }
144
+ /**
145
+ * Initialize filter with dictionary options.
146
+ *
147
+ * Configures the filter with key-value option pairs.
148
+ * Must be called after creation and before processing.
149
+ *
150
+ * Direct mapping to avfilter_init_dict().
151
+ *
152
+ * @param options - Dictionary of filter options
153
+ *
154
+ * @returns 0 on success, negative AVERROR on error:
155
+ * - AVERROR_EINVAL: Invalid parameters
156
+ * - AVERROR_ENOMEM: Memory allocation failure
157
+ *
158
+ * @example
159
+ * ```typescript
160
+ * import { FFmpegError } from 'node-av';
161
+ *
162
+ * const options = { width: '1920', height: '1080' };
163
+ * const ret = context.init(options);
164
+ * FFmpegError.throwIfError(ret, 'init');
165
+ * ```
166
+ *
167
+ * @see {@link initStr} For string-based initialization
168
+ */
169
+ init(options = null) {
170
+ return this.native.init(options ?? null);
171
+ }
172
+ /**
173
+ * Initialize filter with string arguments.
174
+ *
175
+ * Configures the filter using a string representation of parameters.
176
+ * Format depends on the specific filter.
177
+ *
178
+ * Direct mapping to avfilter_init_str().
179
+ *
180
+ * @param args - Filter arguments string
181
+ *
182
+ * @returns 0 on success, negative AVERROR on error:
183
+ * - AVERROR_EINVAL: Invalid arguments
184
+ * - AVERROR_ENOMEM: Memory allocation failure
185
+ *
186
+ * @example
187
+ * ```typescript
188
+ * import { FFmpegError } from 'node-av';
189
+ *
190
+ * // Scale filter with width:height
191
+ * const ret = scaleContext.initStr('1920:1080');
192
+ * FFmpegError.throwIfError(ret, 'initStr');
193
+ *
194
+ * // Crop filter with width:height:x:y
195
+ * const ret2 = cropContext.initStr('640:480:100:50');
196
+ * FFmpegError.throwIfError(ret2, 'initStr');
197
+ * ```
198
+ *
199
+ * @see {@link init} For dictionary-based initialization
200
+ */
201
+ initStr(args = null) {
202
+ return this.native.initStr(args ?? null);
203
+ }
204
+ /**
205
+ * Link this filter's output to another filter's input.
206
+ *
207
+ * Creates a connection between two filters in the graph.
208
+ * Data flows from this filter's output pad to the destination's input pad.
209
+ *
210
+ * Direct mapping to avfilter_link().
211
+ *
212
+ * @param srcPad - Output pad index of this filter
213
+ *
214
+ * @param dst - Destination filter context
215
+ *
216
+ * @param dstPad - Input pad index of destination filter
217
+ *
218
+ * @returns 0 on success, negative AVERROR on error:
219
+ * - AVERROR_EINVAL: Invalid pad indices or incompatible formats
220
+ * - AVERROR_ENOMEM: Memory allocation failure
221
+ *
222
+ * @example
223
+ * ```typescript
224
+ * import { FFmpegError } from 'node-av';
225
+ *
226
+ * // Link source output 0 to scale input 0
227
+ * const ret = source.link(0, scale, 0);
228
+ * FFmpegError.throwIfError(ret, 'link');
229
+ *
230
+ * // Link scale output 0 to sink input 0
231
+ * const ret2 = scale.link(0, sink, 0);
232
+ * FFmpegError.throwIfError(ret2, 'link');
233
+ * ```
234
+ *
235
+ * @see {@link unlink} To disconnect filters
236
+ */
237
+ link(srcPad, dst, dstPad) {
238
+ return this.native.link(srcPad, dst.native, dstPad);
239
+ }
240
+ /**
241
+ * Unlink a filter pad.
242
+ *
243
+ * Disconnects a pad from its linked filter.
244
+ * Used to reconfigure filter connections.
245
+ *
246
+ * Direct mapping to avfilter_link_free().
247
+ *
248
+ * @param pad - Pad index to unlink
249
+ *
250
+ * @example
251
+ * ```typescript
252
+ * // Disconnect output pad 0
253
+ * context.unlink(0);
254
+ * ```
255
+ *
256
+ * @see {@link link} To connect filters
257
+ */
258
+ unlink(pad) {
259
+ this.native.unlink(pad);
260
+ }
261
+ /**
262
+ * Add a frame to a buffer source filter.
263
+ *
264
+ * Sends a frame into the filter graph through a buffer source.
265
+ * Only valid for buffer source filters. Send null to signal EOF.
266
+ *
267
+ * Direct mapping to av_buffersrc_add_frame_flags().
268
+ *
269
+ * @param frame - Frame to send, or null for EOF
270
+ *
271
+ * @param flags - Optional buffersrc flags (defaults to AV_BUFFERSRC_FLAG_NONE = 0)
272
+ *
273
+ * @returns 0 on success, negative AVERROR on error:
274
+ * - AVERROR_EAGAIN: Filter needs more output consumption
275
+ * - AVERROR_EOF: Filter has been closed
276
+ * - AVERROR_EINVAL: Not a buffer source filter
277
+ * - AVERROR_ENOMEM: Memory allocation failure
278
+ *
279
+ * @example
280
+ * ```typescript
281
+ * import { FFmpegError } from 'node-av';
282
+ * import { AVERROR_EAGAIN, AV_BUFFERSRC_FLAG_PUSH } from 'node-av/constants';
283
+ *
284
+ * // Send frame to filter graph with PUSH flag (immediate processing)
285
+ * const ret = await bufferSrc.buffersrcAddFrame(frame, AV_BUFFERSRC_FLAG_PUSH);
286
+ * if (ret === AVERROR_EAGAIN) {
287
+ * // Need to consume output first
288
+ * } else {
289
+ * FFmpegError.throwIfError(ret, 'buffersrcAddFrame');
290
+ * }
291
+ *
292
+ * // Signal EOF
293
+ * await bufferSrc.buffersrcAddFrame(null);
294
+ * ```
295
+ *
296
+ * @see {@link buffersinkGetFrame} To retrieve filtered frames
297
+ */
298
+ async buffersrcAddFrame(frame, flags) {
299
+ return await this.native.buffersrcAddFrame(frame ? frame.getNative() : null, flags);
300
+ }
301
+ /**
302
+ * Add frame to buffer source filter synchronously.
303
+ * Synchronous version of buffersrcAddFrame.
304
+ *
305
+ * Sends a frame to a buffer source filter for processing.
306
+ * Only valid for buffer source filters (buffer, abuffer).
307
+ *
308
+ * Direct mapping to av_buffersrc_add_frame_flags().
309
+ *
310
+ * @param frame - Frame to send (null to mark EOF)
311
+ *
312
+ * @param flags - Optional buffersrc flags (defaults to AV_BUFFERSRC_FLAG_NONE = 0)
313
+ *
314
+ * @returns 0 on success, negative AVERROR on error:
315
+ * - AVERROR_EAGAIN: Need to retrieve output first
316
+ * - AVERROR_EOF: Graph has finished processing
317
+ * - AVERROR_EINVAL: Invalid parameters
318
+ * - AVERROR(ENOMEM): Memory allocation failure
319
+ *
320
+ * @example
321
+ * ```typescript
322
+ * import { FFmpegError } from 'node-av';
323
+ * import { AVERROR_EAGAIN, AV_BUFFERSRC_FLAG_PUSH } from 'node-av/constants';
324
+ *
325
+ * // Send frame to filter with PUSH flag (immediate processing)
326
+ * const ret = bufferSrc.buffersrcAddFrameSync(frame, AV_BUFFERSRC_FLAG_PUSH);
327
+ * if (ret === AVERROR_EAGAIN) {
328
+ * // Need to get output frames first
329
+ * const filtered = new Frame();
330
+ * bufferSink.buffersinkGetFrameSync(filtered);
331
+ * } else {
332
+ * FFmpegError.throwIfError(ret, 'buffersrcAddFrameSync');
333
+ * }
334
+ *
335
+ * // Mark end of stream
336
+ * bufferSrc.buffersrcAddFrameSync(null);
337
+ * ```
338
+ *
339
+ * @see {@link buffersrcAddFrame} For async version
340
+ */
341
+ buffersrcAddFrameSync(frame, flags) {
342
+ return this.native.buffersrcAddFrameSync(frame ? frame.getNative() : null, flags);
343
+ }
344
+ /**
345
+ * Set parameters for a buffer source filter.
346
+ *
347
+ * Configures the format and properties of frames that will be sent
348
+ * to the buffer source. Must be called before sending frames.
349
+ *
350
+ * Direct mapping to av_buffersrc_parameters_set().
351
+ *
352
+ * @param params - Source parameters
353
+ *
354
+ * @param params.width - Video frame width
355
+ *
356
+ * @param params.height - Video frame height
357
+ *
358
+ * @param params.format - Pixel or sample format
359
+ *
360
+ * @param params.timeBase - Time base for timestamps
361
+ *
362
+ * @param params.frameRate - Video frame rate
363
+ *
364
+ * @param params.sampleAspectRatio - Pixel aspect ratio
365
+ *
366
+ * @param params.hwFramesCtx - Hardware frames context
367
+ *
368
+ * @param params.sampleRate - Audio sample rate
369
+ *
370
+ * @param params.channelLayout - Audio channel layout
371
+ *
372
+ * @param params.colorRange - Color range for video
373
+ *
374
+ * @param params.colorSpace - Color space for video
375
+ *
376
+ * @param params.alphaMode - Alpha channel mode
377
+ *
378
+ * @returns 0 on success, negative AVERROR on error:
379
+ * - AVERROR_EINVAL: Invalid parameters
380
+ * - AVERROR_ENOMEM: Memory allocation failure
381
+ *
382
+ * @example
383
+ * ```typescript
384
+ * import { FFmpegError, Rational } from 'node-av';
385
+ * import { AV_PIX_FMT_YUV420P } from 'node-av/constants';
386
+ *
387
+ * // Configure video buffer source
388
+ * const ret = bufferSrc.buffersrcParametersSet({
389
+ * width: 1920,
390
+ * height: 1080,
391
+ * format: AV_PIX_FMT_YUV420P,
392
+ * timeBase: { num: 1, den: 25 },
393
+ * frameRate: { num: 25, den: 1 }
394
+ * });
395
+ * FFmpegError.throwIfError(ret, 'buffersrcParametersSet');
396
+ *
397
+ * @example
398
+ * ```typescript
399
+ * import { FFmpegError } from 'node-av';
400
+ * import { AV_SAMPLE_FMT_FLTP } from 'node-av/constants';
401
+ *
402
+ * // Configure audio buffer source
403
+ * const ret = bufferSrc.buffersrcParametersSet({
404
+ * format: AV_SAMPLE_FMT_FLTP,
405
+ * sampleRate: 44100,
406
+ * channelLayout: AV_CHANNEL_LAYOUT_STEREO
407
+ * });
408
+ * FFmpegError.throwIfError(ret, 'buffersrcParametersSet');
409
+ * ```
410
+ */
411
+ buffersrcParametersSet(params) {
412
+ const nativeParams = { ...params };
413
+ if (params.hwFramesCtx) {
414
+ nativeParams.hwFramesCtx = params.hwFramesCtx.getNative();
415
+ }
416
+ return this.native.buffersrcParametersSet(nativeParams);
417
+ }
418
+ /**
419
+ * Get a frame from a buffer sink filter.
420
+ *
421
+ * Retrieves a filtered frame from the filter graph through a buffer sink.
422
+ * Only valid for buffer sink filters.
423
+ *
424
+ * Direct mapping to av_buffersink_get_frame().
425
+ *
426
+ * @param frame - Frame to receive filtered data
427
+ *
428
+ * @returns 0 on success, negative AVERROR on error:
429
+ * - AVERROR_EAGAIN: No frame available yet
430
+ * - AVERROR_EOF: No more frames will be produced
431
+ * - AVERROR_EINVAL: Not a buffer sink filter
432
+ *
433
+ * @example
434
+ * ```typescript
435
+ * import { FFmpegError, Frame } from 'node-av';
436
+ * import { AVERROR_EAGAIN, AVERROR_EOF } from 'node-av/constants';
437
+ *
438
+ * const frame = new Frame();
439
+ * frame.alloc();
440
+ *
441
+ * const ret = await bufferSink.buffersinkGetFrame(frame);
442
+ * if (ret === AVERROR_EAGAIN) {
443
+ * // No frame available yet
444
+ * } else if (ret === AVERROR_EOF) {
445
+ * // End of stream
446
+ * } else {
447
+ * FFmpegError.throwIfError(ret, 'buffersinkGetFrame');
448
+ * // Process filtered frame
449
+ * }
450
+ * ```
451
+ *
452
+ * @see {@link buffersrcAddFrame} To send frames for filtering
453
+ */
454
+ async buffersinkGetFrame(frame) {
455
+ return await this.native.buffersinkGetFrame(frame.getNative());
456
+ }
457
+ /**
458
+ * Get frame from buffer sink filter synchronously.
459
+ * Synchronous version of buffersinkGetFrame.
460
+ *
461
+ * Retrieves a filtered frame from a buffer sink filter.
462
+ * Only valid for buffer sink filters (buffersink, abuffersink).
463
+ *
464
+ * Direct mapping to av_buffersink_get_frame().
465
+ *
466
+ * @param frame - Frame to receive filtered data
467
+ *
468
+ * @returns 0 on success, negative AVERROR on error:
469
+ * - AVERROR_EAGAIN: Need more input
470
+ * - AVERROR_EOF: No more frames available
471
+ * - AVERROR_EINVAL: Invalid parameters
472
+ *
473
+ * @example
474
+ * ```typescript
475
+ * import { Frame, FFmpegError } from 'node-av';
476
+ * import { AVERROR_EAGAIN, AVERROR_EOF } from 'node-av/constants';
477
+ *
478
+ * // Get filtered frame
479
+ * const filtered = new Frame();
480
+ * const ret = bufferSink.buffersinkGetFrameSync(filtered);
481
+ *
482
+ * if (ret === 0) {
483
+ * // Process filtered frame
484
+ * console.log(`Got filtered frame with ${filtered.nbSamples} samples`);
485
+ * filtered.unref();
486
+ * } else if (ret === AVERROR_EAGAIN) {
487
+ * // Need more input frames
488
+ * } else if (ret === AVERROR_EOF) {
489
+ * // No more frames
490
+ * } else {
491
+ * FFmpegError.throwIfError(ret, 'buffersinkGetFrameSync');
492
+ * }
493
+ * ```
494
+ *
495
+ * @see {@link buffersinkGetFrame} For async version
496
+ */
497
+ buffersinkGetFrameSync(frame) {
498
+ return this.native.buffersinkGetFrameSync(frame.getNative());
499
+ }
500
+ /**
501
+ * Get time base from buffer sink.
502
+ *
503
+ * Returns the time base of frames from a buffer sink filter.
504
+ * Only valid for buffer sink filters.
505
+ *
506
+ * Direct mapping to av_buffersink_get_time_base().
507
+ *
508
+ * @returns Time base as Rational
509
+ *
510
+ * @example
511
+ * ```typescript
512
+ * const timeBase = bufferSink.buffersinkGetTimeBase();
513
+ * console.log(`Time base: ${timeBase.num}/${timeBase.den}`);
514
+ * ```
515
+ */
516
+ buffersinkGetTimeBase() {
517
+ const tb = this.native.buffersinkGetTimeBase();
518
+ return new Rational(tb.num, tb.den);
519
+ }
520
+ /**
521
+ * Get pixel/sample format from buffer sink.
522
+ *
523
+ * Returns the format of frames from a buffer sink filter.
524
+ * Only valid for buffer sink filters.
525
+ *
526
+ * Direct mapping to av_buffersink_get_format().
527
+ *
528
+ * @returns Pixel format for video, sample format for audio
529
+ *
530
+ * @example
531
+ * ```typescript
532
+ * import { AV_PIX_FMT_YUV420P } from 'node-av/constants';
533
+ *
534
+ * const format = bufferSink.buffersinkGetFormat();
535
+ * if (format === AV_PIX_FMT_YUV420P) {
536
+ * console.log('Output is YUV420P');
537
+ * }
538
+ * ```
539
+ */
540
+ buffersinkGetFormat() {
541
+ return this.native.buffersinkGetFormat();
542
+ }
543
+ /**
544
+ * Get frame width from buffer sink.
545
+ *
546
+ * Returns the width of video frames from a buffer sink filter.
547
+ * Only valid for video buffer sink filters.
548
+ *
549
+ * Direct mapping to av_buffersink_get_w().
550
+ *
551
+ * @returns Frame width in pixels
552
+ *
553
+ * @example
554
+ * ```typescript
555
+ * const width = bufferSink.buffersinkGetWidth();
556
+ * console.log(`Output width: ${width}px`);
557
+ * ```
558
+ */
559
+ buffersinkGetWidth() {
560
+ return this.native.buffersinkGetWidth();
561
+ }
562
+ /**
563
+ * Get frame height from buffer sink.
564
+ *
565
+ * Returns the height of video frames from a buffer sink filter.
566
+ * Only valid for video buffer sink filters.
567
+ *
568
+ * Direct mapping to av_buffersink_get_h().
569
+ *
570
+ * @returns Frame height in pixels
571
+ *
572
+ * @example
573
+ * ```typescript
574
+ * const height = bufferSink.buffersinkGetHeight();
575
+ * console.log(`Output height: ${height}px`);
576
+ * ```
577
+ */
578
+ buffersinkGetHeight() {
579
+ return this.native.buffersinkGetHeight();
580
+ }
581
+ /**
582
+ * Get sample aspect ratio from buffer sink.
583
+ *
584
+ * Returns the pixel aspect ratio of video frames from a buffer sink filter.
585
+ * Only valid for video buffer sink filters.
586
+ *
587
+ * Direct mapping to av_buffersink_get_sample_aspect_ratio().
588
+ *
589
+ * @returns Sample aspect ratio as Rational
590
+ *
591
+ * @example
592
+ * ```typescript
593
+ * const sar = bufferSink.buffersinkGetSampleAspectRatio();
594
+ * console.log(`SAR: ${sar.num}:${sar.den}`);
595
+ * ```
596
+ */
597
+ buffersinkGetSampleAspectRatio() {
598
+ const sar = this.native.buffersinkGetSampleAspectRatio();
599
+ return new Rational(sar.num, sar.den);
600
+ }
601
+ /**
602
+ * Get frame rate from buffer sink.
603
+ *
604
+ * Returns the frame rate of video from a buffer sink filter.
605
+ * Only valid for video buffer sink filters.
606
+ *
607
+ * Direct mapping to av_buffersink_get_frame_rate().
608
+ *
609
+ * @returns Frame rate as Rational
610
+ *
611
+ * @example
612
+ * ```typescript
613
+ * const frameRate = bufferSink.buffersinkGetFrameRate();
614
+ * console.log(`Frame rate: ${frameRate.num}/${frameRate.den} fps`);
615
+ * ```
616
+ */
617
+ buffersinkGetFrameRate() {
618
+ const fr = this.native.buffersinkGetFrameRate();
619
+ return new Rational(fr.num, fr.den);
620
+ }
621
+ /**
622
+ * Get sample rate from buffer sink.
623
+ *
624
+ * Returns the sample rate of audio from a buffer sink filter.
625
+ * Only valid for audio buffer sink filters.
626
+ *
627
+ * Direct mapping to av_buffersink_get_sample_rate().
628
+ *
629
+ * @returns Sample rate in Hz
630
+ *
631
+ * @example
632
+ * ```typescript
633
+ * const sampleRate = bufferSink.buffersinkGetSampleRate();
634
+ * console.log(`Sample rate: ${sampleRate} Hz`);
635
+ * ```
636
+ */
637
+ buffersinkGetSampleRate() {
638
+ return this.native.buffersinkGetSampleRate();
639
+ }
640
+ /**
641
+ * Get channel layout from buffer sink.
642
+ *
643
+ * Returns the channel layout of audio from a buffer sink filter.
644
+ * Only valid for audio buffer sink filters.
645
+ *
646
+ * Direct mapping to av_buffersink_get_channel_layout().
647
+ *
648
+ * @returns Channel layout configuration
649
+ *
650
+ * @example
651
+ * ```typescript
652
+ * const layout = bufferSink.buffersinkGetChannelLayout();
653
+ * console.log(`Channels: ${layout.nbChannels}`);
654
+ * ```
655
+ */
656
+ buffersinkGetChannelLayout() {
657
+ return this.native.buffersinkGetChannelLayout();
658
+ }
659
+ /**
660
+ * Get color space from buffer sink.
661
+ *
662
+ * Returns the color space of video from a buffer sink filter.
663
+ * Only valid for video buffer sink filters.
664
+ *
665
+ * Direct mapping to av_buffersink_get_colorspace().
666
+ *
667
+ * @returns Color space
668
+ *
669
+ * @example
670
+ * ```typescript
671
+ * const colorSpace = bufferSink.buffersinkGetColorspace();
672
+ * console.log(`Color space: ${colorSpace}`);
673
+ * ```
674
+ */
675
+ buffersinkGetColorspace() {
676
+ return this.native.buffersinkGetColorspace();
677
+ }
678
+ /**
679
+ * Get color range from buffer sink.
680
+ *
681
+ * Returns the color range of video from a buffer sink filter.
682
+ * Only valid for video buffer sink filters.
683
+ *
684
+ * Direct mapping to av_buffersink_get_color_range().
685
+ *
686
+ * @returns Color range
687
+ *
688
+ * @example
689
+ * ```typescript
690
+ * const colorRange = bufferSink.buffersinkGetColorRange();
691
+ * console.log(`Color range: ${colorRange}`);
692
+ * ```
693
+ */
694
+ buffersinkGetColorRange() {
695
+ return this.native.buffersinkGetColorRange();
696
+ }
697
+ /**
698
+ * Free the filter context.
699
+ *
700
+ * Releases all resources associated with the filter context.
701
+ * The context becomes invalid after calling this.
702
+ *
703
+ * Direct mapping to avfilter_free().
704
+ *
705
+ * @example
706
+ * ```typescript
707
+ * context.free();
708
+ * // Context is now invalid
709
+ * ```
710
+ *
711
+ * @see {@link Symbol.dispose} For automatic cleanup
712
+ */
713
+ free() {
714
+ this.native.free();
715
+ }
716
+ /**
717
+ * Check if filter is a source.
718
+ *
719
+ * Source filters generate frames without input.
720
+ *
721
+ * @returns True if filter has no inputs
722
+ *
723
+ * @example
724
+ * ```typescript
725
+ * if (context.isSource()) {
726
+ * console.log('This is a source filter');
727
+ * }
728
+ * ```
729
+ *
730
+ * @see {@link isSink} To check for sink filters
731
+ */
732
+ isSource() {
733
+ return this.nbInputs === 0;
734
+ }
735
+ /**
736
+ * Check if filter is a sink.
737
+ *
738
+ * Sink filters consume frames without output.
739
+ *
740
+ * @returns True if filter has no outputs
741
+ *
742
+ * @example
743
+ * ```typescript
744
+ * if (context.isSink()) {
745
+ * console.log('This is a sink filter');
746
+ * }
747
+ * ```
748
+ *
749
+ * @see {@link isSource} To check for source filters
750
+ */
751
+ isSink() {
752
+ return this.nbOutputs === 0;
753
+ }
754
+ /**
755
+ * Get the underlying native FilterContext object.
756
+ *
757
+ * @returns The native FilterContext binding object
758
+ *
759
+ * @internal
760
+ */
761
+ getNative() {
762
+ return this.native;
763
+ }
764
+ /**
765
+ * Dispose of the filter context.
766
+ *
767
+ * Implements the Disposable interface for automatic cleanup.
768
+ * Equivalent to calling free().
769
+ *
770
+ * @example
771
+ * ```typescript
772
+ * {
773
+ * using context = graph.createFilter(filter, 'test');
774
+ * context.initStr('640:480');
775
+ * // Use context...
776
+ * } // Automatically freed when leaving scope
777
+ * ```
778
+ */
779
+ [Symbol.dispose]() {
780
+ this.native[Symbol.dispose]();
781
+ }
782
+ }
783
+ //# sourceMappingURL=filter-context.js.map