Skip to content

node-av / lib / FilterInOut

Class: FilterInOut ​

Defined in: src/lib/filter-inout.ts:46

Filter input/output linked list structure for filter graph parsing.

Represents a linked list of labeled filter pads used during filter graph configuration. Each node contains a filter context, pad index, and optional label for connecting filters together. Used internally by avfilter_graph_parse() to track unlinked filter pads during graph construction.

The head of a list owns all of its nodes, including lists appended through next. Once the head is freed, the other nodes read their defaults (e.g. name null) and ignore writes.

Direct mapping to FFmpeg's AVFilterInOut.

Example ​

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

// Create a linked list of filter inputs/outputs
const inputs = FilterInOut.createList([
  { name: 'in', filterCtx: bufferSrc, padIdx: 0 },
  { name: 'overlay', filterCtx: overlay, padIdx: 1 }
]);

// Parse filter graph with labeled connections
const ret = graph.parse(filterString, inputs, outputs);
FFmpegError.throwIfError(ret, 'parse');

// Manual creation and linking
const inout = new FilterInOut();
inout.alloc();
inout.name = 'input';
inout.filterCtx = sourceFilter;
inout.padIdx = 0;

See ​

Implements ​

Constructors ​

Constructor ​

new FilterInOut(): FilterInOut

Defined in: src/lib/filter-inout.ts:49

Returns ​

FilterInOut

Accessors ​

filterCtx ​

Get Signature ​

get filterCtx(): FilterContext | null

Defined in: src/lib/filter-inout.ts:134

Filter context this pad belongs to.

Reference to the filter instance containing this pad.

Direct mapping to AVFilterInOut->filter_ctx.

Returns ​

FilterContext | null

Set Signature ​

set filterCtx(value): void

Defined in: src/lib/filter-inout.ts:139

Parameters ​
value ​

FilterContext | null

Returns ​

void


name ​

Get Signature ​

get name(): string | null

Defined in: src/lib/filter-inout.ts:119

Label name for this filter pad.

Used to reference this connection point in filter graph strings. For example, "[in]" or "[video_out]".

Direct mapping to AVFilterInOut->name.

Returns ​

string | null

Set Signature ​

set name(value): void

Defined in: src/lib/filter-inout.ts:123

Parameters ​
value ​

string | null

Returns ​

void


next ​

Get Signature ​

get next(): FilterInOut | null

Defined in: src/lib/filter-inout.ts:166

Next node in the linked list.

Reference to the next FilterInOut in the chain, or null for the last node.

Direct mapping to AVFilterInOut->next.

Returns ​

FilterInOut | null

Set Signature ​

set next(value): void

Defined in: src/lib/filter-inout.ts:177

Parameters ​
value ​

FilterInOut | null

Returns ​

void


padIdx ​

Get Signature ​

get padIdx(): number

Defined in: src/lib/filter-inout.ts:151

Pad index within the filter.

Index of the input or output pad in the filter context. 0 for the first pad, 1 for the second, etc.

Direct mapping to AVFilterInOut->pad_idx.

Returns ​

number

Set Signature ​

set padIdx(value): void

Defined in: src/lib/filter-inout.ts:155

Parameters ​
value ​

number

Returns ​

void

Methods ​

[dispose]() ​

[dispose](): void

Defined in: src/lib/filter-inout.ts:286

Dispose of the FilterInOut structure.

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

Returns ​

void

Example ​

typescript
{
  using inout = new FilterInOut();
  inout.alloc();
  inout.name = 'test';
  // Use inout...
} // Automatically freed when leaving scope

Implementation of ​

Disposable.[dispose]


alloc() ​

alloc(): void

Defined in: src/lib/filter-inout.ts:203

Allocate a FilterInOut structure.

Allocates memory for the structure. Must be called before using a manually created instance.

Direct mapping to avfilter_inout_alloc().

Returns ​

void

Throws ​

If allocation fails (ENOMEM)

Example ​

typescript
const inout = new FilterInOut();
inout.alloc();
inout.name = 'input';
inout.filterCtx = bufferSource;
inout.padIdx = 0;

See ​


count() ​

count(): number

Defined in: src/lib/filter-inout.ts:247

Count nodes in the linked list.

Counts the total number of nodes starting from this node and following the next pointers.

Returns ​

number

Number of nodes in the list (including this one)

Example ​

typescript
const list = FilterInOut.createList([
  { name: 'in1', filterCtx: filter1, padIdx: 0 },
  { name: 'in2', filterCtx: filter2, padIdx: 0 },
  { name: 'in3', filterCtx: filter3, padIdx: 0 }
]);

console.log(`List has ${list.count()} nodes`); // 3

free() ​

free(): void

Defined in: src/lib/filter-inout.ts:224

Free the FilterInOut structure.

Deallocates the structure and breaks the chain if part of a linked list. Only frees this node, not the entire list.

Direct mapping to avfilter_inout_free().

Returns ​

void

Example ​

typescript
inout.free();
// Structure is now invalid

See ​


getNative() ​

getNative(): NativeFilterInOut

Defined in: src/lib/filter-inout.ts:266

Internal

Get the underlying native FilterInOut object.

Returns ​

NativeFilterInOut

The native FilterInOut binding object

Implementation of ​

NativeWrapper.getNative


createList() ​

static createList(items): FilterInOut | null

Defined in: src/lib/filter-inout.ts:80

Create a linked list of filter inputs/outputs.

Convenience method to build a linked list structure from an array of filter specifications. Each item becomes a node in the list.

Parameters ​

items ​

object[]

Array of filter input/output specifications

Returns ​

FilterInOut | null

Head of the linked list, or null if items is empty

Example ​

typescript
// Create inputs for a filter graph
const inputs = FilterInOut.createList([
  { name: 'video_in', filterCtx: videoBuffer, padIdx: 0 },
  { name: 'audio_in', filterCtx: audioBuffer, padIdx: 0 }
]);

// Create outputs
const outputs = FilterInOut.createList([
  { name: 'video_out', filterCtx: videoSink, padIdx: 0 },
  { name: 'audio_out', filterCtx: audioSink, padIdx: 0 }
]);

See ​

alloc For manual node creation