node-av 4.0.0 → 5.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/README.md +23 -0
- package/binding.gyp +19 -11
- package/dist/api/bitstream-filter.d.ts +13 -12
- package/dist/api/bitstream-filter.js +33 -29
- package/dist/api/bitstream-filter.js.map +1 -1
- package/dist/api/decoder.d.ts +211 -96
- package/dist/api/decoder.js +396 -375
- package/dist/api/decoder.js.map +1 -1
- package/dist/api/demuxer.d.ts +10 -10
- package/dist/api/demuxer.js +7 -10
- package/dist/api/demuxer.js.map +1 -1
- package/dist/api/encoder.d.ts +155 -122
- package/dist/api/encoder.js +368 -541
- package/dist/api/encoder.js.map +1 -1
- package/dist/api/filter-complex.d.ts +769 -0
- package/dist/api/filter-complex.js +1596 -0
- package/dist/api/filter-complex.js.map +1 -0
- package/dist/api/filter-presets.d.ts +68 -0
- package/dist/api/filter-presets.js +96 -0
- package/dist/api/filter-presets.js.map +1 -1
- package/dist/api/filter.d.ts +183 -113
- package/dist/api/filter.js +347 -365
- package/dist/api/filter.js.map +1 -1
- package/dist/api/fmp4-stream.d.ts +18 -2
- package/dist/api/fmp4-stream.js +45 -4
- package/dist/api/fmp4-stream.js.map +1 -1
- package/dist/api/hardware.d.ts +47 -0
- package/dist/api/hardware.js +45 -0
- package/dist/api/hardware.js.map +1 -1
- package/dist/api/index.d.ts +2 -0
- package/dist/api/index.js +3 -0
- package/dist/api/index.js.map +1 -1
- package/dist/api/io-stream.d.ts +3 -3
- package/dist/api/io-stream.js.map +1 -1
- package/dist/api/muxer.d.ts +10 -10
- package/dist/api/muxer.js +6 -6
- package/dist/api/muxer.js.map +1 -1
- package/dist/api/pipeline.d.ts +2 -2
- package/dist/api/pipeline.js +22 -22
- package/dist/api/pipeline.js.map +1 -1
- package/dist/api/rtp-stream.d.ts +5 -2
- package/dist/api/rtp-stream.js +33 -4
- package/dist/api/rtp-stream.js.map +1 -1
- package/dist/api/types.d.ts +63 -7
- package/dist/api/utilities/audio-sample.d.ts +10 -0
- package/dist/api/utilities/audio-sample.js +10 -0
- package/dist/api/utilities/audio-sample.js.map +1 -1
- package/dist/api/utilities/channel-layout.d.ts +1 -0
- package/dist/api/utilities/channel-layout.js +1 -0
- package/dist/api/utilities/channel-layout.js.map +1 -1
- package/dist/api/utilities/image.d.ts +38 -0
- package/dist/api/utilities/image.js +38 -0
- package/dist/api/utilities/image.js.map +1 -1
- package/dist/api/utilities/index.d.ts +1 -0
- package/dist/api/utilities/index.js +2 -0
- package/dist/api/utilities/index.js.map +1 -1
- package/dist/api/utilities/media-type.d.ts +1 -0
- package/dist/api/utilities/media-type.js +1 -0
- package/dist/api/utilities/media-type.js.map +1 -1
- package/dist/api/utilities/pixel-format.d.ts +3 -0
- package/dist/api/utilities/pixel-format.js +3 -0
- package/dist/api/utilities/pixel-format.js.map +1 -1
- package/dist/api/utilities/sample-format.d.ts +5 -0
- package/dist/api/utilities/sample-format.js +5 -0
- package/dist/api/utilities/sample-format.js.map +1 -1
- package/dist/api/utilities/scheduler.d.ts +21 -52
- package/dist/api/utilities/scheduler.js +20 -58
- package/dist/api/utilities/scheduler.js.map +1 -1
- package/dist/api/utilities/streaming.d.ts +32 -1
- package/dist/api/utilities/streaming.js +32 -1
- package/dist/api/utilities/streaming.js.map +1 -1
- package/dist/api/utilities/timestamp.d.ts +14 -0
- package/dist/api/utilities/timestamp.js +14 -0
- package/dist/api/utilities/timestamp.js.map +1 -1
- package/dist/api/utilities/whisper-model.d.ts +310 -0
- package/dist/api/utilities/whisper-model.js +528 -0
- package/dist/api/utilities/whisper-model.js.map +1 -0
- package/dist/api/whisper.d.ts +324 -0
- package/dist/api/whisper.js +362 -0
- package/dist/api/whisper.js.map +1 -0
- package/dist/constants/constants.d.ts +3 -1
- package/dist/constants/constants.js +1 -0
- package/dist/constants/constants.js.map +1 -1
- package/dist/ffmpeg/index.d.ts +3 -3
- package/dist/ffmpeg/index.js +3 -3
- package/dist/ffmpeg/utils.d.ts +27 -0
- package/dist/ffmpeg/utils.js +28 -16
- package/dist/ffmpeg/utils.js.map +1 -1
- package/dist/lib/binding.d.ts +4 -4
- package/dist/lib/binding.js.map +1 -1
- package/dist/lib/codec-parameters.d.ts +47 -1
- package/dist/lib/codec-parameters.js +55 -0
- package/dist/lib/codec-parameters.js.map +1 -1
- package/dist/lib/fifo.d.ts +416 -0
- package/dist/lib/fifo.js +453 -0
- package/dist/lib/fifo.js.map +1 -0
- package/dist/lib/frame.d.ts +96 -1
- package/dist/lib/frame.js +139 -1
- package/dist/lib/frame.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/native-types.d.ts +29 -2
- package/dist/lib/rational.d.ts +18 -0
- package/dist/lib/rational.js +19 -0
- package/dist/lib/rational.js.map +1 -1
- package/dist/lib/types.d.ts +23 -1
- package/install/check.js +2 -2
- package/package.json +31 -21
package/dist/api/filter.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Frame } from '../lib/frame.js';
|
|
2
2
|
import { Scheduler } from './utilities/scheduler.js';
|
|
3
|
-
import type { AVColorRange, AVColorSpace, AVFilterCmdFlag, AVPixelFormat, AVSampleFormat } from '../constants/index.js';
|
|
3
|
+
import type { AVColorRange, AVColorSpace, AVFilterCmdFlag, AVPixelFormat, AVSampleFormat, EOFSignal } from '../constants/index.js';
|
|
4
4
|
import type { FilterContext } from '../lib/filter-context.js';
|
|
5
5
|
import type { ChannelLayout, IDimension, IRational } from '../lib/types.js';
|
|
6
6
|
import type { Encoder } from './encoder.js';
|
|
@@ -72,11 +72,6 @@ export declare class FilterAPI implements Disposable {
|
|
|
72
72
|
/**
|
|
73
73
|
* Create a filter with specified description and configuration.
|
|
74
74
|
*
|
|
75
|
-
* Creates and allocates filter graph immediately.
|
|
76
|
-
* Filter configuration is completed on first frame with frame properties.
|
|
77
|
-
* TimeBase is automatically calculated from first frame based on CFR option.
|
|
78
|
-
* Hardware frames context is automatically detected from input frames.
|
|
79
|
-
*
|
|
80
75
|
* Direct mapping to avfilter_graph_parse_ptr() and avfilter_graph_config().
|
|
81
76
|
*
|
|
82
77
|
* @param description - Filter graph description
|
|
@@ -163,7 +158,6 @@ export declare class FilterAPI implements Disposable {
|
|
|
163
158
|
* Output frame rate from filter graph.
|
|
164
159
|
*
|
|
165
160
|
* Returns the frame rate determined by the filter graph output.
|
|
166
|
-
* Matches FFmpeg CLI's av_buffersink_get_frame_rate() behavior.
|
|
167
161
|
* Returns null if filter is not initialized or frame rate is not set.
|
|
168
162
|
*
|
|
169
163
|
* Direct mapping to av_buffersink_get_frame_rate().
|
|
@@ -372,32 +366,33 @@ export declare class FilterAPI implements Disposable {
|
|
|
372
366
|
*/
|
|
373
367
|
getGraphDescription(): string | null;
|
|
374
368
|
/**
|
|
375
|
-
*
|
|
369
|
+
* Send a frame to the filter.
|
|
376
370
|
*
|
|
377
|
-
*
|
|
371
|
+
* Sends a frame to the filter for processing.
|
|
372
|
+
* Does not return filtered frames - use {@link receive} to retrieve frames.
|
|
378
373
|
* On first frame, automatically builds filter graph with frame properties.
|
|
379
|
-
*
|
|
380
|
-
* Hardware frames context is automatically detected from frame.
|
|
381
|
-
* Returns null if filter is closed and frame is null.
|
|
382
|
-
*
|
|
383
|
-
* **Note**: This method receives only ONE frame per call.
|
|
384
|
-
* A single input frame can produce multiple output frames (e.g., fps filter, deinterlace).
|
|
385
|
-
* To receive all frames from an input, use {@link processAll} or {@link frames} instead.
|
|
374
|
+
* A single input frame can produce zero, one, or multiple output frames.
|
|
386
375
|
*
|
|
387
|
-
*
|
|
376
|
+
* **Important**: This method only SENDS the frame to the filter.
|
|
377
|
+
* You must call {@link receive} separately (potentially multiple times) to get filtered frames.
|
|
388
378
|
*
|
|
389
|
-
*
|
|
379
|
+
* Direct mapping to av_buffersrc_add_frame().
|
|
390
380
|
*
|
|
391
|
-
* @
|
|
381
|
+
* @param frame - Input frame to send to filter
|
|
392
382
|
*
|
|
393
383
|
* @throws {Error} If filter could not be initialized
|
|
394
384
|
*
|
|
395
|
-
* @throws {FFmpegError} If
|
|
385
|
+
* @throws {FFmpegError} If sending frame fails
|
|
396
386
|
*
|
|
397
387
|
* @example
|
|
398
388
|
* ```typescript
|
|
399
|
-
*
|
|
400
|
-
*
|
|
389
|
+
* // Send frame and receive filtered frames
|
|
390
|
+
* await filter.process(inputFrame);
|
|
391
|
+
*
|
|
392
|
+
* // Receive all available filtered frames
|
|
393
|
+
* while (true) {
|
|
394
|
+
* const output = await filter.receive();
|
|
395
|
+
* if (!output) break;
|
|
401
396
|
* console.log(`Got filtered frame: pts=${output.pts}`);
|
|
402
397
|
* output.free();
|
|
403
398
|
* }
|
|
@@ -405,71 +400,67 @@ export declare class FilterAPI implements Disposable {
|
|
|
405
400
|
*
|
|
406
401
|
* @example
|
|
407
402
|
* ```typescript
|
|
408
|
-
*
|
|
409
|
-
*
|
|
410
|
-
*
|
|
411
|
-
*
|
|
412
|
-
*
|
|
403
|
+
* for await (const frame of decoder.frames(input.packets())) {
|
|
404
|
+
* // Send frame
|
|
405
|
+
* await filter.process(frame);
|
|
406
|
+
*
|
|
407
|
+
* // Receive available filtered frames
|
|
408
|
+
* let output;
|
|
409
|
+
* while ((output = await filter.receive())) {
|
|
410
|
+
* await encoder.encode(output);
|
|
411
|
+
* output.free();
|
|
412
|
+
* }
|
|
413
|
+
* frame.free();
|
|
413
414
|
* }
|
|
414
|
-
* // For buffered frames, use the frames() async generator
|
|
415
415
|
* ```
|
|
416
416
|
*
|
|
417
|
-
* @see {@link
|
|
417
|
+
* @see {@link receive} For receiving filtered frames
|
|
418
|
+
* @see {@link processAll} For combined send+receive operation
|
|
418
419
|
* @see {@link frames} For processing frame streams
|
|
419
420
|
* @see {@link flush} For end-of-stream handling
|
|
420
421
|
* @see {@link processSync} For synchronous version
|
|
421
422
|
*/
|
|
422
|
-
process(frame: Frame
|
|
423
|
+
process(frame: Frame): Promise<void>;
|
|
423
424
|
/**
|
|
424
|
-
*
|
|
425
|
+
* Send a frame to the filter synchronously.
|
|
425
426
|
* Synchronous version of process.
|
|
426
427
|
*
|
|
427
|
-
*
|
|
428
|
+
* Sends a frame to the filter for processing.
|
|
429
|
+
* Does not return filtered frames - use {@link receiveSync} to retrieve frames.
|
|
428
430
|
* On first frame, automatically builds filter graph with frame properties.
|
|
429
|
-
*
|
|
430
|
-
* Hardware frames context is automatically detected from frame.
|
|
431
|
-
* Returns null if filter is closed and frame is null.
|
|
432
|
-
*
|
|
433
|
-
* **Note**: This method receives only ONE frame per call.
|
|
434
|
-
* A single input frame can produce multiple output frames (e.g., fps filter, deinterlace).
|
|
435
|
-
* To receive all frames from an input, use {@link processAllSync} or {@link framesSync} instead.
|
|
431
|
+
* A single input frame can produce zero, one, or multiple output frames.
|
|
436
432
|
*
|
|
437
|
-
*
|
|
433
|
+
* **Important**: This method only SENDS the frame to the filter.
|
|
434
|
+
* You must call {@link receiveSync} separately (potentially multiple times) to get filtered frames.
|
|
438
435
|
*
|
|
439
|
-
*
|
|
436
|
+
* Direct mapping to av_buffersrc_add_frame().
|
|
440
437
|
*
|
|
441
|
-
* @
|
|
438
|
+
* @param frame - Input frame to send to filter
|
|
442
439
|
*
|
|
443
440
|
* @throws {Error} If filter could not be initialized
|
|
444
441
|
*
|
|
445
|
-
* @throws {FFmpegError} If
|
|
442
|
+
* @throws {FFmpegError} If sending frame fails
|
|
446
443
|
*
|
|
447
444
|
* @example
|
|
448
445
|
* ```typescript
|
|
449
|
-
*
|
|
450
|
-
*
|
|
446
|
+
* // Send frame and receive filtered frames
|
|
447
|
+
* filter.processSync(inputFrame);
|
|
448
|
+
*
|
|
449
|
+
* // Receive all available filtered frames
|
|
450
|
+
* let output;
|
|
451
|
+
* while ((output = filter.receiveSync())) {
|
|
451
452
|
* console.log(`Got filtered frame: pts=${output.pts}`);
|
|
452
453
|
* output.free();
|
|
453
454
|
* }
|
|
454
455
|
* ```
|
|
455
456
|
*
|
|
456
|
-
* @
|
|
457
|
-
*
|
|
458
|
-
* // Process frame - may buffer internally
|
|
459
|
-
* const output = filter.processSync(frame);
|
|
460
|
-
* if (output) {
|
|
461
|
-
* // Got output immediately
|
|
462
|
-
* yield output;
|
|
463
|
-
* }
|
|
464
|
-
* // For buffered frames, use the framesSync() generator
|
|
465
|
-
* ```
|
|
466
|
-
*
|
|
467
|
-
* @see {@link processAllSync} For processing multiple output frames
|
|
457
|
+
* @see {@link receiveSync} For receiving filtered frames
|
|
458
|
+
* @see {@link processAllSync} For combined send+receive operation
|
|
468
459
|
* @see {@link framesSync} For processing frame streams
|
|
469
460
|
* @see {@link flushSync} For end-of-stream handling
|
|
470
461
|
* @see {@link process} For async version
|
|
471
462
|
*/
|
|
472
|
-
processSync(frame: Frame
|
|
463
|
+
processSync(frame: Frame): void;
|
|
473
464
|
/**
|
|
474
465
|
* Process a frame through the filter.
|
|
475
466
|
*
|
|
@@ -481,7 +472,7 @@ export declare class FilterAPI implements Disposable {
|
|
|
481
472
|
*
|
|
482
473
|
* Direct mapping to av_buffersrc_add_frame() and av_buffersink_get_frame().
|
|
483
474
|
*
|
|
484
|
-
* @param frame - Input frame to process
|
|
475
|
+
* @param frame - Input frame to process
|
|
485
476
|
*
|
|
486
477
|
* @returns Array of filtered frames (empty if buffered or filter closed)
|
|
487
478
|
*
|
|
@@ -525,7 +516,7 @@ export declare class FilterAPI implements Disposable {
|
|
|
525
516
|
*
|
|
526
517
|
* Direct mapping to av_buffersrc_add_frame() and av_buffersink_get_frame().
|
|
527
518
|
*
|
|
528
|
-
* @param frame - Input frame to process
|
|
519
|
+
* @param frame - Input frame to process
|
|
529
520
|
*
|
|
530
521
|
* @returns Array of filtered frames (empty if buffered or filter closed)
|
|
531
522
|
*
|
|
@@ -556,17 +547,22 @@ export declare class FilterAPI implements Disposable {
|
|
|
556
547
|
* @see {@link flushSync} For end-of-stream handling
|
|
557
548
|
* @see {@link process} For async version
|
|
558
549
|
*/
|
|
559
|
-
processAllSync(frame: Frame
|
|
550
|
+
processAllSync(frame: Frame): Frame[];
|
|
560
551
|
/**
|
|
561
552
|
* Process frame stream through filter.
|
|
562
553
|
*
|
|
563
554
|
* High-level async generator for filtering frame streams.
|
|
564
|
-
*
|
|
565
|
-
*
|
|
555
|
+
* Filter is only flushed when EOF (null) signal is explicitly received.
|
|
556
|
+
* Primary interface for stream-based filtering.
|
|
557
|
+
*
|
|
558
|
+
* **EOF Handling:**
|
|
559
|
+
* - Send null to flush filter and get remaining buffered frames
|
|
560
|
+
* - Generator yields null after flushing when null is received
|
|
561
|
+
* - No automatic flushing - filter stays open until EOF or close()
|
|
566
562
|
*
|
|
567
|
-
* @param frames - Async
|
|
563
|
+
* @param frames - Async iterable of frames, single frame, or null to flush
|
|
568
564
|
*
|
|
569
|
-
* @yields {Frame} Filtered frames
|
|
565
|
+
* @yields {Frame | null} Filtered frames, followed by null when explicitly flushed
|
|
570
566
|
*
|
|
571
567
|
* @throws {Error} If filter not ready
|
|
572
568
|
*
|
|
@@ -574,8 +570,12 @@ export declare class FilterAPI implements Disposable {
|
|
|
574
570
|
*
|
|
575
571
|
* @example
|
|
576
572
|
* ```typescript
|
|
577
|
-
* //
|
|
573
|
+
* // Stream of frames with automatic EOF propagation
|
|
578
574
|
* for await (const frame of filter.frames(decoder.frames(packets))) {
|
|
575
|
+
* if (frame === null) {
|
|
576
|
+
* console.log('Filter flushed');
|
|
577
|
+
* break;
|
|
578
|
+
* }
|
|
579
579
|
* await encoder.encode(frame);
|
|
580
580
|
* frame.free();
|
|
581
581
|
* }
|
|
@@ -583,16 +583,23 @@ export declare class FilterAPI implements Disposable {
|
|
|
583
583
|
*
|
|
584
584
|
* @example
|
|
585
585
|
* ```typescript
|
|
586
|
-
* //
|
|
587
|
-
* const
|
|
588
|
-
*
|
|
589
|
-
*
|
|
590
|
-
*
|
|
591
|
-
*
|
|
592
|
-
*
|
|
586
|
+
* // Single frame - no automatic flush
|
|
587
|
+
* for await (const frame of filter.frames(singleFrame)) {
|
|
588
|
+
* await encoder.encode(frame);
|
|
589
|
+
* frame.free();
|
|
590
|
+
* }
|
|
591
|
+
* // Filter remains open, buffered frames not flushed
|
|
592
|
+
* ```
|
|
593
593
|
*
|
|
594
|
-
*
|
|
595
|
-
*
|
|
594
|
+
* @example
|
|
595
|
+
* ```typescript
|
|
596
|
+
* // Explicit flush with EOF
|
|
597
|
+
* for await (const frame of filter.frames(null)) {
|
|
598
|
+
* if (frame === null) {
|
|
599
|
+
* console.log('All buffered frames flushed');
|
|
600
|
+
* break;
|
|
601
|
+
* }
|
|
602
|
+
* console.log('Buffered frame:', frame.pts);
|
|
596
603
|
* frame.free();
|
|
597
604
|
* }
|
|
598
605
|
* ```
|
|
@@ -601,18 +608,23 @@ export declare class FilterAPI implements Disposable {
|
|
|
601
608
|
* @see {@link Decoder.frames} For frames source
|
|
602
609
|
* @see {@link framesSync} For sync version
|
|
603
610
|
*/
|
|
604
|
-
frames(frames: AsyncIterable<Frame | null>): AsyncGenerator<Frame | null>;
|
|
611
|
+
frames(frames: AsyncIterable<Frame | null> | Frame | null): AsyncGenerator<Frame | null>;
|
|
605
612
|
/**
|
|
606
613
|
* Process frame stream through filter synchronously.
|
|
607
614
|
* Synchronous version of frames.
|
|
608
615
|
*
|
|
609
616
|
* High-level sync generator for filtering frame streams.
|
|
610
|
-
*
|
|
611
|
-
*
|
|
617
|
+
* Filter is only flushed when EOF (null) signal is explicitly received.
|
|
618
|
+
* Primary interface for stream-based filtering.
|
|
612
619
|
*
|
|
613
|
-
*
|
|
620
|
+
* **EOF Handling:**
|
|
621
|
+
* - Send null to flush filter and get remaining buffered frames
|
|
622
|
+
* - Generator yields null after flushing when null is received
|
|
623
|
+
* - No automatic flushing - filter stays open until EOF or close()
|
|
614
624
|
*
|
|
615
|
-
* @
|
|
625
|
+
* @param frames - Iterable of frames, single frame, or null to flush
|
|
626
|
+
*
|
|
627
|
+
* @yields {Frame | null} Filtered frames, followed by null when explicitly flushed
|
|
616
628
|
*
|
|
617
629
|
* @throws {Error} If filter not ready
|
|
618
630
|
*
|
|
@@ -620,8 +632,12 @@ export declare class FilterAPI implements Disposable {
|
|
|
620
632
|
*
|
|
621
633
|
* @example
|
|
622
634
|
* ```typescript
|
|
623
|
-
* //
|
|
635
|
+
* // Stream of frames with automatic EOF propagation
|
|
624
636
|
* for (const frame of filter.framesSync(decoder.framesSync(packets))) {
|
|
637
|
+
* if (frame === null) {
|
|
638
|
+
* console.log('Filter flushed');
|
|
639
|
+
* break;
|
|
640
|
+
* }
|
|
625
641
|
* encoder.encodeSync(frame);
|
|
626
642
|
* frame.free();
|
|
627
643
|
* }
|
|
@@ -629,16 +645,23 @@ export declare class FilterAPI implements Disposable {
|
|
|
629
645
|
*
|
|
630
646
|
* @example
|
|
631
647
|
* ```typescript
|
|
632
|
-
* //
|
|
633
|
-
* const
|
|
634
|
-
*
|
|
635
|
-
*
|
|
636
|
-
*
|
|
637
|
-
*
|
|
638
|
-
*
|
|
648
|
+
* // Single frame - no automatic flush
|
|
649
|
+
* for (const frame of filter.framesSync(singleFrame)) {
|
|
650
|
+
* encoder.encodeSync(frame);
|
|
651
|
+
* frame.free();
|
|
652
|
+
* }
|
|
653
|
+
* // Filter remains open, buffered frames not flushed
|
|
654
|
+
* ```
|
|
639
655
|
*
|
|
640
|
-
*
|
|
641
|
-
*
|
|
656
|
+
* @example
|
|
657
|
+
* ```typescript
|
|
658
|
+
* // Explicit flush with EOF
|
|
659
|
+
* for (const frame of filter.framesSync(null)) {
|
|
660
|
+
* if (frame === null) {
|
|
661
|
+
* console.log('All buffered frames flushed');
|
|
662
|
+
* break;
|
|
663
|
+
* }
|
|
664
|
+
* console.log('Buffered frame:', frame.pts);
|
|
642
665
|
* frame.free();
|
|
643
666
|
* }
|
|
644
667
|
* ```
|
|
@@ -647,7 +670,7 @@ export declare class FilterAPI implements Disposable {
|
|
|
647
670
|
* @see {@link Decoder.framesSync} For frames source
|
|
648
671
|
* @see {@link frames} For async version
|
|
649
672
|
*/
|
|
650
|
-
framesSync(frames:
|
|
673
|
+
framesSync(frames: Iterable<Frame | null> | Frame | null): Generator<Frame | null>;
|
|
651
674
|
/**
|
|
652
675
|
* Flush filter and signal end-of-stream.
|
|
653
676
|
*
|
|
@@ -754,57 +777,101 @@ export declare class FilterAPI implements Disposable {
|
|
|
754
777
|
* Receive buffered frame from filter.
|
|
755
778
|
*
|
|
756
779
|
* Drains frames buffered by the filter.
|
|
757
|
-
* Call repeatedly until null to get all buffered frames.
|
|
758
|
-
*
|
|
780
|
+
* Call repeatedly until null or EOF to get all buffered frames.
|
|
781
|
+
* Implements FFmpeg's send/receive pattern.
|
|
782
|
+
*
|
|
783
|
+
* **Return Values:**
|
|
784
|
+
* - `Frame` - Successfully received frame (AVERROR >= 0)
|
|
785
|
+
* - `null` - Need more input data (AVERROR_EAGAIN), or filter not initialized
|
|
786
|
+
* - `undefined` - End of stream reached (AVERROR_EOF), or filter is closed
|
|
759
787
|
*
|
|
760
788
|
* Direct mapping to av_buffersink_get_frame().
|
|
761
789
|
*
|
|
762
|
-
* @returns Buffered frame or
|
|
790
|
+
* @returns Buffered frame, null if need more data, or undefined if stream ended
|
|
763
791
|
*
|
|
764
792
|
* @throws {FFmpegError} If receiving fails
|
|
765
793
|
*
|
|
766
794
|
* @example
|
|
767
795
|
* ```typescript
|
|
768
|
-
*
|
|
769
|
-
* while (
|
|
796
|
+
* // Process all buffered frames
|
|
797
|
+
* while (true) {
|
|
798
|
+
* const frame = await filter.receive();
|
|
799
|
+
* if (!frame) break; // Stop on EAGAIN or EOF
|
|
770
800
|
* console.log(`Received frame: pts=${frame.pts}`);
|
|
771
801
|
* frame.free();
|
|
772
802
|
* }
|
|
773
803
|
* ```
|
|
774
804
|
*
|
|
805
|
+
* @example
|
|
806
|
+
* ```typescript
|
|
807
|
+
* // Handle each return value explicitly
|
|
808
|
+
* const frame = await filter.receive();
|
|
809
|
+
* if (frame === EOF) {
|
|
810
|
+
* console.log('Filter stream ended');
|
|
811
|
+
* } else if (frame === null) {
|
|
812
|
+
* console.log('Need more input data');
|
|
813
|
+
* } else {
|
|
814
|
+
* console.log(`Got frame: pts=${frame.pts}`);
|
|
815
|
+
* frame.free();
|
|
816
|
+
* }
|
|
817
|
+
* ```
|
|
818
|
+
*
|
|
775
819
|
* @see {@link process} For frame processing
|
|
776
820
|
* @see {@link flush} For flushing filter
|
|
777
821
|
* @see {@link receiveSync} For synchronous version
|
|
822
|
+
* @see {@link EOF} For end-of-stream signal
|
|
778
823
|
*/
|
|
779
|
-
receive(): Promise<Frame | null>;
|
|
824
|
+
receive(): Promise<Frame | EOFSignal | null>;
|
|
780
825
|
/**
|
|
781
826
|
* Receive buffered frame from filter synchronously.
|
|
782
827
|
* Synchronous version of receive.
|
|
783
828
|
*
|
|
784
829
|
* Drains frames buffered by the filter.
|
|
785
|
-
* Call repeatedly until null to get all buffered frames.
|
|
786
|
-
*
|
|
830
|
+
* Call repeatedly until null or EOF to get all buffered frames.
|
|
831
|
+
* Implements FFmpeg's send/receive pattern.
|
|
832
|
+
*
|
|
833
|
+
* **Return Values:**
|
|
834
|
+
* - `Frame` - Successfully received frame (AVERROR >= 0)
|
|
835
|
+
* - `null` - Need more input data (AVERROR_EAGAIN), or filter not initialized
|
|
836
|
+
* - `undefined` - End of stream reached (AVERROR_EOF), or filter is closed
|
|
787
837
|
*
|
|
788
838
|
* Direct mapping to av_buffersink_get_frame().
|
|
789
839
|
*
|
|
790
|
-
* @returns Buffered frame or
|
|
840
|
+
* @returns Buffered frame, null if need more data, or undefined if stream ended
|
|
791
841
|
*
|
|
792
842
|
* @throws {FFmpegError} If receiving fails
|
|
793
843
|
*
|
|
794
844
|
* @example
|
|
795
845
|
* ```typescript
|
|
796
|
-
*
|
|
797
|
-
* while (
|
|
846
|
+
* // Process all buffered frames
|
|
847
|
+
* while (true) {
|
|
848
|
+
* const frame = filter.receiveSync();
|
|
849
|
+
* if (!frame) break; // Stop on EAGAIN or EOF
|
|
798
850
|
* console.log(`Received frame: pts=${frame.pts}`);
|
|
799
851
|
* frame.free();
|
|
800
852
|
* }
|
|
801
853
|
* ```
|
|
802
854
|
*
|
|
855
|
+
* @example
|
|
856
|
+
* ```typescript
|
|
857
|
+
* // Handle each return value explicitly
|
|
858
|
+
* const frame = filter.receiveSync();
|
|
859
|
+
* if (frame === EOF) {
|
|
860
|
+
* console.log('Filter stream ended');
|
|
861
|
+
* } else if (frame === null) {
|
|
862
|
+
* console.log('Need more input data');
|
|
863
|
+
* } else {
|
|
864
|
+
* console.log(`Got frame: pts=${frame.pts}`);
|
|
865
|
+
* frame.free();
|
|
866
|
+
* }
|
|
867
|
+
* ```
|
|
868
|
+
*
|
|
803
869
|
* @see {@link processSync} For frame processing
|
|
804
870
|
* @see {@link flushSync} For flushing filter
|
|
805
871
|
* @see {@link receive} For async version
|
|
872
|
+
* @see {@link EOF} For end-of-stream signal
|
|
806
873
|
*/
|
|
807
|
-
receiveSync(): Frame | null;
|
|
874
|
+
receiveSync(): Frame | EOFSignal | null;
|
|
808
875
|
/**
|
|
809
876
|
* Send command to filter.
|
|
810
877
|
*
|
|
@@ -903,9 +970,20 @@ export declare class FilterAPI implements Disposable {
|
|
|
903
970
|
*/
|
|
904
971
|
private runWorker;
|
|
905
972
|
/**
|
|
906
|
-
* Send frame to input queue.
|
|
973
|
+
* Send frame to input queue or flush the pipeline.
|
|
974
|
+
*
|
|
975
|
+
* When frame is provided, queues it for filtering.
|
|
976
|
+
* When null is provided, triggers flush sequence:
|
|
977
|
+
* - Closes input queue
|
|
978
|
+
* - Waits for worker completion
|
|
979
|
+
* - Flushes filter and sends remaining frames to output queue
|
|
980
|
+
* - Closes output queue
|
|
981
|
+
* - Waits for pipeTo task completion
|
|
982
|
+
* - Propagates flush to next component (if any)
|
|
907
983
|
*
|
|
908
|
-
*
|
|
984
|
+
* Used by scheduler system for pipeline control.
|
|
985
|
+
*
|
|
986
|
+
* @param frame - Frame to send, or null to flush
|
|
909
987
|
*
|
|
910
988
|
* @internal
|
|
911
989
|
*/
|
|
@@ -918,14 +996,6 @@ export declare class FilterAPI implements Disposable {
|
|
|
918
996
|
* @internal
|
|
919
997
|
*/
|
|
920
998
|
private receiveFrame;
|
|
921
|
-
/**
|
|
922
|
-
* Flush the entire filter pipeline.
|
|
923
|
-
*
|
|
924
|
-
* Propagates flush through worker, output queue, and next component.
|
|
925
|
-
*
|
|
926
|
-
* @internal
|
|
927
|
-
*/
|
|
928
|
-
private flushPipeline;
|
|
929
999
|
/**
|
|
930
1000
|
* Initialize filter graph from first frame.
|
|
931
1001
|
*
|