stride3d/stride · error · AssetException
Failed to compile a sound asset, ffmpeg failed to convert
Error message
Failed to compile a sound asset, ffmpeg failed to convert {assetSource} What it means
ffmpeg was found and launched, but the conversion of the sound source to raw PCM (f32le) exited nonzero or logged errors. The compiler treats this as a failed conversion and throws an AssetException naming the source file.
Solutions
- Run the same ffmpeg command manually on the source file to see the real codec/error output
- Verify the asset's stream Index, SampleRate, and channel settings match the source media
- Re-encode or re-export the source audio to a standard format (e.g. wav) and re-import
- Check the build log above the exception for ffmpeg's stderr messages
Defensive patterns
Strategy: try-catch
Validate before calling
// pre-flight the conversion with ffprobe/ffmpeg exit code
var probe = ShellHelper.RunProcessAndGetOutputAsync("ffprobe", $"-v error \"{assetSource}\"", logger);
if (probe.Result != 0) logger.Error($"Source media unreadable by ffmpeg: {assetSource}"); Try / catch
try
{
await CompileSoundAsync(asset);
}
catch (AssetException ex) when (ex.Message.Contains("failed to convert"))
{
logger.Error($"Re-encode '{assetSource}' to wav with ffmpeg manually; check stream index/sample rate settings. Details: {ex.Message}");
} Prevention
- Validate the stream Index matches an existing audio stream in the source
- Use standard source formats (wav/mp3/ogg) when authoring audio
- Read ffmpeg stderr in build logs to diagnose codec issues
- Keep SampleRate/channels parameters consistent with the source
When it happens
Trigger: ShellHelper.RunProcessAndGetOutputAsync returns a nonzero exit code, or commandContext.Logger.HasErrors is true after running ffmpeg with the pcm_f32le conversion command line.
Common situations: Unsupported/corrupt audio file format or codec, wrong stream Index parameter pointing at a nonexistent stream, SampleRate/channels values ffmpeg cannot produce from the source, file path with characters that break the command line quoting.
Understand the failure class
Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.
Related errors
- Failed to compile a sound asset, ffmpeg was not found.
- Failed to compile a video asset, ffmpeg was not found.
- Failed to compile a video asset. ffmpeg failed to convert
- Failed to get Vertex BufferData for entity
- Failed to get Indices BufferData for entity
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/1eebd2badb33efe0.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Assets/Media/SoundAssetCompiler.cs:63
// Get absolute path of asset source on disk
var assetDirectory = Parameters.Source.GetParent();
var assetSource = UPath.Combine(assetDirectory, Parameters.Source);
// Execute ffmpeg to convert source to PCM and then encode with Celt
var tempFile = Path.GetTempFileName();
try
{
var channels = Parameters.Spatialized ? 1 : 2;
var commandLine = " -hide_banner -loglevel error" + // hide most log output
$" -i \"{assetSource.ToOSPath()}\"" + // input file
$" -f f32le -acodec pcm_f32le -ac {channels} -ar {Parameters.SampleRate}" + // codec
$" -map 0:{Parameters.Index}" + // stream index
$" -y \"{tempFile}\""; // output file (always overwrite)
var ret = await ShellHelper.RunProcessAndGetOutputAsync(ffmpeg, commandLine, commandContext.Logger);
if (ret != 0 || commandContext.Logger.HasErrors)
{
throw new AssetException($"Failed to compile a sound asset, ffmpeg failed to convert {assetSource}");
}
var encoder = new Celt(Parameters.SampleRate, CompressedSoundSource.SamplesPerFrame, channels, false);
var uncompressed = CompressedSoundSource.SamplesPerFrame * channels * sizeof(short); //compare with int16 for CD quality comparison.. but remember we are dealing with 32 bit floats for encoding!!
var target = (int)Math.Floor(uncompressed / (float)Parameters.CompressionRatio);
var dataUrl = Url + "_Data";
var newSound = new Sound
{
CompressedDataUrl = dataUrl,
Channels = channels,
SampleRate = Parameters.SampleRate,
StreamFromDisk = Parameters.StreamFromDisk,
Spatialized = Parameters.Spatialized,
};
//make sure we don't compress celt dataView on GitHub (pinned to 96fad776d2)