remotion-dev/remotion · error · TypeError
"codec" must be a string
Error message
"codec" must be a string
What it means
First guard in validateLambdaCodec: the codec argument must be a string. Any non-string (undefined, null, number, object) throws a TypeError. (Note: the message has a trailing space, which is a minor source artifact.) The codec is validated against the serverlessCodecs allowlist only after this passes.
Source
Thrown at packages/lambda-client/src/validate-lambda-codec.ts:7
/* 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';
}View on GitHub (pinned to 78fe4bb3fd)
Solutions
- Pass a string codec such as 'h264', 'h265', 'vp8', 'vp9', 'mp3', 'aac', 'wav', or 'gif' (see serverlessCodecs).
- Provide a sensible default (e.g., 'h264') when codec is not configured.
- Type your options object so codec is required string to catch this at compile time.
Example fix
// before
renderMediaOnLambda({ composition: 'Main', codec: undefined });
// after
renderMediaOnLambda({ composition: 'Main', codec: 'h264' }); Defensive patterns
Strategy: type-guard
Validate before calling
if (typeof codec !== 'string') {
throw new TypeError(`codec must be a string, got ${typeof codec}`);
}
validateLambdaCodec(codec); Type guard
const isString = (v: unknown): v is string => typeof v === 'string';
Prevention
- Type codec as string (or a codec union) in options interfaces.
- Default to 'h264' when codec is undefined.
- Fail fast at the config boundary if codec is missing.
When it happens
Trigger: Calling renderMediaOnLambda/renderStillOnLambda or any path that runs validateLambdaCodec with a non-string codec value (e.g., undefined from a missing config field, a number, or an object).
Common situations: Codec option defaulted to undefined; reading codec from config where the field is missing; passing a codec constant that resolved to undefined after a refactor; spread of an options object without codec.
Related errors
- parameter 'diskSizeInMb' must be a number, got a ${typeof di
- parameter 'memorySizeInMb' must be a number, got a ${typeof
- "codec" must be a string
- No supported configs
- ${region} is not a supported AWS region. Must be one of: ${A
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/96ebd7df0dbe0cd4.
Report an issue: GitHub.