Skip to content

node-av / lib / FilterContext

Class: FilterContext

Defined in: src/lib/filter-context.ts:48

Filter instance in a filter graph.

Represents an instantiated filter within a filter graph. Each context contains a specific filter configuration with its parameters, connections to other filters, and input/output pads. Supports both software and hardware filtering operations. Essential for building complex filter chains for audio/video processing.

Direct mapping to FFmpeg's AVFilterContext.

Example

typescript
import { FilterContext, FilterGraph, Filter, FFmpegError } from 'node-av';

// Create filter context in a graph
const graph = new FilterGraph();
const filter = Filter.getByName('scale');
const context = graph.createFilter(filter, 'scaler');

// Initialize with parameters
const ret = context.initStr('640:480');
FFmpegError.throwIfError(ret, 'initStr');

// Link filters together
const ret2 = source.link(0, context, 0);
FFmpegError.throwIfError(ret2, 'link');

// For buffer source/sink
const ret3 = await bufferSrc.buffersrcAddFrame(frame);
FFmpegError.throwIfError(ret3, 'buffersrcAddFrame');

See

Extends

Implements

Constructors

Constructor

new FilterContext(native): FilterContext

Defined in: src/lib/filter-context.ts:56

Internal

Parameters

native

NativeFilterContext

The native filter context instance

Returns

FilterContext

Overrides

OptionMember<NativeFilterContext>.constructor

Properties

native

protected native: NativeFilterContext

Defined in: src/lib/option.ts:999

Inherited from

OptionMember.native

Accessors

filter

Get Signature

get filter(): null | Filter

Defined in: src/lib/filter-context.ts:83

Filter descriptor.

Reference to the filter type this context instantiates.

Direct mapping to AVFilterContext->filter.

Returns

null | Filter


graph

Get Signature

get graph(): null | NativeFilterGraph

Defined in: src/lib/filter-context.ts:95

Parent filter graph.

Reference to the graph containing this filter context.

Direct mapping to AVFilterContext->graph.

Returns

null | NativeFilterGraph


hwDeviceCtx

Get Signature

get hwDeviceCtx(): null | HardwareDeviceContext

Defined in: src/lib/filter-context.ts:141

Hardware device context.

Hardware acceleration context for GPU-based filtering. Set to enable hardware-accelerated filter operations.

Direct mapping to AVFilterContext->hw_device_ctx.

Returns

null | HardwareDeviceContext

Set Signature

set hwDeviceCtx(value): void

Defined in: src/lib/filter-context.ts:161

Parameters
value

null | HardwareDeviceContext

Returns

void


name

Get Signature

get name(): null | string

Defined in: src/lib/filter-context.ts:68

Filter instance name.

User-assigned name for this filter instance in the graph. Used for identification and debugging.

Direct mapping to AVFilterContext->name.

Returns

null | string

Set Signature

set name(value): void

Defined in: src/lib/filter-context.ts:72

Parameters
value

null | string

Returns

void


nbInputs

Get Signature

get nbInputs(): number

Defined in: src/lib/filter-context.ts:106

Number of input pads.

Total number of input connections this filter can accept.

Direct mapping to AVFilterContext->nb_inputs.

Returns

number


nbOutputs

Get Signature

get nbOutputs(): number

Defined in: src/lib/filter-context.ts:117

Number of output pads.

Total number of output connections this filter can provide.

Direct mapping to AVFilterContext->nb_outputs.

Returns

number


ready

Get Signature

get ready(): number

Defined in: src/lib/filter-context.ts:129

Filter readiness state.

Indicates if the filter is ready for processing. Non-zero when ready.

Direct mapping to AVFilterContext->ready.

Returns

number

Methods

[dispose]()

[dispose](): void

Defined in: src/lib/filter-context.ts:809

Dispose of the filter context.

Implements the Disposable interface for automatic cleanup. Equivalent to calling free().

Returns

void

Example

typescript
{
  using context = graph.createFilter(filter, 'test');
  context.initStr('640:480');
  // Use context...
} // Automatically freed when leaving scope

Implementation of

Disposable.[dispose]


buffersinkGetChannelLayout()

buffersinkGetChannelLayout(): ChannelLayout

Defined in: src/lib/filter-context.ts:701

Get channel layout from buffer sink.

Returns the channel layout of audio from a buffer sink filter. Only valid for audio buffer sink filters.

