Skip to content

node-av / lib / avGetMimeTypeDash

Function: avGetMimeTypeDash()

avGetMimeTypeDash(codecpar): string | null

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

Get DASH MIME type for codec parameters.

Determines the MIME type for MPEG-DASH segments based on codec. Uses FFmpeg's segment type selection logic:

  • WebM codecs (VP8, VP9, Vorbis, Opus) → video/webm or audio/webm
  • All other codecs → video/mp4 or audio/mp4

Parameters

codecpar

NativeWrapper<NativeCodecParameters>

Codec parameters

Returns

string | null

MIME type string, or null if invalid media type

Example

typescript
import { avGetMimeTypeDash } from 'node-av/lib';

const stream = input.video();
const mimeType = avGetMimeTypeDash(stream.codecpar);
console.log(mimeType); // "video/mp4" for H.264

// VP9 codec
const mimeTypeVP9 = avGetMimeTypeDash(vp9Stream.codecpar);
console.log(mimeTypeVP9); // "video/webm"

See

https://ffmpeg.org/doxygen/trunk/dashenc_8c_source.html#l00285 - FFmpeg dashenc.c segment type selection