{"record":{"id":"1eebd2badb33efe0","repo":"stride3d/stride","slug":"failed-to-compile-a-sound-asset-ffmpeg-failed-to-convert","errorCode":null,"errorMessage":"Failed to compile a sound asset, ffmpeg failed to convert {assetSource}","messagePattern":"Failed to compile a sound asset, ffmpeg failed to convert (.+?)","errorType":"exception","errorClass":"AssetException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Assets/Media/SoundAssetCompiler.cs","lineNumber":63,"sourceCode":"\n                // Get absolute path of asset source on disk\n                var assetDirectory = Parameters.Source.GetParent();\n                var assetSource = UPath.Combine(assetDirectory, Parameters.Source);\n\n                // Execute ffmpeg to convert source to PCM and then encode with Celt\n                var tempFile = Path.GetTempFileName();\n                try\n                {\n                    var channels = Parameters.Spatialized ? 1 : 2;\n                    var commandLine = \"  -hide_banner -loglevel error\" + // hide most log output\n                                      $\" -i \\\"{assetSource.ToOSPath()}\\\"\" + // input file\n                                      $\" -f f32le -acodec pcm_f32le -ac {channels} -ar {Parameters.SampleRate}\" + // codec\n                                      $\" -map 0:{Parameters.Index}\" + // stream index\n                                      $\" -y \\\"{tempFile}\\\"\"; // output file (always overwrite)\n                    var ret = await ShellHelper.RunProcessAndGetOutputAsync(ffmpeg, commandLine, commandContext.Logger);\n                    if (ret != 0 || commandContext.Logger.HasErrors)\n                    {\n                        throw new AssetException($\"Failed to compile a sound asset, ffmpeg failed to convert {assetSource}\");\n                    }\n\n                    var encoder = new Celt(Parameters.SampleRate, CompressedSoundSource.SamplesPerFrame, channels, false);\n\n                    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!!\n                    var target = (int)Math.Floor(uncompressed / (float)Parameters.CompressionRatio);\n\n                    var dataUrl = Url + \"_Data\";\n                    var newSound = new Sound\n                    {\n                        CompressedDataUrl = dataUrl,\n                        Channels = channels,\n                        SampleRate = Parameters.SampleRate,\n                        StreamFromDisk = Parameters.StreamFromDisk,\n                        Spatialized = Parameters.Spatialized,\n                    };\n\n                    //make sure we don't compress celt data","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Assets/Media/SoundAssetCompiler.cs#L45-L81","documentation":"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.","triggerScenarios":"ShellHelper.RunProcessAndGetOutputAsync returns a nonzero exit code, or commandContext.Logger.HasErrors is true after running ffmpeg with the pcm_f32le conversion command line.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// pre-flight the conversion with ffprobe/ffmpeg exit code\nvar probe = ShellHelper.RunProcessAndGetOutputAsync(\"ffprobe\", $\"-v error \\\"{assetSource}\\\"\", logger);\nif (probe.Result != 0) logger.Error($\"Source media unreadable by ffmpeg: {assetSource}\");","typeGuard":null,"tryCatchPattern":"try\n{\n    await CompileSoundAsync(asset);\n}\ncatch (AssetException ex) when (ex.Message.Contains(\"failed to convert\"))\n{\n    logger.Error($\"Re-encode '{assetSource}' to wav with ffmpeg manually; check stream index/sample rate settings. Details: {ex.Message}\");\n}","preventionTips":["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"],"tags":["audio","ffmpeg","build-pipeline"],"backgroundTag":"http-error-response","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}