Direct mapping to av_buffersink_get_channel_layout().

Returns

ChannelLayout

Channel layout configuration

Example

typescript
const layout = bufferSink.buffersinkGetChannelLayout();
console.log(`Channels: ${layout.nbChannels}`);

buffersinkGetFormat()

buffersinkGetFormat(): AVPixelFormat | AVSampleFormat

Defined in: src/lib/filter-context.ts:579

Get pixel/sample format from buffer sink.

Returns the format of frames from a buffer sink filter. Only valid for buffer sink filters.

Direct mapping to av_buffersink_get_format().

Returns

AVPixelFormat | AVSampleFormat

Pixel format for video, sample format for audio

Example

typescript
import { AV_PIX_FMT_YUV420P } from 'node-av/constants';

const format = bufferSink.buffersinkGetFormat();
if (format === AV_PIX_FMT_YUV420P) {
  console.log('Output is YUV420P');
}

buffersinkGetFrame()

buffersinkGetFrame(frame): Promise<number>

Defined in: src/lib/filter-context.ts:490

Get a frame from a buffer sink filter.

Retrieves a filtered frame from the filter graph through a buffer sink. Only valid for buffer sink filters.

Direct mapping to av_buffersink_get_frame().

Parameters

frame

Frame

Frame to receive filtered data

Returns

Promise<number>

0 on success, negative AVERROR on error:

  • AVERROR_EAGAIN: No frame available yet
  • AVERROR_EOF: No more frames will be produced
  • AVERROR_EINVAL: Not a buffer sink filter

Example

typescript
import { FFmpegError, Frame } from 'node-av';
import { AVERROR_EAGAIN, AVERROR_EOF } from 'node-av/constants';

const frame = new Frame();
frame.alloc();

const ret = await bufferSink.buffersinkGetFrame(frame);
if (ret === AVERROR_EAGAIN) {
  // No frame available yet
} else if (ret === AVERROR_EOF) {
  // End of stream
} else {
  FFmpegError.throwIfError(ret, 'buffersinkGetFrame');
  // Process filtered frame
}

See

buffersrcAddFrame To send frames for filtering


buffersinkGetFrameRate()

buffersinkGetFrameRate(): Rational

Defined in: src/lib/filter-context.ts:660

Get frame rate from buffer sink.

Returns the frame rate of video from a buffer sink filter. Only valid for video buffer sink filters.

Direct mapping to av_buffersink_get_frame_rate().

Returns

Rational

Frame rate as Rational

Example

typescript
const frameRate = bufferSink.buffersinkGetFrameRate();
console.log(`Frame rate: ${frameRate.num}/${frameRate.den} fps`);

buffersinkGetFrameSync()

buffersinkGetFrameSync(frame): number

Defined in: src/lib/filter-context.ts:534

Get frame from buffer sink filter synchronously. Synchronous version of buffersinkGetFrame.

Retrieves a filtered frame from a buffer sink filter. Only valid for buffer sink filters (buffersink, abuffersink).

Direct mapping to av_buffersink_get_frame().

Parameters

frame

Frame

Frame to receive filtered data

Returns

number

0 on success, negative AVERROR on error:

  • AVERROR_EAGAIN: Need more input
  • AVERROR_EOF: No more frames available
  • AVERROR_EINVAL: Invalid parameters

Example

typescript
import { Frame, FFmpegError } from 'node-av';
import { AVERROR_EAGAIN, AVERROR_EOF } from 'node-av/constants';

// Get filtered frame
const filtered = new Frame();
const ret = bufferSink.buffersinkGetFrameSync(filtered);

if (ret === 0) {
  // Process filtered frame
  console.log(`Got filtered frame with ${filtered.nbSamples} samples`);
  filtered.unref();
} else if (ret === AVERROR_EAGAIN) {
  // Need more input frames
} else if (ret === AVERROR_EOF) {
  // No more frames
} else {
  FFmpegError.throwIfError(ret, 'buffersinkGetFrameSync');
}

See

buffersinkGetFrame For async version


buffersinkGetHeight()

buffersinkGetHeight(): number

Defined in: src/lib/filter-context.ts:619

Get frame height from buffer sink.

Returns the height of video frames from a buffer sink filter. Only valid for video buffer sink filters.

Direct mapping to av_buffersink_get_h().

Returns

number

Frame height in pixels

