remotion-dev/remotion · error

Unexpected audio object type ${audioObjectType}

Error message

Unexpected audio object type ${audioObjectType}

What it means

Thrown by mapAudioObjectTypeToCodecString() when the AAC audioObjectType falls outside the set {1, 2, 3, 4, 5, 6, 17, 23}. These are the only MPEG-4 Audio Object Types the parser can map to an mp4a codec string (AAC-LC, HE-AAC, HEv2, Main, SSR, LTP, LD, ELD). Any other value means the file uses an AAC profile the parser does not recognize or support.

Source

Thrown at packages/media-parser/src/aac-codecprivate.ts:223

	switch (audioObjectType) {
		case 1:
			return 'mp4a.40.2';
		case 2:
			return 'mp4a.40.5';
		case 3:
			return 'mp4a.40.29';
		case 4:
			return 'mp4a.40.1';
		case 5:
			return 'mp4a.40.3';
		case 6:
			return 'mp4a.40.4';
		case 17:
			return 'mp4a.40.17';
		case 23:
			return 'mp4a.40.23';
		default:
			throw new Error(`Unexpected audio object type ${audioObjectType}`);
	}
};

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Re-encode the audio to a widely-supported AAC profile (AAC-LC, audioObjectType 2): `ffmpeg -i input -c:a aac -profile:a aac_low output.mp4`.
  2. Migrate to Mediabunny (https://www.remotion.dev/docs/mediabunny/metadata) which has broader codec coverage.
  3. If you call mapAudioObjectTypeToCodecString directly, add a fallback: default to 'mp4a.40.2' for unknown types or skip the track.
  4. File a bug report with the reproducing media file so the supported set can be extended.

Example fix

// before
const codec = mapAudioObjectTypeToCodecString(audioObjectType);

// after (caller-side guard)
const SUPPORTED = new Set([1, 2, 3, 4, 5, 6, 17, 23]);
const codec = SUPPORTED.has(audioObjectType)
  ? mapAudioObjectTypeToCodecString(audioObjectType)
  : 'mp4a.40.2'; // fallback to AAC-LC
Defensive patterns

Strategy: validation

Validate before calling

const SUPPORTED_AAC_OBJECT_TYPES = new Set([1, 2, 3, 4, 5, 6, 17, 23]);

function isSupportedAacObjectType(t: number): boolean {
  return SUPPORTED_AAC_OBJECT_TYPES.has(t);
}

// Usage:
if (isSupportedAacObjectType(audioObjectType)) {
  const codec = mapAudioObjectTypeToCodecString(audioObjectType);
} else {
  console.warn(`Unsupported AAC object type ${audioObjectType}, defaulting to AAC-LC`);
}

Type guard

function isSupportedAacObjectType(type: number): boolean {
  return new Set([1, 2, 3, 4, 5, 6, 17, 23]).has(type);
}

Try / catch

try {
  const codec = mapAudioObjectTypeToCodecString(audioObjectType);
} catch (e) {
  if (e instanceof Error && e.message.startsWith('Unexpected audio object type')) {
    // Fall back to AAC-LC for unsupported profiles
    codec = 'mp4a.40.2';
  } else {
    throw e;
  }
}

Prevention

When it happens

Trigger: A media file whose AAC AudioSpecificConfig encodes an audioObjectType not in the supported set (e.g. type 7 = AAC SBR-explicit, type 8, type 15 in HE-AACv2 signaling, or reserved values). The function is called internally during parseMedia when registering an AAC audio track and deriving its codec string.

Common situations: Files using uncommon or newly defined MPEG-4 Audio Object Types. Files with HE-AACv2 (parametric stereo) where the SBR extension audio object type is not 2 or 5. Corrupted codec private data that parses to a garbage audioObjectType. Edge cases with type 0 (null) when the muxer wrote a zeroed config.

Related errors


AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12). Data as JSON: /api/errors/351df0e3d27461aa. Report an issue: GitHub.