subhra74/xdm · error

Non-zero error code from youtube-dl:

Error message

Non-zero error code from youtube-dl: 

What it means

YDLProcess.Start runs an external youtube-dl/yt-dlp process and, after it exits, throws if the exit code is non-zero. youtube-dl uses non-zero exit codes to signal download/extraction failures (network errors, unsupported URL, HTTP 403/404, missing ffmpeg, etc.). The exception message includes the numeric exit code but not stderr — that is only written to the debug log.

Solutions

  1. Read the debug log entry 'Non-zero error code from youtube-dl: <code>' and the captured process output to see the underlying yt-dlp error.
  2. Update youtube-dl/yt-dlp to the latest version (most failures are stale extractors).
  3. Verify ffmpeg/ffprobe are installed and on PATH if format merging/conversion was requested.
  4. Test the same URL directly with yt-dlp on the command line to reproduce and see the full error text.
  5. Retry with different format selection or pass cookies/user-agent if the site requires authentication.

Example fix

// before
ydl.Start(); // throws generic Exception on failure

// after
try
{
    ydl.Start();
}
catch (Exception ex)
{
    Log.Debug(ex, "ydl failed; check yt-dlp version and ffmpeg availability");
    throw;
}
Defensive patterns

Strategy: try-catch

Validate before calling

var which = TryRun("yt-dlp --version");
if (which == null) throw new Exception("yt-dlp not runnable");

Try / catch

try { ydlProc.Start(); }
catch (Exception ex) when (ex.Message.StartsWith("Non-zero error code from youtube-dl"))
{
    Log.Error(ex, "yt-dlp failed; update yt-dlp, verify ffmpeg on PATH, check the URL");
    throw;
}

Prevention

When it happens

Trigger: Any invocation of a ydl-based operation (download/info extraction via YDLProcess.Start) where the youtube-dl/yt-dlp process terminates with ExitCode != 0 — e.g. unsupported URL, HTTP errors fetching the video, ffmpeg missing for requested format merge, out-of-date extractor.

Common situations: Outdated youtube-dl facing a site layout change (exit code 1); requested format unavailable (exit 1); disk full or permission errors; ffmpeg not on PATH when merging formats (exit 1); site requires cookies/age verification.

Related errors


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

Appendix: source

Thrown at app/XDM/XDM.Core/YDLWrapper/YDLProcess.cs:112

                ydlProc.ErrorDataReceived += (a, b) =>
                {
                    if (b.Data != null)
                    {
                        Log.Debug(b.Data);
                    }
                };

                ydlProc.BeginOutputReadLine();

                ydlProc.WaitForExit();
                fs.Close();

                var exitCode = ydlProc.ExitCode;

                if (ydlProc.ExitCode != 0)
                {
                    Log.Debug("Non-zero error code from youtube-dl: " + ydlProc.ExitCode);
                    throw new Exception("Non-zero error code from youtube-dl: " + ydlProc.ExitCode);
                }
            }
            finally
            {
                ydlProc?.Dispose();
                ydlProc = null;
            }
        }

        private static YtBinaryType GetYtBinaryType(string executableName)
        {
            if (executableName.StartsWith("yt-dlp"))
            {
                return YtBinaryType.YtDlp;
            }
            return YtBinaryType.Yt;
        }

View on GitHub (pinned to 1ca5a25aae)