remotion-dev/remotion · error · TypeError

'${codec}' is not a valid codec for Lambda. The following va

Error message

'${codec}' is not a valid codec for Lambda. The following values are supported: ${serverlessCodecs.join(', ')}

What it means

Second guard in validateLambdaCodec: the codec string must be one of the values in serverlessCodecs (exported from @remotion/serverless-client). An unrecognized codec name throws a TypeError listing every supported codec. The check is case- and spelling-sensitive.

Source

Thrown at packages/lambda-client/src/validate-lambda-codec.ts:11

/* eslint-disable no-console */
import type {ServerlessCodec} from '@remotion/serverless-client';
import {serverlessCodecs} from '@remotion/serverless-client';

export const validateLambdaCodec = (codec: unknown): ServerlessCodec => {
	if (typeof codec !== 'string') {
		throw new TypeError('"codec" must be a string ');
	}

	if (!(serverlessCodecs as readonly string[]).includes(codec)) {
		throw new TypeError(
			"'" +
				codec +
				"' is not a valid codec for Lambda. The following values are supported: " +
				serverlessCodecs.join(', '),
		);
	}

	if ((codec as string) === 'h264-mkv') {
		console.warn(
			'The "h264-mkv" codec for renderMediaOnLambda() is deprecated - it\'s now just "h264".',
		);

		return 'h264';
	}

	return codec as ServerlessCodec;
};

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Use one of the codecs listed in the error message (e.g., 'h264', 'h265', 'vp8', 'vp9', 'mp3', 'aac', 'wav', 'gif').
  2. Match the exact casing shown in the list.
  3. If you need a codec not in the list, render locally with renderMedia() instead of on Lambda.

Example fix

// before
renderMediaOnLambda({ composition: 'Main', codec: 'H264' }); // wrong case

// after
renderMediaOnLambda({ composition: 'Main', codec: 'h264' });
Defensive patterns

Strategy: type-guard

Validate before calling

import { serverlessCodecs } from '@remotion/serverless-client';
if (!(serverlessCodecs as readonly string[]).includes(codec)) {
  throw new TypeError(`Unsupported codec: ${codec}. Supported: ${serverlessCodecs.join(', ')}`);
}

Type guard

import { serverlessCodecs } from '@remotion/serverless-client';
import type { ServerlessCodec } from '@remotion/serverless-client';
const isServerlessCodec = (c: unknown): c is ServerlessCodec =>
  typeof c === 'string' && (serverlessCodecs as readonly string[]).includes(c);

Prevention

When it happens

Trigger: Calling validateLambdaCodec with a string that is not in the serverlessCodecs array (e.g., 'H264' with wrong case, 'x264', 'mov', 'webm', 'prores' if unsupported on Lambda).

Common situations: Using a codec valid for local renderMedia() but not for Lambda (the Lambda set is smaller); typo or wrong casing in the codec string; passing a container format instead of a codec; version mismatch where the codec was renamed/removed.

Related errors


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