{"record":{"id":"7097a99ea54c580a","repo":"remotion-dev/remotion","slug":"invalid-bitrate","errorCode":null,"errorMessage":"Invalid bitrate","messagePattern":"Invalid bitrate","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/media-parser/src/containers/mp3/parse-packet-header.ts","lineNumber":220,"sourceCode":"     10 - Layer II\n     11 - Layer I\n   */\n\tif (layerBits === 0b00) {\n\t\tthrow new Error('Expected Layer I, II or III');\n\t}\n\n\tconst layer = layerBits === 0b11 ? 1 : layerBits === 0b10 ? 2 : 3;\n\n\titerator.getBits(1); // 0b1 means that there is no CRC, 0b0 means there is. Not validating checksum though\n\n\tconst bitrateIndex = iterator.getBits(4);\n\tconst bitrateInKbit = getBitrateKB({\n\t\tbits: bitrateIndex,\n\t\tmpegVersion,\n\t\tlevel: layer as Level,\n\t});\n\tif (bitrateInKbit === 'bad') {\n\t\tthrow new Error('Invalid bitrate');\n\t}\n\n\tif (bitrateInKbit === 'free') {\n\t\tthrow new Error('Free bitrate not supported');\n\t}\n\n\tconst samplingFrequencyIndex = iterator.getBits(2);\n\n\tconst baseSampleRate = getSamplingFrequency({\n\t\tbits: samplingFrequencyIndex,\n\t\tmpegVersion,\n\t});\n\tconst sampleRate =\n\t\taudioVersionId === 0b00 ? baseSampleRate / 2 : baseSampleRate;\n\tconst padding = Boolean(iterator.getBits(1));\n\titerator.getBits(1); // private bit\n\tconst channelMode = iterator.getBits(2); // channel mode\n\titerator.getBits(2); // mode extension","sourceCodeStart":202,"sourceCodeEnd":238,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/media-parser/src/containers/mp3/parse-packet-header.ts#L202-L238","documentation":"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`.","triggerScenarios":"During frame header parsing, the `bitrateIndex` (4 bits read at line 213) is `0b1111`. `getBitrateKB` returns `'bad'`, and the guard throws.","commonSituations":"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.","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."],"exampleFix":"# verify file integrity\nffprobe -v error -i input.mp3\n\n# re-encode from source\nffmpeg -i input.mp3 -codec:a libmp3lame -b:a 192k 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 === 'Invalid bitrate') {\n    console.error('The MP3 frame header contains a forbidden bitrate index (0b1111).');\n  }\n  throw e;\n}","preventionTips":["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."],"tags":["mp3","corrupt-file","invalid-header","bitrate","mpeg-spec"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}