{"record":{"id":"e7a07e358ca746f3","repo":"remotion-dev/remotion","slug":"codec-is-not-a-valid-codec-for-gcp-cloud-run","errorCode":null,"errorMessage":"'${codec}' is not a valid codec for GCP Cloud Run. The following values are supported: ${cloudrunCodecs.join(', ')}","messagePattern":"'(.+?)' is not a valid codec for GCP Cloud Run\\. The following values are supported: (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/cloudrun/src/shared/validate-gcp-codec.ts","lineNumber":20,"sourceCode":"\t'h264',\n\t'vp8',\n\t'vp9',\n\t'mp3',\n\t'aac',\n\t'wav',\n\t'gif',\n\t'prores',\n] as const;\n\nexport type CloudrunCodec = (typeof cloudrunCodecs)[number];\n\nexport const validateCloudrunCodec = (codec: unknown): CloudrunCodec => {\n\tif (typeof codec !== 'string') {\n\t\tthrow new TypeError('\"codec\" must be a string ');\n\t}\n\n\tif (!(cloudrunCodecs as readonly string[]).includes(codec)) {\n\t\tthrow new TypeError(\n\t\t\t\"'\" +\n\t\t\t\tcodec +\n\t\t\t\t\"' is not a valid codec for GCP Cloud Run. The following values are supported: \" +\n\t\t\t\tcloudrunCodecs.join(', '),\n\t\t);\n\t}\n\n\tif (codec === 'h264-mkv') {\n\t\tthrow new Error(\n\t\t\t'The \"h264-mkv\" codec for renderMediaOnCloudrun() is deprecated - it\\'s now just \"h264\".',\n\t\t);\n\t}\n\n\treturn codec as CloudrunCodec;\n};\n","sourceCodeStart":2,"sourceCodeEnd":36,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/cloudrun/src/shared/validate-gcp-codec.ts#L2-L36","documentation":"Thrown by validateCloudrunCodec() when codec is a string but not in the Cloud Run allow-list (h264, vp8, vp9, mp3, aac, wav, gif, prores). Cloud Run constrains codecs to those its bundled ffmpeg/encoder pipeline supports. The message lists all valid values so the caller can pick a supported one.","triggerScenarios":"Passing a codec valid for local rendering or Lambda but unsupported on Cloud Run, e.g. 'h265', 'h264-mkv', 'audio-mp3' (use 'mp3' instead), or any non-listed string.","commonSituations":"Sharing codec config across Lambda and Cloud Run paths where the supported sets differ; copy-pasting from the Lambda docs; using a deprecated codec alias.","solutions":["Switch to one of the supported codecs: h264, vp8, vp9, mp3, aac, wav, gif, prores.","Use 'mp3' or 'aac' instead of audio-specific aliases like 'audio-mp3'.","Branch your codec config per backend if you target both Lambda and Cloud Run."],"exampleFix":"// before\nawait renderMediaOnCloudRun({ codec: 'h265', ... });\n// after\nawait renderMediaOnCloudRun({ codec: 'h264', ... });","handlingStrategy":"validation","validationCode":"import { validateCloudrunCodec } from '@remotion/cloudrun/shared';\nvalidateCloudrunCodec(codec); // throws early with the supported list","typeGuard":"const CLOUDRUN_CODECS = ['h264','vp8','vp9','mp3','aac','wav','gif','prores'] as const;\nfunction isCloudrunCodec(v: unknown): v is typeof CLOUDRUN_CODECS[number] {\n  return typeof v === 'string' && (CLOUDRUN_CODECS as readonly string[]).includes(v);\n}","tryCatchPattern":"if (!isCloudrunCodec(codec)) throw new Error(`Unsupported codec. Use one of: ${CLOUDRUN_CODECS.join(', ')}`);","preventionTips":["Use a shared typed constant for the codec allow-list across your app.","Branch codec config between Lambda and Cloud Run.","Avoid deprecated codec aliases."],"tags":["cloudrun","validation","codec"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}