node-av 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/LICENSE.md +22 -0
- package/README.md +377 -0
- package/binding.gyp +78 -0
- package/dist/api/bitstream-filter.d.ts +246 -0
- package/dist/api/bitstream-filter.js +369 -0
- package/dist/api/bitstream-filter.js.map +1 -0
- package/dist/api/decoder.d.ts +257 -0
- package/dist/api/decoder.js +424 -0
- package/dist/api/decoder.js.map +1 -0
- package/dist/api/encoder.d.ts +298 -0
- package/dist/api/encoder.js +574 -0
- package/dist/api/encoder.js.map +1 -0
- package/dist/api/filter.d.ts +457 -0
- package/dist/api/filter.js +876 -0
- package/dist/api/filter.js.map +1 -0
- package/dist/api/hardware.d.ts +318 -0
- package/dist/api/hardware.js +558 -0
- package/dist/api/hardware.js.map +1 -0
- package/dist/api/index.d.ts +12 -0
- package/dist/api/index.js +20 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/io-stream.d.ts +109 -0
- package/dist/api/io-stream.js +124 -0
- package/dist/api/io-stream.js.map +1 -0
- package/dist/api/media-input.d.ts +295 -0
- package/dist/api/media-input.js +456 -0
- package/dist/api/media-input.js.map +1 -0
- package/dist/api/media-output.d.ts +274 -0
- package/dist/api/media-output.js +486 -0
- package/dist/api/media-output.js.map +1 -0
- package/dist/api/pipeline.d.ts +117 -0
- package/dist/api/pipeline.js +836 -0
- package/dist/api/pipeline.js.map +1 -0
- package/dist/api/types.d.ts +440 -0
- package/dist/api/types.js +2 -0
- package/dist/api/types.js.map +1 -0
- package/dist/api/utilities/audio-sample.d.ts +115 -0
- package/dist/api/utilities/audio-sample.js +110 -0
- package/dist/api/utilities/audio-sample.js.map +1 -0
- package/dist/api/utilities/channel-layout.d.ts +83 -0
- package/dist/api/utilities/channel-layout.js +87 -0
- package/dist/api/utilities/channel-layout.js.map +1 -0
- package/dist/api/utilities/image.d.ts +177 -0
- package/dist/api/utilities/image.js +183 -0
- package/dist/api/utilities/image.js.map +1 -0
- package/dist/api/utilities/index.d.ts +8 -0
- package/dist/api/utilities/index.js +17 -0
- package/dist/api/utilities/index.js.map +1 -0
- package/dist/api/utilities/media-type.d.ts +56 -0
- package/dist/api/utilities/media-type.js +60 -0
- package/dist/api/utilities/media-type.js.map +1 -0
- package/dist/api/utilities/pixel-format.d.ts +94 -0
- package/dist/api/utilities/pixel-format.js +102 -0
- package/dist/api/utilities/pixel-format.js.map +1 -0
- package/dist/api/utilities/sample-format.d.ts +132 -0
- package/dist/api/utilities/sample-format.js +144 -0
- package/dist/api/utilities/sample-format.js.map +1 -0
- package/dist/api/utilities/streaming.d.ts +104 -0
- package/dist/api/utilities/streaming.js +137 -0
- package/dist/api/utilities/streaming.js.map +1 -0
- package/dist/api/utilities/timestamp.d.ts +187 -0
- package/dist/api/utilities/timestamp.js +200 -0
- package/dist/api/utilities/timestamp.js.map +1 -0
- package/dist/api/utils.d.ts +61 -0
- package/dist/api/utils.js +330 -0
- package/dist/api/utils.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/audio-fifo.d.ts +339 -0
- package/dist/lib/audio-fifo.js +365 -0
- package/dist/lib/audio-fifo.js.map +1 -0
- package/dist/lib/binding.d.ts +192 -0
- package/dist/lib/binding.js +70 -0
- package/dist/lib/binding.js.map +1 -0
- package/dist/lib/bitstream-filter-context.d.ts +345 -0
- package/dist/lib/bitstream-filter-context.js +407 -0
- package/dist/lib/bitstream-filter-context.js.map +1 -0
- package/dist/lib/bitstream-filter.d.ts +124 -0
- package/dist/lib/bitstream-filter.js +138 -0
- package/dist/lib/bitstream-filter.js.map +1 -0
- package/dist/lib/channel-layouts.d.ts +51 -0
- package/dist/lib/channel-layouts.js +55 -0
- package/dist/lib/channel-layouts.js.map +1 -0
- package/dist/lib/codec-context.d.ts +763 -0
- package/dist/lib/codec-context.js +974 -0
- package/dist/lib/codec-context.js.map +1 -0
- package/dist/lib/codec-parameters.d.ts +362 -0
- package/dist/lib/codec-parameters.js +460 -0
- package/dist/lib/codec-parameters.js.map +1 -0
- package/dist/lib/codec-parser.d.ts +185 -0
- package/dist/lib/codec-parser.js +193 -0
- package/dist/lib/codec-parser.js.map +1 -0
- package/dist/lib/codec.d.ts +432 -0
- package/dist/lib/codec.js +492 -0
- package/dist/lib/codec.js.map +1 -0
- package/dist/lib/constants.d.ts +2037 -0
- package/dist/lib/constants.js +1659 -0
- package/dist/lib/constants.js.map +1 -0
- package/dist/lib/dictionary.d.ts +371 -0
- package/dist/lib/dictionary.js +406 -0
- package/dist/lib/dictionary.js.map +1 -0
- package/dist/lib/error.d.ts +216 -0
- package/dist/lib/error.js +254 -0
- package/dist/lib/error.js.map +1 -0
- package/dist/lib/filter-context.d.ts +445 -0
- package/dist/lib/filter-context.js +505 -0
- package/dist/lib/filter-context.js.map +1 -0
- package/dist/lib/filter-graph.d.ts +556 -0
- package/dist/lib/filter-graph.js +608 -0
- package/dist/lib/filter-graph.js.map +1 -0
- package/dist/lib/filter-inout.d.ts +205 -0
- package/dist/lib/filter-inout.js +264 -0
- package/dist/lib/filter-inout.js.map +1 -0
- package/dist/lib/filter.d.ts +231 -0
- package/dist/lib/filter.js +260 -0
- package/dist/lib/filter.js.map +1 -0
- package/dist/lib/format-context.d.ts +798 -0
- package/dist/lib/format-context.js +845 -0
- package/dist/lib/format-context.js.map +1 -0
- package/dist/lib/frame.d.ts +784 -0
- package/dist/lib/frame.js +933 -0
- package/dist/lib/frame.js.map +1 -0
- package/dist/lib/hardware-device-context.d.ts +407 -0
- package/dist/lib/hardware-device-context.js +429 -0
- package/dist/lib/hardware-device-context.js.map +1 -0
- package/dist/lib/hardware-frames-context.d.ts +374 -0
- package/dist/lib/hardware-frames-context.js +430 -0
- package/dist/lib/hardware-frames-context.js.map +1 -0
- package/dist/lib/index.d.ts +31 -0
- package/dist/lib/index.js +54 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/input-format.d.ts +216 -0
- package/dist/lib/input-format.js +246 -0
- package/dist/lib/input-format.js.map +1 -0
- package/dist/lib/io-context.d.ts +495 -0
- package/dist/lib/io-context.js +550 -0
- package/dist/lib/io-context.js.map +1 -0
- package/dist/lib/log.d.ts +201 -0
- package/dist/lib/log.js +219 -0
- package/dist/lib/log.js.map +1 -0
- package/dist/lib/native-types.d.ts +719 -0
- package/dist/lib/native-types.js +2 -0
- package/dist/lib/native-types.js.map +1 -0
- package/dist/lib/option.d.ts +589 -0
- package/dist/lib/option.js +853 -0
- package/dist/lib/option.js.map +1 -0
- package/dist/lib/output-format.d.ts +179 -0
- package/dist/lib/output-format.js +205 -0
- package/dist/lib/output-format.js.map +1 -0
- package/dist/lib/packet.d.ts +487 -0
- package/dist/lib/packet.js +558 -0
- package/dist/lib/packet.js.map +1 -0
- package/dist/lib/rational.d.ts +210 -0
- package/dist/lib/rational.js +233 -0
- package/dist/lib/rational.js.map +1 -0
- package/dist/lib/software-resample-context.d.ts +572 -0
- package/dist/lib/software-resample-context.js +610 -0
- package/dist/lib/software-resample-context.js.map +1 -0
- package/dist/lib/software-scale-context.d.ts +290 -0
- package/dist/lib/software-scale-context.js +308 -0
- package/dist/lib/software-scale-context.js.map +1 -0
- package/dist/lib/stream.d.ts +322 -0
- package/dist/lib/stream.js +408 -0
- package/dist/lib/stream.js.map +1 -0
- package/dist/lib/types.d.ts +59 -0
- package/dist/lib/types.js +8 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/utilities.d.ts +346 -0
- package/dist/lib/utilities.js +424 -0
- package/dist/lib/utilities.js.map +1 -0
- package/install/check.js +113 -0
- package/install/ffmpeg.js +163 -0
- package/package.json +107 -0
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { FilterContext } from './filter-context.js';
|
|
2
|
+
import type { NativeFilterInOut, NativeWrapper } from './native-types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Filter input/output helper for graph parsing.
|
|
5
|
+
*
|
|
6
|
+
* Helper structure for parsing filter graphs with named inputs and outputs.
|
|
7
|
+
* Used to connect external sources/sinks to specific points in a filter graph.
|
|
8
|
+
* Supports linked lists for multiple I/O points in complex graphs.
|
|
9
|
+
*
|
|
10
|
+
* Direct mapping to FFmpeg's AVFilterInOut.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { FilterInOut, FilterGraph, FFmpegError } from 'node-av';
|
|
15
|
+
*
|
|
16
|
+
* // Create input/output points for filter graph
|
|
17
|
+
* const inputs = new FilterInOut();
|
|
18
|
+
* inputs.alloc();
|
|
19
|
+
* inputs.name = 'in';
|
|
20
|
+
* inputs.filterCtx = bufferSrcCtx;
|
|
21
|
+
* inputs.padIdx = 0;
|
|
22
|
+
*
|
|
23
|
+
* const outputs = new FilterInOut();
|
|
24
|
+
* outputs.alloc();
|
|
25
|
+
* outputs.name = 'out';
|
|
26
|
+
* outputs.filterCtx = bufferSinkCtx;
|
|
27
|
+
* outputs.padIdx = 0;
|
|
28
|
+
*
|
|
29
|
+
* // Parse filter graph string
|
|
30
|
+
* const ret = filterGraph.parsePtr(
|
|
31
|
+
* '[in] scale=1280:720 [out]',
|
|
32
|
+
* inputs,
|
|
33
|
+
* outputs
|
|
34
|
+
* );
|
|
35
|
+
* FFmpegError.throwIfError(ret, 'parsePtr');
|
|
36
|
+
*
|
|
37
|
+
* // Clean up
|
|
38
|
+
* inputs.free();
|
|
39
|
+
* outputs.free();
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare class FilterInOut implements Disposable, NativeWrapper<NativeFilterInOut> {
|
|
43
|
+
private native;
|
|
44
|
+
/**
|
|
45
|
+
* Create a new FilterInOut instance.
|
|
46
|
+
*
|
|
47
|
+
* The structure is uninitialized - you must call alloc() before use.
|
|
48
|
+
* No FFmpeg resources are allocated until alloc() is called.
|
|
49
|
+
*
|
|
50
|
+
* Direct wrapper around AVFilterInOut.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```typescript
|
|
54
|
+
* import { FilterInOut } from 'node-av';
|
|
55
|
+
*
|
|
56
|
+
* const inout = new FilterInOut();
|
|
57
|
+
* inout.alloc();
|
|
58
|
+
* // Structure is now ready for use
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
constructor();
|
|
62
|
+
/**
|
|
63
|
+
* Create a linked list of FilterInOut structures.
|
|
64
|
+
*
|
|
65
|
+
* Helper method to create a chain of inputs or outputs.
|
|
66
|
+
* Useful for complex filter graphs with multiple I/O points.
|
|
67
|
+
*
|
|
68
|
+
* @param items - Array of {name, filterCtx, padIdx} objects
|
|
69
|
+
*
|
|
70
|
+
* @returns The head of the linked list, or null if items is empty
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```typescript
|
|
74
|
+
* import { FilterInOut, FilterGraph, FFmpegError } from 'node-av';
|
|
75
|
+
*
|
|
76
|
+
* // Create multiple inputs
|
|
77
|
+
* const inputs = FilterInOut.createList([
|
|
78
|
+
* { name: 'video_in', filterCtx: videoBufferCtx, padIdx: 0 },
|
|
79
|
+
* { name: 'audio_in', filterCtx: audioBufferCtx, padIdx: 0 }
|
|
80
|
+
* ]);
|
|
81
|
+
*
|
|
82
|
+
* // Use in filter graph
|
|
83
|
+
* const ret = filterGraph.parsePtr(filterString, inputs, outputs);
|
|
84
|
+
* FFmpegError.throwIfError(ret, 'parsePtr');
|
|
85
|
+
*
|
|
86
|
+
* // Free the entire list
|
|
87
|
+
* inputs?.free();
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
static createList(items: {
|
|
91
|
+
name: string;
|
|
92
|
+
filterCtx: FilterContext;
|
|
93
|
+
padIdx: number;
|
|
94
|
+
}[]): FilterInOut | null;
|
|
95
|
+
/**
|
|
96
|
+
* Name of this input/output point.
|
|
97
|
+
*
|
|
98
|
+
* Direct mapping to AVFilterInOut->name
|
|
99
|
+
*
|
|
100
|
+
* Used to reference this pad in filtergraph strings.
|
|
101
|
+
*/
|
|
102
|
+
get name(): string | null;
|
|
103
|
+
set name(value: string | null);
|
|
104
|
+
/**
|
|
105
|
+
* Associated filter context.
|
|
106
|
+
*
|
|
107
|
+
* Direct mapping to AVFilterInOut->filter_ctx
|
|
108
|
+
*
|
|
109
|
+
* The filter context this pad connects to.
|
|
110
|
+
*/
|
|
111
|
+
get filterCtx(): FilterContext | null;
|
|
112
|
+
set filterCtx(value: FilterContext | null);
|
|
113
|
+
/**
|
|
114
|
+
* Pad index.
|
|
115
|
+
*
|
|
116
|
+
* Direct mapping to AVFilterInOut->pad_idx
|
|
117
|
+
*
|
|
118
|
+
* The input or output pad index on the filter context.
|
|
119
|
+
*/
|
|
120
|
+
get padIdx(): number;
|
|
121
|
+
set padIdx(value: number);
|
|
122
|
+
/**
|
|
123
|
+
* Next element in the linked list.
|
|
124
|
+
*
|
|
125
|
+
* Direct mapping to AVFilterInOut->next
|
|
126
|
+
*
|
|
127
|
+
* Used to chain multiple inputs or outputs together.
|
|
128
|
+
*/
|
|
129
|
+
get next(): FilterInOut | null;
|
|
130
|
+
set next(value: FilterInOut | null);
|
|
131
|
+
/**
|
|
132
|
+
* Allocate the FilterInOut structure.
|
|
133
|
+
*
|
|
134
|
+
* Allocates the structure and initializes it.
|
|
135
|
+
* Must be called before setting properties or using the structure.
|
|
136
|
+
*
|
|
137
|
+
* Direct mapping to avfilter_inout_alloc()
|
|
138
|
+
*
|
|
139
|
+
* @throws {Error} Memory allocation failure (ENOMEM)
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```typescript
|
|
143
|
+
* import { FilterInOut } from 'node-av';
|
|
144
|
+
*
|
|
145
|
+
* const inout = new FilterInOut();
|
|
146
|
+
* inout.alloc();
|
|
147
|
+
* // Structure is now allocated and ready
|
|
148
|
+
* ```
|
|
149
|
+
*
|
|
150
|
+
* @see {@link free} To free the structure
|
|
151
|
+
*/
|
|
152
|
+
alloc(): void;
|
|
153
|
+
/**
|
|
154
|
+
* Free the FilterInOut structure.
|
|
155
|
+
*
|
|
156
|
+
* Releases all resources associated with the structure.
|
|
157
|
+
* Also frees any linked structures in the chain.
|
|
158
|
+
*
|
|
159
|
+
* Direct mapping to avfilter_inout_free()
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```typescript
|
|
163
|
+
* inout.free();
|
|
164
|
+
* // inout is now invalid and should not be used
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
free(): void;
|
|
168
|
+
/**
|
|
169
|
+
* Count elements in the linked list.
|
|
170
|
+
*
|
|
171
|
+
* Helper method to count all elements starting from this one.
|
|
172
|
+
*
|
|
173
|
+
* @returns Number of elements including this one
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* ```typescript
|
|
177
|
+
* const inputs = FilterInOut.createList([...]);
|
|
178
|
+
* console.log(`Total inputs: ${inputs?.count()}`); // e.g., "Total inputs: 3"
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
181
|
+
count(): number;
|
|
182
|
+
/**
|
|
183
|
+
* Get the native FFmpeg AVFilterInOut pointer.
|
|
184
|
+
*
|
|
185
|
+
* @internal For use by other wrapper classes
|
|
186
|
+
* @returns The underlying native FilterInOut object
|
|
187
|
+
*/
|
|
188
|
+
getNative(): NativeFilterInOut;
|
|
189
|
+
/**
|
|
190
|
+
* Dispose of the FilterInOut structure.
|
|
191
|
+
*
|
|
192
|
+
* Implements the Disposable interface for automatic cleanup.
|
|
193
|
+
* Equivalent to calling free().
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```typescript
|
|
197
|
+
* {
|
|
198
|
+
* using inout = new FilterInOut();
|
|
199
|
+
* inout.alloc();
|
|
200
|
+
* // ... use structure
|
|
201
|
+
* } // Automatically freed when leaving scope
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
[Symbol.dispose](): void;
|
|
205
|
+
}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { bindings } from './binding.js';
|
|
2
|
+
import { FilterContext } from './filter-context.js';
|
|
3
|
+
/**
|
|
4
|
+
* Filter input/output helper for graph parsing.
|
|
5
|
+
*
|
|
6
|
+
* Helper structure for parsing filter graphs with named inputs and outputs.
|
|
7
|
+
* Used to connect external sources/sinks to specific points in a filter graph.
|
|
8
|
+
* Supports linked lists for multiple I/O points in complex graphs.
|
|
9
|
+
*
|
|
10
|
+
* Direct mapping to FFmpeg's AVFilterInOut.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { FilterInOut, FilterGraph, FFmpegError } from 'node-av';
|
|
15
|
+
*
|
|
16
|
+
* // Create input/output points for filter graph
|
|
17
|
+
* const inputs = new FilterInOut();
|
|
18
|
+
* inputs.alloc();
|
|
19
|
+
* inputs.name = 'in';
|
|
20
|
+
* inputs.filterCtx = bufferSrcCtx;
|
|
21
|
+
* inputs.padIdx = 0;
|
|
22
|
+
*
|
|
23
|
+
* const outputs = new FilterInOut();
|
|
24
|
+
* outputs.alloc();
|
|
25
|
+
* outputs.name = 'out';
|
|
26
|
+
* outputs.filterCtx = bufferSinkCtx;
|
|
27
|
+
* outputs.padIdx = 0;
|
|
28
|
+
*
|
|
29
|
+
* // Parse filter graph string
|
|
30
|
+
* const ret = filterGraph.parsePtr(
|
|
31
|
+
* '[in] scale=1280:720 [out]',
|
|
32
|
+
* inputs,
|
|
33
|
+
* outputs
|
|
34
|
+
* );
|
|
35
|
+
* FFmpegError.throwIfError(ret, 'parsePtr');
|
|
36
|
+
*
|
|
37
|
+
* // Clean up
|
|
38
|
+
* inputs.free();
|
|
39
|
+
* outputs.free();
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export class FilterInOut {
|
|
43
|
+
native;
|
|
44
|
+
/**
|
|
45
|
+
* Create a new FilterInOut instance.
|
|
46
|
+
*
|
|
47
|
+
* The structure is uninitialized - you must call alloc() before use.
|
|
48
|
+
* No FFmpeg resources are allocated until alloc() is called.
|
|
49
|
+
*
|
|
50
|
+
* Direct wrapper around AVFilterInOut.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```typescript
|
|
54
|
+
* import { FilterInOut } from 'node-av';
|
|
55
|
+
*
|
|
56
|
+
* const inout = new FilterInOut();
|
|
57
|
+
* inout.alloc();
|
|
58
|
+
* // Structure is now ready for use
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
constructor() {
|
|
62
|
+
this.native = new bindings.FilterInOut();
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Create a linked list of FilterInOut structures.
|
|
66
|
+
*
|
|
67
|
+
* Helper method to create a chain of inputs or outputs.
|
|
68
|
+
* Useful for complex filter graphs with multiple I/O points.
|
|
69
|
+
*
|
|
70
|
+
* @param items - Array of {name, filterCtx, padIdx} objects
|
|
71
|
+
*
|
|
72
|
+
* @returns The head of the linked list, or null if items is empty
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* import { FilterInOut, FilterGraph, FFmpegError } from 'node-av';
|
|
77
|
+
*
|
|
78
|
+
* // Create multiple inputs
|
|
79
|
+
* const inputs = FilterInOut.createList([
|
|
80
|
+
* { name: 'video_in', filterCtx: videoBufferCtx, padIdx: 0 },
|
|
81
|
+
* { name: 'audio_in', filterCtx: audioBufferCtx, padIdx: 0 }
|
|
82
|
+
* ]);
|
|
83
|
+
*
|
|
84
|
+
* // Use in filter graph
|
|
85
|
+
* const ret = filterGraph.parsePtr(filterString, inputs, outputs);
|
|
86
|
+
* FFmpegError.throwIfError(ret, 'parsePtr');
|
|
87
|
+
*
|
|
88
|
+
* // Free the entire list
|
|
89
|
+
* inputs?.free();
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
static createList(items) {
|
|
93
|
+
if (items.length === 0)
|
|
94
|
+
return null;
|
|
95
|
+
let head = null;
|
|
96
|
+
let current = null;
|
|
97
|
+
for (const item of items) {
|
|
98
|
+
const inout = new FilterInOut();
|
|
99
|
+
inout.alloc();
|
|
100
|
+
inout.name = item.name;
|
|
101
|
+
inout.filterCtx = item.filterCtx;
|
|
102
|
+
inout.padIdx = item.padIdx;
|
|
103
|
+
if (!head) {
|
|
104
|
+
head = inout;
|
|
105
|
+
current = inout;
|
|
106
|
+
}
|
|
107
|
+
else if (current) {
|
|
108
|
+
current.next = inout;
|
|
109
|
+
current = inout;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return head;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Name of this input/output point.
|
|
116
|
+
*
|
|
117
|
+
* Direct mapping to AVFilterInOut->name
|
|
118
|
+
*
|
|
119
|
+
* Used to reference this pad in filtergraph strings.
|
|
120
|
+
*/
|
|
121
|
+
get name() {
|
|
122
|
+
return this.native.name;
|
|
123
|
+
}
|
|
124
|
+
set name(value) {
|
|
125
|
+
this.native.name = value;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Associated filter context.
|
|
129
|
+
*
|
|
130
|
+
* Direct mapping to AVFilterInOut->filter_ctx
|
|
131
|
+
*
|
|
132
|
+
* The filter context this pad connects to.
|
|
133
|
+
*/
|
|
134
|
+
get filterCtx() {
|
|
135
|
+
const native = this.native.filterCtx;
|
|
136
|
+
return native ? new FilterContext(native) : null;
|
|
137
|
+
}
|
|
138
|
+
set filterCtx(value) {
|
|
139
|
+
this.native.filterCtx = value ? value.getNative() : null;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Pad index.
|
|
143
|
+
*
|
|
144
|
+
* Direct mapping to AVFilterInOut->pad_idx
|
|
145
|
+
*
|
|
146
|
+
* The input or output pad index on the filter context.
|
|
147
|
+
*/
|
|
148
|
+
get padIdx() {
|
|
149
|
+
return this.native.padIdx;
|
|
150
|
+
}
|
|
151
|
+
set padIdx(value) {
|
|
152
|
+
this.native.padIdx = value;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Next element in the linked list.
|
|
156
|
+
*
|
|
157
|
+
* Direct mapping to AVFilterInOut->next
|
|
158
|
+
*
|
|
159
|
+
* Used to chain multiple inputs or outputs together.
|
|
160
|
+
*/
|
|
161
|
+
get next() {
|
|
162
|
+
const native = this.native.next;
|
|
163
|
+
if (!native) {
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
const filterInOut = Object.create(FilterInOut.prototype);
|
|
167
|
+
filterInOut.native = native;
|
|
168
|
+
return filterInOut;
|
|
169
|
+
}
|
|
170
|
+
set next(value) {
|
|
171
|
+
this.native.next = value ? value.getNative() : null;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Allocate the FilterInOut structure.
|
|
175
|
+
*
|
|
176
|
+
* Allocates the structure and initializes it.
|
|
177
|
+
* Must be called before setting properties or using the structure.
|
|
178
|
+
*
|
|
179
|
+
* Direct mapping to avfilter_inout_alloc()
|
|
180
|
+
*
|
|
181
|
+
* @throws {Error} Memory allocation failure (ENOMEM)
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* ```typescript
|
|
185
|
+
* import { FilterInOut } from 'node-av';
|
|
186
|
+
*
|
|
187
|
+
* const inout = new FilterInOut();
|
|
188
|
+
* inout.alloc();
|
|
189
|
+
* // Structure is now allocated and ready
|
|
190
|
+
* ```
|
|
191
|
+
*
|
|
192
|
+
* @see {@link free} To free the structure
|
|
193
|
+
*/
|
|
194
|
+
alloc() {
|
|
195
|
+
this.native.alloc();
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Free the FilterInOut structure.
|
|
199
|
+
*
|
|
200
|
+
* Releases all resources associated with the structure.
|
|
201
|
+
* Also frees any linked structures in the chain.
|
|
202
|
+
*
|
|
203
|
+
* Direct mapping to avfilter_inout_free()
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* ```typescript
|
|
207
|
+
* inout.free();
|
|
208
|
+
* // inout is now invalid and should not be used
|
|
209
|
+
* ```
|
|
210
|
+
*/
|
|
211
|
+
free() {
|
|
212
|
+
this.native.free();
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Count elements in the linked list.
|
|
216
|
+
*
|
|
217
|
+
* Helper method to count all elements starting from this one.
|
|
218
|
+
*
|
|
219
|
+
* @returns Number of elements including this one
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* ```typescript
|
|
223
|
+
* const inputs = FilterInOut.createList([...]);
|
|
224
|
+
* console.log(`Total inputs: ${inputs?.count()}`); // e.g., "Total inputs: 3"
|
|
225
|
+
* ```
|
|
226
|
+
*/
|
|
227
|
+
count() {
|
|
228
|
+
let count = 1;
|
|
229
|
+
let current = this.next;
|
|
230
|
+
while (current) {
|
|
231
|
+
count++;
|
|
232
|
+
current = current.next;
|
|
233
|
+
}
|
|
234
|
+
return count;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Get the native FFmpeg AVFilterInOut pointer.
|
|
238
|
+
*
|
|
239
|
+
* @internal For use by other wrapper classes
|
|
240
|
+
* @returns The underlying native FilterInOut object
|
|
241
|
+
*/
|
|
242
|
+
getNative() {
|
|
243
|
+
return this.native;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Dispose of the FilterInOut structure.
|
|
247
|
+
*
|
|
248
|
+
* Implements the Disposable interface for automatic cleanup.
|
|
249
|
+
* Equivalent to calling free().
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
* ```typescript
|
|
253
|
+
* {
|
|
254
|
+
* using inout = new FilterInOut();
|
|
255
|
+
* inout.alloc();
|
|
256
|
+
* // ... use structure
|
|
257
|
+
* } // Automatically freed when leaving scope
|
|
258
|
+
* ```
|
|
259
|
+
*/
|
|
260
|
+
[Symbol.dispose]() {
|
|
261
|
+
this.native[Symbol.dispose]();
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
//# sourceMappingURL=filter-inout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter-inout.js","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AE,CAAC;IACtB,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,IAAI;QACF,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IACrB,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,KAAK;QACH,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,IAAI,OAAO,GAAuB,IAAI,CAAC,IAAI,CAAC;QAE5C,OAAO,OAAO,EAAE,CAAC;YACf,KAAK,EAAE,CAAC;YACR,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;OAKG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,CAAC,MAAM,CAAC,OAAO,CAAC;QACd,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;IAChC,CAAC;CACF"}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import type { NativeFilter, NativeWrapper } from './native-types.js';
|
|
2
|
+
import type { FilterPad } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Filter definition for media processing.
|
|
5
|
+
*
|
|
6
|
+
* Represents a static filter definition (immutable template).
|
|
7
|
+
* Defines the filter's capabilities, inputs, outputs, and properties.
|
|
8
|
+
* Actual filtering operations are performed through FilterContext instances.
|
|
9
|
+
*
|
|
10
|
+
* Direct mapping to FFmpeg's AVFilter.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { Filter } from 'node-av';
|
|
15
|
+
*
|
|
16
|
+
* // Find a filter by name
|
|
17
|
+
* const scaleFilter = Filter.getByName('scale');
|
|
18
|
+
* if (!scaleFilter) throw new Error('Scale filter not found');
|
|
19
|
+
*
|
|
20
|
+
* // Check filter properties
|
|
21
|
+
* console.log(`Filter: ${scaleFilter.name}`);
|
|
22
|
+
* console.log(`Description: ${scaleFilter.description}`);
|
|
23
|
+
* console.log(`Inputs: ${scaleFilter.inputs.length}`);
|
|
24
|
+
* console.log(`Outputs: ${scaleFilter.outputs.length}`);
|
|
25
|
+
*
|
|
26
|
+
* // Get all video filters
|
|
27
|
+
* const allFilters = Filter.getList();
|
|
28
|
+
* const videoFilters = allFilters.filter(f => f.isVideo());
|
|
29
|
+
* console.log(`Found ${videoFilters.length} video filters`);
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare class Filter implements NativeWrapper<NativeFilter> {
|
|
33
|
+
private native;
|
|
34
|
+
/**
|
|
35
|
+
* Constructor is internal - use static factory methods.
|
|
36
|
+
*
|
|
37
|
+
* Filters are global immutable objects managed by FFmpeg.
|
|
38
|
+
* Use the static factory methods to obtain filter instances.
|
|
39
|
+
*
|
|
40
|
+
* @internal
|
|
41
|
+
*
|
|
42
|
+
* @param native - Native AVFilter to wrap
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* import { Filter } from 'node-av';
|
|
47
|
+
*
|
|
48
|
+
* // Don't use constructor directly
|
|
49
|
+
* // const filter = new Filter(); // Wrong
|
|
50
|
+
*
|
|
51
|
+
* // Use static factory methods instead
|
|
52
|
+
* const filter = Filter.getByName('scale'); // Correct
|
|
53
|
+
* const filters = Filter.getList(); // Correct
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
constructor(native: NativeFilter);
|
|
57
|
+
/**
|
|
58
|
+
* Find a filter by name.
|
|
59
|
+
*
|
|
60
|
+
* Searches for a filter by its exact name.
|
|
61
|
+
* Returns the filter definition if found.
|
|
62
|
+
*
|
|
63
|
+
* Direct mapping to avfilter_get_by_name()
|
|
64
|
+
*
|
|
65
|
+
* @param name - Filter name (e.g., "scale", "overlay", "volume")
|
|
66
|
+
*
|
|
67
|
+
* @returns The filter if found, null otherwise
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* import { Filter } from 'node-av';
|
|
72
|
+
*
|
|
73
|
+
* // Find the scale filter
|
|
74
|
+
* const scaleFilter = Filter.getByName('scale');
|
|
75
|
+
* if (!scaleFilter) {
|
|
76
|
+
* throw new Error('Scale filter not available');
|
|
77
|
+
* }
|
|
78
|
+
*
|
|
79
|
+
* // Find audio volume filter
|
|
80
|
+
* const volumeFilter = Filter.getByName('volume');
|
|
81
|
+
* if (!volumeFilter) {
|
|
82
|
+
* throw new Error('Volume filter not available');
|
|
83
|
+
* }
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* @see {@link getList} To get all available filters
|
|
87
|
+
*/
|
|
88
|
+
static getByName(name: string): Filter | null;
|
|
89
|
+
/**
|
|
90
|
+
* Get list of all available filters.
|
|
91
|
+
*
|
|
92
|
+
* Returns all registered filters in the system.
|
|
93
|
+
* Internally uses avfilter_iterate() to collect all filters.
|
|
94
|
+
*
|
|
95
|
+
* Direct mapping to avfilter_iterate()
|
|
96
|
+
*
|
|
97
|
+
* @returns Array of all registered filters
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```typescript
|
|
101
|
+
* import { Filter } from 'node-av';
|
|
102
|
+
*
|
|
103
|
+
* // Get all video filters
|
|
104
|
+
* const allFilters = Filter.getList();
|
|
105
|
+
* const videoFilters = allFilters.filter(f => f.isVideo());
|
|
106
|
+
* console.log(`Found ${videoFilters.length} video filters`);
|
|
107
|
+
*
|
|
108
|
+
* // Find all source filters
|
|
109
|
+
* const sourceFilters = allFilters.filter(f => f.isSource());
|
|
110
|
+
* sourceFilters.forEach(f => {
|
|
111
|
+
* console.log(`Source filter: ${f.name}`);
|
|
112
|
+
* });
|
|
113
|
+
* ```
|
|
114
|
+
*
|
|
115
|
+
* @see {@link getByName} To find a specific filter
|
|
116
|
+
*/
|
|
117
|
+
static getList(): Filter[];
|
|
118
|
+
/**
|
|
119
|
+
* Filter name.
|
|
120
|
+
*
|
|
121
|
+
* Direct mapping to AVFilter->name
|
|
122
|
+
*
|
|
123
|
+
* The short name of the filter (e.g., "scale", "overlay", "volume").
|
|
124
|
+
*/
|
|
125
|
+
get name(): string | null;
|
|
126
|
+
/**
|
|
127
|
+
* Filter description.
|
|
128
|
+
*
|
|
129
|
+
* Direct mapping to AVFilter->description
|
|
130
|
+
*
|
|
131
|
+
* Human-readable description of what the filter does.
|
|
132
|
+
*/
|
|
133
|
+
get description(): string | null;
|
|
134
|
+
/**
|
|
135
|
+
* Input pads.
|
|
136
|
+
*
|
|
137
|
+
* Direct mapping to AVFilter->inputs
|
|
138
|
+
*
|
|
139
|
+
* Array of input connection points for the filter.
|
|
140
|
+
* Empty array for source filters.
|
|
141
|
+
*/
|
|
142
|
+
get inputs(): FilterPad[];
|
|
143
|
+
/**
|
|
144
|
+
* Output pads.
|
|
145
|
+
*
|
|
146
|
+
* Direct mapping to AVFilter->outputs
|
|
147
|
+
*
|
|
148
|
+
* Array of output connection points for the filter.
|
|
149
|
+
* Empty array for sink filters.
|
|
150
|
+
*/
|
|
151
|
+
get outputs(): FilterPad[];
|
|
152
|
+
/**
|
|
153
|
+
* Filter flags.
|
|
154
|
+
*
|
|
155
|
+
* Direct mapping to AVFilter->flags
|
|
156
|
+
*
|
|
157
|
+
* Bitwise flags indicating filter capabilities (AVFILTER_FLAG_*).
|
|
158
|
+
*/
|
|
159
|
+
get flags(): number;
|
|
160
|
+
/**
|
|
161
|
+
* Check if this is a source filter.
|
|
162
|
+
*
|
|
163
|
+
* Source filters have no inputs and generate data.
|
|
164
|
+
*
|
|
165
|
+
* @returns true if the filter has no input pads, false otherwise
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* ```typescript
|
|
169
|
+
* const filter = Filter.getByName('buffer');
|
|
170
|
+
* if (filter && filter.isSource()) {
|
|
171
|
+
* console.log('This is a source filter');
|
|
172
|
+
* }
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
isSource(): boolean;
|
|
176
|
+
/**
|
|
177
|
+
* Check if this is a sink filter.
|
|
178
|
+
*
|
|
179
|
+
* Sink filters have no outputs and consume data.
|
|
180
|
+
*
|
|
181
|
+
* @returns true if the filter has no output pads, false otherwise
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* ```typescript
|
|
185
|
+
* const filter = Filter.getByName('buffersink');
|
|
186
|
+
* if (filter && filter.isSink()) {
|
|
187
|
+
* console.log('This is a sink filter');
|
|
188
|
+
* }
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
isSink(): boolean;
|
|
192
|
+
/**
|
|
193
|
+
* Check if this is a video filter.
|
|
194
|
+
*
|
|
195
|
+
* Checks if any input or output pad handles video data.
|
|
196
|
+
*
|
|
197
|
+
* @returns true if the filter processes video data, false otherwise
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* ```typescript
|
|
201
|
+
* const filter = Filter.getByName('scale');
|
|
202
|
+
* if (filter && filter.isVideo()) {
|
|
203
|
+
* console.log('This filter processes video');
|
|
204
|
+
* }
|
|
205
|
+
* ```
|
|
206
|
+
*/
|
|
207
|
+
isVideo(): boolean;
|
|
208
|
+
/**
|
|
209
|
+
* Check if this is an audio filter.
|
|
210
|
+
*
|
|
211
|
+
* Checks if any input or output pad handles audio data.
|
|
212
|
+
*
|
|
213
|
+
* @returns true if the filter processes audio data, false otherwise
|
|
214
|
+
*
|
|
215
|
+
* @example
|
|
216
|
+
* ```typescript
|
|
217
|
+
* const filter = Filter.getByName('volume');
|
|
218
|
+
* if (filter && filter.isAudio()) {
|
|
219
|
+
* console.log('This filter processes audio');
|
|
220
|
+
* }
|
|
221
|
+
* ```
|
|
222
|
+
*/
|
|
223
|
+
isAudio(): boolean;
|
|
224
|
+
/**
|
|
225
|
+
* Get the native FFmpeg AVFilter pointer.
|
|
226
|
+
*
|
|
227
|
+
* @internal For use by other wrapper classes
|
|
228
|
+
* @returns The underlying native filter object
|
|
229
|
+
*/
|
|
230
|
+
getNative(): NativeFilter;
|
|
231
|
+
}
|