{"record":{"id":"bd28a4c179529543","repo":"remotion-dev/remotion","slug":"unsupported-level-level-tostring-16","errorCode":null,"errorMessage":"Unsupported level: ${level.toString(16)}","messagePattern":"Unsupported level: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/media-parser/src/containers/avc/max-buffer-size.ts","lineNumber":36,"sourceCode":"\t42: 34816, // Level 4.2\n\t50: 110400, // Level 5.0\n\t51: 184320, // Level 5.1\n\t52: 184320, // Level 5.2\n\t60: 696320, // Level 6.0\n\t61: 696320, // Level 6.1\n\t62: 696320, // Level 6.2\n};\n\nexport const macroBlocksPerFrame = (sps: SpsInfo) => {\n\tconst {pic_width_in_mbs_minus1, pic_height_in_map_units_minus1} = sps;\n\treturn (pic_width_in_mbs_minus1 + 1) * (pic_height_in_map_units_minus1 + 1);\n};\n\nexport const maxMacroblockBufferSize = (sps: SpsInfo) => {\n\tconst {level} = sps;\n\tconst maxMacroblocks = maxMacroblocksByLevel[level];\n\tif (maxMacroblocks === undefined) {\n\t\tthrow new Error(`Unsupported level: ${level.toString(16)}`);\n\t}\n\n\treturn maxMacroblocks;\n};\n","sourceCodeStart":18,"sourceCodeEnd":41,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/media-parser/src/containers/avc/max-buffer-size.ts#L18-L41","documentation":"Thrown by maxMacroblockBufferSize() when the AVC (H.264) SPS level value does not appear in the internal maxMacroblocksByLevel lookup table. The table covers H.264 levels 1.0 through 6.2 (encoded as 10, 11, 12, 13, 20, 21, ..., 62). An unrecognized level means the file claims an H.264 level the parser has not mapped to a maximum macroblock buffer size, so it cannot compute buffer constraints.","triggerScenarios":"Calling maxMacroblockBufferSize() with an SpsInfo object whose level field is not one of the 18 supported values (10-62 in the standard encoding). This arises from files declaring a non-standard or reserved H.264 level, or from a corrupted SPS NAL unit where the level_idc parses to an unexpected integer.","commonSituations":"H.264 streams with experimental or future levels not yet in the table. Files produced by encoders that write a level_idc of 0 or a reserved value. Corrupted SPS data from truncated or bit-flipped NAL units. HEVC (H.265) files misidentified as H.264 where level semantics differ.","solutions":["Re-encode the video to a standard H.264 level: `ffmpeg -i input.mp4 -c:v libx264 -level 4.0 output.mp4`.","Verify the file's actual codec and level with `ffprobe -show_streams input.mp4` and confirm it reports a known H.264 level.","Report the file and its SPS level value to the Remotion team so the lookup table can be extended.","Switch to Mediabunny (https://www.remotion.dev/docs/mediabunny/metadata)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"const KNOWN_H264_LEVELS = new Set([10, 11, 12, 13, 20, 21, 22, 30, 31, 32, 40, 41, 42, 50, 51, 52, 60, 61, 62]);\n\nfunction isKnownH264Level(level: number): boolean {\n  return KNOWN_H264_LEVELS.has(level);\n}","tryCatchPattern":"try {\n  const result = await parseMedia({src, fields: {videoCodec: true}});\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('Unsupported level:')) {\n    console.error('H.264 level not supported. Re-encode: ffmpeg -i input.mp4 -c:v libx264 -level 4.0 output.mp4');\n  } else {\n    throw e;\n  }\n}","preventionTips":["Re-encode video to a standard H.264 level using ffmpeg -level flag.","Verify the H.264 level with ffprobe -show_streams before parsing.","Check for file corruption if ffprobe reports an unusual level.","Migrate to Mediabunny for broader H.264 level support."],"tags":["avc","h264","media-parser","sps","level","unsupported-format"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}