{"record":{"id":"9a6cc179b090a4b4","repo":"immich-app/immich","slug":"codec-config-targetvideocodec-is-unsupported","errorCode":null,"errorMessage":"Codec '${config.targetVideoCodec}' is unsupported","messagePattern":"Codec '(.+?)' is unsupported","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/src/utils/media.ts","lineNumber":98,"sourceCode":"    return BaseConfig.getHWCodecConfig(config, interfaces, tune);\n  }\n\n  private static getSWCodecConfig(config: ConfigFFmpegDto, tune?: VideoTuning): VideoCodecSWConfig {\n    switch (config.targetVideoCodec) {\n      case VideoCodec.H264: {\n        return new H264Config(config, tune);\n      }\n      case VideoCodec.Hevc: {\n        return new HEVCConfig(config, tune);\n      }\n      case VideoCodec.Vp9: {\n        return new VP9Config(config, tune);\n      }\n      case VideoCodec.Av1: {\n        return new AV1Config(config, tune);\n      }\n      default: {\n        throw new Error(`Codec '${config.targetVideoCodec}' is unsupported`);\n      }\n    }\n  }\n\n  private static getHWCodecConfig(config: ConfigFFmpegDto, interfaces: VideoInterfaces, tune?: VideoTuning) {\n    if (!SUPPORTED_HWA_CODECS[config.accel].includes(config.targetVideoCodec)) {\n      throw new Error(\n        `${config.accel.toUpperCase()} acceleration does not support codec '${config.targetVideoCodec.toUpperCase()}'. Supported codecs: ${SUPPORTED_HWA_CODECS[config.accel]}`,\n      );\n    }\n\n    let handler: VideoCodecSWConfig;\n    switch (config.accel) {\n      case TranscodeHardwareAcceleration.Nvenc: {\n        handler = config.accelDecode\n          ? new NvencHwDecodeConfig(config, interfaces, tune)\n          : new NvencSwDecodeConfig(config, interfaces, tune);\n        break;","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/immich-app/immich/blob/e55ac299a4ec7cb372e35dbf2c6c05ee9ce77f6c/server/src/utils/media.ts#L80-L116","documentation":"getSWCodecConfig maps the configured target video codec to its software encoder configuration class (H264Config, HEVCConfig, VP9Config, AV1Config). An unrecognized targetVideoCodec value has no encoder config, so the switch's default throws. Usually indicates an invalid or out-of-range enum in the transcoding settings.","triggerScenarios":"Config with targetVideoCodec not in {h264, hevc, vp9, av1}, e.g. a stale or malformed config file value or an API call passing an unsupported codec string.","commonSituations":"Hand-edited immich-config.json with a bogus codec name; older client sending a removed codec option; type confusion where a string bypasses enum validation.","solutions":["Set ffmpeg.targetVideoCodec to one of: h264, hevc, vp9, av1","Re-save transcoding settings from the admin UI to normalize the config","Validate the config file against the current SystemConfig schema","Upgrade/repair Immich if the config was written by a different version"],"exampleFix":"// before\n{ \"ffmpeg\": { \"targetVideoCodec\": \"mpeg4\" } }\n// after\n{ \"ffmpeg\": { \"targetVideoCodec\": \"h264\" } }","handlingStrategy":"validation","validationCode":"const SW_CODECS = ['h264', 'hevc', 'vp9', 'av1'];\nif (!SW_CODECS.includes(config.targetVideoCodec)) {\n  throw new Error(`targetVideoCodec must be one of ${SW_CODECS.join(', ')}`);\n}","typeGuard":"const isSupportedCodec = (c) => ['h264','hevc','vp9','av1'].includes(c);","tryCatchPattern":"try {\n  const cfg = getSWCodecConfig(config);\n} catch (e) {\n  if (/is unsupported/.test(e.message)) {\n    // reset targetVideoCodec to 'h264' (safe default) and resave config\n  }\n}","preventionTips":["Always set codecs through validated admin UI settings","Default to h264 when in doubt; it is universally supported","Validate config files after restores or manual edits"],"tags":["video","ffmpeg","config","codec"],"backgroundTag":"invalid-enum-value","analyzedSha":"e55ac299a4ec7cb372e35dbf2c6c05ee9ce77f6c","analyzedAt":"2026-09-15T07:20:19.675Z","contentChangedAt":"2026-09-15T07:20:19.675Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}