{"record":{"id":"71bf54e0edd37f17","repo":"stride3d/stride","slug":"unsupported-codec","errorCode":null,"errorMessage":"Unsupported codec.","messagePattern":"Unsupported codec\\.","errorType":"exception","errorClass":"ApplicationException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Video/FFmpeg/FFmpegCodec.cs","lineNumber":40,"sourceCode":"\n        private bool isDisposed = false;\n\n        private AVHWDeviceType HardwareDeviceType => AVHWDeviceType.AV_HWDEVICE_TYPE_D3D11VA;\n\n        public bool IsHardwareAccelerated { get; private set; }\n\n        public AVPixelFormat HardwarePixelFormat => FindPixelFormat(HardwareDeviceType);\n\n        /// <summary>\n        /// Initializes a new instance of the <see cref=\"FFmpegCodec\"/> class.\n        /// </summary>\n        public FFmpegCodec(AVCodecParameters* originalCodecpar)\n        {\n            var codecId = originalCodecpar->codec_id;\n            var pCodec = ffmpeg.avcodec_find_decoder(codecId);\n            if (pCodec == null)\n                // TODO: log?\n                throw new ApplicationException(\"Unsupported codec.\");\n\n            int ret;\n            var pCodecContext = ffmpeg.avcodec_alloc_context3(pCodec);\n\n            ret = ffmpeg.avcodec_parameters_to_context(pCodecContext, originalCodecpar);\n            if (ret < 0)\n                // TODO: log?\n                throw new ApplicationException($\"Could not fill codec parameters. Error code={ret.ToString(\"X8\")}\");\n\n            SetupHardwareAcceleration(pCodecContext);\n\n            if (ffmpeg.avcodec_is_open(pCodecContext) == 0)\n            {\n                ret = ffmpeg.avcodec_open2(pCodecContext, pCodec, null);\n                if (ret < 0)\n                    // TODO: log?\n                    throw new ApplicationException($\"Could not open codec. Error code={ret.ToString(\"X8\")}\");\n            }","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Video/FFmpeg/FFmpegCodec.cs#L22-L58","documentation":"Thrown by the FFmpegCodec constructor when ffmpeg.avcodec_find_decoder returns null for the stream's codec_id, meaning the linked FFmpeg build has no decoder for that codec. The constructor aborts before allocating the codec context.","triggerScenarios":"Opening media whose stream uses a codec not compiled into the FFmpeg build (e.g. proprietary codecs like certain H.264 variants, ProRes, or AC-3 when built without them), or a corrupt container that reports an unknown/invalid codec_id.","commonSituations":"Using a minimal FFmpeg build (no GPL/proprietary decoders enabled) against common commercial media; playing exotic codecs on a stripped distribution; FFmpeg native binaries swapped for a reduced-size build.","solutions":["Link/ship an FFmpeg build that includes a decoder for the codec (enable the needed decoders, e.g. non-free/proprietary where licensed)","Verify the codec with ffprobe and transcode the media to a supported codec (H.264/AAC)","Check ffmpeg.avcodec_find_decoder for the specific codec_id in a small test to confirm build support","Ensure the correct FFmpeg native binaries are deployed, not a trimmed variant"],"exampleFix":"// before\nvar pCodec = ffmpeg.avcodec_find_decoder(codecId);\nif (pCodec == null)\n    throw new ApplicationException(\"Unsupported codec.\");\n// after\nvar pCodec = ffmpeg.avcodec_find_decoder(codecId) ?? ffmpeg.avcodec_find_decoder_and_init(codecId); // or log codecId\nif (pCodec == null)\n{\n    Logger.Error($\"No decoder available for codec {codecId}; rebuild FFmpeg with it enabled\");\n    throw new ApplicationException($\"Unsupported codec {codecId}.\");\n}","handlingStrategy":"fallback","validationCode":"// Pre-check decoder availability before opening the stream\nif (ffmpeg.avcodec_find_decoder(codecpar->codec_id) == null)\n{\n    Logger.Error($\"No FFmpeg decoder for codec_id {codecpar->codec_id}\");\n    return PlaybackResult.UnsupportedCodec;\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    var codec = new FFmpegCodec(codecpar);\n}\ncatch (ApplicationException ex) when (ex.Message == \"Unsupported codec.\")\n{\n    SkipStreamOrShowUnsupportedFormatMessage(ex);\n}","preventionTips":["Ship an FFmpeg build with the decoders your media catalog requires (check with ffprobe)","Normalize ingested media to a supported codec set at upload/import time","Test playback of each codec in your content library on every target platform","Keep a runtime codec-support check before attempting to open streams"],"tags":["ffmpeg","codec","video","missing-decoder"],"backgroundTag":"unsupported-enum-value","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}