NickeManarin/ScreenToGif · error · Exception

Could not find a proper output device for the area of L: {Le

Error message

Could not find a proper output device for the area of L: {Left}, T: {Top}, Width: {Width}, Height: {Height}.

What it means

Thrown by GetOutput(Factory1) in DirectImageCapture when Desktop Duplication (DXGI) cannot find any display output that intersects the requested capture rectangle. The code first tries to match by DeviceName, then falls back to the output with the largest overlapping area; if every adapter's Outputs collection yields nothing, 'output' stays null. It means the DXGI factory enumerated no usable monitor for the given Left/Top/Width/Height region.

Source

Thrown at ScreenToGif/Capture/DirectImageCapture.cs:231

        try
        {
            //Gets the output with the bigger area being intersected.
            var output = factory.Adapters1.SelectMany(s => s.Outputs).FirstOrDefault(f => f.Description.DeviceName == DeviceName) ??
                         factory.Adapters1.SelectMany(s => s.Outputs).OrderByDescending(f =>
                         {
                             var x = Math.Max(Left, f.Description.DesktopBounds.Left);
                             var num1 = Math.Min(Left + Width, f.Description.DesktopBounds.Right);
                             var y = Math.Max(Top, f.Description.DesktopBounds.Top);
                             var num2 = Math.Min(Top + Height, f.Description.DesktopBounds.Bottom);

                             if (num1 >= x && num2 >= y)
                                 return num1 - x + num2 - y;

                             return 0;
                         }).FirstOrDefault();

            if (output == null)
                throw new Exception($"Could not find a proper output device for the area of L: {Left}, T: {Top}, Width: {Width}, Height: {Height}.");

            //Position adjustments, so the correct region is captured.
            OffsetLeft = output.Description.DesktopBounds.Left;
            OffsetTop = output.Description.DesktopBounds.Top;
            DisplayRotation = output.Description.Rotation;

            if (DisplayRotation != DisplayModeRotation.Identity)
            {
                //Texture that is used to receive the pixel data from the GPU.
                TransformTexture = new Texture2D(Device, new Texture2DDescription
                {
                    ArraySize = 1,
                    BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource,
                    CpuAccessFlags = CpuAccessFlags.None,
                    Format = Format.B8G8R8A8_UNorm,
                    Width = Height,
                    Height = Width,
                    OptionFlags = ResourceOptionFlags.None,

View on GitHub (pinned to a4d0a67c21)

Solutions

  1. Disable 'Use Desktop Duplication API' in Options > Capture so ScreenToGif falls back to BitBlt (ImageCapture / CachedCapture).
  2. Run ScreenToGif on a physical session with at least one powered-on monitor attached to the GPU, not over RDP.
  3. Verify the selected monitor still exists in _viewModel.Monitors and that the capture rectangle is inside a real screen's bounds before calling GetDirectCapture.
  4. Update or re-enable the GPU driver so DXGI.Adapters1[*].Outputs is populated.

Example fix

// before
Capture = GetDirectCapture();
Capture.DeviceName = _viewModel.CurrentMonitor.Name;

// after
var target = _viewModel.Monitors.FirstOrDefault(m => m.Name == _viewModel.CurrentMonitor.Name);
if (target == null || !_viewModel.Monitors.Any())
    throw new InvalidOperationException("No DXGI output matches the capture region.");
Capture = GetDirectCapture();
Capture.DeviceName = target.Name;
Defensive patterns

Strategy: validation

Validate before calling

// Run before GetDirectCapture()
var adapters = new Factory1().Adapters1;
var anyOutput = adapters.SelectMany(a => a.Outputs).Any(o =>
{
    var b = o.Description.DesktopBounds;
    var x = Math.Max(Left, b.Left); var r = Math.Min(Left + Width, b.Right);
    var y = Math.Max(Top, b.Top);  var bot = Math.Min(Top + Height, b.Bottom);
    return r >= x && bot >= y;
});
if (!anyOutput) { /* fall back to BitBlt or surface a user message */ }

Type guard

// n/a — runtime enumeration, not a type narrowing problem

Try / catch

try { Capture = GetDirectCapture(); }
catch (Exception ex) when (ex.Message.Contains("output device"))
{
    LogWriter.Log(ex, "DDU output lookup failed, falling back to BitBlt");
    UserSettings.All.UseDesktopDuplication = false;
    Capture = new ImageCapture();
}

Prevention

When it happens

Trigger: Calling GetDirectCapture() / starting a recording with UseDesktopDuplication = true when factory.Adapters1.SelectMany(s => s.Outputs) is empty, or no adapter has an Output whose DesktopBounds intersects {Left, Top, Width, Height}. DeviceName mismatch plus zero geometric intersection.

Common situations: Running inside an RDP / remote session where DXGI exposes no outputs; a headless or VM host without an active physical GPU display; capture region coordinates are off-screen after a monitor layout change; GPU driver disabled/reset so the adapter has no Outputs; selecting a virtual display / mirrored display that DXGI does not expose.

Related errors


AI-assisted analysis of NickeManarin/ScreenToGif@a4d0a67c21 (2026-08-13). Data as JSON: /api/errors/c5bbc2db4ccd5d62. Report an issue: GitHub.