node-av 0.0.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 (175) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE.md +22 -0
  3. package/README.md +377 -0
  4. package/binding.gyp +78 -0
  5. package/dist/api/bitstream-filter.d.ts +246 -0
  6. package/dist/api/bitstream-filter.js +369 -0
  7. package/dist/api/bitstream-filter.js.map +1 -0
  8. package/dist/api/decoder.d.ts +257 -0
  9. package/dist/api/decoder.js +424 -0
  10. package/dist/api/decoder.js.map +1 -0
  11. package/dist/api/encoder.d.ts +298 -0
  12. package/dist/api/encoder.js +574 -0
  13. package/dist/api/encoder.js.map +1 -0
  14. package/dist/api/filter.d.ts +457 -0
  15. package/dist/api/filter.js +876 -0
  16. package/dist/api/filter.js.map +1 -0
  17. package/dist/api/hardware.d.ts +318 -0
  18. package/dist/api/hardware.js +558 -0
  19. package/dist/api/hardware.js.map +1 -0
  20. package/dist/api/index.d.ts +12 -0
  21. package/dist/api/index.js +20 -0
  22. package/dist/api/index.js.map +1 -0
  23. package/dist/api/io-stream.d.ts +109 -0
  24. package/dist/api/io-stream.js +124 -0
  25. package/dist/api/io-stream.js.map +1 -0
  26. package/dist/api/media-input.d.ts +295 -0
  27. package/dist/api/media-input.js +456 -0
  28. package/dist/api/media-input.js.map +1 -0
  29. package/dist/api/media-output.d.ts +274 -0
  30. package/dist/api/media-output.js +486 -0
  31. package/dist/api/media-output.js.map +1 -0
  32. package/dist/api/pipeline.d.ts +117 -0
  33. package/dist/api/pipeline.js +836 -0
  34. package/dist/api/pipeline.js.map +1 -0
  35. package/dist/api/types.d.ts +440 -0
  36. package/dist/api/types.js +2 -0
  37. package/dist/api/types.js.map +1 -0
  38. package/dist/api/utilities/audio-sample.d.ts +115 -0
  39. package/dist/api/utilities/audio-sample.js +110 -0
  40. package/dist/api/utilities/audio-sample.js.map +1 -0
  41. package/dist/api/utilities/channel-layout.d.ts +83 -0
  42. package/dist/api/utilities/channel-layout.js +87 -0
  43. package/dist/api/utilities/channel-layout.js.map +1 -0
  44. package/dist/api/utilities/image.d.ts +177 -0
  45. package/dist/api/utilities/image.js +183 -0
  46. package/dist/api/utilities/image.js.map +1 -0
  47. package/dist/api/utilities/index.d.ts +8 -0
  48. package/dist/api/utilities/index.js +17 -0
  49. package/dist/api/utilities/index.js.map +1 -0
  50. package/dist/api/utilities/media-type.d.ts +56 -0
  51. package/dist/api/utilities/media-type.js +60 -0
  52. package/dist/api/utilities/media-type.js.map +1 -0
  53. package/dist/api/utilities/pixel-format.d.ts +94 -0
  54. package/dist/api/utilities/pixel-format.js +102 -0
  55. package/dist/api/utilities/pixel-format.js.map +1 -0
  56. package/dist/api/utilities/sample-format.d.ts +132 -0
  57. package/dist/api/utilities/sample-format.js +144 -0
  58. package/dist/api/utilities/sample-format.js.map +1 -0
  59. package/dist/api/utilities/streaming.d.ts +104 -0
  60. package/dist/api/utilities/streaming.js +137 -0
  61. package/dist/api/utilities/streaming.js.map +1 -0
  62. package/dist/api/utilities/timestamp.d.ts +187 -0
  63. package/dist/api/utilities/timestamp.js +200 -0
  64. package/dist/api/utilities/timestamp.js.map +1 -0
  65. package/dist/api/utils.d.ts +61 -0
  66. package/dist/api/utils.js +330 -0
  67. package/dist/api/utils.js.map +1 -0
  68. package/dist/index.d.ts +2 -0
  69. package/dist/index.js +5 -0
  70. package/dist/index.js.map +1 -0
  71. package/dist/lib/audio-fifo.d.ts +339 -0
  72. package/dist/lib/audio-fifo.js +365 -0
  73. package/dist/lib/audio-fifo.js.map +1 -0
  74. package/dist/lib/binding.d.ts +192 -0
  75. package/dist/lib/binding.js +70 -0
  76. package/dist/lib/binding.js.map +1 -0
  77. package/dist/lib/bitstream-filter-context.d.ts +345 -0
  78. package/dist/lib/bitstream-filter-context.js +407 -0
  79. package/dist/lib/bitstream-filter-context.js.map +1 -0
  80. package/dist/lib/bitstream-filter.d.ts +124 -0
  81. package/dist/lib/bitstream-filter.js +138 -0
  82. package/dist/lib/bitstream-filter.js.map +1 -0
  83. package/dist/lib/channel-layouts.d.ts +51 -0
  84. package/dist/lib/channel-layouts.js +55 -0
  85. package/dist/lib/channel-layouts.js.map +1 -0
  86. package/dist/lib/codec-context.d.ts +763 -0
  87. package/dist/lib/codec-context.js +974 -0
  88. package/dist/lib/codec-context.js.map +1 -0
  89. package/dist/lib/codec-parameters.d.ts +362 -0
  90. package/dist/lib/codec-parameters.js +460 -0
  91. package/dist/lib/codec-parameters.js.map +1 -0
  92. package/dist/lib/codec-parser.d.ts +185 -0
  93. package/dist/lib/codec-parser.js +193 -0
  94. package/dist/lib/codec-parser.js.map +1 -0
  95. package/dist/lib/codec.d.ts +432 -0
  96. package/dist/lib/codec.js +492 -0
  97. package/dist/lib/codec.js.map +1 -0
  98. package/dist/lib/constants.d.ts +2037 -0
  99. package/dist/lib/constants.js +1659 -0
  100. package/dist/lib/constants.js.map +1 -0
  101. package/dist/lib/dictionary.d.ts +371 -0
  102. package/dist/lib/dictionary.js +406 -0
  103. package/dist/lib/dictionary.js.map +1 -0
  104. package/dist/lib/error.d.ts +216 -0
  105. package/dist/lib/error.js +254 -0
  106. package/dist/lib/error.js.map +1 -0
  107. package/dist/lib/filter-context.d.ts +445 -0
  108. package/dist/lib/filter-context.js +505 -0
  109. package/dist/lib/filter-context.js.map +1 -0
  110. package/dist/lib/filter-graph.d.ts +556 -0
  111. package/dist/lib/filter-graph.js +608 -0
  112. package/dist/lib/filter-graph.js.map +1 -0
  113. package/dist/lib/filter-inout.d.ts +205 -0
  114. package/dist/lib/filter-inout.js +264 -0
  115. package/dist/lib/filter-inout.js.map +1 -0
  116. package/dist/lib/filter.d.ts +231 -0
  117. package/dist/lib/filter.js +260 -0
  118. package/dist/lib/filter.js.map +1 -0
  119. package/dist/lib/format-context.d.ts +798 -0
  120. package/dist/lib/format-context.js +845 -0
  121. package/dist/lib/format-context.js.map +1 -0
  122. package/dist/lib/frame.d.ts +784 -0
  123. package/dist/lib/frame.js +933 -0
  124. package/dist/lib/frame.js.map +1 -0
  125. package/dist/lib/hardware-device-context.d.ts +407 -0
  126. package/dist/lib/hardware-device-context.js +429 -0
  127. package/dist/lib/hardware-device-context.js.map +1 -0
  128. package/dist/lib/hardware-frames-context.d.ts +374 -0
  129. package/dist/lib/hardware-frames-context.js +430 -0
  130. package/dist/lib/hardware-frames-context.js.map +1 -0
  131. package/dist/lib/index.d.ts +31 -0
  132. package/dist/lib/index.js +54 -0
  133. package/dist/lib/index.js.map +1 -0
  134. package/dist/lib/input-format.d.ts +216 -0
  135. package/dist/lib/input-format.js +246 -0
  136. package/dist/lib/input-format.js.map +1 -0
  137. package/dist/lib/io-context.d.ts +495 -0
  138. package/dist/lib/io-context.js +550 -0
  139. package/dist/lib/io-context.js.map +1 -0
  140. package/dist/lib/log.d.ts +201 -0
  141. package/dist/lib/log.js +219 -0
  142. package/dist/lib/log.js.map +1 -0
  143. package/dist/lib/native-types.d.ts +719 -0
  144. package/dist/lib/native-types.js +2 -0
  145. package/dist/lib/native-types.js.map +1 -0
  146. package/dist/lib/option.d.ts +589 -0
  147. package/dist/lib/option.js +853 -0
  148. package/dist/lib/option.js.map +1 -0
  149. package/dist/lib/output-format.d.ts +179 -0
  150. package/dist/lib/output-format.js +205 -0
  151. package/dist/lib/output-format.js.map +1 -0
  152. package/dist/lib/packet.d.ts +487 -0
  153. package/dist/lib/packet.js +558 -0
  154. package/dist/lib/packet.js.map +1 -0
  155. package/dist/lib/rational.d.ts +210 -0
  156. package/dist/lib/rational.js +233 -0
  157. package/dist/lib/rational.js.map +1 -0
  158. package/dist/lib/software-resample-context.d.ts +572 -0
  159. package/dist/lib/software-resample-context.js +610 -0
  160. package/dist/lib/software-resample-context.js.map +1 -0
  161. package/dist/lib/software-scale-context.d.ts +290 -0
  162. package/dist/lib/software-scale-context.js +308 -0
  163. package/dist/lib/software-scale-context.js.map +1 -0
  164. package/dist/lib/stream.d.ts +322 -0
  165. package/dist/lib/stream.js +408 -0
  166. package/dist/lib/stream.js.map +1 -0
  167. package/dist/lib/types.d.ts +59 -0
  168. package/dist/lib/types.js +8 -0
  169. package/dist/lib/types.js.map +1 -0
  170. package/dist/lib/utilities.d.ts +346 -0
  171. package/dist/lib/utilities.js +424 -0
  172. package/dist/lib/utilities.js.map +1 -0
  173. package/install/check.js +113 -0
  174. package/install/ffmpeg.js +163 -0
  175. package/package.json +107 -0
