node-av 1.0.3 → 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 +56 -41
- package/dist/api/bitstream-filter.d.ts +180 -123
- package/dist/api/bitstream-filter.js +182 -126
- package/dist/api/bitstream-filter.js.map +1 -1
- package/dist/api/decoder.d.ts +286 -130
- package/dist/api/decoder.js +321 -159
- package/dist/api/decoder.js.map +1 -1
- package/dist/api/encoder.d.ts +254 -158
- package/dist/api/encoder.js +326 -298
- package/dist/api/encoder.js.map +1 -1
- package/dist/api/filter-presets.d.ts +912 -0
- package/dist/api/filter-presets.js +1407 -0
- package/dist/api/filter-presets.js.map +1 -0
- package/dist/api/filter.d.ts +280 -284
- package/dist/api/filter.js +435 -509
- package/dist/api/filter.js.map +1 -1
- package/dist/api/hardware.d.ts +226 -159
- package/dist/api/hardware.js +405 -287
- package/dist/api/hardware.js.map +1 -1
- package/dist/api/index.d.ts +3 -2
- package/dist/api/index.js +1 -0
- package/dist/api/index.js.map +1 -1
- package/dist/api/io-stream.d.ts +65 -61
- package/dist/api/io-stream.js +45 -47
- package/dist/api/io-stream.js.map +1 -1
- package/dist/api/media-input.d.ts +244 -141
- package/dist/api/media-input.js +207 -104
- package/dist/api/media-input.js.map +1 -1
- package/dist/api/media-output.d.ts +206 -128
- package/dist/api/media-output.js +212 -129
- 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 +22 -182
- package/dist/api/utilities/audio-sample.d.ts +1 -1
- package/dist/api/utilities/image.d.ts +1 -1
- package/dist/api/utilities/media-type.d.ts +1 -1
- package/dist/api/utilities/pixel-format.d.ts +1 -1
- package/dist/api/utilities/sample-format.d.ts +1 -1
- package/dist/api/utilities/timestamp.d.ts +1 -1
- 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 → constants}/channel-layouts.d.ts +1 -1
- package/dist/constants/channel-layouts.js.map +1 -0
- package/dist/{lib → constants}/constants.d.ts +19 -4
- package/dist/{lib → constants}/constants.js +15 -1
- package/dist/constants/constants.js.map +1 -0
- package/dist/constants/decoders.d.ts +609 -0
- package/dist/constants/decoders.js +617 -0
- package/dist/constants/decoders.js.map +1 -0
- package/dist/constants/encoders.d.ts +285 -0
- package/dist/constants/encoders.js +298 -0
- package/dist/constants/encoders.js.map +1 -0
- package/dist/constants/index.d.ts +4 -0
- package/dist/constants/index.js +5 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/audio-fifo.d.ts +128 -171
- package/dist/lib/audio-fifo.js +130 -173
- package/dist/lib/audio-fifo.js.map +1 -1
- package/dist/lib/binding.d.ts +7 -5
- 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 +69 -55
- package/dist/lib/bitstream-filter.js +68 -54
- package/dist/lib/bitstream-filter.js.map +1 -1
- package/dist/lib/codec-context.d.ts +317 -381
- package/dist/lib/codec-context.js +316 -381
- package/dist/lib/codec-context.js.map +1 -1
- package/dist/lib/codec-parameters.d.ts +161 -171
- package/dist/lib/codec-parameters.js +162 -172
- package/dist/lib/codec-parameters.js.map +1 -1
- package/dist/lib/codec-parser.d.ts +92 -105
- package/dist/lib/codec-parser.js +92 -103
- package/dist/lib/codec-parser.js.map +1 -1
- package/dist/lib/codec.d.ts +328 -217
- package/dist/lib/codec.js +392 -218
- package/dist/lib/codec.js.map +1 -1
- package/dist/lib/dictionary.d.ts +150 -204
- package/dist/lib/dictionary.js +159 -213
- package/dist/lib/dictionary.js.map +1 -1
- package/dist/lib/error.d.ts +97 -131
- package/dist/lib/error.js +98 -128
- package/dist/lib/error.js.map +1 -1
- package/dist/lib/filter-context.d.ts +317 -194
- package/dist/lib/filter-context.js +335 -200
- package/dist/lib/filter-context.js.map +1 -1
- package/dist/lib/filter-graph.d.ts +252 -293
- 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 +94 -112
- package/dist/lib/filter.js.map +1 -1
- package/dist/lib/format-context.d.ts +321 -429
- package/dist/lib/format-context.js +314 -386
- package/dist/lib/format-context.js.map +1 -1
- package/dist/lib/frame.d.ts +263 -406
- package/dist/lib/frame.js +263 -408
- package/dist/lib/frame.js.map +1 -1
- package/dist/lib/hardware-device-context.d.ts +150 -204
- 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 +171 -181
- 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 -3
- package/dist/lib/index.js +2 -5
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/input-format.d.ts +90 -118
- package/dist/lib/input-format.js +89 -117
- package/dist/lib/input-format.js.map +1 -1
- package/dist/lib/io-context.d.ts +210 -242
- package/dist/lib/io-context.js +221 -253
- package/dist/lib/io-context.js.map +1 -1
- package/dist/lib/log.d.ts +86 -120
- package/dist/lib/log.js +85 -122
- package/dist/lib/log.js.map +1 -1
- package/dist/lib/native-types.d.ts +127 -112
- package/dist/lib/native-types.js +9 -0
- package/dist/lib/native-types.js.map +1 -1
- package/dist/lib/option.d.ts +285 -242
- package/dist/lib/option.js +310 -250
- package/dist/lib/option.js.map +1 -1
- package/dist/lib/output-format.d.ts +78 -102
- package/dist/lib/output-format.js +77 -101
- package/dist/lib/output-format.js.map +1 -1
- package/dist/lib/packet.d.ts +173 -241
- 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 +242 -326
- 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 +130 -174
- package/dist/lib/software-scale-context.js +132 -176
- package/dist/lib/software-scale-context.js.map +1 -1
- package/dist/lib/stream.d.ts +88 -198
- package/dist/lib/stream.js +87 -197
- package/dist/lib/stream.js.map +1 -1
- package/dist/lib/types.d.ts +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 +32 -24
- package/release_notes.md +43 -13
- package/CHANGELOG.md +0 -8
- package/dist/lib/channel-layouts.js.map +0 -1
- package/dist/lib/constants.js.map +0 -1
- /package/dist/{lib → constants}/channel-layouts.js +0 -0
|
@@ -2,277 +2,288 @@ import { Filter } from './filter.js';
|
|
|
2
2
|
import { HardwareDeviceContext } from './hardware-device-context.js';
|
|
3
3
|
import { OptionMember } from './option.js';
|
|
4
4
|
import { Rational } from './rational.js';
|
|
5
|
+
import type { AVPixelFormat, AVSampleFormat } from '../constants/constants.js';
|
|
5
6
|
import type { Frame } from './frame.js';
|
|
6
7
|
import type { HardwareFramesContext } from './hardware-frames-context.js';
|
|
7
8
|
import type { NativeDictionary, NativeFilterContext, NativeFilterGraph, NativeWrapper } from './native-types.js';
|
|
8
|
-
import type { IRational } from './types.js';
|
|
9
|
+
import type { ChannelLayout, IRational } from './types.js';
|
|
9
10
|
/**
|
|
10
|
-
* Filter
|
|
11
|
+
* Filter instance in a filter graph.
|
|
11
12
|
*
|
|
12
|
-
* Represents an
|
|
13
|
-
*
|
|
14
|
-
*
|
|
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.
|
|
15
17
|
*
|
|
16
18
|
* Direct mapping to FFmpeg's AVFilterContext.
|
|
17
19
|
*
|
|
18
20
|
* @example
|
|
19
21
|
* ```typescript
|
|
20
|
-
* import { FilterGraph, Filter, FFmpegError } from 'node-av';
|
|
22
|
+
* import { FilterContext, FilterGraph, Filter, FFmpegError } from 'node-av';
|
|
21
23
|
*
|
|
22
|
-
* // Create filter context
|
|
23
|
-
* const
|
|
24
|
-
*
|
|
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');
|
|
25
28
|
*
|
|
26
|
-
*
|
|
27
|
-
* const
|
|
28
|
-
*
|
|
29
|
-
* FFmpegError.throwIfError(initRet, 'initStr buffer');
|
|
29
|
+
* // Initialize with parameters
|
|
30
|
+
* const ret = context.initStr('640:480');
|
|
31
|
+
* FFmpegError.throwIfError(ret, 'initStr');
|
|
30
32
|
*
|
|
31
|
-
* // Link filters
|
|
32
|
-
* const
|
|
33
|
-
*
|
|
34
|
-
* const scaleRet = scaleCtx.initStr('1280:720');
|
|
35
|
-
* FFmpegError.throwIfError(scaleRet, 'initStr scale');
|
|
33
|
+
* // Link filters together
|
|
34
|
+
* const ret2 = source.link(0, context, 0);
|
|
35
|
+
* FFmpegError.throwIfError(ret2, 'link');
|
|
36
36
|
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* // Configure and use the graph
|
|
41
|
-
* const configRet = filterGraph.config();
|
|
42
|
-
* FFmpegError.throwIfError(configRet, 'config');
|
|
37
|
+
* // For buffer source/sink
|
|
38
|
+
* const ret3 = await bufferSrc.buffersrcAddFrame(frame);
|
|
39
|
+
* FFmpegError.throwIfError(ret3, 'buffersrcAddFrame');
|
|
43
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
|
|
44
45
|
*/
|
|
45
46
|
export declare class FilterContext extends OptionMember<NativeFilterContext> implements Disposable, NativeWrapper<NativeFilterContext> {
|
|
46
47
|
private _hwDeviceCtx?;
|
|
47
48
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* FilterContexts are created and managed by FilterGraph.
|
|
51
|
-
* Do not instantiate directly.
|
|
52
|
-
*
|
|
49
|
+
* @param native - The native filter context instance
|
|
53
50
|
* @internal
|
|
54
|
-
*
|
|
55
|
-
* @param native - Native AVFilterContext to wrap
|
|
56
51
|
*/
|
|
57
52
|
constructor(native: NativeFilterContext);
|
|
58
53
|
/**
|
|
59
54
|
* Filter instance name.
|
|
60
55
|
*
|
|
61
|
-
*
|
|
56
|
+
* User-assigned name for this filter instance in the graph.
|
|
57
|
+
* Used for identification and debugging.
|
|
62
58
|
*
|
|
63
|
-
* Direct mapping to AVFilterContext->name
|
|
59
|
+
* Direct mapping to AVFilterContext->name.
|
|
64
60
|
*/
|
|
65
61
|
get name(): string | null;
|
|
66
62
|
set name(value: string | null);
|
|
67
63
|
/**
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
* The AVFilter that this context is an instance of.
|
|
64
|
+
* Filter descriptor.
|
|
71
65
|
*
|
|
72
|
-
*
|
|
66
|
+
* Reference to the filter type this context instantiates.
|
|
73
67
|
*
|
|
74
|
-
*
|
|
68
|
+
* Direct mapping to AVFilterContext->filter.
|
|
75
69
|
*/
|
|
76
70
|
get filter(): Filter | null;
|
|
77
71
|
/**
|
|
78
|
-
*
|
|
72
|
+
* Parent filter graph.
|
|
79
73
|
*
|
|
80
|
-
*
|
|
74
|
+
* Reference to the graph containing this filter context.
|
|
81
75
|
*
|
|
82
|
-
* Direct mapping to AVFilterContext->graph
|
|
83
|
-
*
|
|
84
|
-
* @readonly
|
|
76
|
+
* Direct mapping to AVFilterContext->graph.
|
|
85
77
|
*/
|
|
86
78
|
get graph(): NativeFilterGraph | null;
|
|
87
79
|
/**
|
|
88
80
|
* Number of input pads.
|
|
89
81
|
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* Direct mapping to AVFilterContext->nb_inputs
|
|
82
|
+
* Total number of input connections this filter can accept.
|
|
93
83
|
*
|
|
94
|
-
*
|
|
84
|
+
* Direct mapping to AVFilterContext->nb_inputs.
|
|
95
85
|
*/
|
|
96
86
|
get nbInputs(): number;
|
|
97
87
|
/**
|
|
98
88
|
* Number of output pads.
|
|
99
89
|
*
|
|
100
|
-
*
|
|
90
|
+
* Total number of output connections this filter can provide.
|
|
101
91
|
*
|
|
102
|
-
*
|
|
92
|
+
* Direct mapping to AVFilterContext->nb_outputs.
|
|
103
93
|
*/
|
|
104
94
|
get nbOutputs(): number;
|
|
105
95
|
/**
|
|
106
|
-
* Filter readiness
|
|
96
|
+
* Filter readiness state.
|
|
107
97
|
*
|
|
108
|
-
*
|
|
98
|
+
* Indicates if the filter is ready for processing.
|
|
99
|
+
* Non-zero when ready.
|
|
109
100
|
*
|
|
110
|
-
*
|
|
101
|
+
* Direct mapping to AVFilterContext->ready.
|
|
111
102
|
*/
|
|
112
103
|
get ready(): number;
|
|
113
104
|
/**
|
|
114
|
-
*
|
|
105
|
+
* Hardware device context.
|
|
115
106
|
*
|
|
116
|
-
*
|
|
107
|
+
* Hardware acceleration context for GPU-based filtering.
|
|
108
|
+
* Set to enable hardware-accelerated filter operations.
|
|
117
109
|
*
|
|
118
|
-
*
|
|
119
|
-
* Must be set before filter initialization for hardware filters.
|
|
110
|
+
* Direct mapping to AVFilterContext->hw_device_ctx.
|
|
120
111
|
*/
|
|
121
112
|
get hwDeviceCtx(): HardwareDeviceContext | null;
|
|
122
113
|
set hwDeviceCtx(value: HardwareDeviceContext | null);
|
|
123
114
|
/**
|
|
124
|
-
* Initialize
|
|
115
|
+
* Initialize filter with dictionary options.
|
|
125
116
|
*
|
|
126
|
-
*
|
|
117
|
+
* Configures the filter with key-value option pairs.
|
|
118
|
+
* Must be called after creation and before processing.
|
|
127
119
|
*
|
|
128
|
-
*
|
|
120
|
+
* Direct mapping to avfilter_init_dict().
|
|
129
121
|
*
|
|
122
|
+
* @param options - Dictionary of filter options
|
|
130
123
|
* @returns 0 on success, negative AVERROR on error:
|
|
131
|
-
* -
|
|
132
|
-
* -
|
|
133
|
-
* - AVERROR(ENOMEM): Memory allocation failure
|
|
134
|
-
* - <0: Other filter-specific errors
|
|
124
|
+
* - AVERROR_EINVAL: Invalid parameters
|
|
125
|
+
* - AVERROR_ENOMEM: Memory allocation failure
|
|
135
126
|
*
|
|
136
127
|
* @example
|
|
137
128
|
* ```typescript
|
|
138
|
-
* import {
|
|
139
|
-
*
|
|
140
|
-
* const options = new Dictionary();
|
|
141
|
-
* const ret1 = options.set('width', '1280', 0);
|
|
142
|
-
* FFmpegError.throwIfError(ret1, 'set width');
|
|
143
|
-
* const ret2 = options.set('height', '720', 0);
|
|
144
|
-
* FFmpegError.throwIfError(ret2, 'set height');
|
|
129
|
+
* import { FFmpegError } from 'node-av';
|
|
145
130
|
*
|
|
146
|
-
* const
|
|
147
|
-
*
|
|
148
|
-
*
|
|
131
|
+
* const options = { width: '1920', height: '1080' };
|
|
132
|
+
* const ret = context.init(options);
|
|
133
|
+
* FFmpegError.throwIfError(ret, 'init');
|
|
149
134
|
* ```
|
|
150
135
|
*
|
|
151
|
-
* @see initStr
|
|
136
|
+
* @see {@link initStr} For string-based initialization
|
|
152
137
|
*/
|
|
153
138
|
init(options?: NativeDictionary | null): number;
|
|
154
139
|
/**
|
|
155
|
-
* Initialize
|
|
140
|
+
* Initialize filter with string arguments.
|
|
156
141
|
*
|
|
157
|
-
*
|
|
142
|
+
* Configures the filter using a string representation of parameters.
|
|
143
|
+
* Format depends on the specific filter.
|
|
158
144
|
*
|
|
159
|
-
*
|
|
145
|
+
* Direct mapping to avfilter_init_str().
|
|
160
146
|
*
|
|
147
|
+
* @param args - Filter arguments string
|
|
161
148
|
* @returns 0 on success, negative AVERROR on error:
|
|
162
|
-
* -
|
|
163
|
-
* -
|
|
164
|
-
* - AVERROR(ENOMEM): Memory allocation failure
|
|
165
|
-
* - <0: Other filter-specific errors
|
|
149
|
+
* - AVERROR_EINVAL: Invalid arguments
|
|
150
|
+
* - AVERROR_ENOMEM: Memory allocation failure
|
|
166
151
|
*
|
|
167
152
|
* @example
|
|
168
153
|
* ```typescript
|
|
169
|
-
* import {
|
|
154
|
+
* import { FFmpegError } from 'node-av';
|
|
170
155
|
*
|
|
171
|
-
* //
|
|
172
|
-
* const
|
|
173
|
-
* FFmpegError.throwIfError(
|
|
156
|
+
* // Scale filter with width:height
|
|
157
|
+
* const ret = scaleContext.initStr('1920:1080');
|
|
158
|
+
* FFmpegError.throwIfError(ret, 'initStr');
|
|
174
159
|
*
|
|
175
|
-
* //
|
|
176
|
-
* const
|
|
177
|
-
* FFmpegError.throwIfError(
|
|
160
|
+
* // Crop filter with width:height:x:y
|
|
161
|
+
* const ret2 = cropContext.initStr('640:480:100:50');
|
|
162
|
+
* FFmpegError.throwIfError(ret2, 'initStr');
|
|
178
163
|
* ```
|
|
179
164
|
*
|
|
180
|
-
* @see init
|
|
165
|
+
* @see {@link init} For dictionary-based initialization
|
|
181
166
|
*/
|
|
182
167
|
initStr(args?: string | null): number;
|
|
183
168
|
/**
|
|
184
169
|
* Link this filter's output to another filter's input.
|
|
185
170
|
*
|
|
186
|
-
*
|
|
171
|
+
* Creates a connection between two filters in the graph.
|
|
172
|
+
* Data flows from this filter's output pad to the destination's input pad.
|
|
187
173
|
*
|
|
188
|
-
*
|
|
189
|
-
* @param dst - Destination filter context
|
|
190
|
-
* @param dstPad - Input pad index on destination filter
|
|
174
|
+
* Direct mapping to avfilter_link().
|
|
191
175
|
*
|
|
176
|
+
* @param srcPad - Output pad index of this filter
|
|
177
|
+
* @param dst - Destination filter context
|
|
178
|
+
* @param dstPad - Input pad index of destination filter
|
|
192
179
|
* @returns 0 on success, negative AVERROR on error:
|
|
193
|
-
* -
|
|
194
|
-
* -
|
|
195
|
-
* - AVERROR(ENOMEM): Memory allocation failure
|
|
196
|
-
* - <0: Other linking errors
|
|
180
|
+
* - AVERROR_EINVAL: Invalid pad indices or incompatible formats
|
|
181
|
+
* - AVERROR_ENOMEM: Memory allocation failure
|
|
197
182
|
*
|
|
198
183
|
* @example
|
|
199
184
|
* ```typescript
|
|
200
|
-
* import {
|
|
185
|
+
* import { FFmpegError } from 'node-av';
|
|
201
186
|
*
|
|
202
|
-
* // Link
|
|
203
|
-
* const
|
|
204
|
-
* FFmpegError.throwIfError(
|
|
187
|
+
* // Link source output 0 to scale input 0
|
|
188
|
+
* const ret = source.link(0, scale, 0);
|
|
189
|
+
* FFmpegError.throwIfError(ret, 'link');
|
|
205
190
|
*
|
|
206
|
-
* // Link scale to sink
|
|
207
|
-
* const
|
|
208
|
-
* FFmpegError.throwIfError(
|
|
191
|
+
* // Link scale output 0 to sink input 0
|
|
192
|
+
* const ret2 = scale.link(0, sink, 0);
|
|
193
|
+
* FFmpegError.throwIfError(ret2, 'link');
|
|
209
194
|
* ```
|
|
195
|
+
*
|
|
196
|
+
* @see {@link unlink} To disconnect filters
|
|
210
197
|
*/
|
|
211
198
|
link(srcPad: number, dst: FilterContext, dstPad: number): number;
|
|
212
199
|
/**
|
|
213
200
|
* Unlink a filter pad.
|
|
214
201
|
*
|
|
215
|
-
*
|
|
216
|
-
*
|
|
202
|
+
* Disconnects a pad from its linked filter.
|
|
203
|
+
* Used to reconfigure filter connections.
|
|
217
204
|
*
|
|
218
|
-
*
|
|
205
|
+
* Direct mapping to avfilter_link_free().
|
|
206
|
+
*
|
|
207
|
+
* @param pad - Pad index to unlink
|
|
219
208
|
*
|
|
220
209
|
* @example
|
|
221
210
|
* ```typescript
|
|
222
|
-
* //
|
|
223
|
-
*
|
|
211
|
+
* // Disconnect output pad 0
|
|
212
|
+
* context.unlink(0);
|
|
224
213
|
* ```
|
|
214
|
+
*
|
|
215
|
+
* @see {@link link} To connect filters
|
|
225
216
|
*/
|
|
226
217
|
unlink(pad: number): void;
|
|
227
218
|
/**
|
|
228
219
|
* Add a frame to a buffer source filter.
|
|
229
220
|
*
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
* This function is specific to buffer source filters and is used
|
|
233
|
-
* to feed frames into the filter graph.
|
|
221
|
+
* Sends a frame into the filter graph through a buffer source.
|
|
222
|
+
* Only valid for buffer source filters. Send null to signal EOF.
|
|
234
223
|
*
|
|
235
|
-
*
|
|
224
|
+
* Direct mapping to av_buffersrc_add_frame().
|
|
236
225
|
*
|
|
226
|
+
* @param frame - Frame to send, or null for EOF
|
|
237
227
|
* @returns 0 on success, negative AVERROR on error:
|
|
238
|
-
* -
|
|
239
|
-
* -
|
|
240
|
-
* -
|
|
241
|
-
* -
|
|
228
|
+
* - AVERROR_EAGAIN: Filter needs more output consumption
|
|
229
|
+
* - AVERROR_EOF: Filter has been closed
|
|
230
|
+
* - AVERROR_EINVAL: Not a buffer source filter
|
|
231
|
+
* - AVERROR_ENOMEM: Memory allocation failure
|
|
242
232
|
*
|
|
243
233
|
* @example
|
|
244
234
|
* ```typescript
|
|
245
|
-
* import {
|
|
246
|
-
*
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
*
|
|
235
|
+
* import { FFmpegError } from 'node-av';
|
|
236
|
+
* import { AVERROR_EAGAIN } from 'node-av/constants';
|
|
237
|
+
*
|
|
238
|
+
* // Send frame to filter graph
|
|
239
|
+
* const ret = await bufferSrc.buffersrcAddFrame(frame);
|
|
240
|
+
* if (ret === AVERROR_EAGAIN) {
|
|
241
|
+
* // Need to consume output first
|
|
242
|
+
* } else {
|
|
243
|
+
* FFmpegError.throwIfError(ret, 'buffersrcAddFrame');
|
|
244
|
+
* }
|
|
250
245
|
*
|
|
251
|
-
* // Signal
|
|
252
|
-
*
|
|
253
|
-
* FFmpegError.throwIfError(eofRet, 'buffersrcAddFrame EOF');
|
|
246
|
+
* // Signal EOF
|
|
247
|
+
* await bufferSrc.buffersrcAddFrame(null);
|
|
254
248
|
* ```
|
|
249
|
+
*
|
|
250
|
+
* @see {@link buffersinkGetFrame} To retrieve filtered frames
|
|
255
251
|
*/
|
|
256
252
|
buffersrcAddFrame(frame: Frame | null): Promise<number>;
|
|
257
253
|
/**
|
|
258
254
|
* Set parameters for a buffer source filter.
|
|
259
255
|
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
* @param params -
|
|
266
|
-
* @
|
|
256
|
+
* Configures the format and properties of frames that will be sent
|
|
257
|
+
* to the buffer source. Must be called before sending frames.
|
|
258
|
+
*
|
|
259
|
+
* Direct mapping to av_buffersrc_parameters_set().
|
|
260
|
+
*
|
|
261
|
+
* @param params - Source parameters
|
|
262
|
+
* @param params.width - Video frame width
|
|
263
|
+
* @param params.height - Video frame height
|
|
264
|
+
* @param params.format - Pixel or sample format
|
|
265
|
+
* @param params.timeBase - Time base for timestamps
|
|
266
|
+
* @param params.frameRate - Video frame rate
|
|
267
|
+
* @param params.sampleAspectRatio - Pixel aspect ratio
|
|
268
|
+
* @param params.hwFramesCtx - Hardware frames context
|
|
269
|
+
* @param params.sampleRate - Audio sample rate
|
|
270
|
+
* @param params.channelLayout - Audio channel layout
|
|
271
|
+
* @returns 0 on success, negative AVERROR on error:
|
|
272
|
+
* - AVERROR_EINVAL: Invalid parameters
|
|
273
|
+
* - AVERROR_ENOMEM: Memory allocation failure
|
|
267
274
|
*
|
|
268
275
|
* @example
|
|
269
276
|
* ```typescript
|
|
270
|
-
*
|
|
277
|
+
* import { FFmpegError, Rational } from 'node-av';
|
|
278
|
+
* import { AV_PIX_FMT_YUV420P } from 'node-av/constants';
|
|
279
|
+
*
|
|
280
|
+
* // Configure video buffer source
|
|
281
|
+
* const ret = bufferSrc.buffersrcParametersSet({
|
|
271
282
|
* width: 1920,
|
|
272
283
|
* height: 1080,
|
|
273
284
|
* format: AV_PIX_FMT_YUV420P,
|
|
274
|
-
* timeBase: { num: 1, den:
|
|
275
|
-
*
|
|
285
|
+
* timeBase: { num: 1, den: 25 },
|
|
286
|
+
* frameRate: { num: 25, den: 1 }
|
|
276
287
|
* });
|
|
277
288
|
* FFmpegError.throwIfError(ret, 'buffersrcParametersSet');
|
|
278
289
|
* ```
|
|
@@ -291,139 +302,251 @@ export declare class FilterContext extends OptionMember<NativeFilterContext> imp
|
|
|
291
302
|
/**
|
|
292
303
|
* Get a frame from a buffer sink filter.
|
|
293
304
|
*
|
|
294
|
-
*
|
|
295
|
-
*
|
|
296
|
-
* This function is specific to buffer sink filters and is used
|
|
297
|
-
* to retrieve filtered frames from the filter graph.
|
|
305
|
+
* Retrieves a filtered frame from the filter graph through a buffer sink.
|
|
306
|
+
* Only valid for buffer sink filters.
|
|
298
307
|
*
|
|
299
|
-
*
|
|
308
|
+
* Direct mapping to av_buffersink_get_frame().
|
|
300
309
|
*
|
|
310
|
+
* @param frame - Frame to receive filtered data
|
|
301
311
|
* @returns 0 on success, negative AVERROR on error:
|
|
302
|
-
* -
|
|
303
|
-
* -
|
|
304
|
-
* -
|
|
305
|
-
* - AVERROR(EINVAL): Invalid parameters
|
|
312
|
+
* - AVERROR_EAGAIN: No frame available yet
|
|
313
|
+
* - AVERROR_EOF: No more frames will be produced
|
|
314
|
+
* - AVERROR_EINVAL: Not a buffer sink filter
|
|
306
315
|
*
|
|
307
316
|
* @example
|
|
308
317
|
* ```typescript
|
|
309
|
-
* import {
|
|
318
|
+
* import { FFmpegError, Frame } from 'node-av';
|
|
310
319
|
* import { AVERROR_EAGAIN, AVERROR_EOF } from 'node-av/constants';
|
|
311
320
|
*
|
|
312
|
-
* // Get filtered frames
|
|
313
321
|
* const frame = new Frame();
|
|
314
322
|
* frame.alloc();
|
|
315
323
|
*
|
|
316
|
-
*
|
|
317
|
-
*
|
|
318
|
-
* //
|
|
319
|
-
*
|
|
320
|
-
*
|
|
321
|
-
*
|
|
322
|
-
* // Try to get another frame
|
|
323
|
-
* ret = sinkCtx.buffersinkGetFrame(frame);
|
|
324
|
-
* }
|
|
325
|
-
*
|
|
326
|
-
* if (!FFmpegError.is(ret, AVERROR_EAGAIN) && !FFmpegError.is(ret, AVERROR_EOF)) {
|
|
324
|
+
* const ret = await bufferSink.buffersinkGetFrame(frame);
|
|
325
|
+
* if (ret === AVERROR_EAGAIN) {
|
|
326
|
+
* // No frame available yet
|
|
327
|
+
* } else if (ret === AVERROR_EOF) {
|
|
328
|
+
* // End of stream
|
|
329
|
+
* } else {
|
|
327
330
|
* FFmpegError.throwIfError(ret, 'buffersinkGetFrame');
|
|
331
|
+
* // Process filtered frame
|
|
328
332
|
* }
|
|
329
333
|
* ```
|
|
334
|
+
*
|
|
335
|
+
* @see {@link buffersrcAddFrame} To send frames for filtering
|
|
330
336
|
*/
|
|
331
337
|
buffersinkGetFrame(frame: Frame): Promise<number>;
|
|
332
338
|
/**
|
|
333
|
-
*
|
|
339
|
+
* Get time base from buffer sink.
|
|
334
340
|
*
|
|
335
|
-
*
|
|
341
|
+
* Returns the time base of frames from a buffer sink filter.
|
|
342
|
+
* Only valid for buffer sink filters.
|
|
336
343
|
*
|
|
337
|
-
*
|
|
344
|
+
* Direct mapping to av_buffersink_get_time_base().
|
|
338
345
|
*
|
|
339
|
-
* @
|
|
346
|
+
* @returns Time base as Rational
|
|
340
347
|
*
|
|
341
348
|
* @example
|
|
342
349
|
* ```typescript
|
|
343
|
-
*
|
|
344
|
-
*
|
|
350
|
+
* const timeBase = bufferSink.buffersinkGetTimeBase();
|
|
351
|
+
* console.log(`Time base: ${timeBase.num}/${timeBase.den}`);
|
|
352
|
+
* ```
|
|
353
|
+
*/
|
|
354
|
+
buffersinkGetTimeBase(): Rational;
|
|
355
|
+
/**
|
|
356
|
+
* Get pixel/sample format from buffer sink.
|
|
357
|
+
*
|
|
358
|
+
* Returns the format of frames from a buffer sink filter.
|
|
359
|
+
* Only valid for buffer sink filters.
|
|
360
|
+
*
|
|
361
|
+
* Direct mapping to av_buffersink_get_format().
|
|
362
|
+
*
|
|
363
|
+
* @returns Pixel format for video, sample format for audio
|
|
364
|
+
*
|
|
365
|
+
* @example
|
|
366
|
+
* ```typescript
|
|
367
|
+
* import { AV_PIX_FMT_YUV420P } from 'node-av/constants';
|
|
368
|
+
*
|
|
369
|
+
* const format = bufferSink.buffersinkGetFormat();
|
|
370
|
+
* if (format === AV_PIX_FMT_YUV420P) {
|
|
371
|
+
* console.log('Output is YUV420P');
|
|
345
372
|
* }
|
|
346
373
|
* ```
|
|
347
374
|
*/
|
|
375
|
+
buffersinkGetFormat(): AVPixelFormat | AVSampleFormat;
|
|
348
376
|
/**
|
|
349
|
-
* Get
|
|
377
|
+
* Get frame width from buffer sink.
|
|
350
378
|
*
|
|
351
|
-
*
|
|
379
|
+
* Returns the width of video frames from a buffer sink filter.
|
|
380
|
+
* Only valid for video buffer sink filters.
|
|
352
381
|
*
|
|
353
|
-
*
|
|
382
|
+
* Direct mapping to av_buffersink_get_w().
|
|
354
383
|
*
|
|
355
|
-
* @returns
|
|
384
|
+
* @returns Frame width in pixels
|
|
356
385
|
*
|
|
357
386
|
* @example
|
|
358
387
|
* ```typescript
|
|
359
|
-
* const
|
|
360
|
-
* console.log(`
|
|
388
|
+
* const width = bufferSink.buffersinkGetWidth();
|
|
389
|
+
* console.log(`Output width: ${width}px`);
|
|
361
390
|
* ```
|
|
362
391
|
*/
|
|
363
|
-
|
|
392
|
+
buffersinkGetWidth(): number;
|
|
393
|
+
/**
|
|
394
|
+
* Get frame height from buffer sink.
|
|
395
|
+
*
|
|
396
|
+
* Returns the height of video frames from a buffer sink filter.
|
|
397
|
+
* Only valid for video buffer sink filters.
|
|
398
|
+
*
|
|
399
|
+
* Direct mapping to av_buffersink_get_h().
|
|
400
|
+
*
|
|
401
|
+
* @returns Frame height in pixels
|
|
402
|
+
*
|
|
403
|
+
* @example
|
|
404
|
+
* ```typescript
|
|
405
|
+
* const height = bufferSink.buffersinkGetHeight();
|
|
406
|
+
* console.log(`Output height: ${height}px`);
|
|
407
|
+
* ```
|
|
408
|
+
*/
|
|
409
|
+
buffersinkGetHeight(): number;
|
|
410
|
+
/**
|
|
411
|
+
* Get sample aspect ratio from buffer sink.
|
|
412
|
+
*
|
|
413
|
+
* Returns the pixel aspect ratio of video frames from a buffer sink filter.
|
|
414
|
+
* Only valid for video buffer sink filters.
|
|
415
|
+
*
|
|
416
|
+
* Direct mapping to av_buffersink_get_sample_aspect_ratio().
|
|
417
|
+
*
|
|
418
|
+
* @returns Sample aspect ratio as Rational
|
|
419
|
+
*
|
|
420
|
+
* @example
|
|
421
|
+
* ```typescript
|
|
422
|
+
* const sar = bufferSink.buffersinkGetSampleAspectRatio();
|
|
423
|
+
* console.log(`SAR: ${sar.num}:${sar.den}`);
|
|
424
|
+
* ```
|
|
425
|
+
*/
|
|
426
|
+
buffersinkGetSampleAspectRatio(): Rational;
|
|
427
|
+
/**
|
|
428
|
+
* Get frame rate from buffer sink.
|
|
429
|
+
*
|
|
430
|
+
* Returns the frame rate of video from a buffer sink filter.
|
|
431
|
+
* Only valid for video buffer sink filters.
|
|
432
|
+
*
|
|
433
|
+
* Direct mapping to av_buffersink_get_frame_rate().
|
|
434
|
+
*
|
|
435
|
+
* @returns Frame rate as Rational
|
|
436
|
+
*
|
|
437
|
+
* @example
|
|
438
|
+
* ```typescript
|
|
439
|
+
* const frameRate = bufferSink.buffersinkGetFrameRate();
|
|
440
|
+
* console.log(`Frame rate: ${frameRate.num}/${frameRate.den} fps`);
|
|
441
|
+
* ```
|
|
442
|
+
*/
|
|
443
|
+
buffersinkGetFrameRate(): Rational;
|
|
444
|
+
/**
|
|
445
|
+
* Get sample rate from buffer sink.
|
|
446
|
+
*
|
|
447
|
+
* Returns the sample rate of audio from a buffer sink filter.
|
|
448
|
+
* Only valid for audio buffer sink filters.
|
|
449
|
+
*
|
|
450
|
+
* Direct mapping to av_buffersink_get_sample_rate().
|
|
451
|
+
*
|
|
452
|
+
* @returns Sample rate in Hz
|
|
453
|
+
*
|
|
454
|
+
* @example
|
|
455
|
+
* ```typescript
|
|
456
|
+
* const sampleRate = bufferSink.buffersinkGetSampleRate();
|
|
457
|
+
* console.log(`Sample rate: ${sampleRate} Hz`);
|
|
458
|
+
* ```
|
|
459
|
+
*/
|
|
460
|
+
buffersinkGetSampleRate(): number;
|
|
461
|
+
/**
|
|
462
|
+
* Get channel layout from buffer sink.
|
|
463
|
+
*
|
|
464
|
+
* Returns the channel layout of audio from a buffer sink filter.
|
|
465
|
+
* Only valid for audio buffer sink filters.
|
|
466
|
+
*
|
|
467
|
+
* Direct mapping to av_buffersink_get_channel_layout().
|
|
468
|
+
*
|
|
469
|
+
* @returns Channel layout configuration
|
|
470
|
+
*
|
|
471
|
+
* @example
|
|
472
|
+
* ```typescript
|
|
473
|
+
* const layout = bufferSink.buffersinkGetChannelLayout();
|
|
474
|
+
* console.log(`Channels: ${layout.nbChannels}`);
|
|
475
|
+
* ```
|
|
476
|
+
*/
|
|
477
|
+
buffersinkGetChannelLayout(): ChannelLayout;
|
|
364
478
|
/**
|
|
365
479
|
* Free the filter context.
|
|
366
480
|
*
|
|
367
|
-
*
|
|
481
|
+
* Releases all resources associated with the filter context.
|
|
482
|
+
* The context becomes invalid after calling this.
|
|
483
|
+
*
|
|
484
|
+
* Direct mapping to avfilter_free().
|
|
368
485
|
*
|
|
369
486
|
* @example
|
|
370
487
|
* ```typescript
|
|
371
|
-
*
|
|
372
|
-
* //
|
|
488
|
+
* context.free();
|
|
489
|
+
* // Context is now invalid
|
|
373
490
|
* ```
|
|
491
|
+
*
|
|
492
|
+
* @see {@link Symbol.dispose} For automatic cleanup
|
|
374
493
|
*/
|
|
375
494
|
free(): void;
|
|
376
495
|
/**
|
|
377
|
-
* Check if
|
|
496
|
+
* Check if filter is a source.
|
|
378
497
|
*
|
|
379
|
-
* Source filters
|
|
498
|
+
* Source filters generate frames without input.
|
|
380
499
|
*
|
|
381
|
-
* @returns
|
|
500
|
+
* @returns True if filter has no inputs
|
|
382
501
|
*
|
|
383
502
|
* @example
|
|
384
503
|
* ```typescript
|
|
385
|
-
* if (
|
|
504
|
+
* if (context.isSource()) {
|
|
386
505
|
* console.log('This is a source filter');
|
|
387
506
|
* }
|
|
388
507
|
* ```
|
|
508
|
+
*
|
|
509
|
+
* @see {@link isSink} To check for sink filters
|
|
389
510
|
*/
|
|
390
511
|
isSource(): boolean;
|
|
391
512
|
/**
|
|
392
|
-
* Check if
|
|
513
|
+
* Check if filter is a sink.
|
|
393
514
|
*
|
|
394
|
-
* Sink filters
|
|
515
|
+
* Sink filters consume frames without output.
|
|
395
516
|
*
|
|
396
|
-
* @returns
|
|
517
|
+
* @returns True if filter has no outputs
|
|
397
518
|
*
|
|
398
519
|
* @example
|
|
399
520
|
* ```typescript
|
|
400
|
-
* if (
|
|
521
|
+
* if (context.isSink()) {
|
|
401
522
|
* console.log('This is a sink filter');
|
|
402
523
|
* }
|
|
403
524
|
* ```
|
|
525
|
+
*
|
|
526
|
+
* @see {@link isSource} To check for source filters
|
|
404
527
|
*/
|
|
405
528
|
isSink(): boolean;
|
|
406
529
|
/**
|
|
407
|
-
* Check if
|
|
530
|
+
* Check if filter is ready.
|
|
408
531
|
*
|
|
409
|
-
*
|
|
532
|
+
* Indicates whether the filter is ready for processing.
|
|
410
533
|
*
|
|
411
|
-
* @returns
|
|
534
|
+
* @returns True if filter is ready
|
|
412
535
|
*
|
|
413
536
|
* @example
|
|
414
537
|
* ```typescript
|
|
415
|
-
*
|
|
416
|
-
*
|
|
417
|
-
* console.log('Filter is ready for processing');
|
|
538
|
+
* if (context.isReady()) {
|
|
539
|
+
* // Filter is ready for processing
|
|
418
540
|
* }
|
|
419
541
|
* ```
|
|
420
542
|
*/
|
|
421
543
|
isReady(): boolean;
|
|
422
544
|
/**
|
|
423
|
-
* Get the native
|
|
545
|
+
* Get the underlying native FilterContext object.
|
|
424
546
|
*
|
|
425
|
-
* @
|
|
426
|
-
*
|
|
547
|
+
* @returns The native FilterContext binding object
|
|
548
|
+
*
|
|
549
|
+
* @internal
|
|
427
550
|
*/
|
|
428
551
|
getNative(): NativeFilterContext;
|
|
429
552
|
/**
|
|
@@ -435,9 +558,9 @@ export declare class FilterContext extends OptionMember<NativeFilterContext> imp
|
|
|
435
558
|
* @example
|
|
436
559
|
* ```typescript
|
|
437
560
|
* {
|
|
438
|
-
* using
|
|
439
|
-
*
|
|
440
|
-
* //
|
|
561
|
+
* using context = graph.createFilter(filter, 'test');
|
|
562
|
+
* context.initStr('640:480');
|
|
563
|
+
* // Use context...
|
|
441
564
|
* } // Automatically freed when leaving scope
|
|
442
565
|
* ```
|
|
443
566
|
*/
|