{"record":{"id":"c7fe61b84a58a051","repo":"remotion-dev/remotion","slug":"invalid-sampling-frequency-for-mpeg-version","errorCode":null,"errorMessage":"Invalid sampling frequency for MPEG version: ","messagePattern":"Invalid sampling frequency for MPEG version: ","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/media-parser/src/containers/mp3/parse-packet-header.ts","lineNumber":31,"sourceCode":"}: {\n\tbits: number;\n\tmpegVersion: MpegVersion;\n}): number {\n\tconst samplingTable: Record<number, Record<string, number | 'reserved'>> = {\n\t\t0b00: {MPEG1: 44100, MPEG2: 22050},\n\t\t0b01: {MPEG1: 48000, MPEG2: 24000},\n\t\t0b10: {MPEG1: 32000, MPEG2: 16000},\n\t\t0b11: {MPEG1: 'reserved', MPEG2: 'reserved'},\n\t};\n\n\tconst key = `MPEG${mpegVersion}`;\n\tconst value = samplingTable[bits][key];\n\tif (value === 'reserved') {\n\t\tthrow new Error('Reserved sampling frequency');\n\t}\n\n\tif (!value) {\n\t\tthrow new Error(\n\t\t\t'Invalid sampling frequency for MPEG version: ' +\n\t\t\t\tJSON.stringify({bits, version: mpegVersion}),\n\t\t);\n\t}\n\n\treturn value;\n}\n\nfunction getBitrateKB({\n\tbits,\n\tmpegVersion,\n\tlevel,\n}: {\n\tbits: number;\n\tmpegVersion: Version;\n\tlevel: Level;\n}): number | 'free' | 'bad' {\n\tconst bitrateTable: Record<","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/media-parser/src/containers/mp3/parse-packet-header.ts#L13-L49","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# check file integrity\nffprobe -v error -i input.mp3\n\n# re-encode from source if corrupt\nffmpeg -i source.wav -codec:a libmp3lame output.mp3","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await parseMedia({src, fields: {durationInSeconds: true}});\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('Invalid sampling frequency')) {\n    console.error('The MP3 frame header has an unrecognized sampling frequency.');\n  }\n  throw e;\n}","preventionTips":["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."],"tags":["mp3","corrupt-file","invalid-header","sampling-frequency","internal-error"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}