remotion-dev/remotion · warning · Error

Invalid ICC profile size

Error message

Invalid ICC profile size

What it means

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.

Source

Thrown at packages/media-parser/src/containers/iso-base-media/parse-icc-profile.ts:48

	bXYZ: Point | null;
	whitePoint: Point | null;
};

type Entry = {
	tag: string;
	size: number;
	offset: number;
};

export const parseIccProfile = (data: Uint8Array): IccProfile => {
	const iterator = getArrayBufferIterator({
		initialData: data,
		maxBytes: data.length,
		logLevel: 'error',
	});
	const size = iterator.getUint32();
	if (size !== data.length) {
		throw new Error('Invalid ICC profile size');
	}

	const preferredCMMType = iterator.getByteString(4, false);
	const profileVersion = iterator.getByteString(4, false);
	const profileDeviceClass = iterator.getByteString(4, false);
	const colorSpace = iterator.getByteString(4, false);
	const pcs = iterator.getByteString(4, false);
	const dateTime = iterator.getSlice(12);
	const signature = iterator.getByteString(4, false);
	if (signature !== 'acsp') {
		throw new Error('Invalid ICC profile signature');
	}

	const primaryPlatform = iterator.getByteString(4, false);
	const profileFlags = iterator.getUint32();
	const deviceManufacturer = iterator.getByteString(4, false);
	const deviceModel = iterator.getByteString(4, false);
	const deviceAttributes = iterator.getUint64();

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. 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.
  2. Re-fetch the source if you suspect transfer corruption.
  3. If you do not need colour metadata, a re-mux that normalises the colr box is the simplest fix.
  4. Migrate to @remotion/mediabunny (parseMedia is deprecated).

Example fix

// before
const {isHdr} = await parseMedia({src, reader: nodeReader});

// after
try {
  const r = await parseMedia({src, reader: nodeReader});
} catch (err) {
  if (err instanceof Error && /Invalid ICC profile size/.test(err.message)) {
    // colr/ICC payload truncated; re-mux or strip colour metadata
  } else throw err;
}
Defensive patterns

Strategy: try-catch

Validate before calling

// If colour metadata is not needed, strip it before parsing to avoid the ICC path:
//   ffmpeg -i in.mp4 -c copy -map_metadata -1 out.mp4
// Validate ffprobe reads colour fields cleanly:
//   ffprobe -v error -select_streams v:0 -show_entries stream=color_space -of default=nw=1:nk=1 in.mp4
import {execFileSync} from 'node:child_process';
function colorMetadataParses(file: string): boolean {
  try {
    execFileSync('ffprobe', ['-v','error','-select_streams','v:0','-show_entries','stream=color_space,color_transfer,color_primaries','-of','json', file], {encoding:'utf8', stdio:'pipe'});
    return true;
  } catch { return false; }
}

Type guard

// The ICC size header is a deep binary field inside the colr box; not caller-type-guardable.
// => typeGuard: null

Try / catch

try {
  await parseMedia({src, reader: nodeReader});
} catch (err) {
  if (err instanceof Error && /Invalid ICC profile size/.test(err.message)) {
    // colr/ICC payload truncated; re-mux or strip colour metadata
  } else {
    throw err;
  }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12). Data as JSON: /api/errors/83b6ccd455945b23. Report an issue: GitHub.