{"record":{"id":"a11ff192d1b4dc6f","repo":"MathewSachin/Captura","slug":"an-error-occurred-with-ffmpeg-exit-code-exitcod-a11ff1","errorCode":null,"errorMessage":"An Error Occurred with FFmpeg, Exit Code: {ExitCode}.\\nSee FFmpeg Log for more info.","messagePattern":"An Error Occurred with FFmpeg, Exit Code: (.+?)\\.\\\\nSee FFmpeg Log for more info\\.","errorType":"exception","errorClass":"FFmpegException","httpStatus":null,"severity":"error","filePath":"src/Captura.FFmpeg/Video/FFmpegGifConverter.cs","lineNumber":37,"sourceCode":"            }\n\n            var argsBuilder = new FFmpegArgsBuilder();\n\n            argsBuilder.AddInputFile(Args.InputFile);\n\n            const string filter = \"\\\"[0:v] split [a][b];[a] palettegen [p];[b][p] paletteuse\\\"\";\n\n            argsBuilder.AddOutputFile(Args.FileName)\n                .AddArg(\"filter_complex\", filter)\n                .SetFrameRate(Args.FrameRate);\n\n            var process = FFmpegService.StartFFmpeg(argsBuilder.GetArgs(), Args.FileName, out var log);\n            log.ProgressChanged += Progress.Report;\n\n            await Task.Run(() => process.WaitForExit());\n\n            if (process.ExitCode != 0)\n                throw new FFmpegException(process.ExitCode);\n\n            Progress.Report(100);\n        }\n    }\n}\n","sourceCodeStart":19,"sourceCodeEnd":43,"githubUrl":"https://github.com/MathewSachin/Captura/blob/3fdf41529bf4d50cd7a85aedd856f30e34279a47/src/Captura.FFmpeg/Video/FFmpegGifConverter.cs#L19-L43","documentation":"Thrown by FFmpegGifConverter.StartAsync (src/Captura.FFmpeg/Video/FFmpegGifConverter.cs:37) after process.WaitForExit() when exit code is non-zero. The command uses a fixed filter_complex graph `split -> palettegen -> paletteuse`, which is the most failure-prone part: it requires a decodable video input and a single video stream.","triggerScenarios":"ffmpeg exits non-zero while applying the palettegen/paletteuse filter graph. Typical causes: input file not a video, input has no video stream, unsupported input codec, or an ffmpeg build without the required filters.","commonSituations":"User points the converter at a corrupted or audio-only file; the input is an unusual codec this ffmpeg cannot decode; a minimal/static ffmpeg build lacks palettegen/paletteuse filters.","solutions":["Confirm Args.InputFile is a playable video file (ffprobe reports a video stream).","Reproduce the exact command (with the filter_complex string) in a terminal to read the stderr directly.","Use an ffmpeg build that includes the palette filters (standard zeranoe/BTBK builds do).","Inspect the IFFmpegLogRepository entry for Args.FileName."],"exampleFix":"// before\nawait converter.StartAsync(args, progress);\n// after - validate input is decodable video first\nif (!await HasVideoStream(args.InputFile))\n    throw new InvalidOperationException(\"Input has no video stream\");\nawait converter.StartAsync(args, progress);","handlingStrategy":"validation","validationCode":"// confirm InputFile has a decodable video stream before invoking the converter\nif (!await HasVideoStream(Args.InputFile))\n    throw new InvalidOperationException(\"Input has no decodable video stream\");\n// HasVideoStream can shell out to ffprobe or use FFmpegService to run a quick probe","typeGuard":null,"tryCatchPattern":"try { await converter.StartAsync(args, progress); }\ncatch (FFmpegException e) { /* read log for Args.FileName, show ffmpeg stderr */ }","preventionTips":["Reproduce the exact filter_complex command manually first when a conversion fails.","Use a full ffmpeg build (palettegen/paletteuse included).","Validate input is a real video file before offering GIF conversion."],"tags":["ffmpeg","gif","filter-graph","media-processing","csharp"],"backgroundTag":null,"analyzedSha":"3fdf41529bf4d50cd7a85aedd856f30e34279a47","analyzedAt":"2026-08-13T19:35:27.486Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}