{"record":{"id":"35840d9a5e5467e8","repo":"stride3d/stride","slug":"hardware-device-type-devicetype-not-supported","errorCode":null,"errorMessage":"Hardware device type '{deviceType}' not supported","messagePattern":"Hardware device type '(.+?)' not supported","errorType":"exception","errorClass":"NotImplementedException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Video/FFmpeg/FFmpegCodec.cs","lineNumber":77,"sourceCode":"\n            pAVCodecContext = pCodecContext;\n        }\n\n        /// <summary>Initializes the platform-specific hardware decode context, when supported.</summary>\n        partial void SetupHardwareAcceleration(AVCodecContext* pCodecContext);\n\n        /// <summary>Restores the platform-specific get_format callback after <see cref=\"ffmpeg.avcodec_flush_buffers\"/>.</summary>\n        partial void RestoreGetFormatAfterFlush();\n\n        /// <summary>Disposes the platform-specific hardware decode resources.</summary>\n        partial void DisposeHardwareAcceleration();\n\n        private static AVPixelFormat FindPixelFormat(AVHWDeviceType deviceType)\n        {\n            if (deviceType == AVHWDeviceType.AV_HWDEVICE_TYPE_D3D11VA)\n                return AVPixelFormat.AV_PIX_FMT_D3D11;\n\n            throw new NotImplementedException($\"Hardware device type '{deviceType}' not supported\");\n        }\n\n        public void Flush(AVFrame* pFrame)\n        {\n            var ret = ffmpeg.avcodec_send_packet(pAVCodecContext, null);\n            if (ret < 0)\n            {\n                Logger.Debug($\"Couldn't enter codec flushing mode. Error code={ret.ToString(\"X8\")}\");\n            }\n            else\n            {\n                while (ffmpeg.avcodec_receive_frame(pAVCodecContext, pFrame) >= 0)\n                {\n                }\n            }\n\n            if (pAVCodecContext != null)\n            {","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Video/FFmpeg/FFmpegCodec.cs#L59-L95","documentation":"FFmpegCodec.FindPixelFormat throws this NotImplementedException when asked to map a hardware device type to a pixel format and the type is anything other than AV_HWDEVICE_TYPE_D3D11VA. The library only implements hardware decoding pixel-format lookup for Direct3D 11; every other AVHWDeviceType falls through to the throw.","triggerScenarios":"Constructing FFmpegCodec with a hardware decoder whose AVHWDeviceType is not D3D11VA (e.g. AV_HWDEVICE_TYPE_CUDA, VAAPI, VIDEOTOOLBOX, DXVA2), which reaches FindPixelFormat via HardwarePixelFormat.","commonSituations":"Enabling hardware acceleration on Linux/macOS (VAAPI/VDPAU/VideoToolbox) or pre-Windows-11 setups expecting DXVA2; passing an explicit hw device type in code; running on hardware/driver stacks where D3D11VA is unavailable so a different device type is selected.","solutions":["Use the decoder on Windows with the D3D11VA hardware device type, the only supported path.","Fall back to software decoding when the device type is not D3D11VA.","Extend FindPixelFormat with mappings for the additional AVHWDeviceType values you need (e.g. CUDA -> AV_PIX_FMT_CUDA)."],"exampleFix":"// before\nvar codec = new FFmpegCodec(..., AVHWDeviceType.AV_HWDEVICE_TYPE_CUDA);\n// after\nvar deviceType = OperatingSystem.IsWindows()\n    ? AVHWDeviceType.AV_HWDEVICE_TYPE_D3D11VA\n    : AVHWDeviceType.AV_HWDEVICE_TYPE_NONE; // falls back to software decoding","handlingStrategy":"fallback","validationCode":"bool isSupported(AVHWDeviceType t) => t == AVHWDeviceType.AV_HWDEVICE_TYPE_D3D11VA || t == AVHWDeviceType.AV_HWDEVICE_TYPE_NONE;","typeGuard":"static bool SupportsHardwareDecode(AVHWDeviceType t) => t == AVHWDeviceType.AV_HWDEVICE_TYPE_D3D11VA;","tryCatchPattern":"try\n{\n    var codec = new FFmpegCodec(..., AVHWDeviceType.AV_HWDEVICE_TYPE_D3D11VA);\n}\ncatch (NotImplementedException)\n{\n    // fall back to software decoding (no hw device type)\n}","preventionTips":["Only request D3D11VA hardware decoding (Windows).","Gate hardware acceleration on the OS at startup.","Fall back to software decoding when hw accel is unavailable."],"tags":["ffmpeg","hardware-decoding","not-implemented","d3d11"],"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-23T08:17:48.524Z"}