screencapture

package module
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2025 License: MPL-2.0 Imports: 13 Imported by: 0

README

Go Reference

vnc-screencapture

Go VNC screen capture API and CLI.

Command line utility

Install with go install:

go install github.com/und3f/vnc-screencapture/cmd/vnc-screencapture
vnc-screencapture -vnc localhost:5900

API

Example of API usage for capturing few seconds from VNC connection:

conn, _ := net.Dial("tcp", "localhost:5900")

recorder, _ := screencapture.Connect(context.Background(), conn)

defer recorder.Close()

doneCh := make(chan any)
go func() {
    time.Sleep(2 * time.Second)
    doneCh <- struct{}{}
}()

recorder.Record(doneCh)

f, _ := os.Create("out.gif")
defer f.Close()

gifData, _ := recorder.RenderGIF()
gif.EncodeAll(f, gifData)

Documentation

Overview

Package vnc-screencapture provides API for capturing remote screen over VNC connection.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RecordGIF

func RecordGIF(ctx context.Context, conn net.Conn, doneCh chan any) (*gif.GIF, error)

RecordGIF initializes VNC connection, request screen updates until either context canceled, doneCh received, or VNC connection is closed using defaultOptions.

func RecordGIFWithOptions added in v0.1.4

func RecordGIFWithOptions(ctx context.Context, conn net.Conn, options CaptureOptions) (*gif.GIF, error)

Types

type CaptureOptions added in v0.1.4

type CaptureOptions struct {
	FBUpdaterFactory fbupdater.FBUpdaterFactory
	DoneCh           chan any
}

type ScreenCapture added in v0.1.1

type ScreenCapture interface {
	Record(done chan any) error
	RenderGIF() (*gif.GIF, error)
	Close() error
}

ScreenCapture is the interface for capturing VNC screen frames.

Record starts recording screen frames and could be stopped with done channel). Same connection may be reused for recording multiple times.

RenderGIF returns GIF image data and clears captured frames.

func Connect added in v0.1.1

func Connect(ctx context.Context, conn net.Conn) (ScreenCapture, error)

Connect initializes VNC connection and starts message processing goroutine. Use default parameters.

func ConnectWithOptions added in v0.1.4

func ConnectWithOptions(ctx context.Context, conn net.Conn, options CaptureOptions) (ScreenCapture, error)

Connect initializes VNC connection and starts message processing goroutine.

Directories

Path Synopsis
cmd
vnc-screencapture command
vnc-screencapture captures VNC screen and writes captured frames to GIF file.
vnc-screencapture captures VNC screen and writes captured frames to GIF file.

Jump to

Keyboard shortcuts

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