node-av / lib / avGetCodecString
Function: avGetCodecString()
avGetCodecString(
codecpar,frameRate?):string|null
Defined in: src/lib/utilities.ts:272
Get RFC 6381 codec string from codec parameters.
Generates codec strings for MPEG-DASH and HLS manifests following RFC 6381. Uses FFmpeg's centralized ff_make_codec_str() implementation (libavformat/codecstring.c).
Supported codecs:
- WebM codecs: VP8, VP9 (with detailed profile/level), Vorbis, Opus, FLAC
- H.264 (avc1):
avc1.PPCCLL(profile, constraints, level) - HEVC (hvc1):
hvc1.P.PC.TL.C(profile, profile_compatibility, tier+level, constraints) - AV1 (av01):
av01.P.LLT.BB...(profile, level, tier, bitdepth, color info) - AAC:
mp4a.40.AOT(audio object type) - MP2:
mp4a.40.33 - MP3:
mp4a.40.34 - AC-3:
ac-3 - E-AC-3:
ec-3 - MPEG-4 Visual:
mp4v.20(profile/level not implemented)
Parameters
codecpar
NativeWrapper<NativeCodecParameters>
Codec parameters
frameRate?
Optional frame rate for VP9 level calculation (only used for VP9)
Returns
string | null
RFC 6381 codec string, or null if codec not supported
Example
typescript
import { avGetCodecString } from 'node-av/lib';
// Get codec string for DASH/HLS manifest
const stream = output.video();
const codecString = avGetCodecString(stream.codecpar);
console.log(codecString); // "hvc1.1.6.L93.B0" for HEVC, "avc1.42c01e" for H.264
// VP9 with frame rate for accurate level
const codecStringVP9 = avGetCodecString(stream.codecpar, { num: 30, den: 1 });
console.log(codecStringVP9); // "vp09.00.30.08" - detailed VP9 string
// Use for DASH/HLS manifest
const mimeType = `video/mp4; codecs="${codecString}"`;See
codecstring.c - FFmpeg implementation
