remotion-dev/remotion · error · Error

Invalid sampling frequency for MPEG version:

Error message

Invalid sampling frequency for MPEG version: 

What it means

Thrown by `getSamplingFrequency` as a fallback when the sampling frequency table lookup returns a falsy value that is not `'reserved'`. This covers the case where `samplingTable[bits][key]` is `undefined` — i.e., the bits/version combination doesn't exist in the table, indicating corrupt data or an internal table gap.

Source

Thrown at packages/media-parser/src/containers/mp3/parse-packet-header.ts:31

}: {
	bits: number;
	mpegVersion: MpegVersion;
}): number {
	const samplingTable: Record<number, Record<string, number | 'reserved'>> = {
		0b00: {MPEG1: 44100, MPEG2: 22050},
		0b01: {MPEG1: 48000, MPEG2: 24000},
		0b10: {MPEG1: 32000, MPEG2: 16000},
		0b11: {MPEG1: 'reserved', MPEG2: 'reserved'},
	};

	const key = `MPEG${mpegVersion}`;
	const value = samplingTable[bits][key];
	if (value === 'reserved') {
		throw new Error('Reserved sampling frequency');
	}

	if (!value) {
		throw new Error(
			'Invalid sampling frequency for MPEG version: ' +
				JSON.stringify({bits, version: mpegVersion}),
		);
	}

	return value;
}

function getBitrateKB({
	bits,
	mpegVersion,
	level,
}: {
	bits: number;
	mpegVersion: Version;
	level: Level;
}): number | 'free' | 'bad' {
	const bitrateTable: Record<

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Verify file integrity with `ffprobe` or re-download the source.
  2. Re-encode the file from a known-good source.
  3. If parsing a stream, check for network corruption or incomplete reads.
  4. Report the file at remotion.dev/report if it appears valid but triggers this error.

Example fix

# check file integrity
ffprobe -v error -i input.mp3

# re-encode from source if corrupt
ffmpeg -i source.wav -codec:a libmp3lame output.mp3
Defensive patterns

Strategy: try-catch

Try / catch

try {
  await parseMedia({src, fields: {durationInSeconds: true}});
} catch (e) {
  if (e instanceof Error && e.message.startsWith('Invalid sampling frequency')) {
    console.error('The MP3 frame header has an unrecognized sampling frequency.');
  }
  throw e;
}

Prevention

When it happens

Trigger: During MPEG frame header parsing, `bits` (the frequency index) or `mpegVersion` produces a key lookup that returns `undefined` from `samplingTable`. Since the table covers indices 0-3, this would require out-of-range bits values or an unexpected mpegVersion string.

Common situations: Corrupt frame headers where bit-reading produced unexpected values. Internal logic errors in bit extraction (`getBits`). Files with severe byte-level corruption that misaligns bit reading.

Related errors


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