node-av 1.1.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -59
- package/dist/api/bitstream-filter.d.ts +183 -123
- package/dist/api/bitstream-filter.js +185 -127
- package/dist/api/bitstream-filter.js.map +1 -1
- package/dist/api/decoder.d.ts +282 -130
- package/dist/api/decoder.js +290 -142
- package/dist/api/decoder.js.map +1 -1
- package/dist/api/encoder.d.ts +249 -160
- package/dist/api/encoder.js +276 -207
- package/dist/api/encoder.js.map +1 -1
- package/dist/api/filter-presets.d.ts +1944 -96
- package/dist/api/filter-presets.js +2059 -105
- package/dist/api/filter-presets.js.map +1 -1
- package/dist/api/filter.d.ts +264 -200
- package/dist/api/filter.js +269 -231
- package/dist/api/filter.js.map +1 -1
- package/dist/api/hardware.d.ts +246 -117
- package/dist/api/hardware.js +440 -217
- package/dist/api/hardware.js.map +1 -1
- package/dist/api/index.d.ts +3 -3
- package/dist/api/index.js +1 -1
- package/dist/api/index.js.map +1 -1
- package/dist/api/io-stream.d.ts +65 -55
- package/dist/api/io-stream.js +43 -40
- package/dist/api/io-stream.js.map +1 -1
- package/dist/api/media-input.d.ts +242 -139
- package/dist/api/media-input.js +205 -103
- package/dist/api/media-input.js.map +1 -1
- package/dist/api/media-output.d.ts +208 -126
- package/dist/api/media-output.js +212 -126
- package/dist/api/media-output.js.map +1 -1
- package/dist/api/pipeline.d.ts +361 -38
- package/dist/api/pipeline.js +255 -14
- package/dist/api/pipeline.js.map +1 -1
- package/dist/api/types.d.ts +26 -187
- package/dist/api/utilities/audio-sample.d.ts +0 -8
- package/dist/api/utilities/audio-sample.js +0 -8
- package/dist/api/utilities/audio-sample.js.map +1 -1
- package/dist/api/utilities/channel-layout.d.ts +0 -8
- package/dist/api/utilities/channel-layout.js +0 -8
- package/dist/api/utilities/channel-layout.js.map +1 -1
- package/dist/api/utilities/image.d.ts +0 -8
- package/dist/api/utilities/image.js +0 -8
- package/dist/api/utilities/image.js.map +1 -1
- package/dist/api/utilities/index.d.ts +3 -3
- package/dist/api/utilities/index.js +3 -3
- package/dist/api/utilities/index.js.map +1 -1
- package/dist/api/utilities/media-type.d.ts +1 -9
- package/dist/api/utilities/media-type.js +1 -9
- package/dist/api/utilities/media-type.js.map +1 -1
- package/dist/api/utilities/pixel-format.d.ts +1 -9
- package/dist/api/utilities/pixel-format.js +1 -9
- package/dist/api/utilities/pixel-format.js.map +1 -1
- package/dist/api/utilities/sample-format.d.ts +1 -9
- package/dist/api/utilities/sample-format.js +1 -9
- package/dist/api/utilities/sample-format.js.map +1 -1
- package/dist/api/utilities/streaming.d.ts +0 -8
- package/dist/api/utilities/streaming.js +0 -8
- package/dist/api/utilities/streaming.js.map +1 -1
- package/dist/api/utilities/timestamp.d.ts +0 -8
- package/dist/api/utilities/timestamp.js +0 -8
- package/dist/api/utilities/timestamp.js.map +1 -1
- package/dist/api/utils.d.ts +1 -2
- package/dist/api/utils.js +11 -0
- package/dist/api/utils.js.map +1 -1
- package/dist/constants/constants.d.ts +1 -1
- package/dist/constants/constants.js +2 -0
- package/dist/constants/constants.js.map +1 -1
- package/dist/lib/audio-fifo.d.ts +127 -170
- package/dist/lib/audio-fifo.js +130 -173
- package/dist/lib/audio-fifo.js.map +1 -1
- package/dist/lib/binding.d.ts +1 -0
- package/dist/lib/binding.js +7 -0
- package/dist/lib/binding.js.map +1 -1
- package/dist/lib/bitstream-filter-context.d.ts +139 -184
- package/dist/lib/bitstream-filter-context.js +139 -188
- package/dist/lib/bitstream-filter-context.js.map +1 -1
- package/dist/lib/bitstream-filter.d.ts +68 -54
- package/dist/lib/bitstream-filter.js +68 -54
- package/dist/lib/bitstream-filter.js.map +1 -1
- package/dist/lib/codec-context.d.ts +316 -380
- package/dist/lib/codec-context.js +316 -381
- package/dist/lib/codec-context.js.map +1 -1
- package/dist/lib/codec-parameters.d.ts +160 -170
- package/dist/lib/codec-parameters.js +162 -172
- package/dist/lib/codec-parameters.js.map +1 -1
- package/dist/lib/codec-parser.d.ts +91 -104
- package/dist/lib/codec-parser.js +92 -103
- package/dist/lib/codec-parser.js.map +1 -1
- package/dist/lib/codec.d.ts +266 -283
- package/dist/lib/codec.js +270 -287
- package/dist/lib/codec.js.map +1 -1
- package/dist/lib/dictionary.d.ts +149 -203
- package/dist/lib/dictionary.js +158 -212
- package/dist/lib/dictionary.js.map +1 -1
- package/dist/lib/error.d.ts +96 -130
- package/dist/lib/error.js +98 -128
- package/dist/lib/error.js.map +1 -1
- package/dist/lib/filter-context.d.ts +284 -218
- package/dist/lib/filter-context.js +290 -227
- package/dist/lib/filter-context.js.map +1 -1
- package/dist/lib/filter-graph.d.ts +251 -292
- package/dist/lib/filter-graph.js +253 -294
- package/dist/lib/filter-graph.js.map +1 -1
- package/dist/lib/filter-inout.d.ts +87 -95
- package/dist/lib/filter-inout.js +87 -95
- package/dist/lib/filter-inout.js.map +1 -1
- package/dist/lib/filter.d.ts +93 -111
- package/dist/lib/filter.js +93 -111
- package/dist/lib/filter.js.map +1 -1
- package/dist/lib/format-context.d.ts +320 -428
- package/dist/lib/format-context.js +313 -385
- package/dist/lib/format-context.js.map +1 -1
- package/dist/lib/frame.d.ts +262 -405
- package/dist/lib/frame.js +263 -408
- package/dist/lib/frame.js.map +1 -1
- package/dist/lib/hardware-device-context.d.ts +149 -203
- package/dist/lib/hardware-device-context.js +149 -203
- package/dist/lib/hardware-device-context.js.map +1 -1
- package/dist/lib/hardware-frames-context.d.ts +170 -180
- package/dist/lib/hardware-frames-context.js +171 -181
- package/dist/lib/hardware-frames-context.js.map +1 -1
- package/dist/lib/index.d.ts +3 -2
- package/dist/lib/index.js +3 -3
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/input-format.d.ts +89 -117
- package/dist/lib/input-format.js +89 -117
- package/dist/lib/input-format.js.map +1 -1
- package/dist/lib/io-context.d.ts +209 -241
- package/dist/lib/io-context.js +220 -252
- package/dist/lib/io-context.js.map +1 -1
- package/dist/lib/log.d.ts +85 -119
- package/dist/lib/log.js +85 -122
- package/dist/lib/log.js.map +1 -1
- package/dist/lib/native-types.d.ts +118 -106
- package/dist/lib/native-types.js +0 -7
- package/dist/lib/native-types.js.map +1 -1
- package/dist/lib/option.d.ts +437 -218
- package/dist/lib/option.js +462 -226
- package/dist/lib/option.js.map +1 -1
- package/dist/lib/output-format.d.ts +77 -101
- package/dist/lib/output-format.js +77 -101
- package/dist/lib/output-format.js.map +1 -1
- package/dist/lib/packet.d.ts +172 -240
- package/dist/lib/packet.js +172 -241
- package/dist/lib/packet.js.map +1 -1
- package/dist/lib/rational.d.ts +0 -2
- package/dist/lib/rational.js +0 -2
- package/dist/lib/rational.js.map +1 -1
- package/dist/lib/software-resample-context.d.ts +241 -325
- package/dist/lib/software-resample-context.js +242 -326
- package/dist/lib/software-resample-context.js.map +1 -1
- package/dist/lib/software-scale-context.d.ts +129 -173
- package/dist/lib/software-scale-context.js +131 -175
- package/dist/lib/software-scale-context.js.map +1 -1
- package/dist/lib/stream.d.ts +87 -197
- package/dist/lib/stream.js +87 -197
- package/dist/lib/stream.js.map +1 -1
- package/dist/lib/utilities.d.ts +435 -181
- package/dist/lib/utilities.js +438 -182
- package/dist/lib/utilities.js.map +1 -1
- package/install/check.js +0 -1
- package/install/ffmpeg.js +0 -11
- package/package.json +25 -18
- package/release_notes.md +24 -59
- package/CHANGELOG.md +0 -8
package/dist/api/filter.d.ts
CHANGED
|
@@ -1,68 +1,43 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Filter - High-level wrapper for media filtering
|
|
3
|
-
*
|
|
4
|
-
* Implements FFmpeg CLI's filter graph behavior with proper hardware context handling.
|
|
5
|
-
* Uses lazy initialization for hardware inputs: graph is built when first frame arrives
|
|
6
|
-
* with hw_frames_ctx. For software inputs, initializes immediately.
|
|
7
|
-
*
|
|
8
|
-
* Handles filter graph creation, frame processing, and format conversion.
|
|
9
|
-
* Supports complex filter chains and hardware-accelerated filters.
|
|
10
|
-
*
|
|
11
|
-
* @module api/filter
|
|
12
|
-
*/
|
|
13
1
|
import { Frame } from '../lib/index.js';
|
|
14
2
|
import type { AVFilterCmdFlag, AVMediaType } from '../constants/constants.js';
|
|
15
3
|
import type { FilterOptions, StreamInfo } from './types.js';
|
|
16
4
|
/**
|
|
17
|
-
* High-level filter API for
|
|
18
|
-
*
|
|
19
|
-
* Provides a simplified interface for FFmpeg's filter system.
|
|
20
|
-
* Supports both simple filter chains and complex filter graphs.
|
|
21
|
-
* Handles automatic format negotiation and buffer management.
|
|
5
|
+
* High-level filter API for audio and video processing.
|
|
22
6
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
7
|
+
* Provides simplified interface for applying FFmpeg filters to frames.
|
|
8
|
+
* Handles filter graph construction, frame buffering, and command control.
|
|
9
|
+
* Supports both software and hardware-accelerated filtering operations.
|
|
10
|
+
* Essential component for effects, transformations, and format conversions.
|
|
26
11
|
*
|
|
27
12
|
* @example
|
|
28
13
|
* ```typescript
|
|
29
|
-
* import { FilterAPI
|
|
14
|
+
* import { FilterAPI } from 'node-av/api';
|
|
30
15
|
*
|
|
31
|
-
* //
|
|
32
|
-
* const
|
|
33
|
-
* const filter = await FilterAPI.create('scale=1280:720,format=yuv420p', videoStream);
|
|
16
|
+
* // Create video filter
|
|
17
|
+
* const filter = await FilterAPI.create('scale=1280:720', videoInfo);
|
|
34
18
|
*
|
|
35
|
-
* // Process
|
|
36
|
-
* const
|
|
19
|
+
* // Process frame
|
|
20
|
+
* const output = await filter.process(inputFrame);
|
|
21
|
+
* if (output) {
|
|
22
|
+
* console.log(`Filtered frame: ${output.width}x${output.height}`);
|
|
23
|
+
* output.free();
|
|
24
|
+
* }
|
|
37
25
|
* ```
|
|
38
26
|
*
|
|
39
27
|
* @example
|
|
40
28
|
* ```typescript
|
|
41
|
-
* // Hardware
|
|
42
|
-
* const hw =
|
|
43
|
-
* const
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* }
|
|
29
|
+
* // Hardware-accelerated filtering
|
|
30
|
+
* const hw = HardwareContext.auto();
|
|
31
|
+
* const filter = await FilterAPI.create(
|
|
32
|
+
* 'hwupload,scale_cuda=1920:1080,hwdownload',
|
|
33
|
+
* videoInfo,
|
|
34
|
+
* { hardware: hw }
|
|
35
|
+
* );
|
|
47
36
|
* ```
|
|
48
37
|
*
|
|
49
|
-
* @
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* const decoder = await Decoder.create(stream);
|
|
53
|
-
* const hw = await HardwareContext.auto();
|
|
54
|
-
* const filter = await FilterAPI.create('format=nv12,hwupload', decoder.getOutputStreamInfo(), {
|
|
55
|
-
* hardware: hw // Required for hwupload to create hw_frames_ctx
|
|
56
|
-
* });
|
|
57
|
-
* ```
|
|
58
|
-
*
|
|
59
|
-
* @example
|
|
60
|
-
* ```typescript
|
|
61
|
-
* // Hardware decode -> software encode pipeline with hwdownload
|
|
62
|
-
* const hw = await HardwareContext.auto();
|
|
63
|
-
* const decoder = await Decoder.create(stream, { hardware: hw });
|
|
64
|
-
* const filter = await FilterAPI.create('hwdownload,format=yuv420p', decoder.getOutputStreamInfo());
|
|
65
|
-
* ```
|
|
38
|
+
* @see {@link FilterGraph} For low-level filter graph API
|
|
39
|
+
* @see {@link HardwareContext} For hardware acceleration
|
|
40
|
+
* @see {@link Frame} For frame operations
|
|
66
41
|
*/
|
|
67
42
|
export declare class FilterAPI implements Disposable {
|
|
68
43
|
private graph;
|
|
@@ -75,135 +50,162 @@ export declare class FilterAPI implements Disposable {
|
|
|
75
50
|
private description;
|
|
76
51
|
private options;
|
|
77
52
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* @param
|
|
81
|
-
* @param description - Filter graph description
|
|
82
|
-
* @param options - Filter options including hardware context
|
|
53
|
+
* @param config - Stream configuration
|
|
54
|
+
* @param description - Filter description string
|
|
55
|
+
* @param options - Filter options
|
|
83
56
|
* @internal
|
|
84
57
|
*/
|
|
85
58
|
private constructor();
|
|
86
59
|
/**
|
|
87
|
-
* Create a filter
|
|
88
|
-
*
|
|
89
|
-
* Accepts either a Stream (from MediaInput/Decoder) or StreamInfo (for raw data).
|
|
90
|
-
* Automatically sets up buffer source and sink filters.
|
|
60
|
+
* Create a filter with specified description and configuration.
|
|
91
61
|
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
* For
|
|
62
|
+
* Constructs filter graph from description string.
|
|
63
|
+
* Configures input/output buffers and threading.
|
|
64
|
+
* For video filters, uses lazy initialization to detect hardware frames.
|
|
95
65
|
*
|
|
96
|
-
*
|
|
97
|
-
* - hwupload: Requires hardware context, creates its own hw_frames_ctx
|
|
98
|
-
* - hwdownload: Uses hw_frames_ctx propagated from previous filters
|
|
99
|
-
* - Other HW filters: Use propagated hw_frames_ctx or hwupload's output
|
|
66
|
+
* Direct mapping to avfilter_graph_parse_ptr() and avfilter_graph_config().
|
|
100
67
|
*
|
|
101
|
-
* @param description - Filter graph description
|
|
102
|
-
* @param input -
|
|
103
|
-
* @param options -
|
|
68
|
+
* @param description - Filter graph description
|
|
69
|
+
* @param input - Input stream configuration
|
|
70
|
+
* @param options - Filter options
|
|
71
|
+
* @returns Configured filter instance
|
|
104
72
|
*
|
|
105
|
-
* @
|
|
73
|
+
* @throws {Error} If filter creation or configuration fails
|
|
106
74
|
*
|
|
107
|
-
* @throws {FFmpegError} If
|
|
108
|
-
* @throws {Error} If hardware filter requires hardware context but none provided
|
|
75
|
+
* @throws {FFmpegError} If graph parsing or config fails
|
|
109
76
|
*
|
|
110
77
|
* @example
|
|
111
78
|
* ```typescript
|
|
112
|
-
* // Simple filter
|
|
113
|
-
* const filter = await FilterAPI.create('scale=640:480',
|
|
79
|
+
* // Simple video filter
|
|
80
|
+
* const filter = await FilterAPI.create('scale=640:480', videoInfo);
|
|
81
|
+
* ```
|
|
114
82
|
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* // Complex filter chain
|
|
118
86
|
* const filter = await FilterAPI.create(
|
|
119
|
-
* '
|
|
120
|
-
*
|
|
121
|
-
* { hardware: hw }
|
|
87
|
+
* 'crop=640:480:0:0,rotate=PI/4',
|
|
88
|
+
* videoInfo
|
|
122
89
|
* );
|
|
90
|
+
* ```
|
|
123
91
|
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
* });
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* // Audio filter
|
|
95
|
+
* const filter = await FilterAPI.create(
|
|
96
|
+
* 'volume=0.5,aecho=0.8:0.9:1000:0.3',
|
|
97
|
+
* audioInfo
|
|
98
|
+
* );
|
|
132
99
|
* ```
|
|
100
|
+
*
|
|
101
|
+
* @see {@link process} For frame processing
|
|
102
|
+
* @see {@link FilterOptions} For configuration options
|
|
133
103
|
*/
|
|
134
104
|
static create(description: string, input: StreamInfo, options?: FilterOptions): Promise<FilterAPI>;
|
|
135
105
|
/**
|
|
136
|
-
* Process a
|
|
106
|
+
* Process a frame through the filter.
|
|
137
107
|
*
|
|
138
|
-
*
|
|
139
|
-
* May
|
|
108
|
+
* Applies filter operations to input frame.
|
|
109
|
+
* May buffer frames internally before producing output.
|
|
110
|
+
* For video, performs lazy initialization on first frame.
|
|
140
111
|
*
|
|
141
|
-
*
|
|
142
|
-
* Subsequent frames are processed normally. FFmpeg automatically propagates
|
|
143
|
-
* hw_frames_ctx through the filter chain.
|
|
112
|
+
* Direct mapping to av_buffersrc_add_frame() and av_buffersink_get_frame().
|
|
144
113
|
*
|
|
145
|
-
* @param frame - Input frame to
|
|
114
|
+
* @param frame - Input frame to process
|
|
115
|
+
* @returns Filtered frame or null if buffered
|
|
146
116
|
*
|
|
147
|
-
* @
|
|
117
|
+
* @throws {Error} If filter not ready
|
|
148
118
|
*
|
|
149
119
|
* @throws {FFmpegError} If processing fails
|
|
150
|
-
* @throws {Error} If filter not initialized or hardware frame required but not provided
|
|
151
120
|
*
|
|
152
121
|
* @example
|
|
153
122
|
* ```typescript
|
|
154
|
-
* const
|
|
155
|
-
* if (
|
|
156
|
-
*
|
|
123
|
+
* const output = await filter.process(inputFrame);
|
|
124
|
+
* if (output) {
|
|
125
|
+
* console.log(`Got filtered frame: pts=${output.pts}`);
|
|
126
|
+
* output.free();
|
|
127
|
+
* }
|
|
128
|
+
* ```
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```typescript
|
|
132
|
+
* // Process and drain
|
|
133
|
+
* const output = await filter.process(frame);
|
|
134
|
+
* if (output) yield output;
|
|
135
|
+
*
|
|
136
|
+
* // Drain buffered frames
|
|
137
|
+
* let buffered;
|
|
138
|
+
* while ((buffered = await filter.receive()) !== null) {
|
|
139
|
+
* yield buffered;
|
|
157
140
|
* }
|
|
158
141
|
* ```
|
|
142
|
+
*
|
|
143
|
+
* @see {@link receive} For draining buffered frames
|
|
144
|
+
* @see {@link frames} For stream processing
|
|
159
145
|
*/
|
|
160
146
|
process(frame: Frame): Promise<Frame | null>;
|
|
161
147
|
/**
|
|
162
|
-
* Process multiple frames
|
|
148
|
+
* Process multiple frames at once.
|
|
163
149
|
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
150
|
+
* Processes batch of frames and drains all output.
|
|
151
|
+
* Useful for filters that buffer multiple frames.
|
|
166
152
|
*
|
|
167
153
|
* @param frames - Array of input frames
|
|
154
|
+
* @returns Array of all output frames
|
|
168
155
|
*
|
|
169
|
-
* @
|
|
156
|
+
* @throws {Error} If filter not ready
|
|
170
157
|
*
|
|
171
158
|
* @throws {FFmpegError} If processing fails
|
|
172
159
|
*
|
|
173
160
|
* @example
|
|
174
161
|
* ```typescript
|
|
175
|
-
* const
|
|
162
|
+
* const outputs = await filter.processMultiple([frame1, frame2, frame3]);
|
|
163
|
+
* for (const output of outputs) {
|
|
164
|
+
* console.log(`Output frame: pts=${output.pts}`);
|
|
165
|
+
* output.free();
|
|
166
|
+
* }
|
|
176
167
|
* ```
|
|
168
|
+
*
|
|
169
|
+
* @see {@link process} For single frame processing
|
|
177
170
|
*/
|
|
178
171
|
processMultiple(frames: Frame[]): Promise<Frame[]>;
|
|
179
172
|
/**
|
|
180
|
-
* Receive
|
|
173
|
+
* Receive buffered frame from filter.
|
|
174
|
+
*
|
|
175
|
+
* Drains frames buffered by the filter.
|
|
176
|
+
* Call repeatedly until null to get all buffered frames.
|
|
177
|
+
*
|
|
178
|
+
* Direct mapping to av_buffersink_get_frame().
|
|
181
179
|
*
|
|
182
|
-
*
|
|
183
|
-
* Returns null when no more frames are available.
|
|
180
|
+
* @returns Buffered frame or null if none available
|
|
184
181
|
*
|
|
185
|
-
* @
|
|
182
|
+
* @throws {Error} If filter not ready
|
|
186
183
|
*
|
|
187
|
-
* @throws {FFmpegError} If
|
|
184
|
+
* @throws {FFmpegError} If receive fails
|
|
188
185
|
*
|
|
189
186
|
* @example
|
|
190
187
|
* ```typescript
|
|
191
|
-
* // Drain
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
*
|
|
188
|
+
* // Drain buffered frames
|
|
189
|
+
* let frame;
|
|
190
|
+
* while ((frame = await filter.receive()) !== null) {
|
|
191
|
+
* console.log(`Buffered frame: pts=${frame.pts}`);
|
|
192
|
+
* frame.free();
|
|
196
193
|
* }
|
|
197
194
|
* ```
|
|
195
|
+
*
|
|
196
|
+
* @see {@link process} For input processing
|
|
197
|
+
* @see {@link flush} For end-of-stream
|
|
198
198
|
*/
|
|
199
199
|
receive(): Promise<Frame | null>;
|
|
200
200
|
/**
|
|
201
|
-
* Flush
|
|
201
|
+
* Flush filter and signal end-of-stream.
|
|
202
|
+
*
|
|
203
|
+
* Sends null frame to flush buffered data.
|
|
204
|
+
* Must call receive() to get flushed frames.
|
|
202
205
|
*
|
|
203
|
-
*
|
|
204
|
-
* Use receive() to get any remaining frames.
|
|
206
|
+
* Direct mapping to av_buffersrc_add_frame(NULL).
|
|
205
207
|
*
|
|
206
|
-
* @
|
|
208
|
+
* @throws {Error} If filter not ready
|
|
207
209
|
*
|
|
208
210
|
* @throws {FFmpegError} If flush fails
|
|
209
211
|
*
|
|
@@ -211,155 +213,199 @@ export declare class FilterAPI implements Disposable {
|
|
|
211
213
|
* ```typescript
|
|
212
214
|
* await filter.flush();
|
|
213
215
|
* // Get remaining frames
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
* // Process final frames
|
|
216
|
+
* let frame;
|
|
217
|
+
* while ((frame = await filter.receive()) !== null) {
|
|
218
|
+
* frame.free();
|
|
218
219
|
* }
|
|
219
220
|
* ```
|
|
221
|
+
*
|
|
222
|
+
* @see {@link flushFrames} For async iteration
|
|
223
|
+
* @see {@link receive} For draining frames
|
|
220
224
|
*/
|
|
221
225
|
flush(): Promise<void>;
|
|
222
226
|
/**
|
|
223
|
-
* Flush filter and yield
|
|
227
|
+
* Flush filter and yield remaining frames.
|
|
224
228
|
*
|
|
225
|
-
*
|
|
226
|
-
*
|
|
229
|
+
* Convenient async generator for flushing.
|
|
230
|
+
* Combines flush and receive operations.
|
|
227
231
|
*
|
|
228
|
-
* @
|
|
232
|
+
* @yields Remaining frames from filter
|
|
233
|
+
* @throws {Error} If filter not ready
|
|
229
234
|
*
|
|
230
|
-
* @throws {
|
|
235
|
+
* @throws {FFmpegError} If flush fails
|
|
231
236
|
*
|
|
232
237
|
* @example
|
|
233
238
|
* ```typescript
|
|
234
|
-
* // Process all remaining frames with generator
|
|
235
239
|
* for await (const frame of filter.flushFrames()) {
|
|
236
|
-
*
|
|
237
|
-
*
|
|
240
|
+
* console.log(`Flushed frame: pts=${frame.pts}`);
|
|
241
|
+
* frame.free();
|
|
238
242
|
* }
|
|
239
243
|
* ```
|
|
244
|
+
*
|
|
245
|
+
* @see {@link flush} For manual flush
|
|
246
|
+
* @see {@link frames} For complete pipeline
|
|
240
247
|
*/
|
|
241
248
|
flushFrames(): AsyncGenerator<Frame>;
|
|
242
249
|
/**
|
|
243
|
-
* Process
|
|
250
|
+
* Process frame stream through filter.
|
|
244
251
|
*
|
|
245
|
-
*
|
|
246
|
-
* Automatically handles buffering and
|
|
247
|
-
*
|
|
252
|
+
* High-level async generator for filtering frame streams.
|
|
253
|
+
* Automatically handles buffering and flushing.
|
|
254
|
+
* Frees input frames after processing.
|
|
248
255
|
*
|
|
249
|
-
*
|
|
250
|
-
*
|
|
256
|
+
* @param frames - Async generator of input frames
|
|
257
|
+
* @yields Filtered frames
|
|
258
|
+
* @throws {Error} If filter not ready
|
|
251
259
|
*
|
|
252
|
-
* @
|
|
260
|
+
* @throws {FFmpegError} If processing fails
|
|
253
261
|
*
|
|
254
|
-
* @
|
|
262
|
+
* @example
|
|
263
|
+
* ```typescript
|
|
264
|
+
* // Filter decoded frames
|
|
265
|
+
* for await (const frame of filter.frames(decoder.frames(packets))) {
|
|
266
|
+
* await encoder.encode(frame);
|
|
267
|
+
* frame.free();
|
|
268
|
+
* }
|
|
269
|
+
* ```
|
|
255
270
|
*
|
|
256
271
|
* @example
|
|
257
272
|
* ```typescript
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
273
|
+
* // Chain filters
|
|
274
|
+
* const filter1 = await FilterAPI.create('scale=640:480', info);
|
|
275
|
+
* const filter2 = await FilterAPI.create('rotate=PI/4', info);
|
|
276
|
+
*
|
|
277
|
+
* for await (const frame of filter2.frames(filter1.frames(input))) {
|
|
278
|
+
* // Process filtered frames
|
|
279
|
+
* frame.free();
|
|
261
280
|
* }
|
|
262
281
|
* ```
|
|
282
|
+
*
|
|
283
|
+
* @see {@link process} For single frame processing
|
|
284
|
+
* @see {@link flush} For end-of-stream handling
|
|
263
285
|
*/
|
|
264
286
|
frames(frames: AsyncGenerator<Frame>): AsyncGenerator<Frame>;
|
|
265
287
|
/**
|
|
266
|
-
* Send
|
|
288
|
+
* Send command to filter.
|
|
289
|
+
*
|
|
290
|
+
* Sends runtime command to specific filter in graph.
|
|
291
|
+
* Allows dynamic parameter adjustment.
|
|
267
292
|
*
|
|
268
|
-
*
|
|
269
|
-
* Not all filters support commands - check filter documentation.
|
|
293
|
+
* Direct mapping to avfilter_graph_send_command().
|
|
270
294
|
*
|
|
271
|
-
* @param target -
|
|
272
|
-
* @param cmd - Command name
|
|
273
|
-
* @param arg - Command argument
|
|
274
|
-
* @param flags -
|
|
295
|
+
* @param target - Target filter name
|
|
296
|
+
* @param cmd - Command name
|
|
297
|
+
* @param arg - Command argument
|
|
298
|
+
* @param flags - Command flags
|
|
299
|
+
* @returns Response string from filter
|
|
275
300
|
*
|
|
276
|
-
* @
|
|
301
|
+
* @throws {Error} If filter not ready
|
|
302
|
+
*
|
|
303
|
+
* @throws {FFmpegError} If command fails
|
|
277
304
|
*
|
|
278
305
|
* @example
|
|
279
306
|
* ```typescript
|
|
280
|
-
* // Change volume
|
|
307
|
+
* // Change volume at runtime
|
|
281
308
|
* const response = filter.sendCommand('volume', 'volume', '0.5');
|
|
282
|
-
*
|
|
283
|
-
* console.log('Volume changed successfully');
|
|
284
|
-
* }
|
|
309
|
+
* console.log(`Volume changed: ${response}`);
|
|
285
310
|
* ```
|
|
286
311
|
*
|
|
287
|
-
* @
|
|
288
|
-
* ```typescript
|
|
289
|
-
* // Enable/disable all filters at runtime
|
|
290
|
-
* filter.sendCommand('all', 'enable', 'expr=gte(t,10)');
|
|
291
|
-
* ```
|
|
312
|
+
* @see {@link queueCommand} For delayed commands
|
|
292
313
|
*/
|
|
293
314
|
sendCommand(target: string, cmd: string, arg: string, flags?: AVFilterCmdFlag): string;
|
|
294
315
|
/**
|
|
295
|
-
* Queue
|
|
316
|
+
* Queue command for later execution.
|
|
317
|
+
*
|
|
318
|
+
* Schedules command to execute at specific timestamp.
|
|
319
|
+
* Useful for synchronized parameter changes.
|
|
320
|
+
*
|
|
321
|
+
* Direct mapping to avfilter_graph_queue_command().
|
|
296
322
|
*
|
|
297
|
-
*
|
|
298
|
-
*
|
|
323
|
+
* @param target - Target filter name
|
|
324
|
+
* @param cmd - Command name
|
|
325
|
+
* @param arg - Command argument
|
|
326
|
+
* @param ts - Timestamp for execution
|
|
327
|
+
* @param flags - Command flags
|
|
328
|
+
* @throws {Error} If filter not ready
|
|
299
329
|
*
|
|
300
|
-
* @
|
|
301
|
-
* @param cmd - Command name (e.g., "volume", "hue", "brightness")
|
|
302
|
-
* @param arg - Command argument value
|
|
303
|
-
* @param ts - Timestamp when command should execute (in seconds)
|
|
304
|
-
* @param flags - Optional command flags
|
|
330
|
+
* @throws {FFmpegError} If queue fails
|
|
305
331
|
*
|
|
306
332
|
* @example
|
|
307
333
|
* ```typescript
|
|
308
|
-
* //
|
|
309
|
-
* filter.queueCommand('volume', 'volume', '0.
|
|
310
|
-
* filter.queueCommand('volume', 'volume', '0.8', 10.0); // At 10 seconds
|
|
311
|
-
* filter.queueCommand('volume', 'volume', '0.2', 15.0); // At 15 seconds
|
|
334
|
+
* // Queue volume change at 10 seconds
|
|
335
|
+
* filter.queueCommand('volume', 'volume', '0.8', 10.0);
|
|
312
336
|
* ```
|
|
337
|
+
*
|
|
338
|
+
* @see {@link sendCommand} For immediate commands
|
|
313
339
|
*/
|
|
314
340
|
queueCommand(target: string, cmd: string, arg: string, ts: number, flags?: AVFilterCmdFlag): void;
|
|
315
341
|
/**
|
|
316
|
-
* Get
|
|
342
|
+
* Get filter graph description.
|
|
343
|
+
*
|
|
344
|
+
* Returns human-readable graph structure.
|
|
345
|
+
* Useful for debugging filter chains.
|
|
317
346
|
*
|
|
318
|
-
*
|
|
319
|
-
* Useful for debugging and visualization.
|
|
347
|
+
* Direct mapping to avfilter_graph_dump().
|
|
320
348
|
*
|
|
321
349
|
* @returns Graph description or null if not initialized
|
|
322
350
|
*
|
|
323
351
|
* @example
|
|
324
352
|
* ```typescript
|
|
325
353
|
* const description = filter.getGraphDescription();
|
|
326
|
-
* console.log(description);
|
|
354
|
+
* console.log('Filter graph:', description);
|
|
327
355
|
* ```
|
|
328
356
|
*/
|
|
329
357
|
getGraphDescription(): string | null;
|
|
330
358
|
/**
|
|
331
|
-
* Check if
|
|
359
|
+
* Check if filter is ready for processing.
|
|
360
|
+
*
|
|
361
|
+
* @returns true if initialized and ready
|
|
332
362
|
*
|
|
333
|
-
* @
|
|
363
|
+
* @example
|
|
364
|
+
* ```typescript
|
|
365
|
+
* if (filter.isReady()) {
|
|
366
|
+
* const output = await filter.process(frame);
|
|
367
|
+
* }
|
|
368
|
+
* ```
|
|
334
369
|
*/
|
|
335
370
|
isReady(): boolean;
|
|
336
371
|
/**
|
|
337
|
-
* Get
|
|
372
|
+
* Get media type of filter.
|
|
373
|
+
*
|
|
374
|
+
* @returns AVMEDIA_TYPE_VIDEO or AVMEDIA_TYPE_AUDIO
|
|
338
375
|
*
|
|
339
|
-
* @
|
|
376
|
+
* @example
|
|
377
|
+
* ```typescript
|
|
378
|
+
* if (filter.getMediaType() === AVMEDIA_TYPE_VIDEO) {
|
|
379
|
+
* console.log('Video filter');
|
|
380
|
+
* }
|
|
381
|
+
* ```
|
|
340
382
|
*/
|
|
341
383
|
getMediaType(): AVMediaType;
|
|
342
384
|
/**
|
|
343
|
-
* Free
|
|
385
|
+
* Free filter resources.
|
|
344
386
|
*
|
|
345
|
-
* Releases
|
|
346
|
-
*
|
|
387
|
+
* Releases filter graph and contexts.
|
|
388
|
+
* Safe to call multiple times.
|
|
347
389
|
*
|
|
348
390
|
* @example
|
|
349
391
|
* ```typescript
|
|
350
392
|
* filter.free();
|
|
351
|
-
* // filter is now invalid
|
|
352
393
|
* ```
|
|
394
|
+
*
|
|
395
|
+
* @see {@link Symbol.dispose} For automatic cleanup
|
|
353
396
|
*/
|
|
354
397
|
free(): void;
|
|
355
398
|
/**
|
|
356
|
-
* Initialize
|
|
399
|
+
* Initialize filter graph.
|
|
400
|
+
*
|
|
401
|
+
* Creates and configures filter graph components.
|
|
402
|
+
* For video, may use hardware frames context from first frame.
|
|
403
|
+
*
|
|
404
|
+
* @param firstFrame - First frame for hardware detection (video only)
|
|
357
405
|
*
|
|
358
|
-
*
|
|
359
|
-
* Configures the graph for processing.
|
|
406
|
+
* @throws {Error} If initialization fails
|
|
360
407
|
*
|
|
361
|
-
*
|
|
362
|
-
* For software inputs: Initializes without hw_frames_ctx
|
|
408
|
+
* @throws {FFmpegError} If configuration fails
|
|
363
409
|
*
|
|
364
410
|
* @internal
|
|
365
411
|
*/
|
|
@@ -367,51 +413,69 @@ export declare class FilterAPI implements Disposable {
|
|
|
367
413
|
/**
|
|
368
414
|
* Create buffer source with hardware frames context.
|
|
369
415
|
*
|
|
416
|
+
* @param frame - Frame with hw_frames_ctx
|
|
417
|
+
*
|
|
418
|
+
* @throws {Error} If creation fails
|
|
419
|
+
*
|
|
420
|
+
* @throws {FFmpegError} If configuration fails
|
|
421
|
+
*
|
|
370
422
|
* @internal
|
|
371
423
|
*/
|
|
372
424
|
private createBufferSourceWithHwFrames;
|
|
373
425
|
/**
|
|
374
|
-
* Create
|
|
426
|
+
* Create standard buffer source.
|
|
427
|
+
*
|
|
428
|
+
* @throws {Error} If creation fails
|
|
375
429
|
*
|
|
376
430
|
* @internal
|
|
377
431
|
*/
|
|
378
432
|
private createBufferSource;
|
|
379
433
|
/**
|
|
380
|
-
* Create
|
|
434
|
+
* Create buffer sink.
|
|
435
|
+
*
|
|
436
|
+
* @throws {Error} If creation fails
|
|
381
437
|
*
|
|
382
438
|
* @internal
|
|
383
439
|
*/
|
|
384
440
|
private createBufferSink;
|
|
385
441
|
/**
|
|
386
|
-
* Parse
|
|
442
|
+
* Parse filter description and build graph.
|
|
443
|
+
*
|
|
444
|
+
* @param description - Filter description string
|
|
445
|
+
*
|
|
446
|
+
* @throws {Error} If parsing fails
|
|
447
|
+
*
|
|
448
|
+
* @throws {FFmpegError} If graph construction fails
|
|
387
449
|
*
|
|
388
450
|
* @internal
|
|
389
451
|
*/
|
|
390
452
|
private parseFilterDescription;
|
|
391
453
|
/**
|
|
392
|
-
* Check
|
|
454
|
+
* Check hardware requirements for filters.
|
|
393
455
|
*
|
|
394
|
-
*
|
|
395
|
-
*
|
|
396
|
-
*
|
|
397
|
-
*
|
|
456
|
+
* @param description - Filter description
|
|
457
|
+
* @param options - Filter options
|
|
458
|
+
*
|
|
459
|
+
* @throws {Error} If hardware requirements not met
|
|
398
460
|
*
|
|
399
461
|
* @internal
|
|
400
462
|
*/
|
|
401
463
|
private checkHardwareRequirements;
|
|
402
464
|
/**
|
|
403
|
-
* Dispose of
|
|
465
|
+
* Dispose of filter.
|
|
404
466
|
*
|
|
405
|
-
* Implements
|
|
467
|
+
* Implements Disposable interface for automatic cleanup.
|
|
406
468
|
* Equivalent to calling free().
|
|
407
469
|
*
|
|
408
470
|
* @example
|
|
409
471
|
* ```typescript
|
|
410
472
|
* {
|
|
411
|
-
* using filter = await
|
|
412
|
-
* //
|
|
413
|
-
* } // Automatically freed
|
|
473
|
+
* using filter = await FilterAPI.create('scale=640:480', info);
|
|
474
|
+
* // Use filter...
|
|
475
|
+
* } // Automatically freed
|
|
414
476
|
* ```
|
|
477
|
+
*
|
|
478
|
+
* @see {@link free} For manual cleanup
|
|
415
479
|
*/
|
|
416
480
|
[Symbol.dispose](): void;
|
|
417
481
|
}
|