{"record":{"id":"83b6ccd455945b23","repo":"remotion-dev/remotion","slug":"invalid-icc-profile-size","errorCode":null,"errorMessage":"Invalid ICC profile size","messagePattern":"Invalid ICC profile size","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"packages/media-parser/src/containers/iso-base-media/parse-icc-profile.ts","lineNumber":48,"sourceCode":"\tbXYZ: Point | null;\n\twhitePoint: Point | null;\n};\n\ntype Entry = {\n\ttag: string;\n\tsize: number;\n\toffset: number;\n};\n\nexport const parseIccProfile = (data: Uint8Array): IccProfile => {\n\tconst iterator = getArrayBufferIterator({\n\t\tinitialData: data,\n\t\tmaxBytes: data.length,\n\t\tlogLevel: 'error',\n\t});\n\tconst size = iterator.getUint32();\n\tif (size !== data.length) {\n\t\tthrow new Error('Invalid ICC profile size');\n\t}\n\n\tconst preferredCMMType = iterator.getByteString(4, false);\n\tconst profileVersion = iterator.getByteString(4, false);\n\tconst profileDeviceClass = iterator.getByteString(4, false);\n\tconst colorSpace = iterator.getByteString(4, false);\n\tconst pcs = iterator.getByteString(4, false);\n\tconst dateTime = iterator.getSlice(12);\n\tconst signature = iterator.getByteString(4, false);\n\tif (signature !== 'acsp') {\n\t\tthrow new Error('Invalid ICC profile signature');\n\t}\n\n\tconst primaryPlatform = iterator.getByteString(4, false);\n\tconst profileFlags = iterator.getUint32();\n\tconst deviceManufacturer = iterator.getByteString(4, false);\n\tconst deviceModel = iterator.getByteString(4, false);\n\tconst deviceAttributes = iterator.getUint64();","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/media-parser/src/containers/iso-base-media/parse-icc-profile.ts#L30-L66","documentation":"Thrown in parseIccProfile() (called from the colr box handler for ICC color profiles). The 4-byte size header at the start of the ICC payload does not equal data.length, so the ICC profile is truncated or oversized relative to the bytes the colr box provided. The parser rejects it because all subsequent ICC offsets would be unreliable.","triggerScenarios":"parseMedia({src}) on a video whose colr box carries an ICC profile whose declared size header differs from the actual payload length — a truncated or padded ICC blob, or a colr box whose size field is wrong.","commonSituations":"Files with embedded ICC profiles (HDR/colour-managed video) where the profile was stripped/truncated; non-compliant colour metadata from some color-grading tools; corrupted colr boxes.","solutions":["Re-mux and let ffmpeg rebuild colour boxes: ffmpeg -i in.mp4 -c copy out.mp4; if it still fails, strip the ICC profile: ffmpeg -i in.mp4 -c copy -map_metadata -1 out.mp4.","Re-fetch the source if you suspect transfer corruption.","If you do not need colour metadata, a re-mux that normalises the colr box is the simplest fix.","Migrate to @remotion/mediabunny (parseMedia is deprecated)."],"exampleFix":"// before\nconst {isHdr} = await parseMedia({src, reader: nodeReader});\n\n// after\ntry {\n  const r = await parseMedia({src, reader: nodeReader});\n} catch (err) {\n  if (err instanceof Error && /Invalid ICC profile size/.test(err.message)) {\n    // colr/ICC payload truncated; re-mux or strip colour metadata\n  } else throw err;\n}","handlingStrategy":"try-catch","validationCode":"// If colour metadata is not needed, strip it before parsing to avoid the ICC path:\n//   ffmpeg -i in.mp4 -c copy -map_metadata -1 out.mp4\n// Validate ffprobe reads colour fields cleanly:\n//   ffprobe -v error -select_streams v:0 -show_entries stream=color_space -of default=nw=1:nk=1 in.mp4\nimport {execFileSync} from 'node:child_process';\nfunction colorMetadataParses(file: string): boolean {\n  try {\n    execFileSync('ffprobe', ['-v','error','-select_streams','v:0','-show_entries','stream=color_space,color_transfer,color_primaries','-of','json', file], {encoding:'utf8', stdio:'pipe'});\n    return true;\n  } catch { return false; }\n}","typeGuard":"// The ICC size header is a deep binary field inside the colr box; not caller-type-guardable.\n// => typeGuard: null","tryCatchPattern":"try {\n  await parseMedia({src, reader: nodeReader});\n} catch (err) {\n  if (err instanceof Error && /Invalid ICC profile size/.test(err.message)) {\n    // colr/ICC payload truncated; re-mux or strip colour metadata\n  } else {\n    throw err;\n  }\n}","preventionTips":["Strip colour metadata with ffmpeg -map_metadata -1 if you don't need it.","Re-mux HDR/colour-managed files to rebuild the colr box.","Re-fetch sources suspected of corruption.","Migrate to @remotion/mediabunny (parseMedia is deprecated)."],"tags":["mp4","iso-base-media","media-parser","colr","icc","color","corrupt-file","metadata"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}