remotion-dev/remotion · error · Error

Unsupported rotation: ${rotation}

Error message

Unsupported rotation: ${rotation}

What it means

Thrown by rotateCanvasCapturePoint when the rotation, after normalization to [0,360), is not one of 0/90/180/270. Canvas-capture conversion only supports orthogonal rotations because it maps pixel coordinates via closed-form transforms for each cardinal angle.

Source

Thrown at packages/convert/app/lib/canvas-capture-conversion.ts:111

}) => {
	const normalizedRotation = normalizeVideoRotation(rotation);
	if (normalizedRotation === 0) {
		return {x, y};
	}

	if (normalizedRotation === 90) {
		return {x: dimensions.height - y, y: x};
	}

	if (normalizedRotation === 180) {
		return {x: dimensions.width - x, y: dimensions.height - y};
	}

	if (normalizedRotation === 270) {
		return {x: y, y: dimensions.width - x};
	}

	throw new Error(`Unsupported rotation: ${rotation}`);
};

export const mapCanvasCapturePointToSample = ({
	x,
	y,
	sourceDimensions,
	rotation,
	crop,
	sampleDimensions,
}: {
	readonly x: number;
	readonly y: number;
	readonly sourceDimensions: Dimensions;
	readonly rotation: number;
	readonly crop: CropRectangle | null;
	readonly sampleDimensions: Dimensions;
}) => {
	const rotatedPoint = rotateCanvasCapturePoint({

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Snap the rotation to the nearest multiple of 90 before calling rotateCanvasCapturePoint.
  2. Validate rotation ∈ {0,90,180,270} at the source so bad data never reaches this function.
  3. Reject non-orthogonal canvas-capture inputs at ingest.

Example fix

// before
const pt = rotateCanvasCapturePoint({x, y, dimensions, rotation});

// after
const snapped = Math.round(rotation / 90) * 90;
if (![0, 90, 180, 270].includes(((snapped % 360) + 360) % 360)) {
  throw new Error(`Rotation must be a multiple of 90, got ${rotation}`);
}
const pt = rotateCanvasCapturePoint({x, y, dimensions, rotation: snapped});
Defensive patterns

Strategy: type-guard

Validate before calling

const ALLOWED = new Set([0, 90, 180, 270]);
const normalized = ((Math.round(rotation / 90) * 90) % 360 + 360) % 360;
if (!ALLOWED.has(normalized)) throw new Error(`Rotation must be a multiple of 90, got ${rotation}`);

Type guard

function isOrthogonalRotation(r: number): boolean {
  const n = ((r % 360) + 360) % 360;
  return n === 0 || n === 90 || n === 180 || n === 270;
}

Try / catch

null

Prevention

When it happens

Trigger: Passing a rotation value that is not a multiple of 90, or a corrupted rotation field from a canvas-capture file. The function checks each cardinal angle in turn and falls through to the throw.

Common situations: A canvas-capture manifest carrying an arbitrary-angle rotation; bugs producing NaN/undefined rotation; normalized rotation that lands on 45/17/etc.

Related errors


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