node-av 1.1.0 → 1.2.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 +51 -38
- package/dist/api/bitstream-filter.d.ts +180 -123
- package/dist/api/bitstream-filter.js +180 -125
- package/dist/api/bitstream-filter.js.map +1 -1
- package/dist/api/decoder.d.ts +279 -132
- package/dist/api/decoder.js +285 -142
- package/dist/api/decoder.js.map +1 -1
- package/dist/api/encoder.d.ts +246 -162
- package/dist/api/encoder.js +272 -208
- package/dist/api/encoder.js.map +1 -1
- package/dist/api/filter-presets.d.ts +690 -94
- package/dist/api/filter-presets.js +686 -102
- package/dist/api/filter-presets.js.map +1 -1
- package/dist/api/filter.d.ts +249 -213
- package/dist/api/filter.js +252 -242
- package/dist/api/filter.js.map +1 -1
- package/dist/api/hardware.d.ts +224 -117
- package/dist/api/hardware.js +380 -214
- package/dist/api/hardware.js.map +1 -1
- package/dist/api/index.d.ts +3 -3
- package/dist/api/index.js +1 -1
- package/dist/api/index.js.map +1 -1
- package/dist/api/io-stream.d.ts +65 -61
- package/dist/api/io-stream.js +43 -46
- package/dist/api/io-stream.js.map +1 -1
- package/dist/api/media-input.d.ts +242 -140
- package/dist/api/media-input.js +205 -103
- package/dist/api/media-input.js.map +1 -1
- package/dist/api/media-output.d.ts +206 -128
- package/dist/api/media-output.js +210 -128
- package/dist/api/media-output.js.map +1 -1
- package/dist/api/pipeline.d.ts +168 -38
- package/dist/api/pipeline.js +238 -14
- package/dist/api/pipeline.js.map +1 -1
- package/dist/api/types.d.ts +21 -187
- package/dist/api/utils.d.ts +1 -2
- package/dist/api/utils.js +9 -0
- package/dist/api/utils.js.map +1 -1
- package/dist/lib/audio-fifo.d.ts +127 -170
- package/dist/lib/audio-fifo.js +130 -173
- package/dist/lib/audio-fifo.js.map +1 -1
- package/dist/lib/binding.js +5 -0
- package/dist/lib/binding.js.map +1 -1
- package/dist/lib/bitstream-filter-context.d.ts +139 -184
- package/dist/lib/bitstream-filter-context.js +139 -188
- package/dist/lib/bitstream-filter-context.js.map +1 -1
- package/dist/lib/bitstream-filter.d.ts +68 -54
- package/dist/lib/bitstream-filter.js +68 -54
- package/dist/lib/bitstream-filter.js.map +1 -1
- package/dist/lib/codec-context.d.ts +316 -380
- package/dist/lib/codec-context.js +316 -381
- package/dist/lib/codec-context.js.map +1 -1
- package/dist/lib/codec-parameters.d.ts +160 -170
- package/dist/lib/codec-parameters.js +162 -172
- package/dist/lib/codec-parameters.js.map +1 -1
- package/dist/lib/codec-parser.d.ts +91 -104
- package/dist/lib/codec-parser.js +92 -103
- package/dist/lib/codec-parser.js.map +1 -1
- package/dist/lib/codec.d.ts +264 -281
- package/dist/lib/codec.js +268 -285
- package/dist/lib/codec.js.map +1 -1
- package/dist/lib/dictionary.d.ts +149 -203
- package/dist/lib/dictionary.js +158 -212
- package/dist/lib/dictionary.js.map +1 -1
- package/dist/lib/error.d.ts +96 -130
- package/dist/lib/error.js +98 -128
- package/dist/lib/error.js.map +1 -1
- package/dist/lib/filter-context.d.ts +284 -218
- package/dist/lib/filter-context.js +290 -227
- package/dist/lib/filter-context.js.map +1 -1
- package/dist/lib/filter-graph.d.ts +251 -292
- package/dist/lib/filter-graph.js +253 -294
- package/dist/lib/filter-graph.js.map +1 -1
- package/dist/lib/filter-inout.d.ts +87 -95
- package/dist/lib/filter-inout.js +87 -95
- package/dist/lib/filter-inout.js.map +1 -1
- package/dist/lib/filter.d.ts +93 -111
- package/dist/lib/filter.js +93 -111
- package/dist/lib/filter.js.map +1 -1
- package/dist/lib/format-context.d.ts +320 -428
- package/dist/lib/format-context.js +313 -385
- package/dist/lib/format-context.js.map +1 -1
- package/dist/lib/frame.d.ts +262 -405
- package/dist/lib/frame.js +263 -408
- package/dist/lib/frame.js.map +1 -1
- package/dist/lib/hardware-device-context.d.ts +149 -203
- package/dist/lib/hardware-device-context.js +149 -203
- package/dist/lib/hardware-device-context.js.map +1 -1
- package/dist/lib/hardware-frames-context.d.ts +170 -180
- package/dist/lib/hardware-frames-context.js +171 -181
- package/dist/lib/hardware-frames-context.js.map +1 -1
- package/dist/lib/index.d.ts +2 -1
- package/dist/lib/index.js +2 -2
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/input-format.d.ts +89 -117
- package/dist/lib/input-format.js +89 -117
- package/dist/lib/input-format.js.map +1 -1
- package/dist/lib/io-context.d.ts +209 -241
- package/dist/lib/io-context.js +220 -252
- package/dist/lib/io-context.js.map +1 -1
- package/dist/lib/log.d.ts +85 -119
- package/dist/lib/log.js +85 -122
- package/dist/lib/log.js.map +1 -1
- package/dist/lib/native-types.d.ts +117 -106
- package/dist/lib/native-types.js +0 -7
- package/dist/lib/native-types.js.map +1 -1
- package/dist/lib/option.d.ts +284 -241
- package/dist/lib/option.js +309 -249
- package/dist/lib/option.js.map +1 -1
- package/dist/lib/output-format.d.ts +77 -101
- package/dist/lib/output-format.js +77 -101
- package/dist/lib/output-format.js.map +1 -1
- package/dist/lib/packet.d.ts +172 -240
- package/dist/lib/packet.js +172 -241
- package/dist/lib/packet.js.map +1 -1
- package/dist/lib/rational.d.ts +0 -2
- package/dist/lib/rational.js +0 -2
- package/dist/lib/rational.js.map +1 -1
- package/dist/lib/software-resample-context.d.ts +241 -325
- package/dist/lib/software-resample-context.js +242 -326
- package/dist/lib/software-resample-context.js.map +1 -1
- package/dist/lib/software-scale-context.d.ts +129 -173
- package/dist/lib/software-scale-context.js +131 -175
- package/dist/lib/software-scale-context.js.map +1 -1
- package/dist/lib/stream.d.ts +87 -197
- package/dist/lib/stream.js +87 -197
- package/dist/lib/stream.js.map +1 -1
- package/dist/lib/utilities.d.ts +372 -181
- package/dist/lib/utilities.js +373 -182
- package/dist/lib/utilities.js.map +1 -1
- package/install/check.js +0 -1
- package/package.json +21 -12
- package/release_notes.md +43 -59
- package/CHANGELOG.md +0 -8
|
@@ -5,536 +5,495 @@ import type { FilterInOut } from './filter-inout.js';
|
|
|
5
5
|
import type { Filter } from './filter.js';
|
|
6
6
|
import type { NativeFilterGraph, NativeWrapper } from './native-types.js';
|
|
7
7
|
/**
|
|
8
|
-
* Filter graph for
|
|
8
|
+
* Filter graph for audio/video processing pipelines.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* Manages a collection of interconnected filters forming a processing pipeline.
|
|
11
|
+
* Filters are connected through their input/output pads to create complex
|
|
12
|
+
* audio/video transformations. Supports both simple linear chains and complex
|
|
13
|
+
* graphs with multiple inputs/outputs. Essential for effects, format conversions,
|
|
14
|
+
* scaling, and other media processing operations.
|
|
13
15
|
*
|
|
14
16
|
* Direct mapping to FFmpeg's AVFilterGraph.
|
|
15
17
|
*
|
|
16
18
|
* @example
|
|
17
19
|
* ```typescript
|
|
18
|
-
* import { FilterGraph, Filter,
|
|
20
|
+
* import { FilterGraph, Filter, FilterInOut, FFmpegError } from 'node-av';
|
|
19
21
|
*
|
|
20
|
-
* // Create and configure
|
|
22
|
+
* // Create and configure filter graph
|
|
21
23
|
* const graph = new FilterGraph();
|
|
22
24
|
* graph.alloc();
|
|
23
25
|
*
|
|
24
|
-
* // Create
|
|
25
|
-
* const bufferFilter = Filter.getByName('buffer');
|
|
26
|
-
* if (!bufferFilter) throw new Error('Buffer filter not found');
|
|
26
|
+
* // Create filters
|
|
27
27
|
* const bufferSrc = graph.createFilter(
|
|
28
|
-
*
|
|
29
|
-
* '
|
|
30
|
-
* 'video_size=1920x1080:pix_fmt=yuv420p
|
|
28
|
+
* Filter.getByName('buffer')!,
|
|
29
|
+
* 'src',
|
|
30
|
+
* 'video_size=1920x1080:pix_fmt=yuv420p'
|
|
31
31
|
* );
|
|
32
|
-
* if (!bufferSrc) throw new Error('Failed to create buffer source');
|
|
33
32
|
*
|
|
34
|
-
* // Create scale filter
|
|
35
|
-
* const scaleFilter = Filter.getByName('scale');
|
|
36
|
-
* if (!scaleFilter) throw new Error('Scale filter not found');
|
|
37
33
|
* const scale = graph.createFilter(
|
|
38
|
-
*
|
|
34
|
+
* Filter.getByName('scale')!,
|
|
39
35
|
* 'scale',
|
|
40
|
-
* '
|
|
36
|
+
* '640:480'
|
|
41
37
|
* );
|
|
42
|
-
* if (!scale) throw new Error('Failed to create scale filter');
|
|
43
38
|
*
|
|
44
|
-
* // Create buffer sink
|
|
45
|
-
* const sinkFilter = Filter.getByName('buffersink');
|
|
46
|
-
* if (!sinkFilter) throw new Error('Buffersink filter not found');
|
|
47
39
|
* const bufferSink = graph.createFilter(
|
|
48
|
-
*
|
|
49
|
-
* '
|
|
40
|
+
* Filter.getByName('buffersink')!,
|
|
41
|
+
* 'sink'
|
|
50
42
|
* );
|
|
51
|
-
* if (!bufferSink) throw new Error('Failed to create buffer sink');
|
|
52
43
|
*
|
|
53
44
|
* // Link filters
|
|
54
|
-
*
|
|
55
|
-
*
|
|
45
|
+
* bufferSrc.link(0, scale, 0);
|
|
46
|
+
* scale.link(0, bufferSink, 0);
|
|
56
47
|
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
48
|
+
* // Configure graph
|
|
49
|
+
* const ret = await graph.config();
|
|
50
|
+
* FFmpegError.throwIfError(ret, 'config');
|
|
59
51
|
*
|
|
60
|
-
* //
|
|
61
|
-
* const
|
|
62
|
-
* FFmpegError.throwIfError(
|
|
63
|
-
*
|
|
64
|
-
* // Clean up
|
|
65
|
-
* graph.free();
|
|
52
|
+
* // Parse filter string
|
|
53
|
+
* const ret2 = graph.parse2('[in]scale=640:480[out]');
|
|
54
|
+
* FFmpegError.throwIfError(ret2, 'parse2');
|
|
66
55
|
* ```
|
|
56
|
+
*
|
|
57
|
+
* @see [AVFilterGraph](https://ffmpeg.org/doxygen/trunk/structAVFilterGraph.html) - FFmpeg Doxygen
|
|
58
|
+
* @see {@link FilterContext} For filter instances
|
|
59
|
+
* @see {@link Filter} For filter descriptors
|
|
67
60
|
*/
|
|
68
61
|
export declare class FilterGraph extends OptionMember<NativeFilterGraph> implements Disposable, NativeWrapper<NativeFilterGraph> {
|
|
69
|
-
/**
|
|
70
|
-
* Create a new FilterGraph instance.
|
|
71
|
-
*
|
|
72
|
-
* The graph is uninitialized - you must call alloc() before use.
|
|
73
|
-
* No FFmpeg resources are allocated until alloc() is called.
|
|
74
|
-
*
|
|
75
|
-
* Direct wrapper around AVFilterGraph.
|
|
76
|
-
*
|
|
77
|
-
* @example
|
|
78
|
-
* ```typescript
|
|
79
|
-
* import { FilterGraph } from 'node-av';
|
|
80
|
-
*
|
|
81
|
-
* const graph = new FilterGraph();
|
|
82
|
-
* graph.alloc();
|
|
83
|
-
* // Graph is now ready for use
|
|
84
|
-
* ```
|
|
85
|
-
*/
|
|
86
62
|
constructor();
|
|
87
63
|
/**
|
|
88
64
|
* Number of filters in the graph.
|
|
89
65
|
*
|
|
90
|
-
*
|
|
66
|
+
* Total count of filter contexts in this graph.
|
|
91
67
|
*
|
|
92
|
-
*
|
|
68
|
+
* Direct mapping to AVFilterGraph->nb_filters.
|
|
93
69
|
*/
|
|
94
70
|
get nbFilters(): number;
|
|
95
71
|
/**
|
|
96
|
-
* Array of
|
|
97
|
-
*
|
|
98
|
-
* Direct mapping to AVFilterGraph->filters
|
|
72
|
+
* Array of filters in the graph.
|
|
99
73
|
*
|
|
100
74
|
* All filter contexts currently in the graph.
|
|
75
|
+
*
|
|
76
|
+
* Direct mapping to AVFilterGraph->filters.
|
|
101
77
|
*/
|
|
102
78
|
get filters(): FilterContext[] | null;
|
|
103
79
|
/**
|
|
104
|
-
*
|
|
80
|
+
* Threading type for graph execution.
|
|
105
81
|
*
|
|
106
|
-
*
|
|
82
|
+
* Controls how filters are executed in parallel.
|
|
83
|
+
* Use AVFILTER_THREAD_SLICE for slice-based threading.
|
|
107
84
|
*
|
|
108
|
-
*
|
|
85
|
+
* Direct mapping to AVFilterGraph->thread_type.
|
|
109
86
|
*/
|
|
110
87
|
get threadType(): AVFilterConstants;
|
|
111
88
|
set threadType(value: AVFilterConstants);
|
|
112
89
|
/**
|
|
113
|
-
* Number of threads for
|
|
90
|
+
* Number of threads for parallel processing.
|
|
114
91
|
*
|
|
115
|
-
*
|
|
92
|
+
* Number of threads used for filter execution.
|
|
93
|
+
* 0 means automatic detection.
|
|
116
94
|
*
|
|
117
|
-
*
|
|
95
|
+
* Direct mapping to AVFilterGraph->nb_threads.
|
|
118
96
|
*/
|
|
119
97
|
get nbThreads(): number;
|
|
120
98
|
set nbThreads(value: number);
|
|
121
99
|
/**
|
|
122
|
-
*
|
|
100
|
+
* Swscale options for scale filter.
|
|
123
101
|
*
|
|
124
|
-
*
|
|
102
|
+
* Options string passed to swscale for scaling operations.
|
|
125
103
|
*
|
|
126
|
-
*
|
|
104
|
+
* Direct mapping to AVFilterGraph->scale_sws_opts.
|
|
127
105
|
*/
|
|
128
106
|
get scaleSwsOpts(): string | null;
|
|
129
107
|
set scaleSwsOpts(value: string | null);
|
|
130
108
|
/**
|
|
131
|
-
* Allocate
|
|
109
|
+
* Allocate a filter graph.
|
|
132
110
|
*
|
|
133
|
-
* Allocates the graph structure
|
|
134
|
-
* Must be called before
|
|
111
|
+
* Allocates memory for the filter graph structure.
|
|
112
|
+
* Must be called before using the graph.
|
|
135
113
|
*
|
|
136
|
-
* Direct mapping to avfilter_graph_alloc()
|
|
114
|
+
* Direct mapping to avfilter_graph_alloc().
|
|
137
115
|
*
|
|
138
|
-
* @throws {Error}
|
|
116
|
+
* @throws {Error} If allocation fails (ENOMEM)
|
|
139
117
|
*
|
|
140
118
|
* @example
|
|
141
119
|
* ```typescript
|
|
142
|
-
* import { FilterGraph } from 'node-av';
|
|
143
|
-
*
|
|
144
120
|
* const graph = new FilterGraph();
|
|
145
121
|
* graph.alloc();
|
|
146
|
-
* // Graph is now
|
|
122
|
+
* // Graph is now ready for filter creation
|
|
147
123
|
* ```
|
|
148
124
|
*
|
|
149
|
-
* @see {@link free} To
|
|
125
|
+
* @see {@link free} To deallocate
|
|
126
|
+
* @see {@link config} To configure after building
|
|
150
127
|
*/
|
|
151
128
|
alloc(): void;
|
|
152
129
|
/**
|
|
153
130
|
* Free the filter graph.
|
|
154
131
|
*
|
|
155
|
-
* Releases all resources associated with the graph
|
|
156
|
-
*
|
|
132
|
+
* Releases all resources associated with the graph,
|
|
133
|
+
* including all contained filters.
|
|
157
134
|
*
|
|
158
|
-
* Direct mapping to avfilter_graph_free()
|
|
135
|
+
* Direct mapping to avfilter_graph_free().
|
|
159
136
|
*
|
|
160
137
|
* @example
|
|
161
138
|
* ```typescript
|
|
162
139
|
* graph.free();
|
|
163
|
-
* //
|
|
140
|
+
* // Graph is now invalid
|
|
164
141
|
* ```
|
|
142
|
+
*
|
|
143
|
+
* @see {@link alloc} To allocate
|
|
144
|
+
* @see {@link Symbol.dispose} For automatic cleanup
|
|
165
145
|
*/
|
|
166
146
|
free(): void;
|
|
167
147
|
/**
|
|
168
|
-
* Create a filter
|
|
148
|
+
* Create and initialize a filter in the graph.
|
|
169
149
|
*
|
|
170
|
-
*
|
|
150
|
+
* Creates a new filter context, adds it to the graph,
|
|
151
|
+
* and initializes it with the provided arguments.
|
|
171
152
|
*
|
|
172
|
-
*
|
|
173
|
-
* @param name - Name for this filter instance (must be unique in the graph)
|
|
174
|
-
* @param args - Optional initialization arguments (filter-specific format)
|
|
153
|
+
* Direct mapping to avfilter_graph_create_filter().
|
|
175
154
|
*
|
|
176
|
-
* @
|
|
155
|
+
* @param filter - Filter descriptor to instantiate
|
|
156
|
+
* @param name - Name for this filter instance
|
|
157
|
+
* @param args - Initialization arguments (filter-specific)
|
|
158
|
+
* @returns Created filter context, or null on failure
|
|
177
159
|
*
|
|
178
160
|
* @example
|
|
179
161
|
* ```typescript
|
|
180
162
|
* // Create a scale filter
|
|
181
|
-
* const
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
* '
|
|
185
|
-
* '1280:720' // width:height
|
|
163
|
+
* const scale = graph.createFilter(
|
|
164
|
+
* Filter.getByName('scale')!,
|
|
165
|
+
* 'scaler',
|
|
166
|
+
* '640:480' // width:height
|
|
186
167
|
* );
|
|
187
168
|
*
|
|
188
|
-
* // Create a buffer source
|
|
189
|
-
* const
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
* '
|
|
193
|
-
* 'video_size=1920x1080:pix_fmt=yuv420p:time_base=1/25:pixel_aspect=1/1'
|
|
169
|
+
* // Create a buffer source
|
|
170
|
+
* const src = graph.createFilter(
|
|
171
|
+
* Filter.getByName('buffer')!,
|
|
172
|
+
* 'source',
|
|
173
|
+
* 'video_size=1920x1080:pix_fmt=yuv420p:time_base=1/25'
|
|
194
174
|
* );
|
|
195
175
|
* ```
|
|
176
|
+
*
|
|
177
|
+
* @see {@link allocFilter} To allocate without initializing
|
|
178
|
+
* @see {@link getFilter} To retrieve by name
|
|
196
179
|
*/
|
|
197
180
|
createFilter(filter: Filter, name: string, args?: string | null): FilterContext | null;
|
|
198
181
|
/**
|
|
199
|
-
* Allocate a filter
|
|
182
|
+
* Allocate a filter in the graph.
|
|
200
183
|
*
|
|
201
|
-
*
|
|
184
|
+
* Creates a new filter context and adds it to the graph,
|
|
185
|
+
* but does not initialize it. Call init() on the context afterwards.
|
|
202
186
|
*
|
|
203
|
-
*
|
|
204
|
-
* You must call filter.init() or filter.initStr() afterwards.
|
|
187
|
+
* Direct mapping to avfilter_graph_alloc_filter().
|
|
205
188
|
*
|
|
206
|
-
* @param filter -
|
|
207
|
-
* @param name - Name for this filter instance
|
|
208
|
-
*
|
|
209
|
-
* @returns The allocated filter context or null on failure
|
|
189
|
+
* @param filter - Filter descriptor to instantiate
|
|
190
|
+
* @param name - Name for this filter instance
|
|
191
|
+
* @returns Allocated filter context, or null on failure
|
|
210
192
|
*
|
|
211
193
|
* @example
|
|
212
194
|
* ```typescript
|
|
213
|
-
* import {
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
*
|
|
219
|
-
* if (
|
|
220
|
-
*
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
* const ret2 = scaleCtx.setOpt('height', '720');
|
|
225
|
-
* FFmpegError.throwIfError(ret2, 'setOpt height');
|
|
226
|
-
*
|
|
227
|
-
* // Initialize the filter
|
|
228
|
-
* const initRet = scaleCtx.init();
|
|
229
|
-
* FFmpegError.throwIfError(initRet, 'init');
|
|
195
|
+
* import { FFmpegError } from 'node-av';
|
|
196
|
+
*
|
|
197
|
+
* const filter = graph.allocFilter(
|
|
198
|
+
* Filter.getByName('scale')!,
|
|
199
|
+
* 'scaler'
|
|
200
|
+
* );
|
|
201
|
+
* if (filter) {
|
|
202
|
+
* // Initialize separately
|
|
203
|
+
* const ret = filter.initStr('640:480');
|
|
204
|
+
* FFmpegError.throwIfError(ret, 'initStr');
|
|
205
|
+
* }
|
|
230
206
|
* ```
|
|
231
207
|
*
|
|
232
|
-
* @
|
|
233
|
-
* allowing options to be set before initialization.
|
|
208
|
+
* @see {@link createFilter} To allocate and initialize
|
|
234
209
|
*/
|
|
235
210
|
allocFilter(filter: Filter, name: string): FilterContext | null;
|
|
236
211
|
/**
|
|
237
212
|
* Get a filter by name from the graph.
|
|
238
213
|
*
|
|
239
|
-
*
|
|
214
|
+
* Retrieves an existing filter context by its instance name.
|
|
240
215
|
*
|
|
241
|
-
*
|
|
216
|
+
* Direct mapping to avfilter_graph_get_filter().
|
|
242
217
|
*
|
|
243
|
-
* @
|
|
218
|
+
* @param name - Name of the filter instance
|
|
219
|
+
* @returns Filter context if found, null otherwise
|
|
244
220
|
*
|
|
245
221
|
* @example
|
|
246
222
|
* ```typescript
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
*
|
|
223
|
+
* // Find a previously created filter
|
|
224
|
+
* const scaler = graph.getFilter('scaler');
|
|
225
|
+
* if (scaler) {
|
|
226
|
+
* console.log('Found scaler filter');
|
|
250
227
|
* }
|
|
251
228
|
* ```
|
|
229
|
+
*
|
|
230
|
+
* @see {@link createFilter} To create new filters
|
|
252
231
|
*/
|
|
253
232
|
getFilter(name: string): FilterContext | null;
|
|
254
233
|
/**
|
|
255
234
|
* Configure the filter graph.
|
|
256
235
|
*
|
|
257
|
-
*
|
|
236
|
+
* Validates and finalizes the graph configuration.
|
|
237
|
+
* Must be called after all filters are created and linked.
|
|
238
|
+
*
|
|
239
|
+
* Direct mapping to avfilter_graph_config().
|
|
258
240
|
*
|
|
259
241
|
* @returns 0 on success, negative AVERROR on error:
|
|
260
|
-
* -
|
|
261
|
-
* -
|
|
262
|
-
* - AVERROR(ENOMEM): Memory allocation failure
|
|
263
|
-
* - <0: Other configuration errors
|
|
242
|
+
* - AVERROR_EINVAL: Invalid graph configuration
|
|
243
|
+
* - AVERROR_ENOMEM: Memory allocation failure
|
|
264
244
|
*
|
|
265
245
|
* @example
|
|
266
246
|
* ```typescript
|
|
267
|
-
* import {
|
|
247
|
+
* import { FFmpegError } from 'node-av';
|
|
268
248
|
*
|
|
269
|
-
* //
|
|
270
|
-
*
|
|
249
|
+
* // Build graph...
|
|
250
|
+
* // Link filters...
|
|
251
|
+
*
|
|
252
|
+
* // Configure the complete graph
|
|
253
|
+
* const ret = await graph.config();
|
|
271
254
|
* FFmpegError.throwIfError(ret, 'config');
|
|
272
255
|
* // Graph is now ready for processing
|
|
273
256
|
* ```
|
|
274
257
|
*
|
|
275
|
-
* @
|
|
258
|
+
* @see {@link validate} To check configuration
|
|
276
259
|
*/
|
|
277
260
|
config(): Promise<number>;
|
|
278
261
|
/**
|
|
279
|
-
* Parse a
|
|
262
|
+
* Parse a filter graph description.
|
|
280
263
|
*
|
|
281
|
-
*
|
|
264
|
+
* Parses a textual representation of a filter graph and adds
|
|
265
|
+
* filters to this graph. Handles labeled inputs and outputs.
|
|
282
266
|
*
|
|
283
|
-
*
|
|
284
|
-
* @param inputs - Input pad list
|
|
285
|
-
* @param outputs - Output pad list
|
|
267
|
+
* Direct mapping to avfilter_graph_parse().
|
|
286
268
|
*
|
|
269
|
+
* @param filters - Filter graph description string
|
|
270
|
+
* @param inputs - Linked list of graph inputs
|
|
271
|
+
* @param outputs - Linked list of graph outputs
|
|
287
272
|
* @returns 0 on success, negative AVERROR on error:
|
|
288
|
-
* -
|
|
289
|
-
* -
|
|
290
|
-
* - AVERROR(ENOMEM): Memory allocation failure
|
|
291
|
-
* - <0: Other parsing errors
|
|
273
|
+
* - AVERROR_EINVAL: Parse error
|
|
274
|
+
* - AVERROR_ENOMEM: Memory allocation failure
|
|
292
275
|
*
|
|
293
276
|
* @example
|
|
294
277
|
* ```typescript
|
|
295
|
-
* import {
|
|
296
|
-
*
|
|
297
|
-
* const inputs =
|
|
298
|
-
*
|
|
299
|
-
*
|
|
300
|
-
*
|
|
301
|
-
*
|
|
302
|
-
*
|
|
303
|
-
*
|
|
304
|
-
*
|
|
305
|
-
*
|
|
306
|
-
*
|
|
307
|
-
*
|
|
308
|
-
*
|
|
309
|
-
* const ret = graph.parse('[in] scale=1280:720 [out]', inputs, outputs);
|
|
278
|
+
* import { FFmpegError, FilterInOut } from 'node-av';
|
|
279
|
+
*
|
|
280
|
+
* const inputs = FilterInOut.createList([
|
|
281
|
+
* { name: 'in', filterCtx: bufferSrc, padIdx: 0 }
|
|
282
|
+
* ]);
|
|
283
|
+
* const outputs = FilterInOut.createList([
|
|
284
|
+
* { name: 'out', filterCtx: bufferSink, padIdx: 0 }
|
|
285
|
+
* ]);
|
|
286
|
+
*
|
|
287
|
+
* const ret = graph.parse(
|
|
288
|
+
* '[in]scale=640:480,format=yuv420p[out]',
|
|
289
|
+
* inputs,
|
|
290
|
+
* outputs
|
|
291
|
+
* );
|
|
310
292
|
* FFmpegError.throwIfError(ret, 'parse');
|
|
311
293
|
* ```
|
|
294
|
+
*
|
|
295
|
+
* @see {@link parse2} For simpler syntax
|
|
296
|
+
* @see {@link parsePtr} For alternative parsing
|
|
312
297
|
*/
|
|
313
298
|
parse(filters: string, inputs: FilterInOut | null, outputs: FilterInOut | null): number;
|
|
314
299
|
/**
|
|
315
|
-
* Parse a
|
|
300
|
+
* Parse a filter graph description (simplified).
|
|
316
301
|
*
|
|
317
|
-
*
|
|
302
|
+
* Parses a textual filter description with automatic input/output handling.
|
|
303
|
+
* Simpler than parse() but less flexible.
|
|
318
304
|
*
|
|
319
|
-
*
|
|
305
|
+
* Direct mapping to avfilter_graph_parse2().
|
|
320
306
|
*
|
|
307
|
+
* @param filters - Filter graph description string
|
|
321
308
|
* @returns 0 on success, negative AVERROR on error:
|
|
322
|
-
* -
|
|
323
|
-
* -
|
|
324
|
-
* - AVERROR(ENOMEM): Memory allocation failure
|
|
325
|
-
* - <0: Other parsing errors
|
|
309
|
+
* - AVERROR_EINVAL: Parse error
|
|
310
|
+
* - AVERROR_ENOMEM: Memory allocation failure
|
|
326
311
|
*
|
|
327
312
|
* @example
|
|
328
313
|
* ```typescript
|
|
329
|
-
* import {
|
|
314
|
+
* import { FFmpegError } from 'node-av';
|
|
330
315
|
*
|
|
331
316
|
* // Parse a simple filter chain
|
|
332
|
-
* const ret = graph.parse2(
|
|
317
|
+
* const ret = graph.parse2(
|
|
318
|
+
* 'scale=640:480,format=yuv420p'
|
|
319
|
+
* );
|
|
333
320
|
* FFmpegError.throwIfError(ret, 'parse2');
|
|
334
321
|
* ```
|
|
335
322
|
*
|
|
336
|
-
* @
|
|
323
|
+
* @see {@link parse} For labeled inputs/outputs
|
|
337
324
|
*/
|
|
338
325
|
parse2(filters: string): number;
|
|
339
326
|
/**
|
|
340
|
-
* Parse a
|
|
327
|
+
* Parse a filter graph description with pointer.
|
|
341
328
|
*
|
|
342
|
-
*
|
|
329
|
+
* Alternative parsing method with different parameter handling.
|
|
343
330
|
*
|
|
344
|
-
*
|
|
345
|
-
* @param inputs - Optional input pad list (FilterInOut)
|
|
346
|
-
* @param outputs - Optional output pad list (FilterInOut)
|
|
331
|
+
* Direct mapping to avfilter_graph_parse_ptr().
|
|
347
332
|
*
|
|
333
|
+
* @param filters - Filter graph description string
|
|
334
|
+
* @param inputs - Optional linked list of inputs
|
|
335
|
+
* @param outputs - Optional linked list of outputs
|
|
348
336
|
* @returns 0 on success, negative AVERROR on error:
|
|
349
|
-
* -
|
|
350
|
-
* -
|
|
351
|
-
* - AVERROR(ENOMEM): Memory allocation failure
|
|
352
|
-
* - <0: Other parsing errors
|
|
337
|
+
* - AVERROR_EINVAL: Parse error
|
|
338
|
+
* - AVERROR_ENOMEM: Memory allocation failure
|
|
353
339
|
*
|
|
354
340
|
* @example
|
|
355
341
|
* ```typescript
|
|
356
|
-
* import {
|
|
342
|
+
* import { FFmpegError } from 'node-av';
|
|
357
343
|
*
|
|
358
|
-
* // Parse a complex filter graph
|
|
359
344
|
* const ret = graph.parsePtr(
|
|
360
|
-
* '[
|
|
345
|
+
* '[in]scale=w=640:h=480[out]'
|
|
361
346
|
* );
|
|
362
347
|
* FFmpegError.throwIfError(ret, 'parsePtr');
|
|
363
348
|
* ```
|
|
364
349
|
*
|
|
365
|
-
* @
|
|
366
|
-
*
|
|
367
|
-
* import { FilterGraph, FilterInOut, FFmpegError } from 'node-av';
|
|
368
|
-
*
|
|
369
|
-
* // Parse with explicit inputs/outputs
|
|
370
|
-
* const inputs = new FilterInOut();
|
|
371
|
-
* inputs.name = 'in';
|
|
372
|
-
* inputs.filterCtx = buffersrcCtx;
|
|
373
|
-
* inputs.padIdx = 0;
|
|
374
|
-
*
|
|
375
|
-
* const outputs = new FilterInOut();
|
|
376
|
-
* outputs.name = 'out';
|
|
377
|
-
* outputs.filterCtx = buffersinkCtx;
|
|
378
|
-
* outputs.padIdx = 0;
|
|
379
|
-
*
|
|
380
|
-
* const ret = graph.parsePtr(filtersDescr, inputs, outputs);
|
|
381
|
-
* FFmpegError.throwIfError(ret, 'parsePtr');
|
|
382
|
-
* ```
|
|
383
|
-
*
|
|
384
|
-
* @note Similar to parse2 but with different internal handling.
|
|
350
|
+
* @see {@link parse} For standard parsing
|
|
351
|
+
* @see {@link parse2} For simplified parsing
|
|
385
352
|
*/
|
|
386
353
|
parsePtr(filters: string, inputs?: FilterInOut | null, outputs?: FilterInOut | null): number;
|
|
387
354
|
/**
|
|
388
|
-
* Validate the filter graph.
|
|
355
|
+
* Validate the filter graph configuration.
|
|
389
356
|
*
|
|
390
|
-
*
|
|
357
|
+
* Checks if the graph is valid and properly configured.
|
|
358
|
+
* Does not finalize the graph like config() does.
|
|
391
359
|
*
|
|
392
360
|
* @returns 0 on success, negative AVERROR on error:
|
|
393
|
-
* -
|
|
394
|
-
* - AVERROR(EINVAL): Invalid graph structure
|
|
395
|
-
* - <0: Other validation errors
|
|
361
|
+
* - AVERROR_EINVAL: Invalid configuration
|
|
396
362
|
*
|
|
397
363
|
* @example
|
|
398
364
|
* ```typescript
|
|
399
|
-
*
|
|
365
|
+
* import { FFmpegError } from 'node-av';
|
|
366
|
+
*
|
|
400
367
|
* const ret = graph.validate();
|
|
401
|
-
*
|
|
402
|
-
* console.error('Graph validation failed');
|
|
403
|
-
* }
|
|
368
|
+
* FFmpegError.throwIfError(ret, 'validate');
|
|
404
369
|
* ```
|
|
405
370
|
*
|
|
406
|
-
* @
|
|
371
|
+
* @see {@link config} To configure and finalize
|
|
407
372
|
*/
|
|
408
373
|
validate(): number;
|
|
409
374
|
/**
|
|
410
375
|
* Request a frame from the oldest sink.
|
|
411
376
|
*
|
|
412
|
-
*
|
|
377
|
+
* Requests that a frame be output from the oldest sink in the graph.
|
|
378
|
+
* Used to drive the filter graph processing.
|
|
379
|
+
*
|
|
380
|
+
* Direct mapping to avfilter_graph_request_oldest().
|
|
413
381
|
*
|
|
414
382
|
* @returns 0 on success, negative AVERROR on error:
|
|
415
|
-
* -
|
|
416
|
-
* -
|
|
417
|
-
* - AVERROR(EAGAIN): Need more input data
|
|
418
|
-
* - <0: Other processing errors
|
|
383
|
+
* - AVERROR_EOF: End of stream reached
|
|
384
|
+
* - AVERROR_EAGAIN: Need more input
|
|
419
385
|
*
|
|
420
386
|
* @example
|
|
421
387
|
* ```typescript
|
|
422
|
-
* import {
|
|
388
|
+
* import { FFmpegError } from 'node-av';
|
|
423
389
|
* import { AVERROR_EOF, AVERROR_EAGAIN } from 'node-av/constants';
|
|
424
390
|
*
|
|
425
|
-
*
|
|
426
|
-
*
|
|
427
|
-
*
|
|
428
|
-
*
|
|
429
|
-
*
|
|
430
|
-
*
|
|
431
|
-
*
|
|
432
|
-
* FFmpegError.throwIfError(ret, 'requestOldest');
|
|
433
|
-
* }
|
|
434
|
-
* // Process output from sinks
|
|
391
|
+
* const ret = await graph.requestOldest();
|
|
392
|
+
* if (ret === AVERROR_EOF) {
|
|
393
|
+
* // No more frames
|
|
394
|
+
* } else if (ret === AVERROR_EAGAIN) {
|
|
395
|
+
* // Need to provide more input
|
|
396
|
+
* } else {
|
|
397
|
+
* FFmpegError.throwIfError(ret, 'requestOldest');
|
|
435
398
|
* }
|
|
436
399
|
* ```
|
|
437
|
-
*
|
|
438
|
-
* @note Triggers processing in the graph to produce output.
|
|
439
400
|
*/
|
|
440
401
|
requestOldest(): Promise<number>;
|
|
441
402
|
/**
|
|
442
|
-
*
|
|
403
|
+
* Dump the filter graph to a string.
|
|
443
404
|
*
|
|
444
|
-
* Returns a
|
|
445
|
-
*
|
|
405
|
+
* Returns a textual representation of the graph structure.
|
|
406
|
+
* Useful for debugging and visualization.
|
|
446
407
|
*
|
|
447
|
-
*
|
|
408
|
+
* Direct mapping to avfilter_graph_dump().
|
|
409
|
+
*
|
|
410
|
+
* @returns Graph description string, or null on failure
|
|
448
411
|
*
|
|
449
412
|
* @example
|
|
450
413
|
* ```typescript
|
|
451
|
-
* const
|
|
452
|
-
*
|
|
414
|
+
* const graphStr = graph.dump();
|
|
415
|
+
* if (graphStr) {
|
|
416
|
+
* console.log('Graph structure:');
|
|
417
|
+
* console.log(graphStr);
|
|
418
|
+
* }
|
|
453
419
|
* ```
|
|
454
420
|
*/
|
|
455
421
|
dump(): string | null;
|
|
456
422
|
/**
|
|
457
|
-
* Send a command to
|
|
458
|
-
*
|
|
459
|
-
* Direct mapping to avfilter_graph_send_command()
|
|
460
|
-
*
|
|
461
|
-
* @param target - Filter name or "all" to send to all filters
|
|
462
|
-
* @param cmd - Command name (e.g., "volume", "hue", "rate")
|
|
463
|
-
* @param arg - Command argument (e.g., "0.5", "2.0")
|
|
464
|
-
* @param flags - Command flags (AVFilterCmdFlag, default: 0)
|
|
465
|
-
* - AVFILTER_CMD_FLAG_ONE: Stop once a filter understood the command
|
|
466
|
-
* - AVFILTER_CMD_FLAG_FAST: Only execute if fast (hardware acceleration)
|
|
423
|
+
* Send a command to filters in the graph.
|
|
467
424
|
*
|
|
468
|
-
*
|
|
425
|
+
* Sends a command to one or more filters for immediate execution.
|
|
426
|
+
* Target can be a specific filter name or "all" for all filters.
|
|
469
427
|
*
|
|
470
|
-
*
|
|
471
|
-
* ```typescript
|
|
472
|
-
* import { FilterGraph, FFmpegError, AVFILTER_CMD_FLAG_ONE } from 'node-av';
|
|
428
|
+
* Direct mapping to avfilter_graph_send_command().
|
|
473
429
|
*
|
|
474
|
-
*
|
|
475
|
-
*
|
|
476
|
-
*
|
|
477
|
-
*
|
|
478
|
-
*
|
|
479
|
-
* console.log('Response:', result.response);
|
|
480
|
-
* }
|
|
481
|
-
* ```
|
|
430
|
+
* @param target - Filter name or "all"
|
|
431
|
+
* @param cmd - Command to send
|
|
432
|
+
* @param arg - Command argument
|
|
433
|
+
* @param flags - Command flags
|
|
434
|
+
* @returns Error code or response object
|
|
482
435
|
*
|
|
483
436
|
* @example
|
|
484
437
|
* ```typescript
|
|
485
|
-
* // Send command to all filters, stop at first one that handles it
|
|
486
|
-
* const result = graph.sendCommand('all', 'enable', 'expr=gte(t,10)', AVFILTER_CMD_FLAG_ONE);
|
|
487
|
-
*
|
|
488
438
|
* // Send command to specific filter
|
|
489
|
-
* const result = graph.sendCommand(
|
|
439
|
+
* const result = graph.sendCommand(
|
|
440
|
+
* 'volume',
|
|
441
|
+
* 'volume',
|
|
442
|
+
* '0.5'
|
|
443
|
+
* );
|
|
444
|
+
*
|
|
445
|
+
* // Send to all filters
|
|
446
|
+
* const result2 = graph.sendCommand(
|
|
447
|
+
* 'all',
|
|
448
|
+
* 'enable',
|
|
449
|
+
* 'timeline'
|
|
450
|
+
* );
|
|
490
451
|
* ```
|
|
491
452
|
*
|
|
492
|
-
* @
|
|
453
|
+
* @see {@link queueCommand} For delayed execution
|
|
493
454
|
*/
|
|
494
455
|
sendCommand(target: string, cmd: string, arg: string, flags?: AVFilterCmdFlag): number | {
|
|
495
456
|
response: string | null;
|
|
496
457
|
};
|
|
497
458
|
/**
|
|
498
|
-
* Queue a command
|
|
459
|
+
* Queue a command for delayed execution.
|
|
499
460
|
*
|
|
500
|
-
*
|
|
461
|
+
* Schedules a command to be executed at a specific timestamp.
|
|
462
|
+
* The command is executed when the filter processes a frame with that timestamp.
|
|
501
463
|
*
|
|
502
|
-
*
|
|
503
|
-
* @param cmd - Command name (e.g., "volume", "hue", "rate")
|
|
504
|
-
* @param arg - Command argument (e.g., "0.5", "2.0")
|
|
505
|
-
* @param ts - Timestamp when the command should be executed
|
|
506
|
-
* @param flags - Command flags (AVFilterCmdFlag, default: 0)
|
|
507
|
-
* - AVFILTER_CMD_FLAG_ONE: Stop once a filter understood the command
|
|
508
|
-
* - AVFILTER_CMD_FLAG_FAST: Only execute if fast (hardware acceleration)
|
|
464
|
+
* Direct mapping to avfilter_graph_queue_command().
|
|
509
465
|
*
|
|
466
|
+
* @param target - Filter name or "all"
|
|
467
|
+
* @param cmd - Command to queue
|
|
468
|
+
* @param arg - Command argument
|
|
469
|
+
* @param ts - Timestamp for execution
|
|
470
|
+
* @param flags - Command flags
|
|
510
471
|
* @returns 0 on success, negative AVERROR on error
|
|
511
472
|
*
|
|
512
473
|
* @example
|
|
513
474
|
* ```typescript
|
|
514
|
-
* import {
|
|
515
|
-
*
|
|
516
|
-
* // Queue volume change at
|
|
517
|
-
* const ret = graph.queueCommand(
|
|
475
|
+
* import { FFmpegError } from 'node-av';
|
|
476
|
+
*
|
|
477
|
+
* // Queue volume change at 5 seconds
|
|
478
|
+
* const ret = graph.queueCommand(
|
|
479
|
+
* 'volume',
|
|
480
|
+
* 'volume',
|
|
481
|
+
* '0.2',
|
|
482
|
+
* 5000000, // microseconds
|
|
483
|
+
* 0
|
|
484
|
+
* );
|
|
518
485
|
* FFmpegError.throwIfError(ret, 'queueCommand');
|
|
519
486
|
* ```
|
|
520
487
|
*
|
|
521
|
-
* @
|
|
522
|
-
* ```typescript
|
|
523
|
-
* // Queue multiple commands at different times
|
|
524
|
-
* graph.queueCommand('volume', 'volume', '0.5', 5.0);
|
|
525
|
-
* graph.queueCommand('volume', 'volume', '1.0', 10.0);
|
|
526
|
-
* graph.queueCommand('volume', 'volume', '0.2', 15.0);
|
|
527
|
-
* ```
|
|
528
|
-
*
|
|
529
|
-
* @note Commands are executed when processing frames with matching timestamps.
|
|
530
|
-
* @note Not all filters support queued commands.
|
|
488
|
+
* @see {@link sendCommand} For immediate execution
|
|
531
489
|
*/
|
|
532
490
|
queueCommand(target: string, cmd: string, arg: string, ts: number, flags?: AVFilterCmdFlag): number;
|
|
533
491
|
/**
|
|
534
|
-
* Get the native
|
|
492
|
+
* Get the underlying native FilterGraph object.
|
|
493
|
+
*
|
|
494
|
+
* @returns The native FilterGraph binding object
|
|
535
495
|
*
|
|
536
|
-
* @internal
|
|
537
|
-
* @returns The underlying native filter graph object
|
|
496
|
+
* @internal
|
|
538
497
|
*/
|
|
539
498
|
getNative(): NativeFilterGraph;
|
|
540
499
|
/**
|
|
@@ -548,7 +507,7 @@ export declare class FilterGraph extends OptionMember<NativeFilterGraph> impleme
|
|
|
548
507
|
* {
|
|
549
508
|
* using graph = new FilterGraph();
|
|
550
509
|
* graph.alloc();
|
|
551
|
-
* //
|
|
510
|
+
* // Build and use graph...
|
|
552
511
|
* } // Automatically freed when leaving scope
|
|
553
512
|
* ```
|
|
554
513
|
*/
|