Method GetScreenshotAsync
- Namespace
- OBSStudioClient.Model
- Assembly
- OBSClient.dll
GetScreenshotAsync(string, int?, int?, int?, CancellationToken)
Asks OBS Studio for a screenshot of the scene or the input, as it is rendered at the moment.
public Task<ObsScreenshot> GetScreenshotAsync(string format = "png", int? width = null, int? height = null, int? quality = null, CancellationToken cancellationToken = default)
Parameters
formatstringThe image format: one of SupportedImageFormats (
pngandjpgare always among them).widthint?The width to scale the image to, from 8 to 4096, or null. With a height, the image is scaled to fit inside both, and keeps its proportions.
heightint?The height to scale the image to, from 8 to 4096, or null. Without a width and a height the image has the size of the source.
qualityint?The compression quality, from 0 (the smallest file) to 100 (uncompressed), or -1 or null for the default of the format.
cancellationTokenCancellationTokenA token that ends the wait. A request that was not sent yet is not sent.
Returns
- Task<ObsScreenshot>
The screenshot.
Remarks
The image travels over the connection as text: a large screenshot of a source with a high resolution takes time and memory (and a message that large can be refused by the settings of the server); ask for a size that you need, or use SaveScreenshotAsync(string, string, int?, int?, int?, CancellationToken) to have OBS Studio write the file. See GetActivityAsync(CancellationToken) for the moment that the image shows.
Exceptions
- ArgumentException
formatis empty.- ArgumentOutOfRangeException
widthorheightis not from 8 to 4096, orqualityis not from -1 to 100.- ObsRemovedException
The scene or input was destroyed.
- ObsNotConnectedException
There is no connection to OBS Studio.
- ObsNotReadyException
OBS Studio is changing its scene collection, or did so after the call.
- TimeoutException
OBS Studio did not answer in time (WriteTimeout).
- ObsResponseException
OBS Studio refused the request: it does not support the format, or it could not render or encode the image.