stride3d/stride · error · NotImplementedException

Hardware device type

Error message

Hardware device type '{deviceType}' not supported

What it means

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.

Solutions

  1. Use the decoder on Windows with the D3D11VA hardware device type, the only supported path.
  2. Fall back to software decoding when the device type is not D3D11VA.
  3. Extend FindPixelFormat with mappings for the additional AVHWDeviceType values you need (e.g. CUDA -> AV_PIX_FMT_CUDA).

Example fix

// before
var codec = new FFmpegCodec(..., AVHWDeviceType.AV_HWDEVICE_TYPE_CUDA);
// after
var deviceType = OperatingSystem.IsWindows()
    ? AVHWDeviceType.AV_HWDEVICE_TYPE_D3D11VA
    : AVHWDeviceType.AV_HWDEVICE_TYPE_NONE; // falls back to software decoding
Defensive patterns

Strategy: fallback

Validate before calling

bool isSupported(AVHWDeviceType t) => t == AVHWDeviceType.AV_HWDEVICE_TYPE_D3D11VA || t == AVHWDeviceType.AV_HWDEVICE_TYPE_NONE;

Type guard

static bool SupportsHardwareDecode(AVHWDeviceType t) => t == AVHWDeviceType.AV_HWDEVICE_TYPE_D3D11VA;

Try / catch

try
{
    var codec = new FFmpegCodec(..., AVHWDeviceType.AV_HWDEVICE_TYPE_D3D11VA);
}
catch (NotImplementedException)
{
    // fall back to software decoding (no hw device type)
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/35840d9a5e5467e8. Report an issue: GitHub.

Appendix: source

Thrown at sources/engine/Stride.Video/FFmpeg/FFmpegCodec.cs:77

            pAVCodecContext = pCodecContext;
        }

        /// <summary>Initializes the platform-specific hardware decode context, when supported.</summary>
        partial void SetupHardwareAcceleration(AVCodecContext* pCodecContext);

        /// <summary>Restores the platform-specific get_format callback after <see cref="ffmpeg.avcodec_flush_buffers"/>.</summary>
        partial void RestoreGetFormatAfterFlush();

        /// <summary>Disposes the platform-specific hardware decode resources.</summary>
        partial void DisposeHardwareAcceleration();

        private static AVPixelFormat FindPixelFormat(AVHWDeviceType deviceType)
        {
            if (deviceType == AVHWDeviceType.AV_HWDEVICE_TYPE_D3D11VA)
                return AVPixelFormat.AV_PIX_FMT_D3D11;

            throw new NotImplementedException($"Hardware device type '{deviceType}' not supported");
        }

        public void Flush(AVFrame* pFrame)
        {
            var ret = ffmpeg.avcodec_send_packet(pAVCodecContext, null);
            if (ret < 0)
            {
                Logger.Debug($"Couldn't enter codec flushing mode. Error code={ret.ToString("X8")}");
            }
            else
            {
                while (ffmpeg.avcodec_receive_frame(pAVCodecContext, pFrame) >= 0)
                {
                }
            }

            if (pAVCodecContext != null)
            {

View on GitHub (pinned to 96fad776d2)