Skip to content

node-av / lib / avGetSampleFmtFromName

Function: avGetSampleFmtFromName()

avGetSampleFmtFromName(name): AVSampleFormat

Defined in: src/lib/utilities.ts:118

Get sample format from name string.

Converts a sample format name (like "s16", "fltp", etc.) to the corresponding AVSampleFormat enum value.

Direct mapping to av_get_sample_fmt().

Parameters

name

string

Sample format name (e.g., "s16", "fltp", "s32p")

Returns

AVSampleFormat

Sample format enum, or AV_SAMPLE_FMT_NONE if unknown

Example

typescript
const fmt1 = avGetSampleFmtFromName("s16");   // Returns AV_SAMPLE_FMT_S16
const fmt2 = avGetSampleFmtFromName("fltp");  // Returns AV_SAMPLE_FMT_FLTP
const none = avGetSampleFmtFromName("invalid"); // Returns AV_SAMPLE_FMT_NONE

See