stride3d/stride · error · ApplicationException
Unsupported codec.
Error message
Unsupported codec.
What it means
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.
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
Example fix
// before
var pCodec = ffmpeg.avcodec_find_decoder(codecId);
if (pCodec == null)
throw new ApplicationException("Unsupported codec.");
// after
var pCodec = ffmpeg.avcodec_find_decoder(codecId) ?? ffmpeg.avcodec_find_decoder_and_init(codecId); // or log codecId
if (pCodec == null)
{
Logger.Error($"No decoder available for codec {codecId}; rebuild FFmpeg with it enabled");
throw new ApplicationException($"Unsupported codec {codecId}.");
} Defensive patterns
Strategy: fallback
Validate before calling
// Pre-check decoder availability before opening the stream
if (ffmpeg.avcodec_find_decoder(codecpar->codec_id) == null)
{
Logger.Error($"No FFmpeg decoder for codec_id {codecpar->codec_id}");
return PlaybackResult.UnsupportedCodec;
} Try / catch
try
{
var codec = new FFmpegCodec(codecpar);
}
catch (ApplicationException ex) when (ex.Message == "Unsupported codec.")
{
SkipStreamOrShowUnsupportedFormatMessage(ex);
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Could not fill codec parameters. Error code=
- Failed to compile a video asset, ffmpeg was not found.
- Failed to compile a video asset. ffmpeg failed to convert
- No video track found in
- Failed to get HW surface format.
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/71bf54e0edd37f17.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Video/FFmpeg/FFmpegCodec.cs:40
private bool isDisposed = false;
private AVHWDeviceType HardwareDeviceType => AVHWDeviceType.AV_HWDEVICE_TYPE_D3D11VA;
public bool IsHardwareAccelerated { get; private set; }
public AVPixelFormat HardwarePixelFormat => FindPixelFormat(HardwareDeviceType);
/// <summary>
/// Initializes a new instance of the <see cref="FFmpegCodec"/> class.
/// </summary>
public FFmpegCodec(AVCodecParameters* originalCodecpar)
{
var codecId = originalCodecpar->codec_id;
var pCodec = ffmpeg.avcodec_find_decoder(codecId);
if (pCodec == null)
// TODO: log?
throw new ApplicationException("Unsupported codec.");
int ret;
var pCodecContext = ffmpeg.avcodec_alloc_context3(pCodec);
ret = ffmpeg.avcodec_parameters_to_context(pCodecContext, originalCodecpar);
if (ret < 0)
// TODO: log?
throw new ApplicationException($"Could not fill codec parameters. Error code={ret.ToString("X8")}");
SetupHardwareAcceleration(pCodecContext);
if (ffmpeg.avcodec_is_open(pCodecContext) == 0)
{
ret = ffmpeg.avcodec_open2(pCodecContext, pCodec, null);
if (ret < 0)
// TODO: log?
throw new ApplicationException($"Could not open codec. Error code={ret.ToString("X8")}");
}View on GitHub (pinned to 96fad776d2)