remotion-dev/remotion · error

Unexpected sampling frequency index ${samplingFrequencyIndex

Error message

Unexpected sampling frequency index ${samplingFrequencyIndex}

What it means

Thrown by getSampleRateFromSampleFrequencyIndex in @remotion/media-parser when parsing AAC codec private data whose 4-bit sampling frequency index is not one of the 13 valid MPEG-4 AAC values (0x0-0xC), and is not the escape value 0xF (handled separately). This indicates malformed or unsupported AAC metadata in the source file.

Source

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

			return 44100;
		case 5:
			return 32000;
		case 6:
			return 24000;
		case 7:
			return 22050;
		case 8:
			return 16000;
		case 9:
			return 12000;
		case 10:
			return 11025;
		case 11:
			return 8000;
		case 12:
			return 7350;
		default:
			throw new Error(
				`Unexpected sampling frequency index ${samplingFrequencyIndex}`,
			);
	}
};

// codec private, for example [17, 144]
// audioObjectType = 2 = 'AAC LC'
// samplingFrequencyIndex = 3 = '48000 Hz'
// channelConfiguration = 2 = '2 channels'
/**
 * bytes 17,144: 00010 001 | 1 0010 000
                 ^^^^^ ^^^   ^ ^^^^ ^
                 |     |       |    | padding
                 |     |       |
                 |     |       +-- channelConfiguration (2)
                 |     +-- samplingFrequencyIndex (3)
                 +-- audioConfigType (2)
  */

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Re-encode the audio track with a standard encoder: ffmpeg -i in.mp4 -c:a aac -b:a 128k out.mp4.
  2. Use a different, well-formed source file.
  3. If you control the source pipeline, ensure the encoder emits a standard sampling frequency (96000 down to 7350 Hz).

Example fix

# before: file with corrupt AAC metadata
remotion render --props='{"src":"bad.m4a"}'

# after: re-encode audio
ffmpeg -i bad.m4a -c:a aac -b:a 128k -ar 48000 good.m4a
remotion render --props='{"src":"good.m4a"}'
Defensive patterns

Strategy: try-catch

Validate before calling

null

Try / catch

// Media parsing is internal; catch at the render boundary and re-encode:
try {
  await renderMedia(...);
} catch (e) {
  if (e instanceof Error && e.message.includes('sampling frequency index')) {
    // re-encode the offending audio track
  }
  throw e;
}

Prevention

When it happens

Trigger: A media file whose AAC audio track advertises a sampling_frequency_index outside the range 0-12 (and not 0xF, which triggers the 24-bit extension path). Typically a corrupt or non-standard AAC stream encountered during parsing.

Common situations: A truncated or corrupt MP4/M4A file, an audio track produced by a non-standard encoder, or a file with damaged atoms/headers. Rare in well-authored files; usually points to file corruption.

Related errors


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