stride3d/stride · error · Exception
VideoInstance mediaCodec failed to get the AudioEngine
Error message
VideoInstance mediaCodec failed to get the AudioEngine
What it means
During MediaCodecVideoBackend.Initialize, when the video has an audio track and PlayAudio is enabled, the backend could not obtain an AudioEngine from IAudioEngineProvider in Instance.Services, so it cannot create the StreamedBufferSound for the audio stream.
Solutions
- Register IAudioEngineProvider in the services and ensure the engine is constructed before video initialization
- Initialize the Stride audio system before VideoComponent playback
- Set VideoComponent.PlayAudio = false if audio is not needed (path is skipped)
- Fix startup order so audio setup precedes video Initialize
Example fix
// before // no audio registration; video init throws // after services.AddAudio(); // registers IAudioEngineProvider var backend = new MediaCodecVideoBackend(); // then Initialize
Defensive patterns
Strategy: type-guard
Validate before calling
var provider = Instance.Services.GetService<IAudioEngineProvider>(); bool audioReady = provider?.AudioEngine != null; if (!audioReady) Instance.VideoComponent.PlayAudio = false; // or register audio first
Type guard
bool AudioAvailable(SceneInstance s) => s.Services.GetService<IAudioEngineProvider>()?.AudioEngine != null;
Try / catch
try { backend.Initialize(url, start, len); }
catch (Exception ex) when (ex.Message.Contains("failed to get the AudioEngine"))
{ /* init audio subsystem or disable PlayAudio, then retry */ } Prevention
- Initialize Stride audio before video backends
- Register IAudioEngineProvider in startup
- Set PlayAudio=false when audio isn't required
When it happens
Trigger: IAudioEngineProvider missing from Instance.Services (GetService returned null); the audio engine is null because the audio subsystem was never initialized; video with audio track initialized before audio system startup.
Common situations: Custom/minimal service registries without audio; initialization ordering where video starts before Stride audio; platforms with audio support stripped while the media still contains an audio track.
Understand the failure class
Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.
Related errors
- VideoInstance AVFoundation failed to get the AudioEngine
- Unable to read
- Unable to read
- unexpected result from audio decoder.DequeueOutputBuffer
- Unhandled value
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/32553880ba829c67.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Video/Backends/MediaCodecVideoBackend.cs:75
imageReader = ImageReader.NewInstance(videoWidth, videoHeight, ImageFormatType.Yuv420888, maxImages: 8);
rgbaScratchSize = videoWidth * videoHeight * 4;
rgbaScratch = Marshal.AllocHGlobal(rgbaScratchSize);
mediaSynchronizer = new MediaSynchronizer();
mediaCodecVideoExtractor = new MediaCodecVideoExtractor(Instance, mediaSynchronizer, imageReader.Surface);
mediaCodecVideoExtractor.Initialize(Instance.Services, url, startPosition, length);
mediaSynchronizer.RegisterExtractor(mediaCodecVideoExtractor);
mediaSynchronizer.RegisterPlayer(mediaCodecVideoExtractor);
Instance.SetDuration(mediaCodecVideoExtractor.MediaDuration);
var videoComponent = Instance.VideoComponent;
if (mediaCodecVideoExtractor.HasAudioTrack && videoComponent.PlayAudio)
{
var audioEngine = Instance.Services.GetService<IAudioEngineProvider>()?.AudioEngine
?? throw new Exception("VideoInstance mediaCodec failed to get the AudioEngine");
var isSpatialized = videoComponent.AudioEmitters.Any(x => x != null);
audioSound = new StreamedBufferSound(audioEngine, mediaSynchronizer, url, startPosition, length, isSpatialized);
mediaSynchronizer.RegisterExtractor(audioSound);
if (isSpatialized)
{
if (audioSound.GetCountChannels() == 1)
{
foreach (var emitter in videoComponent.AudioEmitters)
{
if (emitter == null)
continue;
var controller = emitter.AttachSound(audioSound);
mediaSynchronizer.RegisterPlayer(controller);
audioControllers.Add(controller);
}View on GitHub (pinned to 96fad776d2)