{"record":{"id":"b37f2acd5b4d1b23","repo":"remotion-dev/remotion","slug":"free-bitrate-not-supported","errorCode":null,"errorMessage":"Free bitrate not supported","messagePattern":"Free bitrate not supported","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/media-parser/src/containers/mp3/parse-packet-header.ts","lineNumber":224,"sourceCode":"\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\n\titerator.getBits(1); // copyright\n\titerator.getBits(1); // original\n\titerator.getBits(2); // emphasis\n","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/media-parser/src/containers/mp3/parse-packet-header.ts#L206-L242","documentation":"Thrown while parsing an MP3 frame header when the 4-bit bitrate index decodes to the 'free' bitrate mode (index 0000). In MP3, 'free' means the bitrate is not encoded in the frame and must be derived from frame size; @remotion/media-parser declines to do that and rejects such files outright. The check happens in parse-packet-header.ts right after getBitrateKB returns the sentinel string 'free'.","triggerScenarios":"Parsing an MP3 whose frame header has bitrateIndex bits == 0b0000. Most common with files produced by experimental/old encoders (LAME --cbr with free-format, or custom encoders) or with the first frame being a non-MPEG filler.","commonSituations":"Hand-edited or truncated MP3s, free-format MP3 files, MP3s wrapped/transcoded by toolchains that emit free-bitrate frames, or random/corrupt data misidentified as MP3.","solutions":["Re-encode the MP3 with a standard fixed bitrate (e.g. 128/192/320 kbit) using a mainstream encoder like LAME or ffmpeg: ffmpeg -i input.mp3 -c:a libmp3lame -b:a 192k output.mp3","If the file is valid free-format MP3 that you must support, pre-scan and reject it before passing to parseMediaStream so the error is handled upstream.","Verify the file is actually MPEG audio and not a mislabeled container by checking the first frame sync (0xFFE/0xFFF) before invoking the parser."],"exampleFix":"// before\nawait parseMediaStream({src: freeFormatMp3Url, fields: {durationInSeconds: true}});\n\n// after: re-encode to a constrained-bitrate MP3 first\n// ffmpeg -i input.mp3 -c:a libmp3lame -b:a 192k output.mp3\nawait parseMediaStream({src: 'output.mp3', fields: {durationInSeconds: true}});","handlingStrategy":"validation","validationCode":"// Read the 4-bit bitrate index of the first MP3 frame and reject 'free' (index 0) up front.\nfunction isFreeBitrateMp3(firstFrame: Uint8Array): boolean {\n  if (firstFrame.length < 4) return false;\n  const b2 = firstFrame[2];\n  const bitrateIndex = (b2 >> 4) & 0x0f;\n  return bitrateIndex === 0b0000; // 'free' bitrate\n}\nif (isFreeBitrateMp3(firstFrame)) {\n  throw new Error('Rejecting free-bitrate MP3 before parsing');\n}","typeGuard":"null","tryCatchPattern":"try {\n  await parseMediaStream({src: mp3Url, fields: {durationInSeconds: true}});\n} catch (err) {\n  if (err instanceof Error && err.message === 'Free bitrate not supported') {\n    // re-encode to a fixed-bitrate MP3, then retry\n  } else throw err;\n}","preventionTips":["Standardize all MP3 assets on a fixed bitrate (128/192/320 kbit) via ffmpeg libmp3lame.","Pre-scan uploads for free-bitrate frames and reject or transcode them.","Do not feed untrusted/experimental MP3s directly to parseMediaStream."],"tags":["mp3","bitrate","unsupported-format","media-parser"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}