MathewSachin/Captura · error · FFmpegException

An Error Occurred with FFmpeg, Exit Code: {ExitCode}.\nSee F

Error message

An Error Occurred with FFmpeg, Exit Code: {ExitCode}.\nSee FFmpeg Log for more info.

What it means

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).

Source

Thrown at src/Captura.FFmpeg/Video/FFmpegVideoConverter.cs:49

            var output = argsBuilder.AddOutputFile(Args.FileName)
                .SetFrameRate(Args.FrameRate);

            _videoCodec.Apply(ServiceProvider.Get<FFmpegSettings>(), Args, output);

            //if (Args.AudioProvider != null)
            {
                _videoCodec.AudioArgsProvider(Args.AudioQuality, output);
            }

            var process = FFmpegService.StartFFmpeg(argsBuilder.GetArgs(), Args.FileName, out var log);

            log.ProgressChanged += Progress.Report;

            await Task.Run(() => process.WaitForExit());

            if (process.ExitCode != 0)
                throw new FFmpegException(process.ExitCode);

            Progress.Report(100);
        }
    }
}

View on GitHub (pinned to 3fdf41529b)

Solutions

  1. Verify the codec's encoder exists: run `ffmpeg.exe -encoders` and match the name.
  2. If using a hardware codec (NVENC/QSV), confirm the hardware/driver is present or fall back to a software codec.
  3. Inspect the IFFmpegLogRepository entry for Args.FileName for the rejected argument.
  4. Ensure the audio args provider matches the output container (e.g. no libmp3lame into an mp4-only flow without the lib).

Example fix

// before
if (process.ExitCode != 0) throw new FFmpegException(process.ExitCode);
// after - include which codec failed for faster diagnosis
if (process.ExitCode != 0)
    throw new FFmpegException(process.ExitCode,
        new InvalidOperationException($"codec {_videoCodec.Name} failed; see ffmpeg log"));
Defensive patterns

Strategy: validation

Validate before calling

// confirm the chosen codec's encoder exists on this ffmpeg build/hardware
var encoders = await GetEncoders(); // wraps `ffmpeg.exe -encoders`
if (!encoders.Contains(codec.EncoderName))
    throw new NotSupportedException($"Encoder {codec.EncoderName} not available");

Try / catch

try { await new FFmpegVideoConverter(codec).StartAsync(args, progress); }
catch (FFmpegException e) { /* read log; suggest switching to a software codec */ }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of MathewSachin/Captura@3fdf41529b (2026-08-13). Data as JSON: /api/errors/28fb072542658da5. Report an issue: GitHub.