Example

typescript
const height = bufferSink.buffersinkGetHeight();
console.log(`Output height: ${height}px`);

buffersinkGetSampleAspectRatio()

buffersinkGetSampleAspectRatio(): Rational

Defined in: src/lib/filter-context.ts:639

Get sample aspect ratio from buffer sink.

Returns the pixel aspect ratio of video frames from a buffer sink filter. Only valid for video buffer sink filters.

Direct mapping to av_buffersink_get_sample_aspect_ratio().

Returns

Rational

Sample aspect ratio as Rational

Example

typescript
const sar = bufferSink.buffersinkGetSampleAspectRatio();
console.log(`SAR: ${sar.num}:${sar.den}`);

buffersinkGetSampleRate()

buffersinkGetSampleRate(): number

Defined in: src/lib/filter-context.ts:681

Get sample rate from buffer sink.

Returns the sample rate of audio from a buffer sink filter. Only valid for audio buffer sink filters.

Direct mapping to av_buffersink_get_sample_rate().

Returns

number

Sample rate in Hz

Example

typescript
const sampleRate = bufferSink.buffersinkGetSampleRate();
console.log(`Sample rate: ${sampleRate} Hz`);

buffersinkGetTimeBase()

buffersinkGetTimeBase(): Rational

Defined in: src/lib/filter-context.ts:554

Get time base from buffer sink.

Returns the time base of frames from a buffer sink filter. Only valid for buffer sink filters.

Direct mapping to av_buffersink_get_time_base().

Returns

Rational

Time base as Rational

Example

typescript
const timeBase = bufferSink.buffersinkGetTimeBase();
console.log(`Time base: ${timeBase.num}/${timeBase.den}`);

buffersinkGetWidth()

buffersinkGetWidth(): number

Defined in: src/lib/filter-context.ts:599

Get frame width from buffer sink.

Returns the width of video frames from a buffer sink filter. Only valid for video buffer sink filters.

Direct mapping to av_buffersink_get_w().

Returns

number

Frame width in pixels

Example

typescript
const width = bufferSink.buffersinkGetWidth();
console.log(`Output width: ${width}px`);

buffersrcAddFrame()

buffersrcAddFrame(frame): Promise<number>

Defined in: src/lib/filter-context.ts:323

Add a frame to a buffer source filter.

Sends a frame into the filter graph through a buffer source. Only valid for buffer source filters. Send null to signal EOF.

Direct mapping to av_buffersrc_add_frame().

Parameters

frame

Frame to send, or null for EOF

null | Frame

Returns

Promise<number>

0 on success, negative AVERROR on error:

  • AVERROR_EAGAIN: Filter needs more output consumption
  • AVERROR_EOF: Filter has been closed
  • AVERROR_EINVAL: Not a buffer source filter
  • AVERROR_ENOMEM: Memory allocation failure

Example

typescript
import { FFmpegError } from 'node-av';
import { AVERROR_EAGAIN } from 'node-av/constants';

// Send frame to filter graph
const ret = await bufferSrc.buffersrcAddFrame(frame);
if (ret === AVERROR_EAGAIN) {
  // Need to consume output first
} else {
  FFmpegError.throwIfError(ret, 'buffersrcAddFrame');
}

// Signal EOF
await bufferSrc.buffersrcAddFrame(null);

See

buffersinkGetFrame To retrieve filtered frames


buffersrcAddFrameSync()

buffersrcAddFrameSync(frame): number

Defined in: src/lib/filter-context.ts:365

Add frame to buffer source filter synchronously. Synchronous version of buffersrcAddFrame.

Sends a frame to a buffer source filter for processing. Only valid for buffer source filters (buffer, abuffer).

Direct mapping to av_buffersrc_add_frame().

Parameters

frame

Frame to send (null to mark EOF)

null | Frame

Returns

number

0 on success, negative AVERROR on error:

  • AVERROR_EAGAIN: Need to retrieve output first
  • AVERROR_EOF: Graph has finished processing
  • AVERROR_EINVAL: Invalid parameters
  • AVERROR(ENOMEM): Memory allocation failure

Example

typescript
import { FFmpegError } from 'node-av';
import { AVERROR_EAGAIN } from 'node-av/constants';

