remotion-dev/remotion · error

Invalid CRC

Error message

Invalid CRC

What it means

Thrown by emitSample() during FLAC frame parsing when parseFrameHeader() returns null. parseFrameHeader returns null in two cases: fewer than 10 bytes remain (truncated frame), or the computed CRC-8 of the frame header does not match the stored CRC byte (data corruption or misaligned read). The error message 'Invalid CRC' covers both, though the CRC mismatch is the more common root cause.

Source

Thrown at packages/media-parser/src/containers/flac/parse-flac-frame.ts:105

};

const emitSample = async ({
	state,
	data,
	offset,
}: {
	state: ParserState;
	data: Uint8Array;
	offset: number;
}) => {
	const iterator = getArrayBufferIterator({
		initialData: data,
		maxBytes: data.length,
		logLevel: 'error',
	});
	const parsed = parseFrameHeader({iterator, state});
	if (!parsed) {
		throw new Error('Invalid CRC');
	}

	const {blockSize, num, sampleRate} = parsed;

	const duration = blockSize / sampleRate;
	const structure = state.structure.getFlacStructure();
	const streamInfo = structure.boxes.find(
		(box) => box.type === 'flac-streaminfo',
	);
	if (!streamInfo) {
		throw new Error('Stream info not found');
	}

	if (streamInfo.minimumBlockSize !== streamInfo.maximumBlockSize) {
		throw new Error('Cannot determine timestamp');
	}

	const timestamp = (num * streamInfo.maximumBlockSize) / streamInfo.sampleRate;

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Verify file integrity with `flac -t input.flac` or `ffprobe input.flac`.
  2. Re-encode from a known-good source: `ffmpeg -i input.flac output.flac`.
  3. Switch to Mediabunny (https://www.remotion.dev/docs/mediabunny/metadata) which may have more robust CRC error recovery.
  4. If the file plays in VLC/ffprobe but fails here, report it to the Remotion team.
Defensive patterns

Strategy: try-catch

Try / catch

try {
  const result = await parseMedia({src, fields: {durationInSeconds: true}});
} catch (e) {
  if (e instanceof Error && e.message === 'Invalid CRC') {
    console.error('FLAC frame CRC mismatch or truncation. Verify: flac -t <file>. Re-encode if corrupt.');
  } else {
    throw e;
  }
}

Prevention

When it happens

Trigger: Parsing a FLAC frame where either (a) the header has fewer than 10 bytes available, or (b) the CRC-8 computed over the header bytes does not match the CRC byte embedded in the stream. This indicates the frame data is corrupted, the read position is misaligned, or the file is truncated mid-frame.

Common situations: Corrupted FLAC files with bit errors in frame headers. Truncated files cut off mid-frame (e.g. incomplete downloads or streams). Files with embedded non-FLAC data that causes the parser to misalign. Aggressive seeking that lands in the middle of a frame without proper sync recovery.

Related errors


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