Class: FrameUtils
Defined in: src/lib/frame-utils.ts:28
Frame processing utilities with persistent native frame pools.
Provides efficient crop, scale, and format conversion operations with minimal JavaScript/C++ boundary crossings.
Example
// Create processor for 320x180 NV12 input
const processor = new FrameUtils(320, 180);
// Process frame with crop and resize
const output = processor.process(inputBuffer, {
crop: { left: 10, top: 10, width: 100, height: 100 },
resize: { width: 200, height: 200 },
format: { to: 'rgba' }
});
// Clean up when done
processor.close();
Implements
Disposable
Constructors
Constructor
new FrameUtils(
width
,height
):FrameUtils
Defined in: src/lib/frame-utils.ts:39
Create a new FrameUtils processor.
Parameters
width
number
Input frame width (must be consistent for all frames)
height
number
Input frame height (must be consistent for all frames)
Returns
FrameUtils
Methods
[dispose]()
[dispose]():
void
Defined in: src/lib/frame-utils.ts:102
Dispose of the processor.
Called automatically when using using
statements.
Returns
void
Example
using processor = new FrameUtils(320, 180);
// Use processor...
// Automatically disposed at the end of the block
Implementation of
Disposable.[dispose]
close()
close():
void
Defined in: src/lib/frame-utils.ts:83
Close and release all resources.
Frees all pooled frames and SWS contexts.
Returns
void
Example
processor.close();
process()
process(
buffer
,options
):Buffer
Defined in: src/lib/frame-utils.ts:66
Process a frame with the specified options.
Parameters
buffer
Buffer
Input buffer containing NV12 frame data
options
ImageOptions
= {}
Processing options
Returns
Buffer
Processed frame as a Buffer
Example
// Simple resize
const resized = processor.process(input, {
resize: { width: 640, height: 480 }
});
// Crop and convert to RGB
const cropped = processor.process(input, {
crop: { left: 100, top: 100, width: 200, height: 200 },
format: { to: 'rgb' }
});