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,457 @@
|
|
|
1
|
+
import { Frame, Stream } from '../lib/index.js';
|
|
2
|
+
import type { AVFilterCmdFlag, AVMediaType, AVPixelFormat, AVSampleFormat, HardwareFramesContext, IRational } from '../lib/index.js';
|
|
3
|
+
import type { FilterOptions, StreamInfo } from './types.js';
|
|
4
|
+
interface VideoFilterConfig {
|
|
5
|
+
type: 'video';
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
pixelFormat: AVPixelFormat;
|
|
9
|
+
timeBase: IRational;
|
|
10
|
+
frameRate?: IRational;
|
|
11
|
+
sampleAspectRatio?: IRational;
|
|
12
|
+
hwFramesCtx?: HardwareFramesContext | null;
|
|
13
|
+
}
|
|
14
|
+
interface AudioFilterConfig {
|
|
15
|
+
type: 'audio';
|
|
16
|
+
sampleRate: number;
|
|
17
|
+
sampleFormat: AVSampleFormat;
|
|
18
|
+
channelLayout: bigint;
|
|
19
|
+
timeBase: IRational;
|
|
20
|
+
}
|
|
21
|
+
type FilterConfig = VideoFilterConfig | AudioFilterConfig;
|
|
22
|
+
/**
|
|
23
|
+
* High-level filter API for media processing.
|
|
24
|
+
*
|
|
25
|
+
* Provides a simplified interface for FFmpeg's filter system.
|
|
26
|
+
* Supports both simple filter chains and complex filter graphs.
|
|
27
|
+
* Handles automatic format negotiation and buffer management.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* import { FilterAPI, Frame } from 'node-av/api';
|
|
32
|
+
*
|
|
33
|
+
* // Create a simple video filter from a stream
|
|
34
|
+
* const videoStream = media.video();
|
|
35
|
+
* const filter = await FilterAPI.create('scale=1280:720,format=yuv420p', videoStream);
|
|
36
|
+
*
|
|
37
|
+
* // Process frames
|
|
38
|
+
* const outputFrame = await filter.process(inputFrame);
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* // Create filter with hardware acceleration
|
|
44
|
+
* const hw = await HardwareContext.auto();
|
|
45
|
+
* const filter = await FilterAPI.create('scale_vt=640:480', videoStream, {
|
|
46
|
+
* hardware: hw
|
|
47
|
+
* });
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare class FilterAPI implements Disposable {
|
|
51
|
+
private graph;
|
|
52
|
+
private buffersrcCtx;
|
|
53
|
+
private buffersinkCtx;
|
|
54
|
+
private config;
|
|
55
|
+
private mediaType;
|
|
56
|
+
private initialized;
|
|
57
|
+
private needsHardware;
|
|
58
|
+
private hardware?;
|
|
59
|
+
private pendingInit?;
|
|
60
|
+
/**
|
|
61
|
+
* Create a new Filter instance.
|
|
62
|
+
*
|
|
63
|
+
* The filter is uninitialized until setup with a filter description.
|
|
64
|
+
* Use the static factory methods for easier creation.
|
|
65
|
+
*
|
|
66
|
+
* @param config - Filter configuration
|
|
67
|
+
* @param hardware - Optional hardware context for late framesContext binding
|
|
68
|
+
* @internal
|
|
69
|
+
*/
|
|
70
|
+
private constructor();
|
|
71
|
+
/**
|
|
72
|
+
* Create a filter from a filter description string.
|
|
73
|
+
*
|
|
74
|
+
* Accepts either a Stream (from MediaInput/Decoder) or StreamInfo (for raw data).
|
|
75
|
+
* Automatically sets up buffer source and sink filters.
|
|
76
|
+
*
|
|
77
|
+
* Handles complex filter chains with multiple filters. Automatically detects if ANY
|
|
78
|
+
* filter in the chain requires hardware acceleration (e.g., scale_vt in
|
|
79
|
+
* "format=nv12,hwupload,scale_vt=640:480").
|
|
80
|
+
*
|
|
81
|
+
* @param description - Filter graph description (e.g., "scale=1280:720" or complex chains)
|
|
82
|
+
* @param input - Stream or StreamInfo describing the input
|
|
83
|
+
* @param options - Optional filter options including hardware context
|
|
84
|
+
*
|
|
85
|
+
* @returns Promise resolving to configured Filter instance
|
|
86
|
+
*
|
|
87
|
+
* @throws {FFmpegError} If filter creation or configuration fails
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```typescript
|
|
91
|
+
* // Simple filter
|
|
92
|
+
* const filter = await FilterAPI.create('scale=640:480', videoStream);
|
|
93
|
+
*
|
|
94
|
+
* // Complex filter chain with hardware
|
|
95
|
+
* const hw = await HardwareContext.auto();
|
|
96
|
+
* const filter = await FilterAPI.create(
|
|
97
|
+
* 'format=nv12,hwupload,scale_vt=640:480,hwdownload,format=yuv420p',
|
|
98
|
+
* videoStream,
|
|
99
|
+
* { hardware: hw }
|
|
100
|
+
* );
|
|
101
|
+
*
|
|
102
|
+
* // From StreamInfo (for raw data)
|
|
103
|
+
* const filter = await FilterAPI.create('scale=640:480', {
|
|
104
|
+
* type: 'video',
|
|
105
|
+
* width: 1920,
|
|
106
|
+
* height: 1080,
|
|
107
|
+
* pixelFormat: AV_PIX_FMT_YUV420P,
|
|
108
|
+
* timeBase: { num: 1, den: 30 }
|
|
109
|
+
* });
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
static create(description: string, input: Stream | StreamInfo, options?: FilterOptions): Promise<FilterAPI>;
|
|
113
|
+
/**
|
|
114
|
+
* Process a single frame through the filter.
|
|
115
|
+
*
|
|
116
|
+
* Sends a frame through the filter graph and returns the filtered result.
|
|
117
|
+
* May return null if the filter needs more input frames.
|
|
118
|
+
*
|
|
119
|
+
* @param frame - Input frame to filter
|
|
120
|
+
*
|
|
121
|
+
* @returns Promise resolving to filtered frame or null
|
|
122
|
+
*
|
|
123
|
+
* @throws {FFmpegError} If processing fails
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```typescript
|
|
127
|
+
* const outputFrame = await filter.process(inputFrame);
|
|
128
|
+
* if (outputFrame) {
|
|
129
|
+
* // Process the filtered frame
|
|
130
|
+
* }
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
process(frame: Frame): Promise<Frame | null>;
|
|
134
|
+
/**
|
|
135
|
+
* Process multiple frames through the filter.
|
|
136
|
+
*
|
|
137
|
+
* Batch processing for better performance.
|
|
138
|
+
* Returns all available output frames.
|
|
139
|
+
*
|
|
140
|
+
* @param frames - Array of input frames
|
|
141
|
+
*
|
|
142
|
+
* @returns Promise resolving to array of filtered frames
|
|
143
|
+
*
|
|
144
|
+
* @throws {FFmpegError} If processing fails
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```typescript
|
|
148
|
+
* const outputFrames = await filter.processMultiple(inputFrames);
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
processMultiple(frames: Frame[]): Promise<Frame[]>;
|
|
152
|
+
/**
|
|
153
|
+
* Receive a filtered frame without sending input.
|
|
154
|
+
*
|
|
155
|
+
* Used to drain buffered frames from the filter.
|
|
156
|
+
* Returns null when no more frames are available.
|
|
157
|
+
*
|
|
158
|
+
* @returns Promise resolving to filtered frame or null
|
|
159
|
+
*
|
|
160
|
+
* @throws {FFmpegError} If receiving fails
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* ```typescript
|
|
164
|
+
* // Drain all buffered frames
|
|
165
|
+
* while (true) {
|
|
166
|
+
* const frame = await filter.receive();
|
|
167
|
+
* if (!frame) break;
|
|
168
|
+
* // Process frame
|
|
169
|
+
* }
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
receive(): Promise<Frame | null>;
|
|
173
|
+
/**
|
|
174
|
+
* Flush the filter by sending null frame.
|
|
175
|
+
*
|
|
176
|
+
* Signals end of stream to the filter.
|
|
177
|
+
* Use receive() to get any remaining frames.
|
|
178
|
+
*
|
|
179
|
+
* @returns Promise resolving when flush is complete
|
|
180
|
+
*
|
|
181
|
+
* @throws {FFmpegError} If flush fails
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* ```typescript
|
|
185
|
+
* await filter.flush();
|
|
186
|
+
* // Get remaining frames
|
|
187
|
+
* while (true) {
|
|
188
|
+
* const frame = await filter.receive();
|
|
189
|
+
* if (!frame) break;
|
|
190
|
+
* // Process final frames
|
|
191
|
+
* }
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
194
|
+
flush(): Promise<void>;
|
|
195
|
+
/**
|
|
196
|
+
* Flush filter and yield all remaining frames as a generator.
|
|
197
|
+
*
|
|
198
|
+
* More convenient than calling flush() + receive() in a loop.
|
|
199
|
+
* Automatically sends flush signal and yields all buffered frames.
|
|
200
|
+
*
|
|
201
|
+
* @returns Async generator of remaining frames
|
|
202
|
+
*
|
|
203
|
+
* @throws {Error} If filter is not initialized
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* ```typescript
|
|
207
|
+
* // Process all remaining frames with generator
|
|
208
|
+
* for await (const frame of filter.flushFrames()) {
|
|
209
|
+
* // Process final frame
|
|
210
|
+
* using _ = frame; // Auto cleanup
|
|
211
|
+
* }
|
|
212
|
+
* ```
|
|
213
|
+
*/
|
|
214
|
+
flushFrames(): AsyncGenerator<Frame>;
|
|
215
|
+
/**
|
|
216
|
+
* Process frames as an async generator.
|
|
217
|
+
*
|
|
218
|
+
* Provides a convenient iterator interface for filtering.
|
|
219
|
+
* Automatically handles buffering and draining.
|
|
220
|
+
* Input frames are automatically freed after processing.
|
|
221
|
+
*
|
|
222
|
+
* IMPORTANT: The yielded frames MUST be freed by the caller!
|
|
223
|
+
* Input frames are automatically freed after processing.
|
|
224
|
+
*
|
|
225
|
+
* @param frames - Async generator of input frames (will be freed automatically)
|
|
226
|
+
*
|
|
227
|
+
* @returns Async generator of filtered frames (ownership transferred to caller)
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* ```typescript
|
|
231
|
+
* for await (const filtered of filter.frames(decoder.frames())) {
|
|
232
|
+
* // Process filtered frame
|
|
233
|
+
* filtered.free(); // Must free output frame
|
|
234
|
+
* }
|
|
235
|
+
* ```
|
|
236
|
+
*/
|
|
237
|
+
frames(frames: AsyncGenerator<Frame>): AsyncGenerator<Frame>;
|
|
238
|
+
/**
|
|
239
|
+
* Get the filter graph description.
|
|
240
|
+
*
|
|
241
|
+
* Returns a string representation of the filter graph in DOT format.
|
|
242
|
+
* Useful for debugging and visualization.
|
|
243
|
+
*
|
|
244
|
+
* @returns Graph description or null if not initialized
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
* ```typescript
|
|
248
|
+
* const description = filter.getGraphDescription();
|
|
249
|
+
* console.log(description);
|
|
250
|
+
* ```
|
|
251
|
+
*/
|
|
252
|
+
getGraphDescription(): string | null;
|
|
253
|
+
/**
|
|
254
|
+
* Check if the filter is initialized and ready.
|
|
255
|
+
*
|
|
256
|
+
* @returns true if the filter is ready for processing
|
|
257
|
+
*/
|
|
258
|
+
isReady(): boolean;
|
|
259
|
+
/**
|
|
260
|
+
* Get the media type of this filter.
|
|
261
|
+
*
|
|
262
|
+
* @returns The media type (video or audio)
|
|
263
|
+
*/
|
|
264
|
+
getMediaType(): AVMediaType;
|
|
265
|
+
/**
|
|
266
|
+
* Get the filter configuration.
|
|
267
|
+
*
|
|
268
|
+
* @returns The filter configuration used to create this instance
|
|
269
|
+
*/
|
|
270
|
+
getConfig(): FilterConfig;
|
|
271
|
+
/**
|
|
272
|
+
* Free all filter resources.
|
|
273
|
+
*
|
|
274
|
+
* Releases the filter graph and all associated filters.
|
|
275
|
+
* The filter instance cannot be used after calling this.
|
|
276
|
+
*
|
|
277
|
+
* @example
|
|
278
|
+
* ```typescript
|
|
279
|
+
* filter.free();
|
|
280
|
+
* // filter is now invalid
|
|
281
|
+
* ```
|
|
282
|
+
*/
|
|
283
|
+
free(): void;
|
|
284
|
+
/**
|
|
285
|
+
* Initialize the filter graph.
|
|
286
|
+
*
|
|
287
|
+
* Sets up buffer source, buffer sink, and parses the filter description.
|
|
288
|
+
* Configures the graph for processing.
|
|
289
|
+
*
|
|
290
|
+
* @internal
|
|
291
|
+
*/
|
|
292
|
+
private initialize;
|
|
293
|
+
/**
|
|
294
|
+
* Create and configure the buffer source filter.
|
|
295
|
+
*
|
|
296
|
+
* @internal
|
|
297
|
+
*/
|
|
298
|
+
private createBufferSource;
|
|
299
|
+
/**
|
|
300
|
+
* Create and configure the buffer sink filter.
|
|
301
|
+
*
|
|
302
|
+
* @internal
|
|
303
|
+
*/
|
|
304
|
+
private createBufferSink;
|
|
305
|
+
/**
|
|
306
|
+
* Parse and connect the filter description.
|
|
307
|
+
*
|
|
308
|
+
* @internal
|
|
309
|
+
*/
|
|
310
|
+
private parseFilterDescription;
|
|
311
|
+
/**
|
|
312
|
+
* Send a command to a filter in the graph.
|
|
313
|
+
*
|
|
314
|
+
* Allows runtime modification of filter parameters without recreating the graph.
|
|
315
|
+
* Not all filters support commands - check filter documentation.
|
|
316
|
+
*
|
|
317
|
+
* @param target - Filter name or "all" to send to all filters
|
|
318
|
+
* @param cmd - Command name (e.g., "volume", "hue", "brightness")
|
|
319
|
+
* @param arg - Command argument value
|
|
320
|
+
* @param flags - Optional command flags
|
|
321
|
+
*
|
|
322
|
+
* @returns Command response
|
|
323
|
+
*
|
|
324
|
+
* @example
|
|
325
|
+
* ```typescript
|
|
326
|
+
* // Change volume dynamically
|
|
327
|
+
* const response = filter.sendCommand('volume', 'volume', '0.5');
|
|
328
|
+
* if (response) {
|
|
329
|
+
* console.log('Volume changed successfully');
|
|
330
|
+
* }
|
|
331
|
+
* ```
|
|
332
|
+
*
|
|
333
|
+
* @example
|
|
334
|
+
* ```typescript
|
|
335
|
+
* // Enable/disable all filters at runtime
|
|
336
|
+
* filter.sendCommand('all', 'enable', 'expr=gte(t,10)');
|
|
337
|
+
* ```
|
|
338
|
+
*/
|
|
339
|
+
sendCommand(target: string, cmd: string, arg: string, flags?: AVFilterCmdFlag): string;
|
|
340
|
+
/**
|
|
341
|
+
* Queue a command to be executed at a specific time.
|
|
342
|
+
*
|
|
343
|
+
* Commands are executed when processing frames with matching timestamps.
|
|
344
|
+
* Useful for scripted filter changes synchronized with media playback.
|
|
345
|
+
*
|
|
346
|
+
* @param target - Filter name or "all" to send to all filters
|
|
347
|
+
* @param cmd - Command name (e.g., "volume", "hue", "brightness")
|
|
348
|
+
* @param arg - Command argument value
|
|
349
|
+
* @param ts - Timestamp when command should execute (in seconds)
|
|
350
|
+
* @param flags - Optional command flags
|
|
351
|
+
*
|
|
352
|
+
* @example
|
|
353
|
+
* ```typescript
|
|
354
|
+
* // Schedule volume changes at specific times
|
|
355
|
+
* filter.queueCommand('volume', 'volume', '0.5', 5.0); // At 5 seconds
|
|
356
|
+
* filter.queueCommand('volume', 'volume', '0.8', 10.0); // At 10 seconds
|
|
357
|
+
* filter.queueCommand('volume', 'volume', '0.2', 15.0); // At 15 seconds
|
|
358
|
+
* ```
|
|
359
|
+
*
|
|
360
|
+
* @example
|
|
361
|
+
* ```typescript
|
|
362
|
+
* // Fade effect at specific timestamp
|
|
363
|
+
* filter.queueCommand('fade', 'alpha', '0.5', 30.0);
|
|
364
|
+
* ```
|
|
365
|
+
*/
|
|
366
|
+
queueCommand(target: string, cmd: string, arg: string, ts: number, flags?: AVFilterCmdFlag): void;
|
|
367
|
+
/**
|
|
368
|
+
* Dispose of the filter.
|
|
369
|
+
*
|
|
370
|
+
* Implements the Disposable interface for automatic cleanup.
|
|
371
|
+
* Equivalent to calling free().
|
|
372
|
+
*
|
|
373
|
+
* @example
|
|
374
|
+
* ```typescript
|
|
375
|
+
* {
|
|
376
|
+
* using filter = await Filter.create('scale=1280:720', config);
|
|
377
|
+
* // ... use filter
|
|
378
|
+
* } // Automatically freed when leaving scope
|
|
379
|
+
* ```
|
|
380
|
+
*/
|
|
381
|
+
[Symbol.dispose](): void;
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Common filter presets for convenience.
|
|
385
|
+
*
|
|
386
|
+
* Provides pre-defined filter strings for common operations.
|
|
387
|
+
* Can be used with Filter.create() for quick setup.
|
|
388
|
+
*
|
|
389
|
+
* @example
|
|
390
|
+
* ```typescript
|
|
391
|
+
* const filter = await Filter.create(
|
|
392
|
+
* FilterPresets.scale(1280, 720),
|
|
393
|
+
* config
|
|
394
|
+
* );
|
|
395
|
+
* ```
|
|
396
|
+
*/
|
|
397
|
+
export declare class FilterPresets {
|
|
398
|
+
/**
|
|
399
|
+
* Scale video to specified dimensions.
|
|
400
|
+
*/
|
|
401
|
+
static scale(width: number, height: number, flags?: string): string;
|
|
402
|
+
/**
|
|
403
|
+
* Crop video to specified dimensions.
|
|
404
|
+
*/
|
|
405
|
+
static crop(width: number, height: number, x?: number, y?: number): string;
|
|
406
|
+
/**
|
|
407
|
+
* Change frame rate.
|
|
408
|
+
*/
|
|
409
|
+
static fps(fps: number): string;
|
|
410
|
+
/**
|
|
411
|
+
* Convert pixel format.
|
|
412
|
+
* Can accept either format name string or AVPixelFormat enum.
|
|
413
|
+
*/
|
|
414
|
+
static format(pixelFormat: string | AVPixelFormat): string;
|
|
415
|
+
/**
|
|
416
|
+
* Rotate video by angle.
|
|
417
|
+
*/
|
|
418
|
+
static rotate(angle: number): string;
|
|
419
|
+
/**
|
|
420
|
+
* Flip video horizontally.
|
|
421
|
+
*/
|
|
422
|
+
static hflip(): string;
|
|
423
|
+
/**
|
|
424
|
+
* Flip video vertically.
|
|
425
|
+
*/
|
|
426
|
+
static vflip(): string;
|
|
427
|
+
/**
|
|
428
|
+
* Apply fade effect.
|
|
429
|
+
*/
|
|
430
|
+
static fade(type: 'in' | 'out', start: number, duration: number): string;
|
|
431
|
+
/**
|
|
432
|
+
* Overlay one video on another.
|
|
433
|
+
*/
|
|
434
|
+
static overlay(x?: number, y?: number): string;
|
|
435
|
+
/**
|
|
436
|
+
* Adjust audio volume.
|
|
437
|
+
*/
|
|
438
|
+
static volume(factor: number): string;
|
|
439
|
+
/**
|
|
440
|
+
* Convert audio sample format.
|
|
441
|
+
* Can accept either format name string or AVSampleFormat enum.
|
|
442
|
+
*/
|
|
443
|
+
static aformat(sampleFormat: string | AVSampleFormat, sampleRate?: number, channelLayout?: string): string;
|
|
444
|
+
/**
|
|
445
|
+
* Change audio tempo without changing pitch.
|
|
446
|
+
*/
|
|
447
|
+
static atempo(factor: number): string;
|
|
448
|
+
/**
|
|
449
|
+
* Apply audio fade.
|
|
450
|
+
*/
|
|
451
|
+
static afade(type: 'in' | 'out', start: number, duration: number): string;
|
|
452
|
+
/**
|
|
453
|
+
* Mix multiple audio streams.
|
|
454
|
+
*/
|
|
455
|
+
static amix(inputs?: number, duration?: 'first' | 'longest' | 'shortest'): string;
|
|
456
|
+
}
|
|
457
|
+
export {};
|