node-av 3.1.3 → 4.0.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 +65 -52
- package/binding.gyp +4 -0
- package/dist/api/audio-frame-buffer.d.ts +201 -0
- package/dist/api/audio-frame-buffer.js +275 -0
- package/dist/api/audio-frame-buffer.js.map +1 -0
- package/dist/api/bitstream-filter.d.ts +319 -78
- package/dist/api/bitstream-filter.js +680 -151
- package/dist/api/bitstream-filter.js.map +1 -1
- package/dist/api/constants.d.ts +44 -0
- package/dist/api/constants.js +45 -0
- package/dist/api/constants.js.map +1 -0
- package/dist/api/data/test_av1.ivf +0 -0
- package/dist/api/data/test_mjpeg.mjpeg +0 -0
- package/dist/api/data/test_vp8.ivf +0 -0
- package/dist/api/data/test_vp9.ivf +0 -0
- package/dist/api/decoder.d.ts +279 -17
- package/dist/api/decoder.js +998 -209
- package/dist/api/decoder.js.map +1 -1
- package/dist/api/{media-input.d.ts → demuxer.d.ts} +294 -44
- package/dist/api/demuxer.js +1968 -0
- package/dist/api/demuxer.js.map +1 -0
- package/dist/api/encoder.d.ts +308 -50
- package/dist/api/encoder.js +1133 -111
- package/dist/api/encoder.js.map +1 -1
- package/dist/api/filter-presets.d.ts +12 -5
- package/dist/api/filter-presets.js +21 -7
- package/dist/api/filter-presets.js.map +1 -1
- package/dist/api/filter.d.ts +406 -40
- package/dist/api/filter.js +966 -139
- package/dist/api/filter.js.map +1 -1
- package/dist/api/{fmp4.d.ts → fmp4-stream.d.ts} +141 -140
- package/dist/api/fmp4-stream.js +539 -0
- package/dist/api/fmp4-stream.js.map +1 -0
- package/dist/api/hardware.d.ts +58 -6
- package/dist/api/hardware.js +127 -11
- package/dist/api/hardware.js.map +1 -1
- package/dist/api/index.d.ts +6 -4
- package/dist/api/index.js +14 -8
- package/dist/api/index.js.map +1 -1
- package/dist/api/io-stream.d.ts +3 -3
- package/dist/api/io-stream.js +5 -4
- package/dist/api/io-stream.js.map +1 -1
- package/dist/api/{media-output.d.ts → muxer.d.ts} +274 -60
- package/dist/api/muxer.js +1934 -0
- package/dist/api/muxer.js.map +1 -0
- package/dist/api/pipeline.d.ts +77 -29
- package/dist/api/pipeline.js +435 -425
- package/dist/api/pipeline.js.map +1 -1
- package/dist/api/rtp-stream.d.ts +312 -0
- package/dist/api/rtp-stream.js +630 -0
- package/dist/api/rtp-stream.js.map +1 -0
- package/dist/api/types.d.ts +476 -55
- package/dist/api/utilities/async-queue.d.ts +91 -0
- package/dist/api/utilities/async-queue.js +162 -0
- package/dist/api/utilities/async-queue.js.map +1 -0
- package/dist/api/utilities/audio-sample.d.ts +1 -1
- package/dist/api/utilities/image.d.ts +1 -1
- package/dist/api/utilities/index.d.ts +2 -0
- package/dist/api/utilities/index.js +4 -0
- package/dist/api/utilities/index.js.map +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/scheduler.d.ts +169 -0
- package/dist/api/utilities/scheduler.js +136 -0
- package/dist/api/utilities/scheduler.js.map +1 -0
- package/dist/api/utilities/streaming.d.ts +74 -15
- package/dist/api/utilities/streaming.js +170 -12
- package/dist/api/utilities/streaming.js.map +1 -1
- package/dist/api/utilities/timestamp.d.ts +1 -1
- package/dist/api/webrtc-stream.d.ts +288 -0
- package/dist/api/webrtc-stream.js +440 -0
- package/dist/api/webrtc-stream.js.map +1 -0
- package/dist/constants/constants.d.ts +51 -1
- package/dist/constants/constants.js +47 -1
- package/dist/constants/constants.js.map +1 -1
- package/dist/constants/encoders.d.ts +2 -1
- package/dist/constants/encoders.js +4 -3
- package/dist/constants/encoders.js.map +1 -1
- package/dist/constants/hardware.d.ts +26 -0
- package/dist/constants/hardware.js +27 -0
- package/dist/constants/hardware.js.map +1 -0
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.js +1 -0
- package/dist/constants/index.js.map +1 -1
- package/dist/lib/binding.d.ts +19 -8
- package/dist/lib/binding.js.map +1 -1
- package/dist/lib/codec-context.d.ts +87 -0
- package/dist/lib/codec-context.js +125 -4
- package/dist/lib/codec-context.js.map +1 -1
- package/dist/lib/codec-parameters.d.ts +183 -1
- package/dist/lib/codec-parameters.js +209 -0
- package/dist/lib/codec-parameters.js.map +1 -1
- package/dist/lib/codec-parser.d.ts +23 -0
- package/dist/lib/codec-parser.js +25 -0
- package/dist/lib/codec-parser.js.map +1 -1
- package/dist/lib/codec.d.ts +26 -4
- package/dist/lib/codec.js +35 -0
- package/dist/lib/codec.js.map +1 -1
- package/dist/lib/dictionary.js +1 -0
- package/dist/lib/dictionary.js.map +1 -1
- package/dist/lib/error.js +1 -1
- package/dist/lib/error.js.map +1 -1
- package/dist/lib/filter-context.d.ts +52 -11
- package/dist/lib/filter-context.js +56 -12
- package/dist/lib/filter-context.js.map +1 -1
- package/dist/lib/filter-graph.d.ts +9 -0
- package/dist/lib/filter-graph.js +13 -0
- package/dist/lib/filter-graph.js.map +1 -1
- package/dist/lib/filter.d.ts +21 -0
- package/dist/lib/filter.js +28 -0
- package/dist/lib/filter.js.map +1 -1
- package/dist/lib/format-context.d.ts +48 -14
- package/dist/lib/format-context.js +76 -7
- package/dist/lib/format-context.js.map +1 -1
- package/dist/lib/frame.d.ts +168 -0
- package/dist/lib/frame.js +212 -0
- package/dist/lib/frame.js.map +1 -1
- package/dist/lib/hardware-device-context.d.ts +3 -2
- package/dist/lib/hardware-device-context.js.map +1 -1
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.js +2 -0
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/input-format.d.ts +21 -0
- package/dist/lib/input-format.js +42 -2
- package/dist/lib/input-format.js.map +1 -1
- package/dist/lib/native-types.d.ts +48 -26
- package/dist/lib/option.d.ts +25 -13
- package/dist/lib/option.js +28 -0
- package/dist/lib/option.js.map +1 -1
- package/dist/lib/output-format.d.ts +22 -1
- package/dist/lib/output-format.js +28 -0
- package/dist/lib/output-format.js.map +1 -1
- package/dist/lib/packet.d.ts +35 -0
- package/dist/lib/packet.js +52 -2
- package/dist/lib/packet.js.map +1 -1
- package/dist/lib/stream.d.ts +126 -0
- package/dist/lib/stream.js +188 -5
- package/dist/lib/stream.js.map +1 -1
- package/dist/lib/sync-queue.d.ts +179 -0
- package/dist/lib/sync-queue.js +197 -0
- package/dist/lib/sync-queue.js.map +1 -0
- package/dist/lib/types.d.ts +27 -1
- package/dist/lib/utilities.d.ts +281 -53
- package/dist/lib/utilities.js +298 -55
- package/dist/lib/utilities.js.map +1 -1
- package/package.json +20 -19
- package/dist/api/fmp4.js +0 -710
- package/dist/api/fmp4.js.map +0 -1
- package/dist/api/media-input.js +0 -1075
- package/dist/api/media-input.js.map +0 -1
- package/dist/api/media-output.js +0 -1040
- package/dist/api/media-output.js.map +0 -1
- package/dist/api/webrtc.d.ts +0 -664
- package/dist/api/webrtc.js +0 -1132
- package/dist/api/webrtc.js.map +0 -1
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import { Packet } from '../lib/
|
|
2
|
-
import
|
|
1
|
+
import { Packet } from '../lib/packet.js';
|
|
2
|
+
import { Muxer } from './muxer.js';
|
|
3
|
+
import { Scheduler, SchedulerControl } from './utilities/scheduler.js';
|
|
4
|
+
import type { Stream } from '../lib/stream.js';
|
|
3
5
|
/**
|
|
4
6
|
* High-level bitstream filter for packet processing.
|
|
5
7
|
*
|
|
6
8
|
* Provides simplified interface for applying bitstream filters to packets.
|
|
7
9
|
* Handles filter initialization, packet processing, and memory management.
|
|
10
|
+
* Supports both synchronous packet-by-packet filtering and async iteration over packets.
|
|
8
11
|
* Supports filters like h264_mp4toannexb, hevc_mp4toannexb, aac_adtstoasc.
|
|
9
12
|
* Essential for format conversion and stream compatibility in transcoding pipelines.
|
|
10
13
|
*
|
|
@@ -15,8 +18,8 @@ import type { Stream } from '../lib/index.js';
|
|
|
15
18
|
* // Create H.264 Annex B converter
|
|
16
19
|
* const filter = BitStreamFilterAPI.create('h264_mp4toannexb', stream);
|
|
17
20
|
*
|
|
18
|
-
* //
|
|
19
|
-
* const outputPackets = await filter.
|
|
21
|
+
* // Filter packet
|
|
22
|
+
* const outputPackets = await filter.filterAll(inputPacket);
|
|
20
23
|
* for (const packet of outputPackets) {
|
|
21
24
|
* await output.writePacket(packet);
|
|
22
25
|
* packet.free();
|
|
@@ -25,7 +28,7 @@ import type { Stream } from '../lib/index.js';
|
|
|
25
28
|
*
|
|
26
29
|
* @example
|
|
27
30
|
* ```typescript
|
|
28
|
-
* //
|
|
31
|
+
* // Filter packet stream
|
|
29
32
|
* const filter = BitStreamFilterAPI.create('hevc_mp4toannexb', videoStream);
|
|
30
33
|
*
|
|
31
34
|
* for await (const packet of filter.packets(input.packets())) {
|
|
@@ -36,15 +39,21 @@ import type { Stream } from '../lib/index.js';
|
|
|
36
39
|
*
|
|
37
40
|
* @see {@link BitStreamFilter} For available filters
|
|
38
41
|
* @see {@link BitStreamFilterContext} For low-level API
|
|
39
|
-
* @see {@link
|
|
42
|
+
* @see {@link Muxer} For writing filtered packets
|
|
40
43
|
*/
|
|
41
44
|
export declare class BitStreamFilterAPI implements Disposable {
|
|
42
45
|
private ctx;
|
|
43
|
-
private
|
|
46
|
+
private bsf;
|
|
44
47
|
private stream;
|
|
48
|
+
private packet;
|
|
45
49
|
private isClosed;
|
|
50
|
+
private inputQueue;
|
|
51
|
+
private outputQueue;
|
|
52
|
+
private workerPromise;
|
|
53
|
+
private nextComponent;
|
|
54
|
+
private pipeToPromise;
|
|
46
55
|
/**
|
|
47
|
-
* @param
|
|
56
|
+
* @param bsf - Bitstream filter
|
|
48
57
|
*
|
|
49
58
|
* @param ctx - Filter context
|
|
50
59
|
*
|
|
@@ -113,7 +122,7 @@ export declare class BitStreamFilterAPI implements Disposable {
|
|
|
113
122
|
* console.log(`Output codec: ${outputParams?.codecId}`);
|
|
114
123
|
* ```
|
|
115
124
|
*/
|
|
116
|
-
get outputCodecParameters(): import("../
|
|
125
|
+
get outputCodecParameters(): import("../index.js").CodecParameters | null;
|
|
117
126
|
/**
|
|
118
127
|
* Get output time base.
|
|
119
128
|
*
|
|
@@ -125,7 +134,7 @@ export declare class BitStreamFilterAPI implements Disposable {
|
|
|
125
134
|
* console.log(`Output timebase: ${tb?.num}/${tb?.den}`);
|
|
126
135
|
* ```
|
|
127
136
|
*/
|
|
128
|
-
get outputTimeBase(): import("../
|
|
137
|
+
get outputTimeBase(): import("../index.js").Rational | null;
|
|
129
138
|
/**
|
|
130
139
|
* Check if filter is open.
|
|
131
140
|
*
|
|
@@ -138,77 +147,137 @@ export declare class BitStreamFilterAPI implements Disposable {
|
|
|
138
147
|
*/
|
|
139
148
|
get isBitstreamFilterOpen(): boolean;
|
|
140
149
|
/**
|
|
141
|
-
*
|
|
150
|
+
* Filter a packet.
|
|
142
151
|
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
152
|
+
* Sends a packet to the filter and attempts to receive a filtered packet.
|
|
153
|
+
* Handles internal buffering - may return null if more packets needed.
|
|
154
|
+
*
|
|
155
|
+
* **Note**: This method receives only ONE packet per call.
|
|
156
|
+
* A single packet can produce multiple output packets (e.g., codec buffering).
|
|
157
|
+
* To receive all packets from a packet, use {@link filterAll} or {@link packets} instead.
|
|
146
158
|
*
|
|
147
159
|
* Direct mapping to av_bsf_send_packet() and av_bsf_receive_packet().
|
|
148
160
|
*
|
|
149
|
-
* @param packet - Packet to filter
|
|
161
|
+
* @param packet - Packet to filter
|
|
150
162
|
*
|
|
151
|
-
* @returns
|
|
163
|
+
* @returns Filtered packet, null if more data needed, or null if filter is closed
|
|
152
164
|
*
|
|
153
165
|
* @throws {FFmpegError} If filtering fails
|
|
154
166
|
*
|
|
155
167
|
* @example
|
|
156
168
|
* ```typescript
|
|
157
|
-
* const
|
|
158
|
-
* if (
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
* }
|
|
169
|
+
* const outPacket = await filter.filter(inputPacket);
|
|
170
|
+
* if (outPacket) {
|
|
171
|
+
* console.log(`Filtered packet: pts=${outPacket.pts}`);
|
|
172
|
+
* await output.writePacket(outPacket);
|
|
173
|
+
* outPacket.free();
|
|
163
174
|
* }
|
|
164
175
|
* ```
|
|
165
176
|
*
|
|
177
|
+
* @see {@link filterAll} For multiple packet filtering
|
|
178
|
+
* @see {@link packets} For stream processing
|
|
179
|
+
* @see {@link flush} For end-of-stream handling
|
|
180
|
+
* @see {@link filterSync} For synchronous version
|
|
181
|
+
*/
|
|
182
|
+
filter(packet: Packet): Promise<Packet | null>;
|
|
183
|
+
/**
|
|
184
|
+
* Filter a packet synchronously.
|
|
185
|
+
* Synchronous version of filter.
|
|
186
|
+
*
|
|
187
|
+
* Sends a packet to the filter and attempts to receive a filtered packet.
|
|
188
|
+
* Handles internal buffering - may return null if more packets needed.
|
|
189
|
+
*
|
|
190
|
+
* **Note**: This method receives only ONE packet per call.
|
|
191
|
+
* A single packet can produce multiple output packets (e.g., codec buffering).
|
|
192
|
+
* To receive all packets from a packet, use {@link filterAllSync} or {@link packetsSync} instead.
|
|
193
|
+
*
|
|
194
|
+
* Direct mapping to av_bsf_send_packet() and av_bsf_receive_packet().
|
|
195
|
+
*
|
|
196
|
+
* @param packet - Packet to filter
|
|
197
|
+
*
|
|
198
|
+
* @returns Filtered packet, null if more data needed, or null if filter is closed
|
|
199
|
+
*
|
|
200
|
+
* @throws {FFmpegError} If filtering fails
|
|
201
|
+
*
|
|
166
202
|
* @example
|
|
167
203
|
* ```typescript
|
|
168
|
-
*
|
|
169
|
-
*
|
|
204
|
+
* const outPacket = filter.filterSync(inputPacket);
|
|
205
|
+
* if (outPacket) {
|
|
206
|
+
* console.log(`Filtered packet: pts=${outPacket.pts}`);
|
|
207
|
+
* output.writePacketSync(outPacket);
|
|
208
|
+
* outPacket.free();
|
|
209
|
+
* }
|
|
170
210
|
* ```
|
|
171
211
|
*
|
|
172
|
-
* @see {@link
|
|
173
|
-
* @see {@link
|
|
212
|
+
* @see {@link filterAllSync} For multiple packet filtering
|
|
213
|
+
* @see {@link packetsSync} For stream processing
|
|
214
|
+
* @see {@link flushSync} For end-of-stream handling
|
|
215
|
+
* @see {@link filter} For async version
|
|
174
216
|
*/
|
|
175
|
-
|
|
217
|
+
filterSync(packet: Packet): Packet | null;
|
|
176
218
|
/**
|
|
177
|
-
*
|
|
178
|
-
* Synchronous version of process.
|
|
219
|
+
* Filter a packet to packets.
|
|
179
220
|
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
221
|
+
* Sends a packet to the filter and receives all available filtered packets.
|
|
222
|
+
* Returns array of packets - may be empty if filter needs more data.
|
|
223
|
+
* One packet can produce zero, one, or multiple packets depending on filter.
|
|
183
224
|
*
|
|
184
225
|
* Direct mapping to av_bsf_send_packet() and av_bsf_receive_packet().
|
|
185
226
|
*
|
|
186
|
-
* @param packet - Packet to filter
|
|
227
|
+
* @param packet - Packet to filter
|
|
187
228
|
*
|
|
188
|
-
* @returns Array of filtered packets
|
|
229
|
+
* @returns Array of filtered packets (empty if more data needed or filter is closed)
|
|
189
230
|
*
|
|
190
231
|
* @throws {FFmpegError} If filtering fails
|
|
191
232
|
*
|
|
192
233
|
* @example
|
|
193
234
|
* ```typescript
|
|
194
|
-
* const outputPackets = filter.
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
* }
|
|
235
|
+
* const outputPackets = await filter.filterAll(inputPacket);
|
|
236
|
+
* for (const packet of outputPackets) {
|
|
237
|
+
* console.log(`Filtered packet: pts=${packet.pts}`);
|
|
238
|
+
* await output.writePacket(packet);
|
|
239
|
+
* packet.free();
|
|
200
240
|
* }
|
|
201
241
|
* ```
|
|
202
242
|
*
|
|
243
|
+
* @see {@link filter} For single packet filtering
|
|
244
|
+
* @see {@link packets} For stream processing
|
|
245
|
+
* @see {@link flush} For end-of-stream handling
|
|
246
|
+
* @see {@link filterAllSync} For synchronous version
|
|
247
|
+
*/
|
|
248
|
+
filterAll(packet: Packet): Promise<Packet[]>;
|
|
249
|
+
/**
|
|
250
|
+
* Filter a packet to packets synchronously.
|
|
251
|
+
* Synchronous version of filterAll.
|
|
252
|
+
*
|
|
253
|
+
* Sends a packet to the filter and receives all available filtered packets.
|
|
254
|
+
* Returns array of packets - may be empty if filter needs more data.
|
|
255
|
+
* One packet can produce zero, one, or multiple packets depending on filter.
|
|
256
|
+
*
|
|
257
|
+
* Direct mapping to av_bsf_send_packet() and av_bsf_receive_packet().
|
|
258
|
+
*
|
|
259
|
+
* @param packet - Packet to filter
|
|
260
|
+
*
|
|
261
|
+
* @returns Array of filtered packets (empty if more data needed or filter is closed)
|
|
262
|
+
*
|
|
263
|
+
* @throws {FFmpegError} If filtering fails
|
|
264
|
+
*
|
|
203
265
|
* @example
|
|
204
266
|
* ```typescript
|
|
205
|
-
*
|
|
206
|
-
* const
|
|
267
|
+
* const outputPackets = filter.filterAllSync(inputPacket);
|
|
268
|
+
* for (const packet of outputPackets) {
|
|
269
|
+
* console.log(`Filtered packet: pts=${packet.pts}`);
|
|
270
|
+
* output.writePacketSync(packet);
|
|
271
|
+
* packet.free();
|
|
272
|
+
* }
|
|
207
273
|
* ```
|
|
208
274
|
*
|
|
209
|
-
* @see {@link
|
|
275
|
+
* @see {@link filterSync} For single packet filtering
|
|
276
|
+
* @see {@link packetsSync} For stream processing
|
|
277
|
+
* @see {@link flushSync} For end-of-stream handling
|
|
278
|
+
* @see {@link filterAll} For async version
|
|
210
279
|
*/
|
|
211
|
-
|
|
280
|
+
filterAllSync(packet: Packet): Packet[];
|
|
212
281
|
/**
|
|
213
282
|
* Process packet stream through filter.
|
|
214
283
|
*
|
|
@@ -243,10 +312,10 @@ export declare class BitStreamFilterAPI implements Disposable {
|
|
|
243
312
|
* }
|
|
244
313
|
* ```
|
|
245
314
|
*
|
|
246
|
-
* @see {@link
|
|
315
|
+
* @see {@link filterAll} For filtering single packets
|
|
247
316
|
* @see {@link flush} For end-of-stream handling
|
|
248
317
|
*/
|
|
249
|
-
packets(packets: AsyncIterable<Packet>): AsyncGenerator<Packet>;
|
|
318
|
+
packets(packets: AsyncIterable<Packet | null>): AsyncGenerator<Packet | null>;
|
|
250
319
|
/**
|
|
251
320
|
* Process packet stream through filter synchronously.
|
|
252
321
|
* Synchronous version of packets.
|
|
@@ -284,93 +353,197 @@ export declare class BitStreamFilterAPI implements Disposable {
|
|
|
284
353
|
*
|
|
285
354
|
* @see {@link packets} For async version
|
|
286
355
|
*/
|
|
287
|
-
packetsSync(packets: Iterable<Packet>): Generator<Packet>;
|
|
356
|
+
packetsSync(packets: Iterable<Packet | null>): Generator<Packet | null>;
|
|
288
357
|
/**
|
|
289
|
-
* Flush filter and
|
|
358
|
+
* Flush filter and signal end-of-stream.
|
|
290
359
|
*
|
|
291
|
-
*
|
|
292
|
-
*
|
|
360
|
+
* Sends null packet to filter to signal end-of-stream.
|
|
361
|
+
* Does nothing if filter is closed.
|
|
362
|
+
* Must call receive() or flushPackets() to get remaining buffered packets.
|
|
293
363
|
*
|
|
294
|
-
* Direct mapping to av_bsf_flush().
|
|
364
|
+
* Direct mapping to av_bsf_send_packet(NULL) and av_bsf_flush().
|
|
295
365
|
*
|
|
296
|
-
* @
|
|
366
|
+
* @throws {FFmpegError} If flush fails
|
|
297
367
|
*
|
|
298
368
|
* @example
|
|
299
369
|
* ```typescript
|
|
300
|
-
*
|
|
301
|
-
*
|
|
302
|
-
*
|
|
303
|
-
*
|
|
304
|
-
*
|
|
305
|
-
*
|
|
370
|
+
* // Signal end of stream
|
|
371
|
+
* await filter.flush();
|
|
372
|
+
*
|
|
373
|
+
* // Then get remaining packets
|
|
374
|
+
* let packet;
|
|
375
|
+
* while ((packet = await filter.receive()) !== null) {
|
|
376
|
+
* console.log('Got buffered packet');
|
|
377
|
+
* await output.writePacket(packet);
|
|
378
|
+
* packet.free();
|
|
306
379
|
* }
|
|
307
380
|
* ```
|
|
308
381
|
*
|
|
309
382
|
* @see {@link flushPackets} For async iteration
|
|
383
|
+
* @see {@link receive} For getting buffered packets
|
|
310
384
|
* @see {@link reset} For state reset only
|
|
385
|
+
* @see {@link flushSync} For synchronous version
|
|
311
386
|
*/
|
|
312
|
-
flush(): Promise<
|
|
387
|
+
flush(): Promise<void>;
|
|
313
388
|
/**
|
|
314
|
-
* Flush filter and
|
|
389
|
+
* Flush filter and signal end-of-stream synchronously.
|
|
315
390
|
* Synchronous version of flush.
|
|
316
391
|
*
|
|
317
|
-
*
|
|
318
|
-
*
|
|
392
|
+
* Sends null packet to filter to signal end-of-stream.
|
|
393
|
+
* Does nothing if filter is closed.
|
|
394
|
+
* Must call receiveSync() or flushPacketsSync() to get remaining buffered packets.
|
|
319
395
|
*
|
|
320
|
-
* Direct mapping to av_bsf_flush().
|
|
396
|
+
* Direct mapping to av_bsf_send_packet(NULL) and av_bsf_flush().
|
|
321
397
|
*
|
|
322
|
-
* @
|
|
398
|
+
* @throws {FFmpegError} If flush fails
|
|
323
399
|
*
|
|
324
400
|
* @example
|
|
325
401
|
* ```typescript
|
|
326
|
-
*
|
|
327
|
-
*
|
|
328
|
-
*
|
|
329
|
-
*
|
|
330
|
-
*
|
|
331
|
-
*
|
|
402
|
+
* // Signal end of stream
|
|
403
|
+
* filter.flushSync();
|
|
404
|
+
*
|
|
405
|
+
* // Then get remaining packets
|
|
406
|
+
* let packet;
|
|
407
|
+
* while ((packet = filter.receiveSync()) !== null) {
|
|
408
|
+
* console.log('Got buffered packet');
|
|
409
|
+
* output.writePacketSync(packet);
|
|
410
|
+
* packet.free();
|
|
332
411
|
* }
|
|
333
412
|
* ```
|
|
334
413
|
*
|
|
414
|
+
* @see {@link flushPacketsSync} For sync iteration
|
|
415
|
+
* @see {@link receiveSync} For getting buffered packets
|
|
416
|
+
* @see {@link reset} For state reset only
|
|
335
417
|
* @see {@link flush} For async version
|
|
336
418
|
*/
|
|
337
|
-
flushSync():
|
|
419
|
+
flushSync(): void;
|
|
338
420
|
/**
|
|
339
|
-
*
|
|
421
|
+
* Receive packet from filter.
|
|
422
|
+
*
|
|
423
|
+
* Gets filtered packets from the filter's internal buffer.
|
|
424
|
+
* Handles packet allocation and error checking.
|
|
425
|
+
* Returns null if filter is closed or no packets available.
|
|
426
|
+
* Call repeatedly until null to drain all buffered packets.
|
|
427
|
+
*
|
|
428
|
+
* Direct mapping to av_bsf_receive_packet().
|
|
429
|
+
*
|
|
430
|
+
* @returns Cloned packet or null if no packets available
|
|
431
|
+
*
|
|
432
|
+
* @throws {FFmpegError} If receive fails with error other than AVERROR_EAGAIN or AVERROR_EOF
|
|
433
|
+
*
|
|
434
|
+
* @example
|
|
435
|
+
* ```typescript
|
|
436
|
+
* const packet = await filter.receive();
|
|
437
|
+
* if (packet) {
|
|
438
|
+
* console.log('Got filtered packet');
|
|
439
|
+
* await output.writePacket(packet);
|
|
440
|
+
* packet.free();
|
|
441
|
+
* }
|
|
442
|
+
* ```
|
|
443
|
+
*
|
|
444
|
+
* @example
|
|
445
|
+
* ```typescript
|
|
446
|
+
* // Drain all buffered packets
|
|
447
|
+
* let packet;
|
|
448
|
+
* while ((packet = await filter.receive()) !== null) {
|
|
449
|
+
* console.log(`Packet PTS: ${packet.pts}`);
|
|
450
|
+
* await output.writePacket(packet);
|
|
451
|
+
* packet.free();
|
|
452
|
+
* }
|
|
453
|
+
* ```
|
|
454
|
+
*
|
|
455
|
+
* @see {@link filter} For filtering packets
|
|
456
|
+
* @see {@link flush} For signaling end-of-stream
|
|
457
|
+
* @see {@link receiveSync} For synchronous version
|
|
458
|
+
*/
|
|
459
|
+
receive(): Promise<Packet | null>;
|
|
460
|
+
/**
|
|
461
|
+
* Receive packet from filter synchronously.
|
|
462
|
+
* Synchronous version of receive.
|
|
463
|
+
*
|
|
464
|
+
* Gets filtered packets from the filter's internal buffer.
|
|
465
|
+
* Handles packet allocation and error checking.
|
|
466
|
+
* Returns null if filter is closed or no packets available.
|
|
467
|
+
* Call repeatedly until null to drain all buffered packets.
|
|
468
|
+
*
|
|
469
|
+
* Direct mapping to av_bsf_receive_packet().
|
|
470
|
+
*
|
|
471
|
+
* @returns Cloned packet or null if no packets available
|
|
472
|
+
*
|
|
473
|
+
* @throws {FFmpegError} If receive fails with error other than AVERROR_EAGAIN or AVERROR_EOF
|
|
474
|
+
*
|
|
475
|
+
* @example
|
|
476
|
+
* ```typescript
|
|
477
|
+
* const packet = filter.receiveSync();
|
|
478
|
+
* if (packet) {
|
|
479
|
+
* console.log('Got filtered packet');
|
|
480
|
+
* output.writePacketSync(packet);
|
|
481
|
+
* packet.free();
|
|
482
|
+
* }
|
|
483
|
+
* ```
|
|
484
|
+
*
|
|
485
|
+
* @example
|
|
486
|
+
* ```typescript
|
|
487
|
+
* // Drain all buffered packets
|
|
488
|
+
* let packet;
|
|
489
|
+
* while ((packet = filter.receiveSync()) !== null) {
|
|
490
|
+
* console.log(`Packet PTS: ${packet.pts}`);
|
|
491
|
+
* output.writePacketSync(packet);
|
|
492
|
+
* packet.free();
|
|
493
|
+
* }
|
|
494
|
+
* ```
|
|
495
|
+
*
|
|
496
|
+
* @see {@link filterSync} For filtering packets
|
|
497
|
+
* @see {@link flushSync} For signaling end-of-stream
|
|
498
|
+
* @see {@link receive} For async version
|
|
499
|
+
*/
|
|
500
|
+
receiveSync(): Packet | null;
|
|
501
|
+
/**
|
|
502
|
+
* Flush all buffered packets as async generator.
|
|
340
503
|
*
|
|
341
504
|
* Convenient async iteration over remaining packets.
|
|
342
|
-
*
|
|
505
|
+
* Automatically sends flush signal and retrieves buffered packets.
|
|
506
|
+
* Useful for end-of-stream processing.
|
|
343
507
|
*
|
|
344
|
-
* @yields {Packet}
|
|
508
|
+
* @yields {Packet} Buffered packets
|
|
345
509
|
*
|
|
346
510
|
* @example
|
|
347
511
|
* ```typescript
|
|
512
|
+
* // Flush at end of filtering
|
|
348
513
|
* for await (const packet of filter.flushPackets()) {
|
|
514
|
+
* console.log('Processing buffered packet');
|
|
349
515
|
* await output.writePacket(packet);
|
|
350
516
|
* packet.free();
|
|
351
517
|
* }
|
|
352
518
|
* ```
|
|
353
519
|
*
|
|
354
|
-
* @see {@link
|
|
520
|
+
* @see {@link filter} For filtering packets
|
|
521
|
+
* @see {@link flush} For signaling end-of-stream
|
|
522
|
+
* @see {@link flushPacketsSync} For synchronous version
|
|
355
523
|
*/
|
|
356
524
|
flushPackets(): AsyncGenerator<Packet>;
|
|
357
525
|
/**
|
|
358
|
-
* Flush
|
|
526
|
+
* Flush all buffered packets as generator synchronously.
|
|
359
527
|
* Synchronous version of flushPackets.
|
|
360
528
|
*
|
|
361
529
|
* Convenient sync iteration over remaining packets.
|
|
362
|
-
*
|
|
530
|
+
* Automatically retrieves buffered packets after flush.
|
|
531
|
+
* Useful for end-of-stream processing.
|
|
363
532
|
*
|
|
364
|
-
* @yields {Packet}
|
|
533
|
+
* @yields {Packet} Buffered packets
|
|
365
534
|
*
|
|
366
535
|
* @example
|
|
367
536
|
* ```typescript
|
|
537
|
+
* // Flush at end of filtering
|
|
368
538
|
* for (const packet of filter.flushPacketsSync()) {
|
|
539
|
+
* console.log('Processing buffered packet');
|
|
369
540
|
* output.writePacketSync(packet);
|
|
370
541
|
* packet.free();
|
|
371
542
|
* }
|
|
372
543
|
* ```
|
|
373
544
|
*
|
|
545
|
+
* @see {@link filterSync} For filtering packets
|
|
546
|
+
* @see {@link flushSync} For signaling end-of-stream
|
|
374
547
|
* @see {@link flushPackets} For async version
|
|
375
548
|
*/
|
|
376
549
|
flushPacketsSync(): Generator<Packet>;
|
|
@@ -436,4 +609,72 @@ export declare class BitStreamFilterAPI implements Disposable {
|
|
|
436
609
|
* @see {@link close} For manual cleanup
|
|
437
610
|
*/
|
|
438
611
|
[Symbol.dispose](): void;
|
|
612
|
+
/**
|
|
613
|
+
* Send packet to input queue.
|
|
614
|
+
*
|
|
615
|
+
* @param packet - Packet to send
|
|
616
|
+
*
|
|
617
|
+
* @internal
|
|
618
|
+
*/
|
|
619
|
+
sendToQueue(packet: Packet): Promise<void>;
|
|
620
|
+
/**
|
|
621
|
+
* Receive packet from output queue.
|
|
622
|
+
*
|
|
623
|
+
* @returns Packet from queue or null if closed
|
|
624
|
+
*
|
|
625
|
+
* @internal
|
|
626
|
+
*/
|
|
627
|
+
receiveFromQueue(): Promise<Packet | null>;
|
|
628
|
+
/**
|
|
629
|
+
* Worker loop for push-based processing.
|
|
630
|
+
*
|
|
631
|
+
* @internal
|
|
632
|
+
*/
|
|
633
|
+
private runWorker;
|
|
634
|
+
/**
|
|
635
|
+
* Pipe output to another bitstream filter.
|
|
636
|
+
*
|
|
637
|
+
* Starts background worker for packet processing.
|
|
638
|
+
* Packets flow through: input → this filter → target filter.
|
|
639
|
+
*
|
|
640
|
+
* @param target - Target bitstream filter
|
|
641
|
+
*
|
|
642
|
+
* @returns Scheduler for continued chaining
|
|
643
|
+
*
|
|
644
|
+
* @example
|
|
645
|
+
* ```typescript
|
|
646
|
+
* const filter1 = BitStreamFilterAPI.create('h264_mp4toannexb', stream);
|
|
647
|
+
* const filter2 = BitStreamFilterAPI.create('dump_extra', stream);
|
|
648
|
+
* filter1.pipeTo(filter2).pipeTo(output, 0);
|
|
649
|
+
* ```
|
|
650
|
+
*/
|
|
651
|
+
pipeTo(target: BitStreamFilterAPI): Scheduler<Packet>;
|
|
652
|
+
/**
|
|
653
|
+
* Pipe output to muxer.
|
|
654
|
+
*
|
|
655
|
+
* Terminal stage - writes filtered packets to output file.
|
|
656
|
+
*
|
|
657
|
+
* @param output - Muxer to write to
|
|
658
|
+
*
|
|
659
|
+
* @param streamIndex - Stream index in output
|
|
660
|
+
*
|
|
661
|
+
* @returns Control interface for pipeline
|
|
662
|
+
*
|
|
663
|
+
* @example
|
|
664
|
+
* ```typescript
|
|
665
|
+
* const filter = BitStreamFilterAPI.create('h264_mp4toannexb', stream);
|
|
666
|
+
* const control = filter.pipeTo(output, 0);
|
|
667
|
+
* await control.send(packet);
|
|
668
|
+
* ```
|
|
669
|
+
*/
|
|
670
|
+
pipeTo(output: Muxer, streamIndex: number): SchedulerControl<Packet>;
|
|
671
|
+
/**
|
|
672
|
+
* Flush pipeline.
|
|
673
|
+
*
|
|
674
|
+
* Closes input queue, waits for worker to finish,
|
|
675
|
+
* then propagates flush to next component.
|
|
676
|
+
*
|
|
677
|
+
* @internal
|
|
678
|
+
*/
|
|
679
|
+
flushPipeline(): Promise<void>;
|
|
439
680
|
}
|