node-av 1.3.0 → 2.1.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 +47 -40
- package/binding.gyp +12 -0
- package/dist/api/bitstream-filter.d.ts +134 -2
- package/dist/api/bitstream-filter.js +200 -2
- package/dist/api/bitstream-filter.js.map +1 -1
- package/dist/api/decoder.d.ts +261 -105
- package/dist/api/decoder.js +384 -171
- package/dist/api/decoder.js.map +1 -1
- package/dist/api/encoder.d.ts +338 -74
- package/dist/api/encoder.js +546 -188
- package/dist/api/encoder.js.map +1 -1
- package/dist/api/filter-presets.d.ts +479 -1513
- package/dist/api/filter-presets.js +1044 -2005
- package/dist/api/filter-presets.js.map +1 -1
- package/dist/api/filter.d.ts +370 -150
- package/dist/api/filter.js +647 -364
- package/dist/api/filter.js.map +1 -1
- package/dist/api/hardware.d.ts +25 -31
- package/dist/api/hardware.js +36 -70
- package/dist/api/hardware.js.map +1 -1
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.js +1 -1
- package/dist/api/index.js.map +1 -1
- package/dist/api/io-stream.d.ts +6 -0
- package/dist/api/io-stream.js +2 -0
- package/dist/api/io-stream.js.map +1 -1
- package/dist/api/media-input.d.ts +208 -2
- package/dist/api/media-input.js +356 -8
- package/dist/api/media-input.js.map +1 -1
- package/dist/api/media-output.d.ts +142 -104
- package/dist/api/media-output.js +446 -179
- package/dist/api/media-output.js.map +1 -1
- package/dist/api/pipeline.d.ts +82 -17
- package/dist/api/pipeline.js +80 -42
- package/dist/api/pipeline.js.map +1 -1
- package/dist/api/types.d.ts +24 -57
- package/dist/api/utils.js +2 -0
- package/dist/api/utils.js.map +1 -1
- package/dist/lib/audio-fifo.d.ts +103 -0
- package/dist/lib/audio-fifo.js +109 -0
- package/dist/lib/audio-fifo.js.map +1 -1
- package/dist/lib/binding.d.ts +1 -0
- package/dist/lib/binding.js.map +1 -1
- package/dist/lib/bitstream-filter-context.d.ts +79 -0
- package/dist/lib/bitstream-filter-context.js +83 -0
- package/dist/lib/bitstream-filter-context.js.map +1 -1
- package/dist/lib/bitstream-filter.d.ts +2 -0
- package/dist/lib/bitstream-filter.js +2 -0
- package/dist/lib/bitstream-filter.js.map +1 -1
- package/dist/lib/codec-context.d.ts +168 -0
- package/dist/lib/codec-context.js +178 -0
- package/dist/lib/codec-context.js.map +1 -1
- package/dist/lib/codec-parameters.d.ts +3 -0
- package/dist/lib/codec-parameters.js +3 -0
- package/dist/lib/codec-parameters.js.map +1 -1
- package/dist/lib/codec-parser.d.ts +6 -0
- package/dist/lib/codec-parser.js +6 -0
- package/dist/lib/codec-parser.js.map +1 -1
- package/dist/lib/codec.d.ts +12 -0
- package/dist/lib/codec.js +12 -0
- package/dist/lib/codec.js.map +1 -1
- package/dist/lib/dictionary.d.ts +18 -2
- package/dist/lib/dictionary.js +18 -2
- package/dist/lib/dictionary.js.map +1 -1
- package/dist/lib/error.d.ts +8 -0
- package/dist/lib/error.js +9 -0
- package/dist/lib/error.js.map +1 -1
- package/dist/lib/filter-context.d.ts +119 -2
- package/dist/lib/filter-context.js +119 -0
- package/dist/lib/filter-context.js.map +1 -1
- package/dist/lib/filter-graph.d.ts +80 -0
- package/dist/lib/filter-graph.js +84 -0
- package/dist/lib/filter-graph.js.map +1 -1
- package/dist/lib/filter-inout.d.ts +1 -0
- package/dist/lib/filter-inout.js +1 -0
- package/dist/lib/filter-inout.js.map +1 -1
- package/dist/lib/filter.d.ts +2 -0
- package/dist/lib/filter.js +2 -0
- package/dist/lib/filter.js.map +1 -1
- package/dist/lib/format-context.d.ts +356 -20
- package/dist/lib/format-context.js +375 -23
- package/dist/lib/format-context.js.map +1 -1
- package/dist/lib/frame.d.ts +84 -1
- package/dist/lib/frame.js +96 -0
- package/dist/lib/frame.js.map +1 -1
- package/dist/lib/hardware-device-context.d.ts +8 -0
- package/dist/lib/hardware-device-context.js +8 -0
- package/dist/lib/hardware-device-context.js.map +1 -1
- package/dist/lib/hardware-frames-context.d.ts +55 -0
- package/dist/lib/hardware-frames-context.js +57 -0
- package/dist/lib/hardware-frames-context.js.map +1 -1
- package/dist/lib/input-format.d.ts +43 -3
- package/dist/lib/input-format.js +48 -0
- package/dist/lib/input-format.js.map +1 -1
- package/dist/lib/io-context.d.ts +212 -0
- package/dist/lib/io-context.js +228 -0
- package/dist/lib/io-context.js.map +1 -1
- package/dist/lib/log.d.ts +2 -0
- package/dist/lib/log.js +2 -0
- package/dist/lib/log.js.map +1 -1
- package/dist/lib/native-types.d.ts +39 -1
- package/dist/lib/option.d.ts +90 -0
- package/dist/lib/option.js +97 -0
- package/dist/lib/option.js.map +1 -1
- package/dist/lib/output-format.d.ts +4 -0
- package/dist/lib/output-format.js +4 -0
- package/dist/lib/output-format.js.map +1 -1
- package/dist/lib/packet.d.ts +7 -0
- package/dist/lib/packet.js +7 -0
- package/dist/lib/packet.js.map +1 -1
- package/dist/lib/rational.d.ts +1 -0
- package/dist/lib/rational.js +1 -0
- package/dist/lib/rational.js.map +1 -1
- package/dist/lib/software-resample-context.d.ts +64 -0
- package/dist/lib/software-resample-context.js +66 -0
- package/dist/lib/software-resample-context.js.map +1 -1
- package/dist/lib/software-scale-context.d.ts +98 -0
- package/dist/lib/software-scale-context.js +102 -0
- package/dist/lib/software-scale-context.js.map +1 -1
- package/dist/lib/stream.d.ts +1 -0
- package/dist/lib/stream.js +1 -0
- package/dist/lib/stream.js.map +1 -1
- package/dist/lib/utilities.d.ts +60 -0
- package/dist/lib/utilities.js +60 -0
- package/dist/lib/utilities.js.map +1 -1
- package/package.json +18 -18
- package/release_notes.md +0 -29
package/dist/api/decoder.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CodecContext, Frame } from '../lib/index.js';
|
|
1
|
+
import { Codec, CodecContext, Frame } from '../lib/index.js';
|
|
2
2
|
import type { Packet, Stream } from '../lib/index.js';
|
|
3
|
-
import type { DecoderOptions
|
|
3
|
+
import type { DecoderOptions } from './types.js';
|
|
4
4
|
/**
|
|
5
5
|
* High-level decoder for audio and video streams.
|
|
6
6
|
*
|
|
@@ -45,14 +45,19 @@ import type { DecoderOptions, StreamInfo } from './types.js';
|
|
|
45
45
|
*/
|
|
46
46
|
export declare class Decoder implements Disposable {
|
|
47
47
|
private codecContext;
|
|
48
|
+
private codec;
|
|
48
49
|
private frame;
|
|
49
|
-
private streamIndex;
|
|
50
50
|
private stream;
|
|
51
|
-
private
|
|
51
|
+
private initialized;
|
|
52
|
+
private isClosed;
|
|
52
53
|
private hardware?;
|
|
53
54
|
/**
|
|
54
55
|
* @param codecContext - Configured codec context
|
|
56
|
+
*
|
|
57
|
+
* @param codec - Codec being used
|
|
58
|
+
*
|
|
55
59
|
* @param stream - Media stream being decoded
|
|
60
|
+
*
|
|
56
61
|
* @param hardware - Optional hardware context
|
|
57
62
|
* Use {@link create} factory method
|
|
58
63
|
*
|
|
@@ -67,7 +72,9 @@ export declare class Decoder implements Disposable {
|
|
|
67
72
|
* Applies custom codec options and threading configuration.
|
|
68
73
|
*
|
|
69
74
|
* @param stream - Media stream to decode
|
|
75
|
+
*
|
|
70
76
|
* @param options - Decoder configuration options
|
|
77
|
+
*
|
|
71
78
|
* @returns Configured decoder instance
|
|
72
79
|
*
|
|
73
80
|
* @throws {Error} If decoder not found for codec
|
|
@@ -120,36 +127,21 @@ export declare class Decoder implements Disposable {
|
|
|
120
127
|
*/
|
|
121
128
|
get isDecoderOpen(): boolean;
|
|
122
129
|
/**
|
|
123
|
-
*
|
|
130
|
+
* Check if decoder has been initialized.
|
|
124
131
|
*
|
|
125
|
-
* Returns
|
|
126
|
-
*
|
|
127
|
-
* Essential for configuring downstream components like encoders or filters.
|
|
132
|
+
* Returns true if decoder is initialized (true by default for decoders).
|
|
133
|
+
* Decoders are pre-initialized from stream parameters.
|
|
128
134
|
*
|
|
129
|
-
* @returns
|
|
135
|
+
* @returns true if decoder has been initialized
|
|
130
136
|
*
|
|
131
137
|
* @example
|
|
132
138
|
* ```typescript
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
* console.log(`Video: ${info.width}x${info.height} @ ${info.pixelFormat}`);
|
|
136
|
-
* console.log(`Frame rate: ${info.frameRate.num}/${info.frameRate.den}`);
|
|
139
|
+
* if (decoder.isDecoderInitialized) {
|
|
140
|
+
* console.log('Decoder is ready to process frames');
|
|
137
141
|
* }
|
|
138
142
|
* ```
|
|
139
|
-
*
|
|
140
|
-
* @example
|
|
141
|
-
* ```typescript
|
|
142
|
-
* const info = decoder.getOutputStreamInfo();
|
|
143
|
-
* if (info.type === 'audio') {
|
|
144
|
-
* console.log(`Audio: ${info.sampleRate}Hz ${info.sampleFormat}`);
|
|
145
|
-
* console.log(`Channels: ${info.channelLayout}`);
|
|
146
|
-
* }
|
|
147
|
-
* ```
|
|
148
|
-
*
|
|
149
|
-
* @see {@link StreamInfo} For format details
|
|
150
|
-
* @see {@link Encoder.create} For matching encoder configuration
|
|
151
143
|
*/
|
|
152
|
-
|
|
144
|
+
get isDecoderInitialized(): boolean;
|
|
153
145
|
/**
|
|
154
146
|
* Check if decoder uses hardware acceleration.
|
|
155
147
|
*
|
|
@@ -165,6 +157,19 @@ export declare class Decoder implements Disposable {
|
|
|
165
157
|
* @see {@link HardwareContext} For hardware setup
|
|
166
158
|
*/
|
|
167
159
|
isHardware(): boolean;
|
|
160
|
+
/**
|
|
161
|
+
* Check if decoder is ready for processing.
|
|
162
|
+
*
|
|
163
|
+
* @returns true if initialized and ready
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* ```typescript
|
|
167
|
+
* if (decoder.isReady()) {
|
|
168
|
+
* const frame = await decoder.decode(packet);
|
|
169
|
+
* }
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
isReady(): boolean;
|
|
168
173
|
/**
|
|
169
174
|
* Decode a packet to a frame.
|
|
170
175
|
*
|
|
@@ -175,6 +180,7 @@ export declare class Decoder implements Disposable {
|
|
|
175
180
|
* Direct mapping to avcodec_send_packet() and avcodec_receive_frame().
|
|
176
181
|
*
|
|
177
182
|
* @param packet - Compressed packet to decode
|
|
183
|
+
*
|
|
178
184
|
* @returns Decoded frame or null if more data needed
|
|
179
185
|
*
|
|
180
186
|
* @throws {Error} If decoder is closed
|
|
@@ -193,7 +199,7 @@ export declare class Decoder implements Disposable {
|
|
|
193
199
|
* @example
|
|
194
200
|
* ```typescript
|
|
195
201
|
* for await (const packet of input.packets()) {
|
|
196
|
-
* if (packet.streamIndex === decoder.
|
|
202
|
+
* if (packet.streamIndex === decoder.getStream().index) {
|
|
197
203
|
* const frame = await decoder.decode(packet);
|
|
198
204
|
* if (frame) {
|
|
199
205
|
* await processFrame(frame);
|
|
@@ -209,57 +215,32 @@ export declare class Decoder implements Disposable {
|
|
|
209
215
|
*/
|
|
210
216
|
decode(packet: Packet): Promise<Frame | null>;
|
|
211
217
|
/**
|
|
212
|
-
*
|
|
218
|
+
* Decode a packet to frame synchronously.
|
|
219
|
+
* Synchronous version of decode.
|
|
213
220
|
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
*
|
|
221
|
+
* Send packet to decoder and attempt to receive frame.
|
|
222
|
+
* Handles decoder buffering and error conditions.
|
|
223
|
+
* May return null if decoder needs more data.
|
|
217
224
|
*
|
|
218
|
-
*
|
|
225
|
+
* @param packet - Compressed packet to decode
|
|
219
226
|
*
|
|
220
|
-
* @returns
|
|
227
|
+
* @returns Decoded frame or null
|
|
221
228
|
*
|
|
222
229
|
* @throws {Error} If decoder is closed
|
|
223
230
|
*
|
|
224
|
-
* @
|
|
225
|
-
* ```typescript
|
|
226
|
-
* // After all packets processed
|
|
227
|
-
* let frame;
|
|
228
|
-
* while ((frame = await decoder.flush()) !== null) {
|
|
229
|
-
* console.log('Got buffered frame');
|
|
230
|
-
* await processFrame(frame);
|
|
231
|
-
* frame.free();
|
|
232
|
-
* }
|
|
233
|
-
* ```
|
|
234
|
-
*
|
|
235
|
-
* @see {@link flushFrames} For async iteration
|
|
236
|
-
* @see {@link frames} For complete decoding pipeline
|
|
237
|
-
*/
|
|
238
|
-
flush(): Promise<Frame | null>;
|
|
239
|
-
/**
|
|
240
|
-
* Flush all buffered frames as async generator.
|
|
241
|
-
*
|
|
242
|
-
* Convenient async iteration over remaining frames.
|
|
243
|
-
* Automatically handles repeated flush calls.
|
|
244
|
-
* Useful for end-of-stream processing.
|
|
245
|
-
*
|
|
246
|
-
* @yields Buffered frames
|
|
247
|
-
* @throws {Error} If decoder is closed
|
|
231
|
+
* @throws {FFmpegError} If decoding fails
|
|
248
232
|
*
|
|
249
233
|
* @example
|
|
250
234
|
* ```typescript
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
-
* console.log(
|
|
254
|
-
* await encoder.encode(frame);
|
|
255
|
-
* frame.free();
|
|
235
|
+
* const frame = decoder.decodeSync(packet);
|
|
236
|
+
* if (frame) {
|
|
237
|
+
* console.log(`Decoded: ${frame.width}x${frame.height}`);
|
|
256
238
|
* }
|
|
257
239
|
* ```
|
|
258
240
|
*
|
|
259
|
-
* @see {@link
|
|
260
|
-
* @see {@link frames} For complete pipeline
|
|
241
|
+
* @see {@link decode} For async version
|
|
261
242
|
*/
|
|
262
|
-
|
|
243
|
+
decodeSync(packet: Packet): Frame | null;
|
|
263
244
|
/**
|
|
264
245
|
* Decode packet stream to frame stream.
|
|
265
246
|
*
|
|
@@ -269,7 +250,9 @@ export declare class Decoder implements Disposable {
|
|
|
269
250
|
* Primary interface for stream-based decoding.
|
|
270
251
|
*
|
|
271
252
|
* @param packets - Async iterable of packets
|
|
272
|
-
*
|
|
253
|
+
*
|
|
254
|
+
* @yields {Frame} Decoded frames
|
|
255
|
+
*
|
|
273
256
|
* @throws {Error} If decoder is closed
|
|
274
257
|
*
|
|
275
258
|
* @throws {FFmpegError} If decoding fails
|
|
@@ -289,7 +272,7 @@ export declare class Decoder implements Disposable {
|
|
|
289
272
|
* ```typescript
|
|
290
273
|
* for await (const frame of decoder.frames(input.packets())) {
|
|
291
274
|
* // Process frame
|
|
292
|
-
* await filter.
|
|
275
|
+
* await filter.process(frame);
|
|
293
276
|
*
|
|
294
277
|
* // Frame automatically freed
|
|
295
278
|
* frame.free();
|
|
@@ -314,90 +297,263 @@ export declare class Decoder implements Disposable {
|
|
|
314
297
|
*/
|
|
315
298
|
frames(packets: AsyncIterable<Packet>): AsyncGenerator<Frame>;
|
|
316
299
|
/**
|
|
317
|
-
*
|
|
300
|
+
* Decode packet stream to frame stream synchronously.
|
|
301
|
+
* Synchronous version of frames.
|
|
318
302
|
*
|
|
319
|
-
*
|
|
320
|
-
*
|
|
321
|
-
*
|
|
303
|
+
* High-level sync generator for complete decoding pipeline.
|
|
304
|
+
* Automatically filters packets for this stream, manages memory,
|
|
305
|
+
* and flushes buffered frames at end.
|
|
306
|
+
*
|
|
307
|
+
* @param packets - Iterable of packets
|
|
308
|
+
*
|
|
309
|
+
* @yields {Frame} Decoded frames
|
|
310
|
+
*
|
|
311
|
+
* @throws {Error} If decoder is closed
|
|
312
|
+
*
|
|
313
|
+
* @throws {FFmpegError} If decoding fails
|
|
322
314
|
*
|
|
323
315
|
* @example
|
|
324
316
|
* ```typescript
|
|
325
|
-
* const
|
|
326
|
-
*
|
|
327
|
-
* //
|
|
328
|
-
* } finally {
|
|
329
|
-
* decoder.close();
|
|
317
|
+
* for (const frame of decoder.framesSync(packets)) {
|
|
318
|
+
* console.log(`Frame: ${frame.width}x${frame.height}`);
|
|
319
|
+
* // Process frame...
|
|
330
320
|
* }
|
|
331
321
|
* ```
|
|
332
322
|
*
|
|
333
|
-
* @see {@link
|
|
323
|
+
* @see {@link frames} For async version
|
|
334
324
|
*/
|
|
335
|
-
|
|
325
|
+
framesSync(packets: Iterable<Packet>): Generator<Frame>;
|
|
336
326
|
/**
|
|
337
|
-
*
|
|
327
|
+
* Flush decoder and signal end-of-stream.
|
|
338
328
|
*
|
|
339
|
-
*
|
|
340
|
-
*
|
|
329
|
+
* Sends null packet to decoder to signal end-of-stream.
|
|
330
|
+
* Does nothing if decoder is closed.
|
|
331
|
+
* Must use receive() or flushFrames() to get remaining buffered frames.
|
|
341
332
|
*
|
|
342
|
-
*
|
|
333
|
+
* Direct mapping to avcodec_send_packet(NULL).
|
|
334
|
+
*
|
|
335
|
+
* @throws {FFmpegError} If flush fails
|
|
343
336
|
*
|
|
344
337
|
* @example
|
|
345
338
|
* ```typescript
|
|
346
|
-
*
|
|
347
|
-
*
|
|
339
|
+
* // Signal end of stream
|
|
340
|
+
* await decoder.flush();
|
|
341
|
+
*
|
|
342
|
+
* // Then get remaining frames
|
|
343
|
+
* let frame;
|
|
344
|
+
* while ((frame = await decoder.receive()) !== null) {
|
|
345
|
+
* console.log('Got buffered frame');
|
|
346
|
+
* frame.free();
|
|
348
347
|
* }
|
|
349
348
|
* ```
|
|
350
349
|
*
|
|
351
|
-
* @see {@link
|
|
350
|
+
* @see {@link flushFrames} For convenient async iteration
|
|
351
|
+
* @see {@link receive} For getting buffered frames
|
|
352
352
|
*/
|
|
353
|
-
|
|
353
|
+
flush(): Promise<void>;
|
|
354
354
|
/**
|
|
355
|
-
*
|
|
355
|
+
* Flush decoder and signal end-of-stream synchronously.
|
|
356
|
+
* Synchronous version of flush.
|
|
356
357
|
*
|
|
357
|
-
*
|
|
358
|
-
*
|
|
358
|
+
* Send null packet to signal end of input stream.
|
|
359
|
+
* Decoder may still have buffered frames.
|
|
360
|
+
* Call receiveSync() repeatedly to get remaining frames.
|
|
359
361
|
*
|
|
360
|
-
* @
|
|
362
|
+
* @throws {FFmpegError} If flush fails
|
|
361
363
|
*
|
|
362
364
|
* @example
|
|
363
365
|
* ```typescript
|
|
364
|
-
*
|
|
365
|
-
*
|
|
366
|
-
*
|
|
366
|
+
* decoder.flushSync();
|
|
367
|
+
* // Get remaining frames
|
|
368
|
+
* let frame;
|
|
369
|
+
* while ((frame = decoder.receiveSync()) !== null) {
|
|
370
|
+
* console.log('Buffered frame');
|
|
371
|
+
* }
|
|
367
372
|
* ```
|
|
368
373
|
*
|
|
369
|
-
* @see {@link
|
|
370
|
-
* @see {@link getStreamIndex} For index only
|
|
374
|
+
* @see {@link flush} For async version
|
|
371
375
|
*/
|
|
372
|
-
|
|
376
|
+
flushSync(): void;
|
|
373
377
|
/**
|
|
374
|
-
*
|
|
378
|
+
* Flush all buffered frames as async generator.
|
|
375
379
|
*
|
|
376
|
-
*
|
|
377
|
-
*
|
|
380
|
+
* Convenient async iteration over remaining frames.
|
|
381
|
+
* Automatically sends flush signal and retrieves buffered frames.
|
|
382
|
+
* Useful for end-of-stream processing.
|
|
378
383
|
*
|
|
379
|
-
* @
|
|
384
|
+
* @yields {Frame} Buffered frames
|
|
380
385
|
*
|
|
381
|
-
* @
|
|
386
|
+
* @example
|
|
387
|
+
* ```typescript
|
|
388
|
+
* // Flush at end of decoding
|
|
389
|
+
* for await (const frame of decoder.flushFrames()) {
|
|
390
|
+
* console.log('Processing buffered frame');
|
|
391
|
+
* await encoder.encode(frame);
|
|
392
|
+
* frame.free();
|
|
393
|
+
* }
|
|
394
|
+
* ```
|
|
395
|
+
*
|
|
396
|
+
* @see {@link flush} For signaling end-of-stream
|
|
397
|
+
* @see {@link frames} For complete pipeline
|
|
382
398
|
*/
|
|
383
|
-
|
|
399
|
+
flushFrames(): AsyncGenerator<Frame>;
|
|
400
|
+
/**
|
|
401
|
+
* Flush all buffered frames as generator synchronously.
|
|
402
|
+
* Synchronous version of flushFrames.
|
|
403
|
+
*
|
|
404
|
+
* Convenient sync iteration over remaining frames.
|
|
405
|
+
* Automatically sends flush signal and retrieves buffered frames.
|
|
406
|
+
* Useful for end-of-stream processing.
|
|
407
|
+
*
|
|
408
|
+
* @yields {Frame} Buffered frames
|
|
409
|
+
*
|
|
410
|
+
* @example
|
|
411
|
+
* ```typescript
|
|
412
|
+
* // Flush at end of decoding
|
|
413
|
+
* for (const frame of decoder.flushFramesSync()) {
|
|
414
|
+
* console.log('Processing buffered frame');
|
|
415
|
+
* encoder.encodeSync(frame);
|
|
416
|
+
* frame.free();
|
|
417
|
+
* }
|
|
418
|
+
* ```
|
|
419
|
+
*
|
|
420
|
+
* @see {@link flushFrames} For async version
|
|
421
|
+
*/
|
|
422
|
+
flushFramesSync(): Generator<Frame>;
|
|
384
423
|
/**
|
|
385
424
|
* Receive frame from decoder.
|
|
386
425
|
*
|
|
387
|
-
*
|
|
426
|
+
* Gets decoded frames from the codec's internal buffer.
|
|
388
427
|
* Handles frame cloning and error checking.
|
|
389
428
|
* Hardware frames include hw_frames_ctx reference.
|
|
429
|
+
* Call repeatedly until null to drain all buffered frames.
|
|
390
430
|
*
|
|
391
431
|
* Direct mapping to avcodec_receive_frame().
|
|
392
432
|
*
|
|
393
|
-
* @returns Cloned frame or null
|
|
433
|
+
* @returns Cloned frame or null if no frames available
|
|
394
434
|
*
|
|
395
435
|
* @throws {FFmpegError} If receive fails with error other than AVERROR_EAGAIN or AVERROR_EOF
|
|
396
436
|
*
|
|
437
|
+
* @example
|
|
438
|
+
* ```typescript
|
|
439
|
+
* const frame = await decoder.receive();
|
|
440
|
+
* if (frame) {
|
|
441
|
+
* console.log('Got decoded frame');
|
|
442
|
+
* frame.free();
|
|
443
|
+
* }
|
|
444
|
+
* ```
|
|
445
|
+
*
|
|
446
|
+
* @example
|
|
447
|
+
* ```typescript
|
|
448
|
+
* // Drain all buffered frames
|
|
449
|
+
* let frame;
|
|
450
|
+
* while ((frame = await decoder.receive()) !== null) {
|
|
451
|
+
* console.log(`Frame PTS: ${frame.pts}`);
|
|
452
|
+
* frame.free();
|
|
453
|
+
* }
|
|
454
|
+
* ```
|
|
455
|
+
*
|
|
456
|
+
* @see {@link decode} For sending packets and receiving frames
|
|
457
|
+
* @see {@link flush} For signaling end-of-stream
|
|
458
|
+
*/
|
|
459
|
+
receive(): Promise<Frame | null>;
|
|
460
|
+
/**
|
|
461
|
+
* Receive frame from decoder synchronously.
|
|
462
|
+
* Synchronous version of receive.
|
|
463
|
+
*
|
|
464
|
+
* Gets decoded frames from the codec's internal buffer.
|
|
465
|
+
* Handles frame cloning and error checking.
|
|
466
|
+
* Hardware frames include hw_frames_ctx reference.
|
|
467
|
+
* Call repeatedly until null to drain all buffered frames.
|
|
468
|
+
*
|
|
469
|
+
* Direct mapping to avcodec_receive_frame().
|
|
470
|
+
*
|
|
471
|
+
* @returns Cloned frame or null if no frames available
|
|
472
|
+
*
|
|
473
|
+
* @throws {FFmpegError} If receive fails with error other than AVERROR_EAGAIN or AVERROR_EOF
|
|
474
|
+
*
|
|
475
|
+
* @example
|
|
476
|
+
* ```typescript
|
|
477
|
+
* const frame = decoder.receiveSync();
|
|
478
|
+
* if (frame) {
|
|
479
|
+
* console.log('Got decoded frame');
|
|
480
|
+
* frame.free();
|
|
481
|
+
* }
|
|
482
|
+
* ```
|
|
483
|
+
*
|
|
484
|
+
* @example
|
|
485
|
+
* ```typescript
|
|
486
|
+
* // Drain all buffered frames
|
|
487
|
+
* let frame;
|
|
488
|
+
* while ((frame = decoder.receiveSync()) !== null) {
|
|
489
|
+
* console.log(`Frame PTS: ${frame.pts}`);
|
|
490
|
+
* frame.free();
|
|
491
|
+
* }
|
|
492
|
+
* ```
|
|
493
|
+
*
|
|
494
|
+
* @see {@link receive} For async version
|
|
495
|
+
*/
|
|
496
|
+
receiveSync(): Frame | null;
|
|
497
|
+
/**
|
|
498
|
+
* Close decoder and free resources.
|
|
499
|
+
*
|
|
500
|
+
* Releases codec context and internal frame buffer.
|
|
501
|
+
* Safe to call multiple times.
|
|
502
|
+
* Automatically called by Symbol.dispose.
|
|
503
|
+
*
|
|
504
|
+
* @example
|
|
505
|
+
* ```typescript
|
|
506
|
+
* const decoder = await Decoder.create(stream);
|
|
507
|
+
* try {
|
|
508
|
+
* // Use decoder
|
|
509
|
+
* } finally {
|
|
510
|
+
* decoder.close();
|
|
511
|
+
* }
|
|
512
|
+
* ```
|
|
513
|
+
*
|
|
514
|
+
* @see {@link Symbol.dispose} For automatic cleanup
|
|
515
|
+
*/
|
|
516
|
+
close(): void;
|
|
517
|
+
/**
|
|
518
|
+
* Get stream object.
|
|
519
|
+
*
|
|
520
|
+
* Returns the underlying stream being decoded.
|
|
521
|
+
* Provides access to stream metadata and parameters.
|
|
522
|
+
*
|
|
523
|
+
* @returns Stream object
|
|
524
|
+
*
|
|
397
525
|
* @internal
|
|
398
526
|
*
|
|
527
|
+
* @see {@link Stream} For stream details
|
|
399
528
|
*/
|
|
400
|
-
|
|
529
|
+
getStream(): Stream;
|
|
530
|
+
/**
|
|
531
|
+
* Get decoder codec.
|
|
532
|
+
*
|
|
533
|
+
* Returns the codec used by this decoder.
|
|
534
|
+
* Useful for checking codec capabilities and properties.
|
|
535
|
+
*
|
|
536
|
+
* @returns Codec instance
|
|
537
|
+
*
|
|
538
|
+
* @internal
|
|
539
|
+
*
|
|
540
|
+
* @see {@link Codec} For codec details
|
|
541
|
+
*/
|
|
542
|
+
getCodec(): Codec;
|
|
543
|
+
/**
|
|
544
|
+
* Get underlying codec context.
|
|
545
|
+
*
|
|
546
|
+
* Returns the codec context for advanced operations.
|
|
547
|
+
* Useful for accessing low-level codec properties and settings.
|
|
548
|
+
* Returns null if decoder is closed.
|
|
549
|
+
*
|
|
550
|
+
* @returns Codec context or null if closed
|
|
551
|
+
*
|
|
552
|
+
* @internal
|
|
553
|
+
*
|
|
554
|
+
* @see {@link CodecContext} For context details
|
|
555
|
+
*/
|
|
556
|
+
getCodecContext(): CodecContext | null;
|
|
401
557
|
/**
|
|
402
558
|
* Dispose of decoder.
|
|
403
559
|
*
|