node-av 3.1.3 → 5.0.0
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.
- package/README.md +88 -52
- package/binding.gyp +23 -11
- package/dist/api/audio-frame-buffer.d.ts +201 -0
- package/dist/api/audio-frame-buffer.js +275 -0
- package/dist/api/audio-frame-buffer.js.map +1 -0
- package/dist/api/bitstream-filter.d.ts +320 -78
- package/dist/api/bitstream-filter.js +684 -151
- package/dist/api/bitstream-filter.js.map +1 -1
- package/dist/api/constants.d.ts +44 -0
- package/dist/api/constants.js +45 -0
- package/dist/api/constants.js.map +1 -0
- package/dist/api/data/test_av1.ivf +0 -0
- package/dist/api/data/test_mjpeg.mjpeg +0 -0
- package/dist/api/data/test_vp8.ivf +0 -0
- package/dist/api/data/test_vp9.ivf +0 -0
- package/dist/api/decoder.d.ts +454 -77
- package/dist/api/decoder.js +1081 -271
- package/dist/api/decoder.js.map +1 -1
- package/dist/api/{media-input.d.ts → demuxer.d.ts} +295 -45
- package/dist/api/demuxer.js +1965 -0
- package/dist/api/demuxer.js.map +1 -0
- package/dist/api/encoder.d.ts +423 -132
- package/dist/api/encoder.js +1089 -240
- package/dist/api/encoder.js.map +1 -1
- package/dist/api/filter-complex.d.ts +769 -0
- package/dist/api/filter-complex.js +1596 -0
- package/dist/api/filter-complex.js.map +1 -0
- package/dist/api/filter-presets.d.ts +80 -5
- package/dist/api/filter-presets.js +117 -7
- package/dist/api/filter-presets.js.map +1 -1
- package/dist/api/filter.d.ts +561 -125
- package/dist/api/filter.js +1083 -274
- package/dist/api/filter.js.map +1 -1
- package/dist/api/{fmp4.d.ts → fmp4-stream.d.ts} +141 -140
- package/dist/api/fmp4-stream.js +539 -0
- package/dist/api/fmp4-stream.js.map +1 -0
- package/dist/api/hardware.d.ts +58 -6
- package/dist/api/hardware.js +127 -11
- package/dist/api/hardware.js.map +1 -1
- package/dist/api/index.d.ts +8 -4
- package/dist/api/index.js +17 -8
- package/dist/api/index.js.map +1 -1
- package/dist/api/io-stream.d.ts +6 -6
- package/dist/api/io-stream.js +5 -4
- package/dist/api/io-stream.js.map +1 -1
- package/dist/api/{media-output.d.ts → muxer.d.ts} +280 -66
- package/dist/api/muxer.js +1934 -0
- package/dist/api/muxer.js.map +1 -0
- package/dist/api/pipeline.d.ts +77 -29
- package/dist/api/pipeline.js +449 -439
- package/dist/api/pipeline.js.map +1 -1
- package/dist/api/rtp-stream.d.ts +312 -0
- package/dist/api/rtp-stream.js +630 -0
- package/dist/api/rtp-stream.js.map +1 -0
- package/dist/api/types.d.ts +533 -56
- package/dist/api/utilities/async-queue.d.ts +91 -0
- package/dist/api/utilities/async-queue.js +162 -0
- package/dist/api/utilities/async-queue.js.map +1 -0
- package/dist/api/utilities/audio-sample.d.ts +11 -1
- package/dist/api/utilities/audio-sample.js +10 -0
- package/dist/api/utilities/audio-sample.js.map +1 -1
- package/dist/api/utilities/channel-layout.d.ts +1 -0
- package/dist/api/utilities/channel-layout.js +1 -0
- package/dist/api/utilities/channel-layout.js.map +1 -1
- package/dist/api/utilities/image.d.ts +39 -1
- package/dist/api/utilities/image.js +38 -0
- package/dist/api/utilities/image.js.map +1 -1
- package/dist/api/utilities/index.d.ts +3 -0
- package/dist/api/utilities/index.js +6 -0
- package/dist/api/utilities/index.js.map +1 -1
- package/dist/api/utilities/media-type.d.ts +2 -1
- package/dist/api/utilities/media-type.js +1 -0
- package/dist/api/utilities/media-type.js.map +1 -1
- package/dist/api/utilities/pixel-format.d.ts +4 -1
- package/dist/api/utilities/pixel-format.js +3 -0
- package/dist/api/utilities/pixel-format.js.map +1 -1
- package/dist/api/utilities/sample-format.d.ts +6 -1
- package/dist/api/utilities/sample-format.js +5 -0
- package/dist/api/utilities/sample-format.js.map +1 -1
- package/dist/api/utilities/scheduler.d.ts +138 -0
- package/dist/api/utilities/scheduler.js +98 -0
- package/dist/api/utilities/scheduler.js.map +1 -0
- package/dist/api/utilities/streaming.d.ts +105 -15
- package/dist/api/utilities/streaming.js +201 -12
- package/dist/api/utilities/streaming.js.map +1 -1
- package/dist/api/utilities/timestamp.d.ts +15 -1
- package/dist/api/utilities/timestamp.js +14 -0
- package/dist/api/utilities/timestamp.js.map +1 -1
- package/dist/api/utilities/whisper-model.d.ts +310 -0
- package/dist/api/utilities/whisper-model.js +528 -0
- package/dist/api/utilities/whisper-model.js.map +1 -0
- package/dist/api/webrtc-stream.d.ts +288 -0
- package/dist/api/webrtc-stream.js +440 -0
- package/dist/api/webrtc-stream.js.map +1 -0
- package/dist/api/whisper.d.ts +324 -0
- package/dist/api/whisper.js +362 -0
- package/dist/api/whisper.js.map +1 -0
- package/dist/constants/constants.d.ts +54 -2
- package/dist/constants/constants.js +48 -1
- package/dist/constants/constants.js.map +1 -1
- package/dist/constants/encoders.d.ts +2 -1
- package/dist/constants/encoders.js +4 -3
- package/dist/constants/encoders.js.map +1 -1
- package/dist/constants/hardware.d.ts +26 -0
- package/dist/constants/hardware.js +27 -0
- package/dist/constants/hardware.js.map +1 -0
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.js +1 -0
- package/dist/constants/index.js.map +1 -1
- package/dist/ffmpeg/index.d.ts +3 -3
- package/dist/ffmpeg/index.js +3 -3
- package/dist/ffmpeg/utils.d.ts +27 -0
- package/dist/ffmpeg/utils.js +28 -16
- package/dist/ffmpeg/utils.js.map +1 -1
- package/dist/lib/binding.d.ts +22 -11
- package/dist/lib/binding.js.map +1 -1
- package/dist/lib/codec-context.d.ts +87 -0
- package/dist/lib/codec-context.js +125 -4
- package/dist/lib/codec-context.js.map +1 -1
- package/dist/lib/codec-parameters.d.ts +229 -1
- package/dist/lib/codec-parameters.js +264 -0
- package/dist/lib/codec-parameters.js.map +1 -1
- package/dist/lib/codec-parser.d.ts +23 -0
- package/dist/lib/codec-parser.js +25 -0
- package/dist/lib/codec-parser.js.map +1 -1
- package/dist/lib/codec.d.ts +26 -4
- package/dist/lib/codec.js +35 -0
- package/dist/lib/codec.js.map +1 -1
- package/dist/lib/dictionary.js +1 -0
- package/dist/lib/dictionary.js.map +1 -1
- package/dist/lib/error.js +1 -1
- package/dist/lib/error.js.map +1 -1
- package/dist/lib/fifo.d.ts +416 -0
- package/dist/lib/fifo.js +453 -0
- package/dist/lib/fifo.js.map +1 -0
- package/dist/lib/filter-context.d.ts +52 -11
- package/dist/lib/filter-context.js +56 -12
- package/dist/lib/filter-context.js.map +1 -1
- package/dist/lib/filter-graph.d.ts +9 -0
- package/dist/lib/filter-graph.js +13 -0
- package/dist/lib/filter-graph.js.map +1 -1
- package/dist/lib/filter.d.ts +21 -0
- package/dist/lib/filter.js +28 -0
- package/dist/lib/filter.js.map +1 -1
- package/dist/lib/format-context.d.ts +48 -14
- package/dist/lib/format-context.js +76 -7
- package/dist/lib/format-context.js.map +1 -1
- package/dist/lib/frame.d.ts +264 -1
- package/dist/lib/frame.js +351 -1
- package/dist/lib/frame.js.map +1 -1
- package/dist/lib/hardware-device-context.d.ts +3 -2
- package/dist/lib/hardware-device-context.js.map +1 -1
- package/dist/lib/index.d.ts +2 -0
- package/dist/lib/index.js +4 -0
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/input-format.d.ts +21 -0
- package/dist/lib/input-format.js +42 -2
- package/dist/lib/input-format.js.map +1 -1
- package/dist/lib/native-types.d.ts +76 -27
- package/dist/lib/option.d.ts +25 -13
- package/dist/lib/option.js +28 -0
- package/dist/lib/option.js.map +1 -1
- package/dist/lib/output-format.d.ts +22 -1
- package/dist/lib/output-format.js +28 -0
- package/dist/lib/output-format.js.map +1 -1
- package/dist/lib/packet.d.ts +35 -0
- package/dist/lib/packet.js +52 -2
- package/dist/lib/packet.js.map +1 -1
- package/dist/lib/rational.d.ts +18 -0
- package/dist/lib/rational.js +19 -0
- package/dist/lib/rational.js.map +1 -1
- package/dist/lib/stream.d.ts +126 -0
- package/dist/lib/stream.js +188 -5
- package/dist/lib/stream.js.map +1 -1
- package/dist/lib/sync-queue.d.ts +179 -0
- package/dist/lib/sync-queue.js +197 -0
- package/dist/lib/sync-queue.js.map +1 -0
- package/dist/lib/types.d.ts +49 -1
- package/dist/lib/utilities.d.ts +281 -53
- package/dist/lib/utilities.js +298 -55
- package/dist/lib/utilities.js.map +1 -1
- package/install/check.js +2 -2
- package/package.json +37 -26
- package/dist/api/fmp4.js +0 -710
- package/dist/api/fmp4.js.map +0 -1
- package/dist/api/media-input.js +0 -1075
- package/dist/api/media-input.js.map +0 -1
- package/dist/api/media-output.js +0 -1040
- package/dist/api/media-output.js.map +0 -1
- package/dist/api/webrtc.d.ts +0 -664
- package/dist/api/webrtc.js +0 -1132
- package/dist/api/webrtc.js.map +0 -1
package/dist/api/filter.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import { Frame } from '../lib/
|
|
2
|
-
import
|
|
1
|
+
import { Frame } from '../lib/frame.js';
|
|
2
|
+
import { Scheduler } from './utilities/scheduler.js';
|
|
3
|
+
import type { AVColorRange, AVColorSpace, AVFilterCmdFlag, AVPixelFormat, AVSampleFormat, EOFSignal } from '../constants/index.js';
|
|
4
|
+
import type { FilterContext } from '../lib/filter-context.js';
|
|
5
|
+
import type { ChannelLayout, IDimension, IRational } from '../lib/types.js';
|
|
6
|
+
import type { Encoder } from './encoder.js';
|
|
3
7
|
import type { FilterOptions } from './types.js';
|
|
4
8
|
/**
|
|
5
9
|
* High-level filter API for audio and video processing.
|
|
@@ -44,8 +48,17 @@ export declare class FilterAPI implements Disposable {
|
|
|
44
48
|
private options;
|
|
45
49
|
private buffersrcCtx;
|
|
46
50
|
private buffersinkCtx;
|
|
51
|
+
private frame;
|
|
52
|
+
private initializePromise;
|
|
47
53
|
private initialized;
|
|
48
54
|
private isClosed;
|
|
55
|
+
private calculatedTimeBase;
|
|
56
|
+
private lastFrameProps;
|
|
57
|
+
private inputQueue;
|
|
58
|
+
private outputQueue;
|
|
59
|
+
private workerPromise;
|
|
60
|
+
private nextComponent;
|
|
61
|
+
private pipeToPromise;
|
|
49
62
|
/**
|
|
50
63
|
* @param graph - Filter graph instance
|
|
51
64
|
*
|
|
@@ -59,46 +72,43 @@ export declare class FilterAPI implements Disposable {
|
|
|
59
72
|
/**
|
|
60
73
|
* Create a filter with specified description and configuration.
|
|
61
74
|
*
|
|
62
|
-
* Creates and allocates filter graph immediately.
|
|
63
|
-
* Filter configuration is completed on first frame with frame properties.
|
|
64
|
-
* Hardware frames context is automatically detected from input frames.
|
|
65
|
-
*
|
|
66
75
|
* Direct mapping to avfilter_graph_parse_ptr() and avfilter_graph_config().
|
|
67
76
|
*
|
|
68
77
|
* @param description - Filter graph description
|
|
69
78
|
*
|
|
70
|
-
* @param options - Filter options
|
|
79
|
+
* @param options - Filter options
|
|
71
80
|
*
|
|
72
81
|
* @returns Configured filter instance
|
|
73
82
|
*
|
|
83
|
+
* @throws {Error} If cfr=true but framerate is not set
|
|
84
|
+
*
|
|
74
85
|
* @example
|
|
75
86
|
* ```typescript
|
|
76
|
-
* // Simple video filter
|
|
77
|
-
* const filter = FilterAPI.create('scale=640:480'
|
|
78
|
-
* timeBase: video.timeBase
|
|
79
|
-
* });
|
|
87
|
+
* // Simple video filter (VFR mode, auto timeBase)
|
|
88
|
+
* const filter = FilterAPI.create('scale=640:480');
|
|
80
89
|
* ```
|
|
81
90
|
*
|
|
82
91
|
* @example
|
|
83
92
|
* ```typescript
|
|
84
|
-
* //
|
|
85
|
-
* const filter = FilterAPI.create('
|
|
86
|
-
*
|
|
93
|
+
* // CFR mode with constant framerate
|
|
94
|
+
* const filter = FilterAPI.create('scale=1920:1080', {
|
|
95
|
+
* cfr: true,
|
|
96
|
+
* framerate: { num: 25, den: 1 }
|
|
87
97
|
* });
|
|
88
98
|
* ```
|
|
89
99
|
*
|
|
90
100
|
* @example
|
|
91
101
|
* ```typescript
|
|
92
|
-
* // Audio filter
|
|
93
|
-
* const filter = FilterAPI.create('
|
|
94
|
-
*
|
|
102
|
+
* // Audio filter with resampling
|
|
103
|
+
* const filter = FilterAPI.create('aformat=sample_fmts=s16:sample_rates=44100', {
|
|
104
|
+
* audioResampleOpts: 'async=1'
|
|
95
105
|
* });
|
|
96
106
|
* ```
|
|
97
107
|
*
|
|
98
108
|
* @see {@link process} For frame processing
|
|
99
109
|
* @see {@link FilterOptions} For configuration options
|
|
100
110
|
*/
|
|
101
|
-
static create(description: string, options
|
|
111
|
+
static create(description: string, options?: FilterOptions): FilterAPI;
|
|
102
112
|
/**
|
|
103
113
|
* Check if filter is open.
|
|
104
114
|
*
|
|
@@ -126,6 +136,205 @@ export declare class FilterAPI implements Disposable {
|
|
|
126
136
|
* ```
|
|
127
137
|
*/
|
|
128
138
|
get isFilterInitialized(): boolean;
|
|
139
|
+
/**
|
|
140
|
+
* Get buffersink filter context.
|
|
141
|
+
*
|
|
142
|
+
* Provides access to the buffersink filter context for advanced operations.
|
|
143
|
+
* Returns null if filter is not initialized.
|
|
144
|
+
*
|
|
145
|
+
* @returns Buffersink context or null
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```typescript
|
|
149
|
+
* const sink = filter.buffersink;
|
|
150
|
+
* if (sink) {
|
|
151
|
+
* const fr = sink.buffersinkGetFrameRate();
|
|
152
|
+
* console.log(`Output frame rate: ${fr.num}/${fr.den}`);
|
|
153
|
+
* }
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
get buffersink(): FilterContext | null;
|
|
157
|
+
/**
|
|
158
|
+
* Output frame rate from filter graph.
|
|
159
|
+
*
|
|
160
|
+
* Returns the frame rate determined by the filter graph output.
|
|
161
|
+
* Returns null if filter is not initialized or frame rate is not set.
|
|
162
|
+
*
|
|
163
|
+
* Direct mapping to av_buffersink_get_frame_rate().
|
|
164
|
+
*
|
|
165
|
+
* @returns Frame rate or null if not available
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* ```typescript
|
|
169
|
+
* const frameRate = filter.frameRate;
|
|
170
|
+
* if (frameRate) {
|
|
171
|
+
* console.log(`Filter output: ${frameRate.num}/${frameRate.den} fps`);
|
|
172
|
+
* }
|
|
173
|
+
* ```
|
|
174
|
+
*
|
|
175
|
+
* @see {@link timeBase} For output timebase
|
|
176
|
+
*/
|
|
177
|
+
get frameRate(): IRational | null;
|
|
178
|
+
/**
|
|
179
|
+
* Output time base from filter graph.
|
|
180
|
+
*
|
|
181
|
+
* Returns the time base of the buffersink output.
|
|
182
|
+
* Matches FFmpeg CLI's av_buffersink_get_time_base() behavior.
|
|
183
|
+
*
|
|
184
|
+
* Direct mapping to av_buffersink_get_time_base().
|
|
185
|
+
*
|
|
186
|
+
* @returns Time base or null if not initialized
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* ```typescript
|
|
190
|
+
* const timeBase = filter.timeBase;
|
|
191
|
+
* if (timeBase) {
|
|
192
|
+
* console.log(`Filter timebase: ${timeBase.num}/${timeBase.den}`);
|
|
193
|
+
* }
|
|
194
|
+
* ```
|
|
195
|
+
*
|
|
196
|
+
* @see {@link frameRate} For output frame rate
|
|
197
|
+
*/
|
|
198
|
+
get timeBase(): IRational | null;
|
|
199
|
+
/**
|
|
200
|
+
* Output format from filter graph.
|
|
201
|
+
*
|
|
202
|
+
* Returns the pixel format (video) or sample format (audio) of the buffersink output.
|
|
203
|
+
* Matches FFmpeg CLI's av_buffersink_get_format() behavior.
|
|
204
|
+
*
|
|
205
|
+
* Direct mapping to av_buffersink_get_format().
|
|
206
|
+
*
|
|
207
|
+
* @returns Pixel format or sample format, or null if not initialized
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* ```typescript
|
|
211
|
+
* const format = filter.format;
|
|
212
|
+
* if (format !== null) {
|
|
213
|
+
* console.log(`Filter output format: ${format}`);
|
|
214
|
+
* }
|
|
215
|
+
* ```
|
|
216
|
+
*/
|
|
217
|
+
get format(): AVPixelFormat | AVSampleFormat | null;
|
|
218
|
+
/**
|
|
219
|
+
* Output dimensions from filter graph (video only).
|
|
220
|
+
*
|
|
221
|
+
* Returns the width and height of the buffersink output.
|
|
222
|
+
* Matches FFmpeg CLI's av_buffersink_get_w() and av_buffersink_get_h() behavior.
|
|
223
|
+
* Only meaningful for video filters.
|
|
224
|
+
*
|
|
225
|
+
* Direct mapping to av_buffersink_get_w() and av_buffersink_get_h().
|
|
226
|
+
*
|
|
227
|
+
* @returns Dimensions object or null if not initialized
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* ```typescript
|
|
231
|
+
* const dims = filter.dimensions;
|
|
232
|
+
* if (dims) {
|
|
233
|
+
* console.log(`Filter output: ${dims.width}x${dims.height}`);
|
|
234
|
+
* }
|
|
235
|
+
* ```
|
|
236
|
+
*/
|
|
237
|
+
get dimensions(): IDimension | null;
|
|
238
|
+
/**
|
|
239
|
+
* Output sample rate from filter graph (audio only).
|
|
240
|
+
*
|
|
241
|
+
* Returns the sample rate of the buffersink output.
|
|
242
|
+
* Matches FFmpeg CLI's av_buffersink_get_sample_rate() behavior.
|
|
243
|
+
* Only meaningful for audio filters.
|
|
244
|
+
*
|
|
245
|
+
* Direct mapping to av_buffersink_get_sample_rate().
|
|
246
|
+
*
|
|
247
|
+
* @returns Sample rate or null if not initialized
|
|
248
|
+
*
|
|
249
|
+
* @example
|
|
250
|
+
* ```typescript
|
|
251
|
+
* const sampleRate = filter.sampleRate;
|
|
252
|
+
* if (sampleRate) {
|
|
253
|
+
* console.log(`Filter output sample rate: ${sampleRate} Hz`);
|
|
254
|
+
* }
|
|
255
|
+
* ```
|
|
256
|
+
*/
|
|
257
|
+
get sampleRate(): number | null;
|
|
258
|
+
/**
|
|
259
|
+
* Output channel layout from filter graph (audio only).
|
|
260
|
+
*
|
|
261
|
+
* Returns the channel layout of the buffersink output.
|
|
262
|
+
* Matches FFmpeg CLI's av_buffersink_get_ch_layout() behavior.
|
|
263
|
+
* Only meaningful for audio filters.
|
|
264
|
+
*
|
|
265
|
+
* Direct mapping to av_buffersink_get_ch_layout().
|
|
266
|
+
*
|
|
267
|
+
* @returns Channel layout or null if not initialized
|
|
268
|
+
*
|
|
269
|
+
* @example
|
|
270
|
+
* ```typescript
|
|
271
|
+
* const layout = filter.channelLayout;
|
|
272
|
+
* if (layout) {
|
|
273
|
+
* console.log(`Filter output channels: ${layout.nbChannels}`);
|
|
274
|
+
* }
|
|
275
|
+
* ```
|
|
276
|
+
*/
|
|
277
|
+
get channelLayout(): ChannelLayout | null;
|
|
278
|
+
/**
|
|
279
|
+
* Output color space from filter graph (video only).
|
|
280
|
+
*
|
|
281
|
+
* Returns the color space of the buffersink output.
|
|
282
|
+
* Matches FFmpeg CLI's av_buffersink_get_colorspace() behavior.
|
|
283
|
+
* Only meaningful for video filters.
|
|
284
|
+
*
|
|
285
|
+
* Direct mapping to av_buffersink_get_colorspace().
|
|
286
|
+
*
|
|
287
|
+
* @returns Color space or null if not initialized
|
|
288
|
+
*
|
|
289
|
+
* @example
|
|
290
|
+
* ```typescript
|
|
291
|
+
* const colorSpace = filter.colorSpace;
|
|
292
|
+
* if (colorSpace !== null) {
|
|
293
|
+
* console.log(`Filter output color space: ${colorSpace}`);
|
|
294
|
+
* }
|
|
295
|
+
* ```
|
|
296
|
+
*/
|
|
297
|
+
get colorSpace(): AVColorSpace | null;
|
|
298
|
+
/**
|
|
299
|
+
* Output color range from filter graph (video only).
|
|
300
|
+
*
|
|
301
|
+
* Returns the color range of the buffersink output.
|
|
302
|
+
* Matches FFmpeg CLI's av_buffersink_get_color_range() behavior.
|
|
303
|
+
* Only meaningful for video filters.
|
|
304
|
+
*
|
|
305
|
+
* Direct mapping to av_buffersink_get_color_range().
|
|
306
|
+
*
|
|
307
|
+
* @returns Color range or null if not initialized
|
|
308
|
+
*
|
|
309
|
+
* @example
|
|
310
|
+
* ```typescript
|
|
311
|
+
* const colorRange = filter.colorRange;
|
|
312
|
+
* if (colorRange !== null) {
|
|
313
|
+
* console.log(`Filter output color range: ${colorRange}`);
|
|
314
|
+
* }
|
|
315
|
+
* ```
|
|
316
|
+
*/
|
|
317
|
+
get colorRange(): AVColorRange | null;
|
|
318
|
+
/**
|
|
319
|
+
* Output sample aspect ratio from filter graph (video only).
|
|
320
|
+
*
|
|
321
|
+
* Returns the sample aspect ratio of the buffersink output.
|
|
322
|
+
* Matches FFmpeg CLI's av_buffersink_get_sample_aspect_ratio() behavior.
|
|
323
|
+
* Only meaningful for video filters.
|
|
324
|
+
*
|
|
325
|
+
* Direct mapping to av_buffersink_get_sample_aspect_ratio().
|
|
326
|
+
*
|
|
327
|
+
* @returns Sample aspect ratio or null if not initialized
|
|
328
|
+
*
|
|
329
|
+
* @example
|
|
330
|
+
* ```typescript
|
|
331
|
+
* const sar = filter.sampleAspectRatio;
|
|
332
|
+
* if (sar) {
|
|
333
|
+
* console.log(`Filter output SAR: ${sar.num}:${sar.den}`);
|
|
334
|
+
* }
|
|
335
|
+
* ```
|
|
336
|
+
*/
|
|
337
|
+
get sampleAspectRatio(): IRational | null;
|
|
129
338
|
/**
|
|
130
339
|
* Check if filter is ready for processing.
|
|
131
340
|
*
|
|
@@ -157,28 +366,33 @@ export declare class FilterAPI implements Disposable {
|
|
|
157
366
|
*/
|
|
158
367
|
getGraphDescription(): string | null;
|
|
159
368
|
/**
|
|
160
|
-
*
|
|
369
|
+
* Send a frame to the filter.
|
|
161
370
|
*
|
|
162
|
-
*
|
|
371
|
+
* Sends a frame to the filter for processing.
|
|
372
|
+
* Does not return filtered frames - use {@link receive} to retrieve frames.
|
|
163
373
|
* On first frame, automatically builds filter graph with frame properties.
|
|
164
|
-
*
|
|
165
|
-
* Hardware frames context is automatically detected from frame.
|
|
166
|
-
* Returns null if filter is closed and frame is null.
|
|
374
|
+
* A single input frame can produce zero, one, or multiple output frames.
|
|
167
375
|
*
|
|
168
|
-
*
|
|
376
|
+
* **Important**: This method only SENDS the frame to the filter.
|
|
377
|
+
* You must call {@link receive} separately (potentially multiple times) to get filtered frames.
|
|
169
378
|
*
|
|
170
|
-
*
|
|
379
|
+
* Direct mapping to av_buffersrc_add_frame().
|
|
171
380
|
*
|
|
172
|
-
* @
|
|
381
|
+
* @param frame - Input frame to send to filter
|
|
173
382
|
*
|
|
174
383
|
* @throws {Error} If filter could not be initialized
|
|
175
384
|
*
|
|
176
|
-
* @throws {FFmpegError} If
|
|
385
|
+
* @throws {FFmpegError} If sending frame fails
|
|
177
386
|
*
|
|
178
387
|
* @example
|
|
179
388
|
* ```typescript
|
|
180
|
-
*
|
|
181
|
-
*
|
|
389
|
+
* // Send frame and receive filtered frames
|
|
390
|
+
* await filter.process(inputFrame);
|
|
391
|
+
*
|
|
392
|
+
* // Receive all available filtered frames
|
|
393
|
+
* while (true) {
|
|
394
|
+
* const output = await filter.receive();
|
|
395
|
+
* if (!output) break;
|
|
182
396
|
* console.log(`Got filtered frame: pts=${output.pts}`);
|
|
183
397
|
* output.free();
|
|
184
398
|
* }
|
|
@@ -186,125 +400,169 @@ export declare class FilterAPI implements Disposable {
|
|
|
186
400
|
*
|
|
187
401
|
* @example
|
|
188
402
|
* ```typescript
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
403
|
+
* for await (const frame of decoder.frames(input.packets())) {
|
|
404
|
+
* // Send frame
|
|
405
|
+
* await filter.process(frame);
|
|
406
|
+
*
|
|
407
|
+
* // Receive available filtered frames
|
|
408
|
+
* let output;
|
|
409
|
+
* while ((output = await filter.receive())) {
|
|
410
|
+
* await encoder.encode(output);
|
|
411
|
+
* output.free();
|
|
412
|
+
* }
|
|
413
|
+
* frame.free();
|
|
194
414
|
* }
|
|
195
|
-
* // For buffered frames, use the frames() async generator
|
|
196
415
|
* ```
|
|
197
416
|
*
|
|
417
|
+
* @see {@link receive} For receiving filtered frames
|
|
418
|
+
* @see {@link processAll} For combined send+receive operation
|
|
198
419
|
* @see {@link frames} For processing frame streams
|
|
199
420
|
* @see {@link flush} For end-of-stream handling
|
|
421
|
+
* @see {@link processSync} For synchronous version
|
|
200
422
|
*/
|
|
201
|
-
process(frame: Frame
|
|
423
|
+
process(frame: Frame): Promise<void>;
|
|
202
424
|
/**
|
|
203
|
-
*
|
|
425
|
+
* Send a frame to the filter synchronously.
|
|
204
426
|
* Synchronous version of process.
|
|
205
427
|
*
|
|
206
|
-
*
|
|
428
|
+
* Sends a frame to the filter for processing.
|
|
429
|
+
* Does not return filtered frames - use {@link receiveSync} to retrieve frames.
|
|
207
430
|
* On first frame, automatically builds filter graph with frame properties.
|
|
208
|
-
*
|
|
209
|
-
* Hardware frames context is automatically detected from frame.
|
|
210
|
-
* Returns null if filter is closed and frame is null.
|
|
431
|
+
* A single input frame can produce zero, one, or multiple output frames.
|
|
211
432
|
*
|
|
212
|
-
*
|
|
433
|
+
* **Important**: This method only SENDS the frame to the filter.
|
|
434
|
+
* You must call {@link receiveSync} separately (potentially multiple times) to get filtered frames.
|
|
213
435
|
*
|
|
214
|
-
*
|
|
436
|
+
* Direct mapping to av_buffersrc_add_frame().
|
|
215
437
|
*
|
|
216
|
-
* @
|
|
438
|
+
* @param frame - Input frame to send to filter
|
|
217
439
|
*
|
|
218
440
|
* @throws {Error} If filter could not be initialized
|
|
219
441
|
*
|
|
220
|
-
* @throws {FFmpegError} If
|
|
442
|
+
* @throws {FFmpegError} If sending frame fails
|
|
221
443
|
*
|
|
222
444
|
* @example
|
|
223
445
|
* ```typescript
|
|
224
|
-
*
|
|
225
|
-
*
|
|
446
|
+
* // Send frame and receive filtered frames
|
|
447
|
+
* filter.processSync(inputFrame);
|
|
448
|
+
*
|
|
449
|
+
* // Receive all available filtered frames
|
|
450
|
+
* let output;
|
|
451
|
+
* while ((output = filter.receiveSync())) {
|
|
226
452
|
* console.log(`Got filtered frame: pts=${output.pts}`);
|
|
227
453
|
* output.free();
|
|
228
454
|
* }
|
|
229
455
|
* ```
|
|
230
456
|
*
|
|
231
|
-
* @
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
*
|
|
235
|
-
* if (output) {
|
|
236
|
-
* // Got output immediately
|
|
237
|
-
* yield output;
|
|
238
|
-
* }
|
|
239
|
-
* // For buffered frames, use the framesSync() generator
|
|
240
|
-
* ```
|
|
241
|
-
*
|
|
457
|
+
* @see {@link receiveSync} For receiving filtered frames
|
|
458
|
+
* @see {@link processAllSync} For combined send+receive operation
|
|
459
|
+
* @see {@link framesSync} For processing frame streams
|
|
460
|
+
* @see {@link flushSync} For end-of-stream handling
|
|
242
461
|
* @see {@link process} For async version
|
|
243
462
|
*/
|
|
244
|
-
processSync(frame: Frame
|
|
463
|
+
processSync(frame: Frame): void;
|
|
245
464
|
/**
|
|
246
|
-
* Process
|
|
465
|
+
* Process a frame through the filter.
|
|
466
|
+
*
|
|
467
|
+
* Applies filter operations to input frame and receives all available output frames.
|
|
468
|
+
* Returns array of frames - may be empty if filter needs more input.
|
|
469
|
+
* On first frame, automatically builds filter graph with frame properties.
|
|
470
|
+
* One input frame can produce zero, one, or multiple output frames depending on filter.
|
|
471
|
+
* Hardware frames context is automatically detected from frame.
|
|
247
472
|
*
|
|
248
|
-
*
|
|
249
|
-
* Useful for filters that buffer multiple frames.
|
|
473
|
+
* Direct mapping to av_buffersrc_add_frame() and av_buffersink_get_frame().
|
|
250
474
|
*
|
|
251
|
-
* @param
|
|
475
|
+
* @param frame - Input frame to process
|
|
252
476
|
*
|
|
253
|
-
* @returns Array of
|
|
477
|
+
* @returns Array of filtered frames (empty if buffered or filter closed)
|
|
254
478
|
*
|
|
255
|
-
* @throws {Error} If filter not
|
|
479
|
+
* @throws {Error} If filter could not be initialized
|
|
256
480
|
*
|
|
257
481
|
* @throws {FFmpegError} If processing fails
|
|
258
482
|
*
|
|
259
483
|
* @example
|
|
260
484
|
* ```typescript
|
|
261
|
-
* const
|
|
262
|
-
* for (const output of
|
|
263
|
-
* console.log(`
|
|
485
|
+
* const frames = await filter.processAll(inputFrame);
|
|
486
|
+
* for (const output of frames) {
|
|
487
|
+
* console.log(`Got filtered frame: pts=${output.pts}`);
|
|
264
488
|
* output.free();
|
|
265
489
|
* }
|
|
266
490
|
* ```
|
|
267
491
|
*
|
|
492
|
+
* @example
|
|
493
|
+
* ```typescript
|
|
494
|
+
* // Process frame - may return multiple frames (e.g. fps filter)
|
|
495
|
+
* const frames = await filter.processAll(frame);
|
|
496
|
+
* for (const output of frames) {
|
|
497
|
+
* yield output;
|
|
498
|
+
* }
|
|
499
|
+
* ```
|
|
500
|
+
*
|
|
268
501
|
* @see {@link process} For single frame processing
|
|
502
|
+
* @see {@link frames} For processing frame streams
|
|
503
|
+
* @see {@link flush} For end-of-stream handling
|
|
504
|
+
* @see {@link processAllSync} For synchronous version
|
|
269
505
|
*/
|
|
270
|
-
|
|
506
|
+
processAll(frame: Frame | null): Promise<Frame[]>;
|
|
271
507
|
/**
|
|
272
|
-
* Process
|
|
273
|
-
* Synchronous version of
|
|
508
|
+
* Process a frame through the filter synchronously.
|
|
509
|
+
* Synchronous version of processAll.
|
|
274
510
|
*
|
|
275
|
-
*
|
|
276
|
-
*
|
|
511
|
+
* Applies filter operations to input frame and receives all available output frames.
|
|
512
|
+
* Returns array of frames - may be empty if filter needs more input.
|
|
513
|
+
* On first frame, automatically builds filter graph with frame properties.
|
|
514
|
+
* One input frame can produce zero, one, or multiple output frames depending on filter.
|
|
515
|
+
* Hardware frames context is automatically detected from frame.
|
|
277
516
|
*
|
|
278
|
-
*
|
|
517
|
+
* Direct mapping to av_buffersrc_add_frame() and av_buffersink_get_frame().
|
|
279
518
|
*
|
|
280
|
-
* @
|
|
519
|
+
* @param frame - Input frame to process
|
|
281
520
|
*
|
|
282
|
-
* @
|
|
521
|
+
* @returns Array of filtered frames (empty if buffered or filter closed)
|
|
522
|
+
*
|
|
523
|
+
* @throws {Error} If filter could not be initialized
|
|
283
524
|
*
|
|
284
525
|
* @throws {FFmpegError} If processing fails
|
|
285
526
|
*
|
|
286
527
|
* @example
|
|
287
528
|
* ```typescript
|
|
288
|
-
* const outputs = filter.
|
|
529
|
+
* const outputs = filter.processAllSync(inputFrame);
|
|
289
530
|
* for (const output of outputs) {
|
|
290
|
-
* console.log(`
|
|
531
|
+
* console.log(`Got filtered frame: pts=${output.pts}`);
|
|
291
532
|
* output.free();
|
|
292
533
|
* }
|
|
293
534
|
* ```
|
|
294
535
|
*
|
|
295
|
-
* @
|
|
536
|
+
* @example
|
|
537
|
+
* ```typescript
|
|
538
|
+
* // Process frame - may return multiple frames (e.g. fps filter)
|
|
539
|
+
* const outputs = filter.processAllSync(frame);
|
|
540
|
+
* for (const output of outputs) {
|
|
541
|
+
* yield output;
|
|
542
|
+
* }
|
|
543
|
+
* ```
|
|
544
|
+
*
|
|
545
|
+
* @see {@link processSync} For single frame processing
|
|
546
|
+
* @see {@link framesSync} For processing frame streams
|
|
547
|
+
* @see {@link flushSync} For end-of-stream handling
|
|
548
|
+
* @see {@link process} For async version
|
|
296
549
|
*/
|
|
297
|
-
|
|
550
|
+
processAllSync(frame: Frame): Frame[];
|
|
298
551
|
/**
|
|
299
552
|
* Process frame stream through filter.
|
|
300
553
|
*
|
|
301
554
|
* High-level async generator for filtering frame streams.
|
|
302
|
-
*
|
|
303
|
-
*
|
|
555
|
+
* Filter is only flushed when EOF (null) signal is explicitly received.
|
|
556
|
+
* Primary interface for stream-based filtering.
|
|
557
|
+
*
|
|
558
|
+
* **EOF Handling:**
|
|
559
|
+
* - Send null to flush filter and get remaining buffered frames
|
|
560
|
+
* - Generator yields null after flushing when null is received
|
|
561
|
+
* - No automatic flushing - filter stays open until EOF or close()
|
|
304
562
|
*
|
|
305
|
-
* @param frames - Async
|
|
563
|
+
* @param frames - Async iterable of frames, single frame, or null to flush
|
|
306
564
|
*
|
|
307
|
-
* @yields {Frame} Filtered frames
|
|
565
|
+
* @yields {Frame | null} Filtered frames, followed by null when explicitly flushed
|
|
308
566
|
*
|
|
309
567
|
* @throws {Error} If filter not ready
|
|
310
568
|
*
|
|
@@ -312,8 +570,12 @@ export declare class FilterAPI implements Disposable {
|
|
|
312
570
|
*
|
|
313
571
|
* @example
|
|
314
572
|
* ```typescript
|
|
315
|
-
* //
|
|
573
|
+
* // Stream of frames with automatic EOF propagation
|
|
316
574
|
* for await (const frame of filter.frames(decoder.frames(packets))) {
|
|
575
|
+
* if (frame === null) {
|
|
576
|
+
* console.log('Filter flushed');
|
|
577
|
+
* break;
|
|
578
|
+
* }
|
|
317
579
|
* await encoder.encode(frame);
|
|
318
580
|
* frame.free();
|
|
319
581
|
* }
|
|
@@ -321,35 +583,48 @@ export declare class FilterAPI implements Disposable {
|
|
|
321
583
|
*
|
|
322
584
|
* @example
|
|
323
585
|
* ```typescript
|
|
324
|
-
* //
|
|
325
|
-
* const
|
|
326
|
-
*
|
|
327
|
-
*
|
|
328
|
-
*
|
|
329
|
-
*
|
|
330
|
-
*
|
|
586
|
+
* // Single frame - no automatic flush
|
|
587
|
+
* for await (const frame of filter.frames(singleFrame)) {
|
|
588
|
+
* await encoder.encode(frame);
|
|
589
|
+
* frame.free();
|
|
590
|
+
* }
|
|
591
|
+
* // Filter remains open, buffered frames not flushed
|
|
592
|
+
* ```
|
|
331
593
|
*
|
|
332
|
-
*
|
|
333
|
-
*
|
|
594
|
+
* @example
|
|
595
|
+
* ```typescript
|
|
596
|
+
* // Explicit flush with EOF
|
|
597
|
+
* for await (const frame of filter.frames(null)) {
|
|
598
|
+
* if (frame === null) {
|
|
599
|
+
* console.log('All buffered frames flushed');
|
|
600
|
+
* break;
|
|
601
|
+
* }
|
|
602
|
+
* console.log('Buffered frame:', frame.pts);
|
|
334
603
|
* frame.free();
|
|
335
604
|
* }
|
|
336
605
|
* ```
|
|
337
606
|
*
|
|
338
607
|
* @see {@link process} For single frame processing
|
|
339
|
-
* @see {@link
|
|
608
|
+
* @see {@link Decoder.frames} For frames source
|
|
609
|
+
* @see {@link framesSync} For sync version
|
|
340
610
|
*/
|
|
341
|
-
frames(frames:
|
|
611
|
+
frames(frames: AsyncIterable<Frame | null> | Frame | null): AsyncGenerator<Frame | null>;
|
|
342
612
|
/**
|
|
343
613
|
* Process frame stream through filter synchronously.
|
|
344
614
|
* Synchronous version of frames.
|
|
345
615
|
*
|
|
346
616
|
* High-level sync generator for filtering frame streams.
|
|
347
|
-
*
|
|
348
|
-
*
|
|
617
|
+
* Filter is only flushed when EOF (null) signal is explicitly received.
|
|
618
|
+
* Primary interface for stream-based filtering.
|
|
619
|
+
*
|
|
620
|
+
* **EOF Handling:**
|
|
621
|
+
* - Send null to flush filter and get remaining buffered frames
|
|
622
|
+
* - Generator yields null after flushing when null is received
|
|
623
|
+
* - No automatic flushing - filter stays open until EOF or close()
|
|
349
624
|
*
|
|
350
|
-
* @param frames -
|
|
625
|
+
* @param frames - Iterable of frames, single frame, or null to flush
|
|
351
626
|
*
|
|
352
|
-
* @yields {Frame} Filtered frames
|
|
627
|
+
* @yields {Frame | null} Filtered frames, followed by null when explicitly flushed
|
|
353
628
|
*
|
|
354
629
|
* @throws {Error} If filter not ready
|
|
355
630
|
*
|
|
@@ -357,8 +632,12 @@ export declare class FilterAPI implements Disposable {
|
|
|
357
632
|
*
|
|
358
633
|
* @example
|
|
359
634
|
* ```typescript
|
|
360
|
-
* //
|
|
635
|
+
* // Stream of frames with automatic EOF propagation
|
|
361
636
|
* for (const frame of filter.framesSync(decoder.framesSync(packets))) {
|
|
637
|
+
* if (frame === null) {
|
|
638
|
+
* console.log('Filter flushed');
|
|
639
|
+
* break;
|
|
640
|
+
* }
|
|
362
641
|
* encoder.encodeSync(frame);
|
|
363
642
|
* frame.free();
|
|
364
643
|
* }
|
|
@@ -366,23 +645,32 @@ export declare class FilterAPI implements Disposable {
|
|
|
366
645
|
*
|
|
367
646
|
* @example
|
|
368
647
|
* ```typescript
|
|
369
|
-
* //
|
|
370
|
-
* const
|
|
371
|
-
*
|
|
372
|
-
*
|
|
373
|
-
*
|
|
374
|
-
*
|
|
375
|
-
*
|
|
648
|
+
* // Single frame - no automatic flush
|
|
649
|
+
* for (const frame of filter.framesSync(singleFrame)) {
|
|
650
|
+
* encoder.encodeSync(frame);
|
|
651
|
+
* frame.free();
|
|
652
|
+
* }
|
|
653
|
+
* // Filter remains open, buffered frames not flushed
|
|
654
|
+
* ```
|
|
376
655
|
*
|
|
377
|
-
*
|
|
378
|
-
*
|
|
656
|
+
* @example
|
|
657
|
+
* ```typescript
|
|
658
|
+
* // Explicit flush with EOF
|
|
659
|
+
* for (const frame of filter.framesSync(null)) {
|
|
660
|
+
* if (frame === null) {
|
|
661
|
+
* console.log('All buffered frames flushed');
|
|
662
|
+
* break;
|
|
663
|
+
* }
|
|
664
|
+
* console.log('Buffered frame:', frame.pts);
|
|
379
665
|
* frame.free();
|
|
380
666
|
* }
|
|
381
667
|
* ```
|
|
382
668
|
*
|
|
669
|
+
* @see {@link processSync} For single frame processing
|
|
670
|
+
* @see {@link Decoder.framesSync} For frames source
|
|
383
671
|
* @see {@link frames} For async version
|
|
384
672
|
*/
|
|
385
|
-
framesSync(frames:
|
|
673
|
+
framesSync(frames: Iterable<Frame | null> | Frame | null): Generator<Frame | null>;
|
|
386
674
|
/**
|
|
387
675
|
* Flush filter and signal end-of-stream.
|
|
388
676
|
*
|
|
@@ -405,7 +693,8 @@ export declare class FilterAPI implements Disposable {
|
|
|
405
693
|
* ```
|
|
406
694
|
*
|
|
407
695
|
* @see {@link flushFrames} For async iteration
|
|
408
|
-
* @see {@link
|
|
696
|
+
* @see {@link receive} For getting flushed frames
|
|
697
|
+
* @see {@link flushSync} For synchronous version
|
|
409
698
|
*/
|
|
410
699
|
flush(): Promise<void>;
|
|
411
700
|
/**
|
|
@@ -430,6 +719,8 @@ export declare class FilterAPI implements Disposable {
|
|
|
430
719
|
* }
|
|
431
720
|
* ```
|
|
432
721
|
*
|
|
722
|
+
* @see {@link flushFramesSync} For sync iteration
|
|
723
|
+
* @see {@link receiveSync} For getting flushed frames
|
|
433
724
|
* @see {@link flush} For async version
|
|
434
725
|
*/
|
|
435
726
|
flushSync(): void;
|
|
@@ -452,8 +743,9 @@ export declare class FilterAPI implements Disposable {
|
|
|
452
743
|
* }
|
|
453
744
|
* ```
|
|
454
745
|
*
|
|
746
|
+
* @see {@link process} For frame processing
|
|
455
747
|
* @see {@link flush} For manual flush
|
|
456
|
-
* @see {@link
|
|
748
|
+
* @see {@link flushFramesSync} For sync version
|
|
457
749
|
*/
|
|
458
750
|
flushFrames(): AsyncGenerator<Frame>;
|
|
459
751
|
/**
|
|
@@ -476,6 +768,8 @@ export declare class FilterAPI implements Disposable {
|
|
|
476
768
|
* }
|
|
477
769
|
* ```
|
|
478
770
|
*
|
|
771
|
+
* @see {@link processSync} For frame processing
|
|
772
|
+
* @see {@link flushSync} For manual flush
|
|
479
773
|
* @see {@link flushFrames} For async version
|
|
480
774
|
*/
|
|
481
775
|
flushFramesSync(): Generator<Frame>;
|
|
@@ -483,51 +777,101 @@ export declare class FilterAPI implements Disposable {
|
|
|
483
777
|
* Receive buffered frame from filter.
|
|
484
778
|
*
|
|
485
779
|
* Drains frames buffered by the filter.
|
|
486
|
-
* Call repeatedly until null to get all buffered frames.
|
|
487
|
-
*
|
|
780
|
+
* Call repeatedly until null or EOF to get all buffered frames.
|
|
781
|
+
* Implements FFmpeg's send/receive pattern.
|
|
782
|
+
*
|
|
783
|
+
* **Return Values:**
|
|
784
|
+
* - `Frame` - Successfully received frame (AVERROR >= 0)
|
|
785
|
+
* - `null` - Need more input data (AVERROR_EAGAIN), or filter not initialized
|
|
786
|
+
* - `undefined` - End of stream reached (AVERROR_EOF), or filter is closed
|
|
488
787
|
*
|
|
489
788
|
* Direct mapping to av_buffersink_get_frame().
|
|
490
789
|
*
|
|
491
|
-
* @returns Buffered frame or
|
|
790
|
+
* @returns Buffered frame, null if need more data, or undefined if stream ended
|
|
492
791
|
*
|
|
493
792
|
* @throws {FFmpegError} If receiving fails
|
|
494
793
|
*
|
|
495
794
|
* @example
|
|
496
795
|
* ```typescript
|
|
497
|
-
*
|
|
498
|
-
* while (
|
|
796
|
+
* // Process all buffered frames
|
|
797
|
+
* while (true) {
|
|
798
|
+
* const frame = await filter.receive();
|
|
799
|
+
* if (!frame) break; // Stop on EAGAIN or EOF
|
|
499
800
|
* console.log(`Received frame: pts=${frame.pts}`);
|
|
500
801
|
* frame.free();
|
|
501
802
|
* }
|
|
502
803
|
* ```
|
|
804
|
+
*
|
|
805
|
+
* @example
|
|
806
|
+
* ```typescript
|
|
807
|
+
* // Handle each return value explicitly
|
|
808
|
+
* const frame = await filter.receive();
|
|
809
|
+
* if (frame === EOF) {
|
|
810
|
+
* console.log('Filter stream ended');
|
|
811
|
+
* } else if (frame === null) {
|
|
812
|
+
* console.log('Need more input data');
|
|
813
|
+
* } else {
|
|
814
|
+
* console.log(`Got frame: pts=${frame.pts}`);
|
|
815
|
+
* frame.free();
|
|
816
|
+
* }
|
|
817
|
+
* ```
|
|
818
|
+
*
|
|
819
|
+
* @see {@link process} For frame processing
|
|
820
|
+
* @see {@link flush} For flushing filter
|
|
821
|
+
* @see {@link receiveSync} For synchronous version
|
|
822
|
+
* @see {@link EOF} For end-of-stream signal
|
|
503
823
|
*/
|
|
504
|
-
receive(): Promise<Frame | null>;
|
|
824
|
+
receive(): Promise<Frame | EOFSignal | null>;
|
|
505
825
|
/**
|
|
506
826
|
* Receive buffered frame from filter synchronously.
|
|
507
827
|
* Synchronous version of receive.
|
|
508
828
|
*
|
|
509
829
|
* Drains frames buffered by the filter.
|
|
510
|
-
* Call repeatedly until null to get all buffered frames.
|
|
511
|
-
*
|
|
830
|
+
* Call repeatedly until null or EOF to get all buffered frames.
|
|
831
|
+
* Implements FFmpeg's send/receive pattern.
|
|
832
|
+
*
|
|
833
|
+
* **Return Values:**
|
|
834
|
+
* - `Frame` - Successfully received frame (AVERROR >= 0)
|
|
835
|
+
* - `null` - Need more input data (AVERROR_EAGAIN), or filter not initialized
|
|
836
|
+
* - `undefined` - End of stream reached (AVERROR_EOF), or filter is closed
|
|
512
837
|
*
|
|
513
838
|
* Direct mapping to av_buffersink_get_frame().
|
|
514
839
|
*
|
|
515
|
-
* @returns Buffered frame or
|
|
840
|
+
* @returns Buffered frame, null if need more data, or undefined if stream ended
|
|
516
841
|
*
|
|
517
842
|
* @throws {FFmpegError} If receiving fails
|
|
518
843
|
*
|
|
519
844
|
* @example
|
|
520
845
|
* ```typescript
|
|
521
|
-
*
|
|
522
|
-
* while (
|
|
846
|
+
* // Process all buffered frames
|
|
847
|
+
* while (true) {
|
|
848
|
+
* const frame = filter.receiveSync();
|
|
849
|
+
* if (!frame) break; // Stop on EAGAIN or EOF
|
|
523
850
|
* console.log(`Received frame: pts=${frame.pts}`);
|
|
524
851
|
* frame.free();
|
|
525
852
|
* }
|
|
526
853
|
* ```
|
|
527
854
|
*
|
|
855
|
+
* @example
|
|
856
|
+
* ```typescript
|
|
857
|
+
* // Handle each return value explicitly
|
|
858
|
+
* const frame = filter.receiveSync();
|
|
859
|
+
* if (frame === EOF) {
|
|
860
|
+
* console.log('Filter stream ended');
|
|
861
|
+
* } else if (frame === null) {
|
|
862
|
+
* console.log('Need more input data');
|
|
863
|
+
* } else {
|
|
864
|
+
* console.log(`Got frame: pts=${frame.pts}`);
|
|
865
|
+
* frame.free();
|
|
866
|
+
* }
|
|
867
|
+
* ```
|
|
868
|
+
*
|
|
869
|
+
* @see {@link processSync} For frame processing
|
|
870
|
+
* @see {@link flushSync} For flushing filter
|
|
528
871
|
* @see {@link receive} For async version
|
|
872
|
+
* @see {@link EOF} For end-of-stream signal
|
|
529
873
|
*/
|
|
530
|
-
receiveSync(): Frame | null;
|
|
874
|
+
receiveSync(): Frame | EOFSignal | null;
|
|
531
875
|
/**
|
|
532
876
|
* Send command to filter.
|
|
533
877
|
*
|
|
@@ -591,6 +935,20 @@ export declare class FilterAPI implements Disposable {
|
|
|
591
935
|
* @see {@link sendCommand} For immediate commands
|
|
592
936
|
*/
|
|
593
937
|
queueCommand(target: string, cmd: string, arg: string, ts: number, flags?: AVFilterCmdFlag): void;
|
|
938
|
+
/**
|
|
939
|
+
* Pipe decoded frames to a filter component or encoder.
|
|
940
|
+
*
|
|
941
|
+
* @param target - Filter to receive frames or encoder to encode frames
|
|
942
|
+
*
|
|
943
|
+
* @returns Scheduler for continued chaining
|
|
944
|
+
*
|
|
945
|
+
* @example
|
|
946
|
+
* ```typescript
|
|
947
|
+
* decoder.pipeTo(filter).pipeTo(encoder)
|
|
948
|
+
* ```
|
|
949
|
+
*/
|
|
950
|
+
pipeTo(target: FilterAPI): Scheduler<Frame>;
|
|
951
|
+
pipeTo(target: Encoder): Scheduler<Frame>;
|
|
594
952
|
/**
|
|
595
953
|
* Free filter resources.
|
|
596
954
|
*
|
|
@@ -605,6 +963,39 @@ export declare class FilterAPI implements Disposable {
|
|
|
605
963
|
* @see {@link Symbol.dispose} For automatic cleanup
|
|
606
964
|
*/
|
|
607
965
|
close(): void;
|
|
966
|
+
/**
|
|
967
|
+
* Worker loop for push-based processing.
|
|
968
|
+
*
|
|
969
|
+
* @internal
|
|
970
|
+
*/
|
|
971
|
+
private runWorker;
|
|
972
|
+
/**
|
|
973
|
+
* Send frame to input queue or flush the pipeline.
|
|
974
|
+
*
|
|
975
|
+
* When frame is provided, queues it for filtering.
|
|
976
|
+
* When null is provided, triggers flush sequence:
|
|
977
|
+
* - Closes input queue
|
|
978
|
+
* - Waits for worker completion
|
|
979
|
+
* - Flushes filter and sends remaining frames to output queue
|
|
980
|
+
* - Closes output queue
|
|
981
|
+
* - Waits for pipeTo task completion
|
|
982
|
+
* - Propagates flush to next component (if any)
|
|
983
|
+
*
|
|
984
|
+
* Used by scheduler system for pipeline control.
|
|
985
|
+
*
|
|
986
|
+
* @param frame - Frame to send, or null to flush
|
|
987
|
+
*
|
|
988
|
+
* @internal
|
|
989
|
+
*/
|
|
990
|
+
private sendToQueue;
|
|
991
|
+
/**
|
|
992
|
+
* Receive frame from output queue.
|
|
993
|
+
*
|
|
994
|
+
* @returns Frame from output queue or null if closed
|
|
995
|
+
*
|
|
996
|
+
* @internal
|
|
997
|
+
*/
|
|
998
|
+
private receiveFrame;
|
|
608
999
|
/**
|
|
609
1000
|
* Initialize filter graph from first frame.
|
|
610
1001
|
*
|
|
@@ -640,6 +1031,51 @@ export declare class FilterAPI implements Disposable {
|
|
|
640
1031
|
* @see {@link initialize} For async version
|
|
641
1032
|
*/
|
|
642
1033
|
private initializeSync;
|
|
1034
|
+
/**
|
|
1035
|
+
* Check if frame properties changed and handle according to dropOnChange/allowReinit options.
|
|
1036
|
+
*
|
|
1037
|
+
* Implements FFmpeg's IFILTER_FLAG_DROPCHANGED and IFILTER_FLAG_REINIT logic
|
|
1038
|
+
*
|
|
1039
|
+
* @param frame - Frame to check
|
|
1040
|
+
*
|
|
1041
|
+
* @returns true if frame should be processed, false if frame should be dropped
|
|
1042
|
+
*
|
|
1043
|
+
* @throws {Error} If format changed and allowReinit is false
|
|
1044
|
+
*
|
|
1045
|
+
* @internal
|
|
1046
|
+
*/
|
|
1047
|
+
private checkFramePropertiesChanged;
|
|
1048
|
+
/**
|
|
1049
|
+
* Calculate timeBase from frame based on media type and CFR option.
|
|
1050
|
+
*
|
|
1051
|
+
* Implements FFmpeg's ifilter_parameters_from_frame logic:
|
|
1052
|
+
* - Audio: Always { 1, sample_rate }
|
|
1053
|
+
* - Video CFR: 1/framerate (inverse of framerate)
|
|
1054
|
+
* - Video VFR: Use frame.timeBase
|
|
1055
|
+
*
|
|
1056
|
+
* @param frame - Input frame
|
|
1057
|
+
*
|
|
1058
|
+
* @returns Calculated timeBase
|
|
1059
|
+
*
|
|
1060
|
+
* @internal
|
|
1061
|
+
*/
|
|
1062
|
+
private calculateTimeBase;
|
|
1063
|
+
/**
|
|
1064
|
+
* Post-process output frame from buffersink.
|
|
1065
|
+
*
|
|
1066
|
+
* Applies FFmpeg's fg_output_step() behavior:
|
|
1067
|
+
* 1. Sets frame.timeBase from buffersink (filters can change timeBase, e.g., aresample)
|
|
1068
|
+
* 2. Calculates video frame duration from frame rate if not set
|
|
1069
|
+
*
|
|
1070
|
+
* This must be called AFTER buffersinkGetFrame() for every output frame.
|
|
1071
|
+
*
|
|
1072
|
+
* @param frame - Output frame from buffersink
|
|
1073
|
+
*
|
|
1074
|
+
* @throws {Error} If buffersink context not available
|
|
1075
|
+
*
|
|
1076
|
+
* @internal
|
|
1077
|
+
*/
|
|
1078
|
+
private postProcessOutputFrame;
|
|
643
1079
|
/**
|
|
644
1080
|
* Create buffer source with frame parameters.
|
|
645
1081
|
*
|