{"record":{"id":"242b878a4d497e91","repo":"stride3d/stride","slug":"failed-to-compile-a-video-asset-ffmpeg-failed-to-convert","errorCode":null,"errorMessage":"Failed to compile a video asset. ffmpeg failed to convert {assetSource}.","messagePattern":"Failed to compile a video asset\\. ffmpeg failed to convert (.+?)\\.","errorType":"exception","errorClass":"AssetException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Assets/Media/VideoAssetCompiler.cs","lineNumber":208,"sourceCode":"                            var trimmingOptions = videoDuration.Enabled ?\n                                    $\" -ss {startTime.Hours:D2}:{startTime.Minutes:D2}:{startTime.Seconds:D2}.{startTime.Milliseconds:D3}\" +\n                                    $\" -t {duration.Hours:D2}:{duration.Minutes:D2}:{duration.Seconds:D2}.{duration.Milliseconds:D3}\": \n                                    \"\";\n\n                            var commandLine = \"  -hide_banner -loglevel error\" + // hide most log output\n                                              \"  -nostdin\" + // no interaction (background process)\n                                              $\" -i \\\"{assetSource.ToOSPath()}\\\"\" + // input file\n                                              $\"{trimmingOptions}\" + \n                                              \"  -f mp4 -vcodec \" + targetCodecFormat + // codec\n                                              channelFlag + // audio channels\n                                              $\"  -vf scale={targetSize.Width}:{targetSize.Height} \" + // adjust the resolution\n                                              sidedataStripCommand +   // strip of stereoscopic sidedata tag\n                                              //\" -an\" + // no audio\n                                              //\" -pix_fmt yuv422p\" + // pixel format (planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples))\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                                throw new AssetException($\"Failed to compile a video asset. ffmpeg failed to convert {assetSource}.\");\n                        }\n                        else\n                        {\n                            commandContext.Logger.Info(string.Format(\"Video Asset Compiler: \\\"{0}\\\". No Re-encoding necessary\",\n                                videoAsset.Source.GetFileName()));\n\n                            // Use temporary file\n                            tempFile = assetSource.ToOSPath();\n                        }\n\n                        var dataUrl = Url + \"_Data\";\n                        var video = new Video.Video\n                        {\n                            CompressedDataUrl = dataUrl,\n                        };\n\n                        // Make sure we don't compress h264 data\n                        commandContext.AddTag(new ObjectUrl(UrlType.Content, dataUrl), Builder.DoNotCompressTag);","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Assets/Media/VideoAssetCompiler.cs#L190-L226","documentation":"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.","triggerScenarios":"ShellHelper.RunProcessAndGetOutputAsync(ffmpeg, commandLine, ...) returns ret != 0 or commandContext.Logger.HasErrors after building the conversion command (including sidedataStripCommand on Windows stereoscopic videos).","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// pre-check the source decodes cleanly\nvar probe = ShellHelper.RunProcessAndGetOutputAsync(\"ffprobe\", $\"-v error \\\"{assetSource}\\\"\", logger);\nif (probe.Result != 0) logger.Error($\"ffmpeg cannot read '{assetSource}'; re-encode before import.\");","typeGuard":null,"tryCatchPattern":"try\n{\n    await CompileVideoAsync(asset);\n}\ncatch (AssetException ex) when (ex.Message.Contains(\"failed to convert\"))\n{\n    logger.Error($\"Re-encode '{assetSource}' to mp4/h264 manually and re-import. Details: {ex.Message}\");\n}","preventionTips":["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"],"tags":["video","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"}