// Send frame to filter
const ret = bufferSrc.buffersrcAddFrameSync(frame);
if (ret === AVERROR_EAGAIN) {
  // Need to get output frames first
  const filtered = new Frame();
  bufferSink.buffersinkGetFrameSync(filtered);
} else {
  FFmpegError.throwIfError(ret, 'buffersrcAddFrameSync');
}

// Mark end of stream
bufferSrc.buffersrcAddFrameSync(null);

See

buffersrcAddFrame For async version


buffersrcParametersSet()

buffersrcParametersSet(params): number

Defined in: src/lib/filter-context.ts:434

Set parameters for a buffer source filter.

Configures the format and properties of frames that will be sent to the buffer source. Must be called before sending frames.

Direct mapping to av_buffersrc_parameters_set().

Parameters

params

Source parameters

channelLayout?

bigint

Audio channel layout

colorRange?

AVColorRange

Color range for video

colorSpace?

AVColorSpace

Color space for video

format?

AVPixelFormat | AVSampleFormat

Pixel or sample format

frameRate?

IRational

Video frame rate

height?

number

Video frame height

hwFramesCtx?

null | HardwareFramesContext

Hardware frames context

sampleAspectRatio?

IRational

Pixel aspect ratio

sampleRate?

number

Audio sample rate

timeBase?

IRational

Time base for timestamps

width?

number

Video frame width

Returns

number

0 on success, negative AVERROR on error:

  • AVERROR_EINVAL: Invalid parameters
  • AVERROR_ENOMEM: Memory allocation failure

Example

typescript
import { FFmpegError, Rational } from 'node-av';
import { AV_PIX_FMT_YUV420P } from 'node-av/constants';

// Configure video buffer source
const ret = bufferSrc.buffersrcParametersSet({
  width: 1920,
  height: 1080,
  format: AV_PIX_FMT_YUV420P,
  timeBase: { num: 1, den: 25 },
  frameRate: { num: 25, den: 1 }
});
FFmpegError.throwIfError(ret, 'buffersrcParametersSet');

