Table of Contents

Method SaveScreenshotAsync

Namespace
OBSStudioClient.Model
Assembly
OBSClient.dll

SaveScreenshotAsync(string, string, int?, int?, int?, CancellationToken)

Has OBS Studio write a screenshot of the scene or the input to a file, and returns when the file is written.

public Task SaveScreenshotAsync(string path, string format = "png", int? width = null, int? height = null, int? quality = null, CancellationToken cancellationToken = default)

Parameters

path string

The path of the file, on the computer that OBS Studio runs on: for example C:\Users\me\Desktop\screenshot.png. The folder has to exist.

format string

The image format: one of SupportedImageFormats. It is not taken from the extension of the path.

width int?

The width to scale the image to, from 8 to 4096, or null.

height int?

The height to scale the image to, from 8 to 4096, or null.

quality int?

The compression quality, from 0 (the smallest file) to 100 (uncompressed), or -1 or null for the default of the format.

cancellationToken CancellationToken

A token that ends the wait. A request that was not sent yet is not sent.

Returns

Task

A task that completes when OBS Studio has written the file.

Remarks

The file is written on the computer of OBS Studio. OBS Studio does not send ScreenshotSaved for a screenshot that a request made: the call returns when the file is written. See SetEnabledAsync(bool, CancellationToken) for the order of changes.

Exceptions

ArgumentException

path or format is empty.

ArgumentOutOfRangeException

width or height is not from 8 to 4096, or quality is not from -1 to 100.

ObsRemovedException

The scene or input was destroyed.

ObsNotConnectedException

There is no connection to OBS Studio. Nothing was changed.

ObsNotReadyException

OBS Studio is changing its scene collection, or did so after the call. Nothing was changed.

ObsUnknownOutcomeException

OBS Studio did not answer in time, or the connection ended: it is not known whether it wrote the file.

ObsResponseException

OBS Studio refused the request: it does not support the format, the folder does not exist, or it could not render, encode or write the image.