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 extensionView on GitHub (pinned to 78fe4bb3fd)
Solutions
- Verify the file is valid MP3 audio with `ffprobe -i file.mp3`.
- Re-encode the file from a known-good source using ffmpeg/LAME.
- Check for incomplete downloads or file transfer corruption.
- 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
- Validate MP3 files with ffprobe -v error before parsing.
- Re-encode corrupt files from a known-good source using ffmpeg.
- Check for partial downloads or storage media corruption.
- Use try-catch for untrusted or user-uploaded audio files.
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
- Reserved sampling frequency
- Expected MPEG Version 1 or 2
- Expected Layer I, II or III
- Unknown MP3 header
- Bitrate mismatch at offset ${initialOffset}: ${bitrateInKbit
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/7097a99ea54c580a.
Report an issue: GitHub.