stride3d/stride · error · AssetException
Failed to compile a video asset. ffmpeg failed to convert
Error message
Failed to compile a video asset. ffmpeg failed to convert {assetSource}. What it means
ffmpeg located and invoked for the video asset returned a nonzero exit code or logged errors during conversion/re-encoding (including the stereoscopic sidedata strip on Windows). The compiler aborts with this AssetException naming the source file.
Solutions
- Run the exact failing ffmpeg command manually to read the real error output
- Re-encode the source to a common format (mp4/h264) and re-import the asset
- Check the build log above the exception for ffmpeg's stderr
- Update ffmpeg to a recent build if option flags are rejected
Defensive patterns
Strategy: try-catch
Validate before calling
// pre-check the source decodes cleanly
var probe = ShellHelper.RunProcessAndGetOutputAsync("ffprobe", $"-v error \"{assetSource}\"", logger);
if (probe.Result != 0) logger.Error($"ffmpeg cannot read '{assetSource}'; re-encode before import."); Try / catch
try
{
await CompileVideoAsync(asset);
}
catch (AssetException ex) when (ex.Message.Contains("failed to convert"))
{
logger.Error($"Re-encode '{assetSource}' to mp4/h264 manually and re-import. Details: {ex.Message}");
} Prevention
- Author video sources in mp4/h264 to avoid re-encoding pitfalls
- Read ffmpeg stderr in logs to find the failing option
- Keep ffmpeg updated when compiler flags change between versions
- Check for DRM/protected content which ffmpeg cannot convert
When it happens
Trigger: ShellHelper.RunProcessAndGetOutputAsync(ffmpeg, commandLine, ...) returns ret != 0 or commandContext.Logger.HasErrors after building the conversion command (including sidedataStripCommand on Windows stereoscopic videos).
Common situations: Unsupported source codec/container or DRM-protected video, invalid ffmpeg arguments composed for the platform, corrupt input, stream parameters ffmpeg refuses (e.g. odd dimensions with some pixel formats), ffmpeg version differences rejecting options like -apply_trc or sidedata strip flags.
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 video asset, ffmpeg was not found.
- Failed to compile a sound asset, ffmpeg was not found.
- Failed to compile a sound 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/242b878a4d497e91.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Assets/Media/VideoAssetCompiler.cs:208
var trimmingOptions = videoDuration.Enabled ?
$" -ss {startTime.Hours:D2}:{startTime.Minutes:D2}:{startTime.Seconds:D2}.{startTime.Milliseconds:D3}" +
$" -t {duration.Hours:D2}:{duration.Minutes:D2}:{duration.Seconds:D2}.{duration.Milliseconds:D3}":
"";
var commandLine = " -hide_banner -loglevel error" + // hide most log output
" -nostdin" + // no interaction (background process)
$" -i \"{assetSource.ToOSPath()}\"" + // input file
$"{trimmingOptions}" +
" -f mp4 -vcodec " + targetCodecFormat + // codec
channelFlag + // audio channels
$" -vf scale={targetSize.Width}:{targetSize.Height} " + // adjust the resolution
sidedataStripCommand + // strip of stereoscopic sidedata tag
//" -an" + // no audio
//" -pix_fmt yuv422p" + // pixel format (planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples))
$" -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 video asset. ffmpeg failed to convert {assetSource}.");
}
else
{
commandContext.Logger.Info(string.Format("Video Asset Compiler: \"{0}\". No Re-encoding necessary",
videoAsset.Source.GetFileName()));
// Use temporary file
tempFile = assetSource.ToOSPath();
}
var dataUrl = Url + "_Data";
var video = new Video.Video
{
CompressedDataUrl = dataUrl,
};
// Make sure we don't compress h264 data
commandContext.AddTag(new ObjectUrl(UrlType.Content, dataUrl), Builder.DoNotCompressTag);View on GitHub (pinned to 96fad776d2)