@@ -0,0 +1,260 @@
1
+ import { bindings } from './binding.js';
2
+ import { AVMEDIA_TYPE_AUDIO, AVMEDIA_TYPE_VIDEO } from './constants.js';
3
+ /**
4
+ * Filter definition for media processing.
5
+ *
6
+ * Represents a static filter definition (immutable template).
7
+ * Defines the filter's capabilities, inputs, outputs, and properties.
8
+ * Actual filtering operations are performed through FilterContext instances.
9
+ *
10
+ * Direct mapping to FFmpeg's AVFilter.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * import { Filter } from 'node-av';
15
+ *
16
+ * // Find a filter by name
17
+ * const scaleFilter = Filter.getByName('scale');
18
+ * if (!scaleFilter) throw new Error('Scale filter not found');
19
+ *
20
+ * // Check filter properties
21
+ * console.log(`Filter: ${scaleFilter.name}`);
22
+ * console.log(`Description: ${scaleFilter.description}`);
23
+ * console.log(`Inputs: ${scaleFilter.inputs.length}`);
24
+ * console.log(`Outputs: ${scaleFilter.outputs.length}`);
25
+ *
26
+ * // Get all video filters
27
+ * const allFilters = Filter.getList();
28
+ * const videoFilters = allFilters.filter(f => f.isVideo());
29
+ * console.log(`Found ${videoFilters.length} video filters`);
30
+ * ```
31
+ */
32
+ export class Filter {
33
+ native;
34
+ /**
35
+ * Constructor is internal - use static factory methods.
36
+ *
37
+ * Filters are global immutable objects managed by FFmpeg.
38
+ * Use the static factory methods to obtain filter instances.
39
+ *
40
+ * @internal
41
+ *
42
+ * @param native - Native AVFilter to wrap
43
+ *
44
+ * @example
45
+ * ```typescript
46
+ * import { Filter } from 'node-av';
47
+ *
48
+ * // Don't use constructor directly
49
+ * // const filter = new Filter(); // Wrong
50
+ *
51
+ * // Use static factory methods instead
52
+ * const filter = Filter.getByName('scale'); // Correct
53
+ * const filters = Filter.getList(); // Correct
54
+ * ```
55
+ */
56
+ constructor(native) {
57
+ this.native = native;
58
+ }
59
+ /**
60
+ * Find a filter by name.
61
+ *
62
+ * Searches for a filter by its exact name.
63
+ * Returns the filter definition if found.
64
+ *
65
+ * Direct mapping to avfilter_get_by_name()
66
+ *
67
+ * @param name - Filter name (e.g., "scale", "overlay", "volume")
68
+ *
69
+ * @returns The filter if found, null otherwise
70
+ *
71
+ * @example
72
+ * ```typescript
73
+ * import { Filter } from 'node-av';
74
+ *
75
+ * // Find the scale filter
76
+ * const scaleFilter = Filter.getByName('scale');
77
+ * if (!scaleFilter) {
78
+ * throw new Error('Scale filter not available');
79
+ * }
80
+ *
81
+ * // Find audio volume filter
82
+ * const volumeFilter = Filter.getByName('volume');
83
+ * if (!volumeFilter) {
84
+ * throw new Error('Volume filter not available');
85
+ * }
86
+ * ```
87
+ *
88
+ * @see {@link getList} To get all available filters
89
+ */
90
+ static getByName(name) {
91
+ const native = bindings.Filter.getByName(name);
92
+ return native ? new Filter(native) : null;
93
+ }
94
+ /**
95
+ * Get list of all available filters.
96
+ *
97
+ * Returns all registered filters in the system.
98
+ * Internally uses avfilter_iterate() to collect all filters.
99
+ *
100
+ * Direct mapping to avfilter_iterate()
101
+ *
102
+ * @returns Array of all registered filters
103
+ *
104
+ * @example
105
+ * ```typescript
106
+ * import { Filter } from 'node-av';
107
+ *
108
+ * // Get all video filters
109
+ * const allFilters = Filter.getList();
110
+ * const videoFilters = allFilters.filter(f => f.isVideo());
111
+ * console.log(`Found ${videoFilters.length} video filters`);
112
+ *
113
+ * // Find all source filters
114
+ * const sourceFilters = allFilters.filter(f => f.isSource());
115
+ * sourceFilters.forEach(f => {
116
+ * console.log(`Source filter: ${f.name}`);
117
+ * });
118
+ * ```
119
+ *
120
+ * @see {@link getByName} To find a specific filter
121
+ */
122
+ static getList() {
123
+ const natives = bindings.Filter.getList();
124
+ return natives.map((native) => new Filter(native));
125
+ }
126
+ /**
127
+ * Filter name.
128
+ *
129
+ * Direct mapping to AVFilter->name
130
+ *
131
+ * The short name of the filter (e.g., "scale", "overlay", "volume").
132
+ */
133
+ get name() {
134
+ return this.native.name;
135
+ }
136
+ /**
137
+ * Filter description.
138
+ *
139
+ * Direct mapping to AVFilter->description
140
+ *
141
+ * Human-readable description of what the filter does.
142
+ */
143
+ get description() {
144
+ return this.native.description;
145
+ }
146
+ /**
147
+ * Input pads.
148
+ *
149
+ * Direct mapping to AVFilter->inputs
150
+ *
151
+ * Array of input connection points for the filter.
152
+ * Empty array for source filters.
153
+ */
154
+ get inputs() {
155
+ return this.native.inputs;
156
+ }
157
+ /**
158
+ * Output pads.
159
+ *
160
+ * Direct mapping to AVFilter->outputs
161
+ *
162
+ * Array of output connection points for the filter.
163
+ * Empty array for sink filters.
164
+ */
165
+ get outputs() {
166
+ return this.native.outputs;
167
+ }
168
+ /**
169
+ * Filter flags.
170
+ *
171
+ * Direct mapping to AVFilter->flags
172
+ *
173
+ * Bitwise flags indicating filter capabilities (AVFILTER_FLAG_*).
174
+ */
175
+ get flags() {
176
+ return this.native.flags;
177
+ }
178
+ /**
179
+ * Check if this is a source filter.
180
+ *
181
+ * Source filters have no inputs and generate data.
182
+ *
183
+ * @returns true if the filter has no input pads, false otherwise
184
+ *
185
+ * @example
186
+ * ```typescript
187
+ * const filter = Filter.getByName('buffer');
188
+ * if (filter && filter.isSource()) {
189
+ * console.log('This is a source filter');
190
+ * }
191
+ * ```
192
+ */
193
+ isSource() {
194
+ return this.inputs.length === 0;
195
+ }
196
+ /**
197
+ * Check if this is a sink filter.
198
+ *
199
+ * Sink filters have no outputs and consume data.
200
+ *
201
+ * @returns true if the filter has no output pads, false otherwise
202
+ *
203
+ * @example
204
+ * ```typescript
205
+ * const filter = Filter.getByName('buffersink');
206
+ * if (filter && filter.isSink()) {
207
+ * console.log('This is a sink filter');
208
+ * }
209
+ * ```
210
+ */
211
+ isSink() {
212
+ return this.outputs.length === 0;
213
+ }
214
+ /**
215
+ * Check if this is a video filter.
216
+ *
217
+ * Checks if any input or output pad handles video data.
218
+ *
219
+ * @returns true if the filter processes video data, false otherwise
220
+ *
221
+ * @example
222
+ * ```typescript
223
+ * const filter = Filter.getByName('scale');
224
+ * if (filter && filter.isVideo()) {
225
+ * console.log('This filter processes video');
226
+ * }
227
+ * ```
228
+ */
229
+ isVideo() {
230
+ return this.inputs.some((i) => i.type === AVMEDIA_TYPE_VIDEO) || this.outputs.some((o) => o.type === AVMEDIA_TYPE_VIDEO);
231
+ }
232
+ /**
233
+ * Check if this is an audio filter.
234
+ *
235
+ * Checks if any input or output pad handles audio data.
236
+ *
237
+ * @returns true if the filter processes audio data, false otherwise
238
+ *
239
+ * @example
240
+ * ```typescript
241
+ * const filter = Filter.getByName('volume');
242
+ * if (filter && filter.isAudio()) {
243
+ * console.log('This filter processes audio');
244
+ * }
245
+ * ```
246
+ */
247
+ isAudio() {
248
+ return this.inputs.some((i) => i.type === AVMEDIA_TYPE_AUDIO) || this.outputs.some((o) => o.type === AVMEDIA_TYPE_AUDIO);
249
+ }
250
+ /**
251
+ * Get the native FFmpeg AVFilter pointer.
252
+ *
253
+ * @internal For use by other wrapper classes
254
+ * @returns The underlying native filter object
255
+ */
256
+ getNative() {
257
+ return this.native;
258
+ }
259
+ }
260
+ //# sourceMappingURL=filter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter.js","sourceRoot":"","sources":["../../src/lib/filter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAKxE;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,OAAO,MAAM;IACT,MAAM,CAAe;IAE7B;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,YAAY,MAAoB;QAC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