@example
```typescript
import { FFmpegError } from 'node-av';
import { AV_SAMPLE_FMT_FLTP } from 'node-av/constants';

// Configure audio buffer source
const ret = bufferSrc.buffersrcParametersSet({
  format: AV_SAMPLE_FMT_FLTP,
  sampleRate: 44100,
  channelLayout: AV_CHANNEL_LAYOUT_STEREO
});
FFmpegError.throwIfError(ret, 'buffersrcParametersSet');

free()

free(): void

Defined in: src/lib/filter-context.ts:721

Free the filter context.

Releases all resources associated with the filter context. The context becomes invalid after calling this.

Direct mapping to avfilter_free().

Returns

void

Example

typescript
context.free();
// Context is now invalid

See

Symbol.dispose For automatic cleanup


getNative()

getNative(): NativeFilterContext

Defined in: src/lib/filter-context.ts:790

Internal

Get the underlying native FilterContext object.

Returns

NativeFilterContext

The native FilterContext binding object

Implementation of

NativeWrapper.getNative


getOption()

Get an option value from this object.

Uses the AVOption API to retrieve options.

Direct mapping to av_opt_get* functions.

Param

Option name

Param

Option type (defaults to AV_OPT_TYPE_STRING)

Param

Search flags (default: AV_OPT_SEARCH_CHILDREN)

Example

typescript
import { AV_OPT_TYPE_STRING, AV_OPT_TYPE_RATIONAL, AV_OPT_TYPE_PIXEL_FMT, AV_OPT_TYPE_INT64 } from 'node-av/constants';

// String options (default)
const preset = obj.getOption('preset');
const codec = obj.getOption('codec', AV_OPT_TYPE_STRING);

// Typed options
const framerate = obj.getOption('framerate', AV_OPT_TYPE_RATIONAL); // Returns {num, den}
const pixFmt = obj.getOption('pix_fmt', AV_OPT_TYPE_PIXEL_FMT); // Returns AVPixelFormat
const bitrate = obj.getOption('bitrate', AV_OPT_TYPE_INT64); // Returns bigint

Call Signature

getOption(name, type?, searchFlags?): null | string

Defined in: src/lib/option.ts:1217

Parameters
name

string

type?

AVOptionTypeString

searchFlags?

AVOptionSearchFlags

Returns

null | string

Inherited from

OptionMember.getOption

Call Signature

getOption(name, type, searchFlags?): null | string

Defined in: src/lib/option.ts:1218

Parameters
name

string

type

AVOptionTypeColor

searchFlags?

AVOptionSearchFlags

Returns

null | string

Inherited from

OptionMember.getOption

Call Signature

getOption(name, type, searchFlags?): null | number

Defined in: src/lib/option.ts:1221

Parameters
name

string

type

AVOptionTypeInt

searchFlags?

AVOptionSearchFlags

Returns

null | number

Inherited from

OptionMember.getOption

Call Signature

getOption(name, type, searchFlags?): null | bigint

Defined in: src/lib/option.ts:1222

Parameters
name

string

type

AVOptionTypeInt64

searchFlags?

AVOptionSearchFlags

Returns

null | bigint

Inherited from

OptionMember.getOption

Call Signature

getOption(name, type, searchFlags?): null | number

Defined in: src/lib/option.ts:1223

Parameters
name

string

type

AVOptionTypeUint

searchFlags?

AVOptionSearchFlags

Returns

null | number

Inherited from

OptionMember.getOption

Call Signature

getOption(name, type, searchFlags?): null | bigint

Defined in: src/lib/option.ts:1224

Parameters
name

string

type

AVOptionTypeUint64

searchFlags?

AVOptionSearchFlags

Returns

null | bigint

Inherited from

OptionMember.getOption

Call Signature

getOption(name, type, searchFlags?): null | number

Defined in: src/lib/option.ts:1225

Parameters
name

string

type

AVOptionTypeFlags

searchFlags?

AVOptionSearchFlags

Returns

null | number

Inherited from

OptionMember.getOption

Call Signature

getOption(name, type, searchFlags?): null | boolean

Defined in: src/lib/option.ts:1226

Parameters
name

string

type

AVOptionTypeBool

searchFlags?

AVOptionSearchFlags

Returns

null | boolean

Inherited from

OptionMember.getOption

Call Signature

getOption(name, type, searchFlags?): null | number

Defined in: src/lib/option.ts:1227

Parameters
name

string

type

AVOptionTypeDuration

searchFlags?

AVOptionSearchFlags

Returns

null | number

Inherited from

OptionMember.getOption

Call Signature

getOption(name, type, searchFlags?): null | number

Defined in: src/lib/option.ts:1228

Parameters
name

string

type

AVOptionTypeConst

searchFlags?

AVOptionSearchFlags

Returns

null | number

Inherited from

OptionMember.getOption

Call Signature

getOption(name, type, searchFlags?): null | number

Defined in: src/lib/option.ts:1231

Parameters
name

string

type

AVOptionTypeDouble

searchFlags?

AVOptionSearchFlags

Returns

null | number

Inherited from

OptionMember.getOption

Call Signature

getOption(name, type, searchFlags?): null | number

Defined in: src/lib/option.ts:1232

Parameters
name

string

type

AVOptionTypeFloat

searchFlags?

AVOptionSearchFlags

Returns

null | number

Inherited from

OptionMember.getOption

Call Signature

getOption(name, type, searchFlags?): null | IRational

Defined in: src/lib/option.ts:1235

Parameters
name

string

type

AVOptionTypeRational

searchFlags?

AVOptionSearchFlags

Returns

null | IRational

Inherited from

OptionMember.getOption

Call Signature

getOption(name, type, searchFlags?): null | IRational

Defined in: src/lib/option.ts:1236

Parameters
name

string

type

AVOptionTypeVideoRate

searchFlags?

AVOptionSearchFlags

Returns

null | IRational

Inherited from

OptionMember.getOption

Call Signature

getOption(name, type, searchFlags?): null | AVPixelFormat

Defined in: src/lib/option.ts:1237

Parameters
name

string

type

AVOptionTypePixelFmt

searchFlags?

AVOptionSearchFlags

Returns

null | AVPixelFormat

Inherited from

OptionMember.getOption

Call Signature

getOption(name, type, searchFlags?): null | AVSampleFormat

Defined in: src/lib/option.ts:1238

Parameters
name

string

type

AVOptionTypeSampleFmt

searchFlags?

AVOptionSearchFlags

Returns

null | AVSampleFormat

Inherited from

OptionMember.getOption

Call Signature

getOption(name, type, searchFlags?): null | { height: number; width: number; }

Defined in: src/lib/option.ts:1239

Parameters
name

string

type

AVOptionTypeImageSize

searchFlags?

AVOptionSearchFlags

Returns

null | { height: number; width: number; }

Inherited from

OptionMember.getOption

Call Signature

getOption(name, type, searchFlags?): null | ChannelLayout

Defined in: src/lib/option.ts:1240

Parameters
name

string

type

AVOptionTypeChLayout

searchFlags?

AVOptionSearchFlags

Returns

null | ChannelLayout

Inherited from

OptionMember.getOption

Call Signature

getOption(name, type, searchFlags?): null | Dictionary

Defined in: src/lib/option.ts:1241

Parameters
name

string

type

AVOptionTypeDict

searchFlags?

AVOptionSearchFlags

Returns

null | Dictionary

Inherited from

OptionMember.getOption

Call Signature

getOption(name, type, searchFlags?): null | string

Defined in: src/lib/option.ts:1242

Parameters
name

string

type

AVOptionTypeBinary

searchFlags?

AVOptionSearchFlags

Returns

null | string

Inherited from

OptionMember.getOption


init()

init(options): number

Defined in: src/lib/filter-context.ts:192

Initialize filter with dictionary options.

Configures the filter with key-value option pairs. Must be called after creation and before processing.

Direct mapping to avfilter_init_dict().

Parameters

options

Dictionary of filter options

null | NativeDictionary

Returns

number

0 on success, negative AVERROR on error:

  • AVERROR_EINVAL: Invalid parameters
  • AVERROR_ENOMEM: Memory allocation failure

Example

typescript
import { FFmpegError } from 'node-av';

const options = { width: '1920', height: '1080' };
const ret = context.init(options);
FFmpegError.throwIfError(ret, 'init');

See

initStr For string-based initialization


initStr()

initStr(args): number

Defined in: src/lib/filter-context.ts:225

Initialize filter with string arguments.

Configures the filter using a string representation of parameters. Format depends on the specific filter.

Direct mapping to avfilter_init_str().

Parameters

args

Filter arguments string

null | string

Returns

number

0 on success, negative AVERROR on error:

  • AVERROR_EINVAL: Invalid arguments
  • AVERROR_ENOMEM: Memory allocation failure

Example

typescript
import { FFmpegError } from 'node-av';

// Scale filter with width:height
const ret = scaleContext.initStr('1920:1080');
FFmpegError.throwIfError(ret, 'initStr');

// Crop filter with width:height:x:y
const ret2 = cropContext.initStr('640:480:100:50');
FFmpegError.throwIfError(ret2, 'initStr');

See

init For dictionary-based initialization


isReady()

isReady(): boolean

Defined in: src/lib/filter-context.ts:779

Check if filter is ready.

Indicates whether the filter is ready for processing.

Returns

boolean

True if filter is ready

Example

typescript
if (context.isReady()) {
  // Filter is ready for processing
}

isSink()

isSink(): boolean

Defined in: src/lib/filter-context.ts:761

Check if filter is a sink.

Sink filters consume frames without output.

Returns

boolean

True if filter has no outputs

Example

typescript
if (context.isSink()) {
  console.log('This is a sink filter');
}

See

isSource To check for source filters


isSource()

isSource(): boolean

Defined in: src/lib/filter-context.ts:741

Check if filter is a source.

Source filters generate frames without input.

Returns

boolean

True if filter has no inputs

Example

typescript
if (context.isSource()) {
  console.log('This is a source filter');
}

See

isSink To check for sink filters


link(srcPad, dst, dstPad): number

Defined in: src/lib/filter-context.ts:262

Link this filter's output to another filter's input.

Creates a connection between two filters in the graph. Data flows from this filter's output pad to the destination's input pad.

Direct mapping to avfilter_link().

Parameters

srcPad

number

Output pad index of this filter

dst

FilterContext

Destination filter context

dstPad

number

Input pad index of destination filter

Returns

number

0 on success, negative AVERROR on error:

  • AVERROR_EINVAL: Invalid pad indices or incompatible formats
  • AVERROR_ENOMEM: Memory allocation failure

Example

typescript
import { FFmpegError } from 'node-av';

// Link source output 0 to scale input 0
const ret = source.link(0, scale, 0);
FFmpegError.throwIfError(ret, 'link');

// Link scale output 0 to sink input 0
const ret2 = scale.link(0, sink, 0);
FFmpegError.throwIfError(ret2, 'link');

See

unlink To disconnect filters


listOptions()

listOptions(): OptionInfo[]

Defined in: src/lib/option.ts:1358

List all available options for this object.

Uses the AVOption API to enumerate all options. Useful for discovering available settings and their types.

Direct mapping to av_opt_next() iteration.

Returns

OptionInfo[]

Array of option information objects

Example

typescript
const options = obj.listOptions();
for (const opt of options) {
  console.log(`${opt.name}: ${opt.help}`);
  console.log(`  Type: ${opt.type}, Default: ${opt.defaultValue}`);
  console.log(`  Range: ${opt.min} - ${opt.max}`);
}

See

OptionInfo For option metadata structure

Inherited from

OptionMember.listOptions


setOption()

Set an option on this object.

Uses the AVOption API to set options. Available options depend on the specific object type.

Direct mapping to av_opt_set* functions.

Param

Option name

Param

Option value

Param

Option type (defaults to AV_OPT_TYPE_STRING)

Param

Search flags (default: AV_OPT_SEARCH_CHILDREN)

Example

typescript
import { FFmpegError } from 'node-av';
import { AV_OPT_TYPE_STRING, AV_OPT_TYPE_INT64, AV_OPT_TYPE_RATIONAL, AV_OPT_TYPE_PIXEL_FMT } from 'node-av/constants';

// String options (default)
let ret = obj.setOption('preset', 'fast');
FFmpegError.throwIfError(ret, 'set preset');

ret = obj.setOption('codec', 'h264', AV_OPT_TYPE_STRING);
FFmpegError.throwIfError(ret, 'set codec');

// Integer options
ret = obj.setOption('bitrate', 2000000, AV_OPT_TYPE_INT64);
FFmpegError.throwIfError(ret, 'set bitrate');

ret = obj.setOption('threads', 4, AV_OPT_TYPE_INT);
FFmpegError.throwIfError(ret, 'set threads');

// Complex types with proper types
ret = obj.setOption('framerate', {num: 30, den: 1}, AV_OPT_TYPE_RATIONAL);
FFmpegError.throwIfError(ret, 'set framerate');

ret = obj.setOption('pix_fmt', AV_PIX_FMT_YUV420P, AV_OPT_TYPE_PIXEL_FMT);
FFmpegError.throwIfError(ret, 'set pixel format');

Call Signature

setOption(name, value, type?, searchFlags?): number

Defined in: src/lib/option.ts:1006

Parameters
name

string

value

string

type?

AVOptionTypeString

searchFlags?

AVOptionSearchFlags

Returns

number

Inherited from

OptionMember.setOption

Call Signature

setOption(name, value, type, searchFlags?): number

Defined in: src/lib/option.ts:1007

Parameters
name

string

value

string

type

AVOptionTypeColor

searchFlags?

AVOptionSearchFlags

Returns

number

Inherited from

OptionMember.setOption

Call Signature

setOption(name, value, type, searchFlags?): number

Defined in: src/lib/option.ts:1010

Parameters
name

string

value

number

type

AVOptionTypeInt

searchFlags?

AVOptionSearchFlags

Returns

number

Inherited from

OptionMember.setOption

Call Signature

setOption(name, value, type, searchFlags?): number

Defined in: src/lib/option.ts:1011

Parameters
name

string

value

bigint

type

AVOptionTypeInt64

searchFlags?

AVOptionSearchFlags

Returns

number

Inherited from

OptionMember.setOption

Call Signature

setOption(name, value, type, searchFlags?): number

Defined in: src/lib/option.ts:1012

Parameters
name

string

value

number

type

AVOptionTypeUint

searchFlags?

AVOptionSearchFlags

Returns

number

Inherited from

OptionMember.setOption

Call Signature

setOption(name, value, type, searchFlags?): number

Defined in: src/lib/option.ts:1013

Parameters
name

string

value

bigint

type

AVOptionTypeUint64

searchFlags?

AVOptionSearchFlags

Returns

number

Inherited from

OptionMember.setOption

Call Signature

setOption(name, value, type, searchFlags?): number

Defined in: src/lib/option.ts:1014

Parameters
name

string

value

number

type

AVOptionTypeFlags

searchFlags?

AVOptionSearchFlags

Returns

number

Inherited from

OptionMember.setOption

Call Signature

setOption(name, value, type, searchFlags?): number

Defined in: src/lib/option.ts:1015

Parameters
name

string

value

boolean

type

AVOptionTypeBool

searchFlags?

AVOptionSearchFlags

Returns

number

Inherited from

OptionMember.setOption

Call Signature

setOption(name, value, type, searchFlags?): number

Defined in: src/lib/option.ts:1016

Parameters
name

string

value

number

type

AVOptionTypeDuration

searchFlags?

AVOptionSearchFlags

Returns

number

Inherited from

OptionMember.setOption

Call Signature

setOption(name, value, type, searchFlags?): number

Defined in: src/lib/option.ts:1017

Parameters
name

string

value

number

type

AVOptionTypeConst

searchFlags?

AVOptionSearchFlags

Returns

number

Inherited from

OptionMember.setOption

Call Signature

setOption(name, value, type, searchFlags?): number

Defined in: src/lib/option.ts:1020

Parameters
name

string

value

number

type

AVOptionTypeDouble

searchFlags?

AVOptionSearchFlags

Returns

number

Inherited from

OptionMember.setOption

Call Signature

setOption(name, value, type, searchFlags?): number

Defined in: src/lib/option.ts:1021

Parameters
name

string

value

number

type

AVOptionTypeFloat

searchFlags?

AVOptionSearchFlags

Returns

number

Inherited from

OptionMember.setOption

Call Signature

setOption(name, value, type, searchFlags?): number

Defined in: src/lib/option.ts:1024

Parameters
name

string

value

IRational

type

AVOptionTypeRational

searchFlags?

AVOptionSearchFlags

Returns

number

Inherited from

OptionMember.setOption

Call Signature

setOption(name, value, type, searchFlags?): number

Defined in: src/lib/option.ts:1025

Parameters
name

string

value

IRational

type

AVOptionTypeVideoRate

searchFlags?

AVOptionSearchFlags

Returns

number

Inherited from

OptionMember.setOption

Call Signature

setOption(name, value, type, searchFlags?): number

Defined in: src/lib/option.ts:1026

Parameters
name

string

value

AVPixelFormat

type

AVOptionTypePixelFmt

searchFlags?

AVOptionSearchFlags

Returns

number

Inherited from

OptionMember.setOption

Call Signature

setOption(name, value, type, searchFlags?): number

Defined in: src/lib/option.ts:1027

Parameters
name

string

value

AVSampleFormat

type

AVOptionTypeSampleFmt

searchFlags?

AVOptionSearchFlags

Returns

number

Inherited from

OptionMember.setOption

Call Signature

setOption(name, value, type, searchFlags?): number

Defined in: src/lib/option.ts:1028

Parameters
name

string

value
height

number

width

number

type

AVOptionTypeImageSize

searchFlags?

AVOptionSearchFlags

Returns

number

Inherited from

OptionMember.setOption

Call Signature

setOption(name, value, type, searchFlags?): number

Defined in: src/lib/option.ts:1029

Parameters
name

string

value

number | bigint

type

AVOptionTypeChLayout

searchFlags?

AVOptionSearchFlags

Returns

number

Inherited from

OptionMember.setOption

Call Signature

setOption(name, value, type, searchFlags?): number

Defined in: src/lib/option.ts:1030

Parameters
name

string

value

Buffer

type

AVOptionTypeBinary

searchFlags?

AVOptionSearchFlags

Returns

number

Inherited from

OptionMember.setOption

Call Signature

setOption(name, value, type, searchFlags?): number

Defined in: src/lib/option.ts:1031

Parameters
name

string

value

number[]

type

AVOptionTypeBinaryIntArray

searchFlags?

AVOptionSearchFlags

Returns

number

Inherited from

OptionMember.setOption

Call Signature

setOption(name, value, type, searchFlags?): number

Defined in: src/lib/option.ts:1032

Parameters
name

string

value

Dictionary

type

AVOptionTypeDict

searchFlags?

AVOptionSearchFlags

Returns

number

Inherited from

OptionMember.setOption


unlink(pad): void

Defined in: src/lib/filter-context.ts:284

Unlink a filter pad.

Disconnects a pad from its linked filter. Used to reconfigure filter connections.

Direct mapping to avfilter_link_free().

Parameters

pad

number

Pad index to unlink

Returns

void

Example

typescript
// Disconnect output pad 0
context.unlink(0);

See

link To connect filters