subhra74/xdm · error · Exception

FFmpeg process could not be started - Process.Start

Error message

FFmpeg process could not be started - Process.Start

What it means

FFmpegMediaProcessor.ProcessMedia builds a ProcessStartInfo for the ffmpeg binary and calls Process.Start. If the OS returns a null Process (process creation failed at the Win32 level despite the path being found), XDM throws 'FFmpeg process could not be started - Process.Start'.

Solutions

  1. Verify the resolved ffmpeg path is a valid executable: run it manually from a terminal ('<path> -version')
  2. Reinstall/restore the bundled ffmpeg binary; check antivirus quarantine logs and whitelist ffmpeg
  3. Check file permissions/execute bits on the binary (especially Linux/macOS: chmod +x)
  4. Wrap ProcessMedia startup in try/catch with a retry, and log the full Win32Exception for diagnosis

Example fix

// before
using var proc = Process.Start(pb);
if (proc == null)
    throw new Exception("FFmpeg process could not be started - Process.Start");
// after
using var proc = Process.Start(pb);
if (proc == null)
    throw new InvalidOperationException(
        $"FFmpeg process could not be started at '{pb.FileName}'. Verify the binary is executable and not blocked by antivirus.");
Defensive patterns

Strategy: validation

Validate before calling

// Verify the ffmpeg binary is startable before processing
var path = FFmpegMediaProcessor.FindFFmpegBinary();
if (!File.Exists(path)) throw new FileNotFoundException("ffmpeg missing", path);
var check = Process.Start(new ProcessStartInfo(path, "-version")
    { UseShellExecute = false, RedirectStandardOutput = true });
if (check == null) throw new InvalidOperationException($"Cannot execute ffmpeg at {path}");
check.WaitForExit(5000);

Try / catch

try
{
    processor.ProcessMedia(args);
}
catch (Exception ex) when (ex.Message.Contains("FFmpeg process could not be started"))
{
    Log.Error(ex, "ffmpeg failed to launch; check AV quarantine, execute permission, and binary integrity");
    FallBackToRawStream();
}

Prevention

When it happens

Trigger: Process.Start(pb) returns null during ProcessMedia, e.g. the ffmpeg path points to a non-executable file, a blocked/broken AV quarantine, or an OS-level CreateProcess failure.

Common situations: Antivirus quarantining or blocking ffmpeg.exe right after it was located; corrupt or replaced ffmpeg binary; insufficient permissions on the executable; working directory missing; on Linux, a non-executable ffmpeg file path.

Related errors


AI-assisted analysis of subhra74/xdm@1ca5a25aae (2026-09-13). Data as JSON: /api/errors/c494e31d9f0c5d73. Report an issue: GitHub.

Appendix: source

Thrown at app/XDM/XDM.Core/Downloader/MediaProcessor/FFmpegMediaProcessor.cs:108

                    FileName = file,
                    UseShellExecute = false,
                    CreateNoWindow = true
                };

#if NET5_0_OR_GREATER
                foreach (var arg in args)
                {
                    pb.ArgumentList.Add(arg);
                }
#else
                pb.Arguments = XDM.Compatibility.ProcessStartInfoHelper.ArgumentListToArgsString(args);
#endif
                pb.RedirectStandardOutput = true;

                using var proc = Process.Start(pb);
                if (proc == null)
                {
                    throw new Exception("FFmpeg process could not be started - Process.Start");
                }

                proc.OutputDataReceived += (a, b) =>
                {
                    try
                    {
                        var line = b.Data;
                        if (line != null)
                        {
                            Log.Debug(line);
                            if (duration == 0.0)
                            {
                                var md = ParsingHelper.RxDuration.Match(line);
                                var ret = ParsingHelper.ParseTime(md);
                                if (ret > 0) duration = ret;
                            }
                            var mt = ParsingHelper.RxTime.Match(line);
                            var ret2 = ParsingHelper.ParseTime(mt);

View on GitHub (pinned to 1ca5a25aae)