capture

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package capture defines the screen capture contract shared by the platform backends: DXGI Desktop Duplication on Windows, ScreenCaptureKit on macOS, and PipeWire or KMS on Linux.

Index

Constants

This section is empty.

Variables

View Source
var ErrAccessLost = errors.New("capture: access lost")

ErrAccessLost means the source must be reopened (mode change, secure desktop, fullscreen switch).

View Source
var ErrTimeout = errors.New("capture: no new frame")

ErrTimeout means no new image arrived in the wait window: the screen did not change. It is not a failure.

Functions

This section is empty.

Types

type Display

type Display struct {
	ID      string
	Name    string
	Adapter gpu.Adapter
	// X and Y are the display's top-left corner on the desktop, in pixels
	// (Windows; 0, 0 for the primary display).
	X, Y    int
	Width   int
	Height  int
	Refresh float64
	HDR     bool
	Primary bool
}

Display describes one capturable output.

type Format

type Format uint8

Format is the pixel layout of a captured surface.

const (
	FormatBGRA8   Format = iota + 1 // 8-bit SDR desktop
	FormatRGB10A2                   // 10-bit SDR or HDR10 (PQ) desktop
	FormatRGBA16F                   // scRGB HDR desktop
	FormatNV12                      // capture already converted to 4:2:0 8-bit
	FormatP010                      // capture already converted to 4:2:0 10-bit
)

func (Format) String

func (f Format) String() string

type Frame

type Frame struct {
	Surface uintptr
	Adapter gpu.LUID
	Format  Format
	Width   int
	Height  int
	// Presented is when the compositor showed this image, on the monotonic
	// clock of the platform (QPC on Windows, mach_absolute_time on macOS).
	Presented time.Duration
	// Acquired is when the source handed the frame to the caller, same clock.
	Acquired time.Duration
	// Dirty lists changed rectangles when the backend reports them; nil means
	// the whole frame may have changed.
	Dirty []Rect
}

Frame is a GPU surface owned by the source until Release is called on it. Surface is the platform handle: an ID3D11Texture2D* on Windows, a CVPixelBufferRef (IOSurface backed) on macOS.

type Rect

type Rect struct{ X, Y, W, H int }

type Source

type Source interface {
	// Next blocks for up to timeout for a new frame. The returned frame stays
	// valid until Release.
	Next(timeout time.Duration) (Frame, error)
	Release() error
	Close() error
}

Source produces frames from one display.

Directories

Path Synopsis
Package cursor reads the host's system cursor: whether it shows, whether an app holds the mouse, and where it is.
Package cursor reads the host's system cursor: whether it shows, whether an app holds the mouse, and where it is.
Package display lists the capturable displays of this machine and opens one with the platform's capture backend: DXGI Desktop Duplication on Windows, ScreenCaptureKit on macOS.
Package display lists the capturable displays of this machine and opens one with the platform's capture backend: DXGI Desktop Duplication on Windows, ScreenCaptureKit on macOS.
Package dxgi captures a Windows display with DXGI Desktop Duplication.
Package dxgi captures a Windows display with DXGI Desktop Duplication.
Package sck captures a macOS display with ScreenCaptureKit through purego, with no cgo.
Package sck captures a macOS display with ScreenCaptureKit through purego, with no cgo.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL