remotion-dev/remotion · error

Invalid sample rate mode: ${mode.toString(2)}

Error message

Invalid sample rate mode: ${mode.toString(2)}

What it means

Thrown by getSampleRate() when the 4-bit sample-rate mode field does not match any of the 15 handled patterns (0b0000 through 0b1110, with 0b1111 sharing the 0b0000 branch). Since all 16 possible 4-bit values are covered by prior branches, this throw is effectively unreachable defensive code — it would only fire if the bit iterator returned an out-of-range value.

Source

Thrown at packages/media-parser/src/containers/flac/get-sample-rate.ts:78

	}

	if (mode === 0b1011) {
		return 96000;
	}

	if (mode === 0b1100) {
		return 'uncommon-u8';
	}

	if (mode === 0b1101) {
		return 'uncommon-u16';
	}

	if (mode === 0b1110) {
		return 'uncommon-u16-10';
	}

	throw new Error(`Invalid sample rate mode: ${mode.toString(2)}`);
};

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. If you encounter this, report it as an internal bug to the Remotion team.
  2. Update to the latest @remotion/media-parser version.
  3. Switch to Mediabunny (https://www.remotion.dev/docs/mediabunny/metadata).
Defensive patterns

Strategy: try-catch

Try / catch

try {
  const result = await parseMedia({src, fields: {sampleRate: true}});
} catch (e) {
  if (e instanceof Error && e.message.startsWith('Invalid sample rate mode:')) {
    // Effectively unreachable; if hit, report as internal bug
    console.error('Internal parser error in FLAC sample rate. Report this file to Remotion.');
  } else {
    throw e;
  }
}

Prevention

When it happens

Trigger: Logically unreachable: all 16 possible 4-bit values (0b0000 through 0b1111) are handled by prior conditional branches. Would only trigger if the iterator's getBits(4) returned a value outside [0, 15], indicating an internal bug.

Common situations: Should never occur in normal operation. If observed, it indicates a bug in the BufferIterator bit-reading implementation or an unintended edit to the function's branch logic.

Related errors


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