stride3d/stride · error · Exception
VideoInstance AVFoundation failed to get the AudioEngine
Error message
VideoInstance AVFoundation failed to get the AudioEngine
What it means
While setting up audio for an AVFoundation-backed video instance, the code could not resolve an IAudioEngineProvider (or its AudioEngine) from Instance.Services, so no audio engine exists to register the audio stream with. The library throws rather than silently playing video without audio.
Solutions
- Register IAudioEngineProvider (and ensure the audio engine is created) in the game's service registry before initializing video
- Ensure the Stride audio system is initialized prior to video playback
- If audio is unwanted, set VideoComponent.PlayAudio = false so the path is skipped
- Check initialization order in Game onStart so audio precedes VideoComponent usage
Example fix
// before
var engine = Instance.Services.GetService<IAudioEngineProvider>()?.AudioEngine
?? throw new Exception("...");
// after
// in startup, before video init:
services.AddAudio(); // or manually register IAudioEngineProvider
var engine = Instance.Services.GetService<IAudioEngineProvider>()?.AudioEngine
?? throw new Exception("..."); 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"))
{ /* disable PlayAudio or initialize audio system and retry */ } Prevention
- Register IAudioEngineProvider during app startup before any video init
- Keep Stride audio services intact in custom service registries
- Set PlayAudio=false for video-only scenarios
When it happens
Trigger: IAudioEngineProvider not registered in the service registry (Services.GetService returned null); audio engine not yet created/initialized when the video initializes; PlayAudio enabled and video has audio but the audio system was never set up.
Common situations: Running with a minimal/custom service registry missing Stride's audio module; console/platform builds where audio was intentionally stripped; initializing video before the audio engine in startup order.
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 mediaCodec failed to get the AudioEngine
- AVAssetReader (audio) create failed
- AVAssetReader.StartReading (audio) failed
- Unhandled value
- Failed to compile a sound asset, ffmpeg was not found.
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/8fc4031ecf43bae3.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Video/Backends/AVFoundationVideoBackend.cs:348
Instance.NotifyFramePresented();
}
finally
{
imported?.Dispose();
}
}
private void InitializeAudio(string url, long startPosition, long length)
{
var audioTracks = asset.TracksWithMediaType(AVMediaTypes.Audio.GetConstant());
if (audioTracks == null || audioTracks.Length == 0)
return;
var videoComponent = Instance.VideoComponent;
if (!videoComponent.PlayAudio)
return;
var audioEngine = Instance.Services.GetService<IAudioEngineProvider>()?.AudioEngine
?? throw new Exception("VideoInstance AVFoundation failed to get the AudioEngine");
audioSynchronizer = new MediaSynchronizer();
audioSynchronizer.PlayRange = Instance.PlayRange;
audioSynchronizer.IsLooping = Instance.IsLooping;
audioSynchronizer.LoopRange = Instance.LoopRange;
var isSpatialized = videoComponent.AudioEmitters.Any(x => x != null);
audioSound = new StreamedBufferSound(audioEngine, audioSynchronizer, url, startPosition, length, isSpatialized);
audioSynchronizer.RegisterExtractor(audioSound);
if (isSpatialized)
{
if (audioSound.GetCountChannels() == 1)
{
foreach (var emitter in videoComponent.AudioEmitters)
{
if (emitter == null)
continue;View on GitHub (pinned to 96fad776d2)