@revizly/node-av 5.2.2-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 (254) hide show
  1. package/BUILD_LINUX.md +61 -0
  2. package/LICENSE.md +22 -0
  3. package/README.md +662 -0
  4. package/build_mac_local.sh +69 -0
  5. package/dist/api/audio-frame-buffer.d.ts +205 -0
  6. package/dist/api/audio-frame-buffer.js +287 -0
  7. package/dist/api/audio-frame-buffer.js.map +1 -0
  8. package/dist/api/bitstream-filter.d.ts +820 -0
  9. package/dist/api/bitstream-filter.js +1242 -0
  10. package/dist/api/bitstream-filter.js.map +1 -0
  11. package/dist/api/constants.d.ts +44 -0
  12. package/dist/api/constants.js +45 -0
  13. package/dist/api/constants.js.map +1 -0
  14. package/dist/api/data/test_av1.ivf +0 -0
  15. package/dist/api/data/test_h264.h264 +0 -0
  16. package/dist/api/data/test_hevc.h265 +0 -0
  17. package/dist/api/data/test_mjpeg.mjpeg +0 -0
  18. package/dist/api/data/test_vp8.ivf +0 -0
  19. package/dist/api/data/test_vp9.ivf +0 -0
  20. package/dist/api/decoder.d.ts +1088 -0
  21. package/dist/api/decoder.js +1775 -0
  22. package/dist/api/decoder.js.map +1 -0
  23. package/dist/api/demuxer.d.ts +1219 -0
  24. package/dist/api/demuxer.js +2081 -0
  25. package/dist/api/demuxer.js.map +1 -0
  26. package/dist/api/device.d.ts +586 -0
  27. package/dist/api/device.js +961 -0
  28. package/dist/api/device.js.map +1 -0
  29. package/dist/api/encoder.d.ts +1132 -0
  30. package/dist/api/encoder.js +1988 -0
  31. package/dist/api/encoder.js.map +1 -0
  32. package/dist/api/filter-complex.d.ts +821 -0
  33. package/dist/api/filter-complex.js +1604 -0
  34. package/dist/api/filter-complex.js.map +1 -0
  35. package/dist/api/filter-presets.d.ts +1286 -0
  36. package/dist/api/filter-presets.js +2152 -0
  37. package/dist/api/filter-presets.js.map +1 -0
  38. package/dist/api/filter.d.ts +1234 -0
  39. package/dist/api/filter.js +1976 -0
  40. package/dist/api/filter.js.map +1 -0
  41. package/dist/api/fmp4-stream.d.ts +426 -0
  42. package/dist/api/fmp4-stream.js +739 -0
  43. package/dist/api/fmp4-stream.js.map +1 -0
  44. package/dist/api/hardware.d.ts +651 -0
  45. package/dist/api/hardware.js +1260 -0
  46. package/dist/api/hardware.js.map +1 -0
  47. package/dist/api/index.d.ts +17 -0
  48. package/dist/api/index.js +32 -0
  49. package/dist/api/index.js.map +1 -0
  50. package/dist/api/io-stream.d.ts +307 -0
  51. package/dist/api/io-stream.js +282 -0
  52. package/dist/api/io-stream.js.map +1 -0
  53. package/dist/api/muxer.d.ts +957 -0
  54. package/dist/api/muxer.js +2002 -0
  55. package/dist/api/muxer.js.map +1 -0
  56. package/dist/api/pipeline.d.ts +607 -0
  57. package/dist/api/pipeline.js +1145 -0
  58. package/dist/api/pipeline.js.map +1 -0
  59. package/dist/api/utilities/async-queue.d.ts +120 -0
  60. package/dist/api/utilities/async-queue.js +211 -0
  61. package/dist/api/utilities/async-queue.js.map +1 -0
  62. package/dist/api/utilities/audio-sample.d.ts +117 -0
  63. package/dist/api/utilities/audio-sample.js +112 -0
  64. package/dist/api/utilities/audio-sample.js.map +1 -0
  65. package/dist/api/utilities/channel-layout.d.ts +76 -0
  66. package/dist/api/utilities/channel-layout.js +80 -0
  67. package/dist/api/utilities/channel-layout.js.map +1 -0
  68. package/dist/api/utilities/electron-shared-texture.d.ts +328 -0
  69. package/dist/api/utilities/electron-shared-texture.js +503 -0
  70. package/dist/api/utilities/electron-shared-texture.js.map +1 -0
  71. package/dist/api/utilities/image.d.ts +207 -0
  72. package/dist/api/utilities/image.js +213 -0
  73. package/dist/api/utilities/image.js.map +1 -0
  74. package/dist/api/utilities/index.d.ts +12 -0
  75. package/dist/api/utilities/index.js +25 -0
  76. package/dist/api/utilities/index.js.map +1 -0
  77. package/dist/api/utilities/media-type.d.ts +49 -0
  78. package/dist/api/utilities/media-type.js +53 -0
  79. package/dist/api/utilities/media-type.js.map +1 -0
  80. package/dist/api/utilities/pixel-format.d.ts +89 -0
  81. package/dist/api/utilities/pixel-format.js +97 -0
  82. package/dist/api/utilities/pixel-format.js.map +1 -0
  83. package/dist/api/utilities/sample-format.d.ts +129 -0
  84. package/dist/api/utilities/sample-format.js +141 -0
  85. package/dist/api/utilities/sample-format.js.map +1 -0
  86. package/dist/api/utilities/scheduler.d.ts +138 -0
  87. package/dist/api/utilities/scheduler.js +98 -0
  88. package/dist/api/utilities/scheduler.js.map +1 -0
  89. package/dist/api/utilities/streaming.d.ts +186 -0
  90. package/dist/api/utilities/streaming.js +309 -0
  91. package/dist/api/utilities/streaming.js.map +1 -0
  92. package/dist/api/utilities/timestamp.d.ts +193 -0
  93. package/dist/api/utilities/timestamp.js +206 -0
  94. package/dist/api/utilities/timestamp.js.map +1 -0
  95. package/dist/api/utilities/whisper-model.d.ts +310 -0
  96. package/dist/api/utilities/whisper-model.js +528 -0
  97. package/dist/api/utilities/whisper-model.js.map +1 -0
  98. package/dist/api/utils.d.ts +19 -0
  99. package/dist/api/utils.js +39 -0
  100. package/dist/api/utils.js.map +1 -0
  101. package/dist/api/whisper.d.ts +324 -0
  102. package/dist/api/whisper.js +362 -0
  103. package/dist/api/whisper.js.map +1 -0
  104. package/dist/constants/channel-layouts.d.ts +53 -0
  105. package/dist/constants/channel-layouts.js +57 -0
  106. package/dist/constants/channel-layouts.js.map +1 -0
  107. package/dist/constants/constants.d.ts +2325 -0
  108. package/dist/constants/constants.js +1887 -0
  109. package/dist/constants/constants.js.map +1 -0
  110. package/dist/constants/decoders.d.ts +633 -0
  111. package/dist/constants/decoders.js +641 -0
  112. package/dist/constants/decoders.js.map +1 -0
  113. package/dist/constants/encoders.d.ts +295 -0
  114. package/dist/constants/encoders.js +308 -0
  115. package/dist/constants/encoders.js.map +1 -0
  116. package/dist/constants/hardware.d.ts +26 -0
  117. package/dist/constants/hardware.js +27 -0
  118. package/dist/constants/hardware.js.map +1 -0
  119. package/dist/constants/index.d.ts +5 -0
  120. package/dist/constants/index.js +6 -0
  121. package/dist/constants/index.js.map +1 -0
  122. package/dist/ffmpeg/index.d.ts +99 -0
  123. package/dist/ffmpeg/index.js +115 -0
  124. package/dist/ffmpeg/index.js.map +1 -0
  125. package/dist/ffmpeg/utils.d.ts +31 -0
  126. package/dist/ffmpeg/utils.js +68 -0
  127. package/dist/ffmpeg/utils.js.map +1 -0
  128. package/dist/ffmpeg/version.d.ts +6 -0
  129. package/dist/ffmpeg/version.js +7 -0
  130. package/dist/ffmpeg/version.js.map +1 -0
  131. package/dist/index.d.ts +4 -0
  132. package/dist/index.js +9 -0
  133. package/dist/index.js.map +1 -0
  134. package/dist/lib/audio-fifo.d.ts +399 -0
  135. package/dist/lib/audio-fifo.js +431 -0
  136. package/dist/lib/audio-fifo.js.map +1 -0
  137. package/dist/lib/binding.d.ts +228 -0
  138. package/dist/lib/binding.js +60 -0
  139. package/dist/lib/binding.js.map +1 -0
  140. package/dist/lib/bitstream-filter-context.d.ts +379 -0
  141. package/dist/lib/bitstream-filter-context.js +441 -0
  142. package/dist/lib/bitstream-filter-context.js.map +1 -0
  143. package/dist/lib/bitstream-filter.d.ts +140 -0
  144. package/dist/lib/bitstream-filter.js +154 -0
  145. package/dist/lib/bitstream-filter.js.map +1 -0
  146. package/dist/lib/codec-context.d.ts +1071 -0
  147. package/dist/lib/codec-context.js +1354 -0
  148. package/dist/lib/codec-context.js.map +1 -0
  149. package/dist/lib/codec-parameters.d.ts +616 -0
  150. package/dist/lib/codec-parameters.js +761 -0
  151. package/dist/lib/codec-parameters.js.map +1 -0
  152. package/dist/lib/codec-parser.d.ts +201 -0
  153. package/dist/lib/codec-parser.js +213 -0
  154. package/dist/lib/codec-parser.js.map +1 -0
  155. package/dist/lib/codec.d.ts +586 -0
  156. package/dist/lib/codec.js +713 -0
  157. package/dist/lib/codec.js.map +1 -0
  158. package/dist/lib/device.d.ts +291 -0
  159. package/dist/lib/device.js +324 -0
  160. package/dist/lib/device.js.map +1 -0
  161. package/dist/lib/dictionary.d.ts +333 -0
  162. package/dist/lib/dictionary.js +372 -0
  163. package/dist/lib/dictionary.js.map +1 -0
  164. package/dist/lib/error.d.ts +242 -0
  165. package/dist/lib/error.js +303 -0
  166. package/dist/lib/error.js.map +1 -0
  167. package/dist/lib/fifo.d.ts +416 -0
  168. package/dist/lib/fifo.js +453 -0
  169. package/dist/lib/fifo.js.map +1 -0
  170. package/dist/lib/filter-context.d.ts +712 -0
  171. package/dist/lib/filter-context.js +789 -0
  172. package/dist/lib/filter-context.js.map +1 -0
  173. package/dist/lib/filter-graph-segment.d.ts +160 -0
  174. package/dist/lib/filter-graph-segment.js +171 -0
  175. package/dist/lib/filter-graph-segment.js.map +1 -0
  176. package/dist/lib/filter-graph.d.ts +641 -0
  177. package/dist/lib/filter-graph.js +704 -0
  178. package/dist/lib/filter-graph.js.map +1 -0
  179. package/dist/lib/filter-inout.d.ts +198 -0
  180. package/dist/lib/filter-inout.js +257 -0
  181. package/dist/lib/filter-inout.js.map +1 -0
  182. package/dist/lib/filter.d.ts +243 -0
  183. package/dist/lib/filter.js +272 -0
  184. package/dist/lib/filter.js.map +1 -0
  185. package/dist/lib/format-context.d.ts +1254 -0
  186. package/dist/lib/format-context.js +1379 -0
  187. package/dist/lib/format-context.js.map +1 -0
  188. package/dist/lib/frame-utils.d.ts +116 -0
  189. package/dist/lib/frame-utils.js +98 -0
  190. package/dist/lib/frame-utils.js.map +1 -0
  191. package/dist/lib/frame.d.ts +1222 -0
  192. package/dist/lib/frame.js +1435 -0
  193. package/dist/lib/frame.js.map +1 -0
  194. package/dist/lib/hardware-device-context.d.ts +362 -0
  195. package/dist/lib/hardware-device-context.js +383 -0
  196. package/dist/lib/hardware-device-context.js.map +1 -0
  197. package/dist/lib/hardware-frames-context.d.ts +419 -0
  198. package/dist/lib/hardware-frames-context.js +477 -0
  199. package/dist/lib/hardware-frames-context.js.map +1 -0
  200. package/dist/lib/index.d.ts +35 -0
  201. package/dist/lib/index.js +60 -0
  202. package/dist/lib/index.js.map +1 -0
  203. package/dist/lib/input-format.d.ts +249 -0
  204. package/dist/lib/input-format.js +306 -0
  205. package/dist/lib/input-format.js.map +1 -0
  206. package/dist/lib/io-context.d.ts +696 -0
  207. package/dist/lib/io-context.js +769 -0
  208. package/dist/lib/io-context.js.map +1 -0
  209. package/dist/lib/log.d.ts +174 -0
  210. package/dist/lib/log.js +184 -0
  211. package/dist/lib/log.js.map +1 -0
  212. package/dist/lib/native-types.d.ts +946 -0
  213. package/dist/lib/native-types.js +2 -0
  214. package/dist/lib/native-types.js.map +1 -0
  215. package/dist/lib/option.d.ts +927 -0
  216. package/dist/lib/option.js +1583 -0
  217. package/dist/lib/option.js.map +1 -0
  218. package/dist/lib/output-format.d.ts +180 -0
  219. package/dist/lib/output-format.js +213 -0
  220. package/dist/lib/output-format.js.map +1 -0
  221. package/dist/lib/packet.d.ts +501 -0
  222. package/dist/lib/packet.js +590 -0
  223. package/dist/lib/packet.js.map +1 -0
  224. package/dist/lib/rational.d.ts +251 -0
  225. package/dist/lib/rational.js +278 -0
  226. package/dist/lib/rational.js.map +1 -0
  227. package/dist/lib/software-resample-context.d.ts +552 -0
  228. package/dist/lib/software-resample-context.js +592 -0
  229. package/dist/lib/software-resample-context.js.map +1 -0
  230. package/dist/lib/software-scale-context.d.ts +344 -0
  231. package/dist/lib/software-scale-context.js +366 -0
  232. package/dist/lib/software-scale-context.js.map +1 -0
  233. package/dist/lib/stream.d.ts +379 -0
  234. package/dist/lib/stream.js +526 -0
  235. package/dist/lib/stream.js.map +1 -0
  236. package/dist/lib/sync-queue.d.ts +179 -0
  237. package/dist/lib/sync-queue.js +197 -0
  238. package/dist/lib/sync-queue.js.map +1 -0
  239. package/dist/lib/types.d.ts +34 -0
  240. package/dist/lib/types.js +2 -0
  241. package/dist/lib/types.js.map +1 -0
  242. package/dist/lib/utilities.d.ts +1127 -0
  243. package/dist/lib/utilities.js +1225 -0
  244. package/dist/lib/utilities.js.map +1 -0
  245. package/dist/utils/electron.d.ts +49 -0
  246. package/dist/utils/electron.js +63 -0
  247. package/dist/utils/electron.js.map +1 -0
  248. package/dist/utils/index.d.ts +4 -0
  249. package/dist/utils/index.js +5 -0
  250. package/dist/utils/index.js.map +1 -0
  251. package/install/check.js +121 -0
  252. package/install/ffmpeg.js +66 -0
  253. package/jellyfin-ffmpeg.patch +181 -0
  254. package/package.json +129 -0
