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