{"record":{"id":"28fb072542658da5","repo":"MathewSachin/Captura","slug":"an-error-occurred-with-ffmpeg-exit-code-exitcod-28fb07","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/FFmpegVideoConverter.cs","lineNumber":49,"sourceCode":"\n            var output = argsBuilder.AddOutputFile(Args.FileName)\n                .SetFrameRate(Args.FrameRate);\n\n            _videoCodec.Apply(ServiceProvider.Get<FFmpegSettings>(), Args, output);\n\n            //if (Args.AudioProvider != null)\n            {\n                _videoCodec.AudioArgsProvider(Args.AudioQuality, output);\n            }\n\n            var process = FFmpegService.StartFFmpeg(argsBuilder.GetArgs(), Args.FileName, out var log);\n\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":31,"sourceCodeEnd":55,"githubUrl":"https://github.com/MathewSachin/Captura/blob/3fdf41529bf4d50cd7a85aedd856f30e34279a47/src/Captura.FFmpeg/Video/FFmpegVideoConverter.cs#L31-L55","documentation":"Thrown by FFmpegVideoConverter.StartAsync (src/Captura.FFmpeg/Video/FFmpegVideoConverter.cs:49) after WaitForExit when exit code != 0. The codec's Apply() and AudioArgsProvider build encoder-specific arguments, so failure usually traces to an encoder that this machine/ffmpeg build cannot satisfy (e.g. QSV, NVENC, hardware-specific options).","triggerScenarios":"Transcoding exits non-zero because the selected FFmpegVideoCodec produced args ffmpeg rejected: missing encoder in the build, hardware encoder absent (no Intel QSG / NVIDIA NVENC), unsupported preset/crf combo, or incompatible audio args.","commonSituations":"Choosing an NVENC/QSV codec on hardware lacking that GPU/quick-sync; an ffmpeg build without libx264/libvpx; a preset name that this ffmpeg version renamed; audio codec incompatible with the output container.","solutions":["Verify the codec's encoder exists: run `ffmpeg.exe -encoders` and match the name.","If using a hardware codec (NVENC/QSV), confirm the hardware/driver is present or fall back to a software codec.","Inspect the IFFmpegLogRepository entry for Args.FileName for the rejected argument.","Ensure the audio args provider matches the output container (e.g. no libmp3lame into an mp4-only flow without the lib)."],"exampleFix":"// before\nif (process.ExitCode != 0) throw new FFmpegException(process.ExitCode);\n// after - include which codec failed for faster diagnosis\nif (process.ExitCode != 0)\n    throw new FFmpegException(process.ExitCode,\n        new InvalidOperationException($\"codec {_videoCodec.Name} failed; see ffmpeg log\"));","handlingStrategy":"validation","validationCode":"// confirm the chosen codec's encoder exists on this ffmpeg build/hardware\nvar encoders = await GetEncoders(); // wraps `ffmpeg.exe -encoders`\nif (!encoders.Contains(codec.EncoderName))\n    throw new NotSupportedException($\"Encoder {codec.EncoderName} not available\");","typeGuard":null,"tryCatchPattern":"try { await new FFmpegVideoConverter(codec).StartAsync(args, progress); }\ncatch (FFmpegException e) { /* read log; suggest switching to a software codec */ }","preventionTips":["Filter the codec dropdown to encoders actually present (`ffmpeg.exe -encoders`).","For NVENC/QSV codecs, detect hardware availability before listing them.","Keep a software fallback codec (x264) always available."],"tags":["ffmpeg","codec","hardware-encoder","media-processing","csharp"],"backgroundTag":null,"analyzedSha":"3fdf41529bf4d50cd7a85aedd856f30e34279a47","analyzedAt":"2026-08-13T19:35:27.486Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}