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
- Verify file integrity with `ffprobe` or re-download the source.
- Re-encode the file from a known-good source.
- If parsing a stream, check for network corruption or incomplete reads.
- 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
- Validate MP3 files with ffprobe to ensure frame headers are well-formed.
- Re-encode corrupt files from a known-good source.
- Check network transfers for data corruption.
- Report files that trigger this at remotion.dev/report.
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
- Reserved sampling frequency
- Unknown MP3 header
- Expected 1
- Expected MPEG Version 1 or 2
- Expected Layer I, II or III
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/c7fe61b84a58a051.
Report an issue: GitHub.