{"record":{"id":"1d78db87a6e73426","repo":"remotion-dev/remotion","slug":"invalid-channel-count-bits-tostring-2","errorCode":null,"errorMessage":"Invalid channel count: ${bits.toString(2)}","messagePattern":"Invalid channel count: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/media-parser/src/containers/flac/get-channel-count.ts","lineNumber":49,"sourceCode":"\t\treturn 7;\n\t}\n\n\tif (bits === 0b0111) {\n\t\treturn 8;\n\t}\n\n\tif (bits === 0b1000 || bits === 0b1001 || bits === 0b1010) {\n\t\treturn 2;\n\t}\n\n\t// 0b1011..0b1111 are reserved per RFC 9639 §9.1.3 (Channels Bits).\n\t// Some encoders/files in the wild may nonetheless use these values.\n\t// Be lenient and treat them as stereo (2 channels) to keep parsing robust.\n\tif (bits >= 0b1011 && bits <= 0b1111) {\n\t\treturn 2;\n\t}\n\n\tthrow new Error(`Invalid channel count: ${bits.toString(2)}`);\n};\n","sourceCodeStart":31,"sourceCodeEnd":51,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/media-parser/src/containers/flac/get-channel-count.ts#L31-L51","documentation":"Thrown by getChannelCount() when the 4-bit channel-assignment field in a FLAC frame header does not match any handled value. The function maps 0b0000-0b0111 to 1-8 channels, 0b1000-0b1010 to stereo (left/right/side channel decorrelation), and 0b1011-0b1111 are treated leniently as stereo. Since every 4-bit value (0-15) is handled by a prior branch, this throw is effectively unreachable defensive code.","triggerScenarios":"Logically unreachable: all 16 possible 4-bit values (0b0000 through 0b1111) are handled. Would only fire if the iterator's getBits() returned a value outside [0, 15] due to an internal bug, or if branch logic were modified to create a gap.","commonSituations":"Should never occur in normal operation. If seen, it signals an internal bug in the bit-reading iterator or an unintended edit to the function's control flow.","solutions":["If you encounter this, report it as a bug to the Remotion team with the reproducing FLAC file.","Update to the latest @remotion/media-parser version.","Switch to Mediabunny (https://www.remotion.dev/docs/mediabunny/metadata)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const result = await parseMedia({src, fields: {numberOfAudioChannels: true}});\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('Invalid channel count:')) {\n    // This is effectively unreachable; if hit, report as internal bug\n    console.error('Internal parser error in FLAC channel count. Report this file to Remotion.');\n  } else {\n    throw e;\n  }\n}","preventionTips":["Keep @remotion/media-parser updated to the latest version.","If this error appears, report the file as a potential internal bug to Remotion.","Migrate to Mediabunny as a more robust alternative."],"tags":["flac","media-parser","channel-count","unreachable","defensive"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}