remotion-dev/remotion · error · Error

Invalid bitrate

Error message

Invalid bitrate

What it means

Thrown by `innerParseMp3PacketHeader` when the 4-bit bitrate index read from the MPEG frame header is `0b1111` (15), which the MPEG specification marks as 'bad'/forbidden. The bitrate table in `getBitrateKB` maps all `0b1111` entries to `'bad'`, triggering this error at `parse-packet-header.ts:219-221`.

Source

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

     10 - Layer II
     11 - Layer I
   */
	if (layerBits === 0b00) {
		throw new Error('Expected Layer I, II or III');
	}

	const layer = layerBits === 0b11 ? 1 : layerBits === 0b10 ? 2 : 3;

	iterator.getBits(1); // 0b1 means that there is no CRC, 0b0 means there is. Not validating checksum though

	const bitrateIndex = iterator.getBits(4);
	const bitrateInKbit = getBitrateKB({
		bits: bitrateIndex,
		mpegVersion,
		level: layer as Level,
	});
	if (bitrateInKbit === 'bad') {
		throw new Error('Invalid bitrate');
	}

	if (bitrateInKbit === 'free') {
		throw new Error('Free bitrate not supported');
	}

	const samplingFrequencyIndex = iterator.getBits(2);

	const baseSampleRate = getSamplingFrequency({
		bits: samplingFrequencyIndex,
		mpegVersion,
	});
	const sampleRate =
		audioVersionId === 0b00 ? baseSampleRate / 2 : baseSampleRate;
	const padding = Boolean(iterator.getBits(1));
	iterator.getBits(1); // private bit
	const channelMode = iterator.getBits(2); // channel mode
	iterator.getBits(2); // mode extension

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Verify the file is valid MP3 audio with `ffprobe -i file.mp3`.
  2. Re-encode the file from a known-good source using ffmpeg/LAME.
  3. Check for incomplete downloads or file transfer corruption.
  4. Report the file at remotion.dev/report if it appears valid but still triggers this.

Example fix

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

# re-encode from source
ffmpeg -i input.mp3 -codec:a libmp3lame -b:a 192k output.mp3
Defensive patterns

Strategy: try-catch

Try / catch

try {
  await parseMedia({src, fields: {durationInSeconds: true}});
} catch (e) {
  if (e instanceof Error && e.message === 'Invalid bitrate') {
    console.error('The MP3 frame header contains a forbidden bitrate index (0b1111).');
  }
  throw e;
}

Prevention

When it happens

Trigger: During frame header parsing, the `bitrateIndex` (4 bits read at line 213) is `0b1111`. `getBitrateKB` returns `'bad'`, and the guard throws.

Common situations: Corrupt frame headers with damaged bitrate index bits. Non-MP3 data being parsed as MPEG audio frames. Files with byte-level corruption from bad downloads or storage media. Random data encountered after offset misalignment.

Related errors


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