@@ -0,0 +1,198 @@
1
+ import { FilterContext } from './filter-context.js';
2
+ import type { NativeFilterInOut, NativeWrapper } from './native-types.js';
3
+ /**
4
+ * Filter input/output linked list structure for filter graph parsing.
5
+ *
6
+ * Represents a linked list of labeled filter pads used during filter graph
7
+ * configuration. Each node contains a filter context, pad index, and optional
8
+ * label for connecting filters together. Used internally by avfilter_graph_parse()
9
+ * to track unlinked filter pads during graph construction.
10
+ *
11
+ * Direct mapping to FFmpeg's AVFilterInOut.
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * import { FilterInOut, FilterContext, FFmpegError } from 'node-av';
16
+ *
17
+ * // Create a linked list of filter inputs/outputs
18
+ * const inputs = FilterInOut.createList([
19
+ * { name: 'in', filterCtx: bufferSrc, padIdx: 0 },
20
+ * { name: 'overlay', filterCtx: overlay, padIdx: 1 }
21
+ * ]);
22
+ *
23
+ * // Parse filter graph with labeled connections
24
+ * const ret = graph.parse(filterString, inputs, outputs);
25
+ * FFmpegError.throwIfError(ret, 'parse');
26
+ *
27
+ * // Manual creation and linking
28
+ * const inout = new FilterInOut();
29
+ * inout.alloc();
30
+ * inout.name = 'input';
31
+ * inout.filterCtx = sourceFilter;
32
+ * inout.padIdx = 0;
33
+ * ```
34
+ *
35
+ * @see [AVFilterInOut](https://ffmpeg.org/doxygen/trunk/structAVFilterInOut.html) - FFmpeg Doxygen
36
+ * @see {@link FilterGraph} For parsing filter descriptions
37
+ * @see {@link FilterContext} For filter instances
38
+ */
39
+ export declare class FilterInOut implements Disposable, NativeWrapper<NativeFilterInOut> {
40
+ private native;
41
+ constructor();
42
+ /**
43
+ * Create a linked list of filter inputs/outputs.
44
+ *
45
+ * Convenience method to build a linked list structure from an array
46
+ * of filter specifications. Each item becomes a node in the list.
47
+ *
48
+ * @param items - Array of filter input/output specifications
49
+ *
50
+ * @returns Head of the linked list, or null if items is empty
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * // Create inputs for a filter graph
55
+ * const inputs = FilterInOut.createList([
56
+ * { name: 'video_in', filterCtx: videoBuffer, padIdx: 0 },
57
+ * { name: 'audio_in', filterCtx: audioBuffer, padIdx: 0 }
58
+ * ]);
59
+ *
60
+ * // Create outputs
61
+ * const outputs = FilterInOut.createList([
62
+ * { name: 'video_out', filterCtx: videoSink, padIdx: 0 },
63
+ * { name: 'audio_out', filterCtx: audioSink, padIdx: 0 }
64
+ * ]);
65
+ * ```
66
+ *
67
+ * @see {@link alloc} For manual node creation
68
+ */
69
+ static createList(items: {
70
+ name: string;
71
+ filterCtx: FilterContext;
72
+ padIdx: number;
73
+ }[]): FilterInOut | null;
74
+ /**
75
+ * Label name for this filter pad.
76
+ *
77
+ * Used to reference this connection point in filter graph strings.
78
+ * For example, "[in]" or "[video_out]".
79
+ *
80
+ * Direct mapping to AVFilterInOut->name.
81
+ */
82
+ get name(): string | null;
83
+ set name(value: string | null);
84
+ /**
85
+ * Filter context this pad belongs to.
86
+ *
87
+ * Reference to the filter instance containing this pad.
88
+ *
89
+ * Direct mapping to AVFilterInOut->filter_ctx.
90
+ */
91
+ get filterCtx(): FilterContext | null;
92
+ set filterCtx(value: FilterContext | null);
93
+ /**
94
+ * Pad index within the filter.
95
+ *
96
+ * Index of the input or output pad in the filter context.
97
+ * 0 for the first pad, 1 for the second, etc.
98
+ *
99
+ * Direct mapping to AVFilterInOut->pad_idx.
100
+ */
101
+ get padIdx(): number;
102
+ set padIdx(value: number);
103
+ /**
104
+ * Next node in the linked list.
105
+ *
106
+ * Reference to the next FilterInOut in the chain, or null for the last node.
107
+ *
108
+ * Direct mapping to AVFilterInOut->next.
109
+ */
110
+ get next(): FilterInOut | null;
111
+ set next(value: FilterInOut | null);
112
+ /**
113
+ * Allocate a FilterInOut structure.
114
+ *
115
+ * Allocates memory for the structure. Must be called before using
116
+ * a manually created instance.
117
+ *
118
+ * Direct mapping to avfilter_inout_alloc().
119
+ *
120
+ * @throws {Error} If allocation fails (ENOMEM)
121
+ *
122
+ * @example
123
+ * ```typescript
124
+ * const inout = new FilterInOut();
125
+ * inout.alloc();
126
+ * inout.name = 'input';
127
+ * inout.filterCtx = bufferSource;
128
+ * inout.padIdx = 0;
129
+ * ```
130
+ *
131
+ * @see {@link free} To deallocate
132
+ * @see {@link createList} For automatic allocation
133
+ */
134
+ alloc(): void;
135
+ /**
136
+ * Free the FilterInOut structure.
137
+ *
138
+ * Deallocates the structure and breaks the chain if part of a linked list.
139
+ * Only frees this node, not the entire list.
140
+ *
141
+ * Direct mapping to avfilter_inout_free().
142
+ *
143
+ * @example
144
+ * ```typescript
145
+ * inout.free();
146
+ * // Structure is now invalid
147
+ * ```
148
+ *
149
+ * @see {@link alloc} To allocate
150
+ * @see {@link Symbol.dispose} For automatic cleanup
151
+ */
152
+ free(): void;
153
+ /**
154
+ * Count nodes in the linked list.
155
+ *
156
+ * Counts the total number of nodes starting from this node
157
+ * and following the next pointers.
158
+ *
159
+ * @returns Number of nodes in the list (including this one)
160
+ *
161
+ * @example
162
+ * ```typescript
163
+ * const list = FilterInOut.createList([
164
+ * { name: 'in1', filterCtx: filter1, padIdx: 0 },
165
+ * { name: 'in2', filterCtx: filter2, padIdx: 0 },
166
+ * { name: 'in3', filterCtx: filter3, padIdx: 0 }
167
+ * ]);
168
+ *
169
+ * console.log(`List has ${list.count()} nodes`); // 3
170
+ * ```
171
+ */
172
+ count(): number;
173
+ /**
174
+ * Get the underlying native FilterInOut object.
175
+ *
176
+ * @returns The native FilterInOut binding object
177
+ *
178
+ * @internal
179
+ */
180
+ getNative(): NativeFilterInOut;
181
+ /**
182
+ * Dispose of the FilterInOut structure.
183
+ *
184
+ * Implements the Disposable interface for automatic cleanup.
185
+ * Equivalent to calling free().
186
+ *
187
+ * @example
188
+ * ```typescript
189
+ * {
190
+ * using inout = new FilterInOut();
191
+ * inout.alloc();
192
+ * inout.name = 'test';
193
+ * // Use inout...
194
+ * } // Automatically freed when leaving scope
195
+ * ```
196
+ */
197
+ [Symbol.dispose](): void;
198
+ }
@@ -0,0 +1,257 @@
1
+ import { bindings } from './binding.js';
2
+ import { FilterContext } from './filter-context.js';
3
+ /**
4
+ * Filter input/output linked list structure for filter graph parsing.
5
+ *
6
+ * Represents a linked list of labeled filter pads used during filter graph
7
+ * configuration. Each node contains a filter context, pad index, and optional
8
+ * label for connecting filters together. Used internally by avfilter_graph_parse()
9
+ * to track unlinked filter pads during graph construction.
10
+ *
11
+ * Direct mapping to FFmpeg's AVFilterInOut.
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * import { FilterInOut, FilterContext, FFmpegError } from 'node-av';
16
+ *
17
+ * // Create a linked list of filter inputs/outputs
18
+ * const inputs = FilterInOut.createList([
19
+ * { name: 'in', filterCtx: bufferSrc, padIdx: 0 },
20
+ * { name: 'overlay', filterCtx: overlay, padIdx: 1 }
21
+ * ]);
22
+ *
23
+ * // Parse filter graph with labeled connections
24
+ * const ret = graph.parse(filterString, inputs, outputs);
25
+ * FFmpegError.throwIfError(ret, 'parse');
26
+ *
27
+ * // Manual creation and linking
28
+ * const inout = new FilterInOut();
29
+ * inout.alloc();
30
+ * inout.name = 'input';
31
+ * inout.filterCtx = sourceFilter;
32
+ * inout.padIdx = 0;
33
+ * ```
34
+ *
35
+ * @see [AVFilterInOut](https://ffmpeg.org/doxygen/trunk/structAVFilterInOut.html) - FFmpeg Doxygen
36
+ * @see {@link FilterGraph} For parsing filter descriptions
37
+ * @see {@link FilterContext} For filter instances
38
+ */
39
+ export class FilterInOut {
40
+ native;
41
+ constructor() {
42
+ this.native = new bindings.FilterInOut();
43
+ }
44
+ /**
45
+ * Create a linked list of filter inputs/outputs.
46
+ *
47
+ * Convenience method to build a linked list structure from an array
48
+ * of filter specifications. Each item becomes a node in the list.
49
+ *
50
+ * @param items - Array of filter input/output specifications
51
+ *
52
+ * @returns Head of the linked list, or null if items is empty
53
+ *
54
+ * @example
55
+ * ```typescript
56
+ * // Create inputs for a filter graph
57
+ * const inputs = FilterInOut.createList([
58
+ * { name: 'video_in', filterCtx: videoBuffer, padIdx: 0 },
59
+ * { name: 'audio_in', filterCtx: audioBuffer, padIdx: 0 }
60
+ * ]);
61
+ *
62
+ * // Create outputs
63
+ * const outputs = FilterInOut.createList([
64
+ * { name: 'video_out', filterCtx: videoSink, padIdx: 0 },
65
+ * { name: 'audio_out', filterCtx: audioSink, padIdx: 0 }
66
+ * ]);
67
+ * ```
68
+ *
69
+ * @see {@link alloc} For manual node creation
70
+ */
71
+ static createList(items) {
72
+ if (items.length === 0)
73
+ return null;
74
+ let head = null;
75
+ let current = null;
76
+ for (const item of items) {
77
+ const inout = new FilterInOut();
78
+ inout.alloc();
79
+ inout.name = item.name;
80
+ inout.filterCtx = item.filterCtx;
81
+ inout.padIdx = item.padIdx;
82
+ if (!head) {
83
+ head = inout;
84
+ current = inout;
85
+ }
86
+ else if (current) {
87
+ current.next = inout;
88
+ current = inout;
89
+ }
90
+ }
91
+ return head;
92
+ }
93
+ /**
94
+ * Label name for this filter pad.
95
+ *
96
+ * Used to reference this connection point in filter graph strings.
97
+ * For example, "[in]" or "[video_out]".
98
+ *
99
+ * Direct mapping to AVFilterInOut->name.
100
+ */
101
+ get name() {
102
+ return this.native.name;
103
+ }
104
+ set name(value) {
105
+ this.native.name = value;
106
+ }
107
+ /**
108
+ * Filter context this pad belongs to.
109
+ *
110
+ * Reference to the filter instance containing this pad.
111
+ *
112
+ * Direct mapping to AVFilterInOut->filter_ctx.
113
+ */
114
+ get filterCtx() {
115
+ const native = this.native.filterCtx;
116
+ return native ? new FilterContext(native) : null;
117
+ }
118
+ set filterCtx(value) {
119
+ this.native.filterCtx = value ? value.getNative() : null;
120
+ }
121
+ /**
122
+ * Pad index within the filter.
123
+ *
124
+ * Index of the input or output pad in the filter context.
125
+ * 0 for the first pad, 1 for the second, etc.
126
+ *
127
+ * Direct mapping to AVFilterInOut->pad_idx.
128
+ */
129
+ get padIdx() {
130
+ return this.native.padIdx;
131
+ }
132
+ set padIdx(value) {
133
+ this.native.padIdx = value;
134
+ }
135
+ /**
136
+ * Next node in the linked list.
137
+ *
138
+ * Reference to the next FilterInOut in the chain, or null for the last node.
139
+ *
140
+ * Direct mapping to AVFilterInOut->next.
141
+ */
142
+ get next() {
143
+ const native = this.native.next;
144
+ if (!native) {
145
+ return null;
146
+ }
147
+ const filterInOut = Object.create(FilterInOut.prototype);
148
+ filterInOut.native = native;
149
+ return filterInOut;
150
+ }
151
+ set next(value) {
152
+ this.native.next = value ? value.getNative() : null;
153
+ }
154
+ /**
155
+ * Allocate a FilterInOut structure.
156
+ *
157
+ * Allocates memory for the structure. Must be called before using
158
+ * a manually created instance.
159
+ *
160
+ * Direct mapping to avfilter_inout_alloc().
161
+ *
162
+ * @throws {Error} If allocation fails (ENOMEM)
163
+ *
164
+ * @example
165
+ * ```typescript
166
+ * const inout = new FilterInOut();
167
+ * inout.alloc();
168
+ * inout.name = 'input';
169
+ * inout.filterCtx = bufferSource;
170
+ * inout.padIdx = 0;
171
+ * ```
172
+ *
173
+ * @see {@link free} To deallocate
174
+ * @see {@link createList} For automatic allocation
175
+ */
176
+ alloc() {
177
+ this.native.alloc();
178
+ }
179
+ /**
180
+ * Free the FilterInOut structure.
181
+ *
182
+ * Deallocates the structure and breaks the chain if part of a linked list.
183
+ * Only frees this node, not the entire list.
184
+ *
185
+ * Direct mapping to avfilter_inout_free().
186
+ *
187
+ * @example
188
+ * ```typescript
189
+ * inout.free();
190
+ * // Structure is now invalid
191
+ * ```
192
+ *
193
+ * @see {@link alloc} To allocate
194
+ * @see {@link Symbol.dispose} For automatic cleanup
195
+ */
196
+ free() {
197
+ this.native.free();
198
+ }
199
+ /**
200
+ * Count nodes in the linked list.
201
+ *
202
+ * Counts the total number of nodes starting from this node
203
+ * and following the next pointers.
204
+ *
205
+ * @returns Number of nodes in the list (including this one)
206
+ *
207
+ * @example
208
+ * ```typescript
209
+ * const list = FilterInOut.createList([
210
+ * { name: 'in1', filterCtx: filter1, padIdx: 0 },
211
+ * { name: 'in2', filterCtx: filter2, padIdx: 0 },
212
+ * { name: 'in3', filterCtx: filter3, padIdx: 0 }
213
+ * ]);
214
+ *
215
+ * console.log(`List has ${list.count()} nodes`); // 3
216
+ * ```
217
+ */
218
+ count() {
219
+ let count = 1;
220
+ let current = this.next;
221
+ while (current) {
222
+ count++;
223
+ current = current.next;
224
+ }
225
+ return count;
226
+ }
227
+ /**
228
+ * Get the underlying native FilterInOut object.
229
+ *
230
+ * @returns The native FilterInOut binding object
231
+ *
232
+ * @internal
233
+ */
234
+ getNative() {
235
+ return this.native;
236
+ }
237
+ /**
238
+ * Dispose of the FilterInOut structure.
239
+ *
240
+ * Implements the Disposable interface for automatic cleanup.
241
+ * Equivalent to calling free().
242
+ *
243
+ * @example
244
+ * ```typescript
245
+ * {
246
+ * using inout = new FilterInOut();
247
+ * inout.alloc();
248
+ * inout.name = 'test';
249
+ * // Use inout...
250
+ * } // Automatically freed when leaving scope
251
+ * ```
252
+ */
253
+ [Symbol.dispose]() {
254
+ this.native[Symbol.dispose]();
255
+ }
256
+ }
257
+ //# sourceMappingURL=filter-inout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter-inout.js","sourceRoot":"","sources":["../../src/lib/filter-inout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,OAAO,WAAW;IACd,MAAM,CAAoB;IAElC;QACE,IAAI,CAAC,MAAM,GAAG,IAAI,QAAQ,CAAC,WAAW,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CAAC;QACzB,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;;OAMG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACH,CAAC,MAAM,CAAC,OAAO,CAAC;QACd,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;IAChC,CAAC;CACF"}
@@ -0,0 +1,243 @@
1
+ import { type AVMediaType } from '../constants/constants.js';
2
+ import type { NativeFilter, NativeWrapper } from './native-types.js';
3
+ /**
4
+ * Filter pad information
5
+ */
6
+ export interface FilterPad {
7
+ name: string | null;
8
+ type: AVMediaType;
9
+ }
10
+ /**
11
+ * Filter descriptor for video/audio processing.
12
+ *
13
+ * Represents a filter that can be used in filter graphs for processing
14
+ * audio and video frames. Filters can be sources (no inputs), sinks (no outputs),
15
+ * or processors (with both inputs and outputs). Each filter has specific
16
+ * capabilities and pad configurations.
17
+ *
18
+ * Direct mapping to FFmpeg's AVFilter.
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * import { Filter } from 'node-av';
23
+ *
24
+ * // Get a specific filter
25
+ * const scaleFilter = Filter.getByName('scale');
26
+ * if (scaleFilter) {
27
+ * console.log(`Filter: ${scaleFilter.name}`);
28
+ * console.log(`Description: ${scaleFilter.description}`);
29
+ * console.log(`Inputs: ${scaleFilter.inputs.length}`);
30
+ * console.log(`Outputs: ${scaleFilter.outputs.length}`);
31
+ * }
32
+ *
33
+ * // List all video filters
34
+ * const filters = Filter.getList();
35
+ * const videoFilters = filters.filter(f => f.isVideo());
36
+ * console.log(`Found ${videoFilters.length} video filters`);
37
+ * ```
38
+ *
39
+ * @see [AVFilter](https://ffmpeg.org/doxygen/trunk/structAVFilter.html) - FFmpeg Doxygen
40
+ * @see {@link FilterContext} For using filters in graphs
41
+ * @see {@link FilterGraph} For building filter pipelines
42
+ */
43
+ export declare class Filter implements NativeWrapper<NativeFilter> {
44
+ private native;
45
+ /**
46
+ * @param native - The native filter instance
47
+ *
48
+ * @internal
49
+ */
50
+ constructor(native: NativeFilter);
51
+ /**
52
+ * Get a filter by name.
53
+ *
54
+ * Retrieves a specific filter descriptor by its name.
55
+ * Common filter names include 'scale', 'crop', 'overlay', 'aformat', etc.
56
+ *
57
+ * Direct mapping to avfilter_get_by_name().
58
+ *
59
+ * @param name - Name of the filter
60
+ *
61
+ * @returns Filter instance if found, null otherwise
62
+ *
63
+ * @example
64
+ * ```typescript
65
+ * // Get video scaling filter
66
+ * const scale = Filter.getByName('scale');
67
+ * if (!scale) {
68
+ * throw new Error('Scale filter not available');
69
+ * }
70
+ *
71
+ * // Get audio format filter
72
+ * const aformat = Filter.getByName('aformat');
73
+ * ```
74
+ *
75
+ * @see {@link getList} To list all available filters
76
+ */
77
+ static getByName(name: string): Filter | null;
78
+ /**
79
+ * Get list of all available filters.
80
+ *
81
+ * Returns an array of all registered filters in FFmpeg.
82
+ * Useful for discovering available filters or building filter lists.
83
+ *
84
+ * @returns Array of all available filters
85
+ *
86
+ * @example
87
+ * ```typescript
88
+ * // List all filters
89
+ * const filters = Filter.getList();
90
+ * console.log(`Total filters: ${filters.length}`);
91
+ *
92
+ * // Find all source filters (generators)
93
+ * const sources = filters.filter(f => f.isSource());
94
+ * console.log(`Source filters: ${sources.length}`);
95
+ *
96
+ * // Find all sink filters (outputs)
97
+ * const sinks = filters.filter(f => f.isSink());
98
+ * console.log(`Sink filters: ${sinks.length}`);
99
+ * ```
100
+ *
101
+ * @see {@link getByName} To get a specific filter
102
+ */
103
+ static getList(): Filter[];
104
+ /**
105
+ * Filter name.
106
+ *
107
+ * Unique identifier for the filter (e.g., 'scale', 'overlay').
108
+ *
109
+ * Direct mapping to AVFilter->name.
110
+ */
111
+ get name(): string | null;
112
+ /**
113
+ * Filter description.
114
+ *
115
+ * Human-readable description of what the filter does.
116
+ *
117
+ * Direct mapping to AVFilter->description.
118
+ */
119
+ get description(): string | null;
120
+ /**
121
+ * Input pads.
122
+ *
123
+ * Array of input pad descriptors.
124
+ * Empty array for source filters.
125
+ *
126
+ * Direct mapping to AVFilter->inputs.
127
+ */
128
+ get inputs(): FilterPad[];
129
+ /**
130
+ * Output pads.
131
+ *
132
+ * Array of output pad descriptors.
133
+ * Empty array for sink filters.
134
+ *
135
+ * Direct mapping to AVFilter->outputs.
136
+ */
137
+ get outputs(): FilterPad[];
138
+ /**
139
+ * Filter flags.
140
+ *
141
+ * Combination of AVFILTER_FLAG_* values indicating filter capabilities.
142
+ *
143
+ * Direct mapping to AVFilter->flags.
144
+ */
145
+ get flags(): number;
146
+ /**
147
+ * Check if filter has specific flags.
148
+ *
149
+ * Tests whether all specified flags are set using bitwise AND.
150
+ *
151
+ * @param flags - One or more flag values to check
152
+ *
153
+ * @returns true if all specified flags are set, false otherwise
154
+ *
155
+ * @example
156
+ * ```typescript
157
+ * import { AVFILTER_FLAG_DYNAMIC_INPUTS } from 'node-av/constants';
158
+ *
159
+ * if (filter.hasFlags(AVFILTER_FLAG_DYNAMIC_INPUTS)) {
160
+ * console.log('This filter supports dynamic inputs');
161
+ * }
162
+ * ```
163
+ *
164
+ * @see {@link flags} For direct flags access
165
+ */
166
+ hasFlags(...flags: number[]): boolean;
167
+ /**
168
+ * Check if filter is a source.
169
+ *
170
+ * Source filters generate frames without input
171
+ * (e.g., 'testsrc', 'color', 'anullsrc').
172
+ *
173
+ * @returns True if filter has no inputs
174
+ *
175
+ * @example
176
+ * ```typescript
177
+ * const filter = Filter.getByName('testsrc');
178
+ * if (filter?.isSource()) {
179
+ * console.log('This is a source filter');
180
+ * }
181
+ * ```
182
+ *
183
+ * @see {@link isSink} To check for sink filters
184
+ */
185
+ isSource(): boolean;
186
+ /**
187
+ * Check if filter is a sink.
188
+ *
189
+ * Sink filters consume frames without output
190
+ * (e.g., 'nullsink', 'buffersink').
191
+ *
192
+ * @returns True if filter has no outputs
193
+ *
194
+ * @example
195
+ * ```typescript
196
+ * const filter = Filter.getByName('nullsink');
197
+ * if (filter?.isSink()) {
198
+ * console.log('This is a sink filter');
199
+ * }
200
+ * ```
201
+ *
202
+ * @see {@link isSource} To check for source filters
203
+ */
204
+ isSink(): boolean;
205
+ /**
206
+ * Check if filter processes video.
207
+ *
208
+ * @returns True if filter has video inputs or outputs
209
+ *
210
+ * @example
211
+ * ```typescript
212
+ * const filters = Filter.getList();
213
+ * const videoFilters = filters.filter(f => f.isVideo());
214
+ * console.log(`Video filters: ${videoFilters.length}`);
215
+ * ```
216
+ *
217
+ * @see {@link isAudio} To check for audio filters
218
+ */
219
+ isVideo(): boolean;
220
+ /**
221
+ * Check if filter processes audio.
222
+ *
223
+ * @returns True if filter has audio inputs or outputs
224
+ *
225
+ * @example
226
+ * ```typescript
227
+ * const filters = Filter.getList();
228
+ * const audioFilters = filters.filter(f => f.isAudio());
229
+ * console.log(`Audio filters: ${audioFilters.length}`);
230
+ * ```
231
+ *
232
+ * @see {@link isVideo} To check for video filters
233
+ */
234
+ isAudio(): boolean;
235
+ /**
236
+ * Get the underlying native Filter object.
237
+ *
238
+ * @returns The native Filter binding object
239
+ *
240
+ * @internal
241
+ */
242
+ getNative(): NativeFilter;
243
+ }