Skip to content
Class

AvFrameAudioSampleResource

A custom AudioSampleResource backed by NodeAV's Frame, which in turn is backed by FFmpeg's AVFrame. You can use this resource to create AudioSample instances that are directly backed by FFmpeg's AVFrame without data having to be copied.

When passed, the Frame is now owned by resource, meaning it takes care of closing the frame later. If you want to keep a copy for your own use, clone the frame first.

Extends: AudioSampleResource

Constructor

ts
constructor(
	frame: NodeAv.Frame,
): AvFrameAudioSampleResource;

Properties

frame

ts
get frame(): Frame;

The NodeAV Frame instance backing this resource. Access throws if the resource has already been closed.

Methods

close()

ts
close(): void;

getDataPlane()

ts
getDataPlane(
	planeIndex: number,
): Uint8Array<ArrayBufferLike>;

Returns the audio sample data for the plane given by planeIndex. The audio data must be in the format returned by getFormat(). For interleaved formats, there is only one plane.

getFormat()

ts
getFormat(): AudioSampleFormat;

Returns the audio sample format. See sample formats

getNumberOfChannels()

ts
getNumberOfChannels(): number;

Returns the number of audio channels.

getNumberOfFrames()

ts
getNumberOfFrames(): number;

Returns the number of audio frames in the sample, per channel.

getSampleRate()

ts
getSampleRate(): number;

Returns the audio sample rate in hertz.

getTimestamp()

ts
getTimestamp(): number;

Returns the presentation timestamp of the sample in seconds.

Released under the Mozilla Public License 2.0.