overwolf.media API
Use this API to capture a screenshot of the currently running game.
Permissions required: Media
Methods Reference
- overwolf.media.takeScreenshot()
- overwolf.media.takeScreenshot()
- overwolf.media.takeScreenshotEx()
- overwolf.media.takeWindowsScreenshotByHandle()
- overwolf.media.takeWindowsScreenshotByHandle()
- overwolf.media.takeWindowsScreenshotByName()
- overwolf.media.takeWindowsScreenshotByName()
- overwolf.media.getScreenshotUrl()
- overwolf.media.createScreenshotBuffer()
- overwolf.media.shareImage()
- overwolf.media.postMediaEvent()
- overwolf.media.getAppVideoCaptureFolderSize()
- overwolf.media.getAppScreenCaptureFolderSize()
- overwolf.media.getWebcams()
- overwolf.media.isXboxDVREnabled()
- overwolf.media.disableXboxDVR()
- overwolf.media.startGifBuffer() - Deprecated
- overwolf.media.stopGifBuffer() - Deprecated
- overwolf.media.generateGif() - Deprecated
- overwolf.media.deleteOldGifs() - Deprecated
- overwolf.media.getGifsSize() - Deprecated
Events Reference
- overwolf.media.onMediaEvent
- overwolf.media.onScreenshotTaken
- overwolf.media.onSconGifGenerationError - Deprecated
Types Reference
- overwolf.media.ScreenshotOptions Object
- overwolf.media.MemoryScreenshotParams Object
- overwolf.media.RescaleParams Object
- overwolf.media.CropParams Object
- overwolf.media.CreateScreenshotBufferParams Object
- overwolf.media.ScreenshotBuffer Object
- overwolf.media.CaptureFrameResult Object
- overwolf.media.enums.ImageFormat enum
- overwolf.media.enums.eMediaType enum
- overwolf.media.enums.eSourceType enum
- overwolf.media.enums.eVideoSourceTransform enum
- overwolf.media.FileResult Object
- overwolf.media.GetAppVideoCaptureFolderSizeResult Object
- overwolf.media.ScreenshotTakenEvent Object
- overwolf.media.GetWebcamsResult Object
- overwolf.media.Webcam Object
- overwolf.media.XboxDVRStatusResult Object
- overwolf.media.GifGenerationErrorEvent - Deprecated
In-memory screenshot overview
Some methods in the overwold.media API allows you to take in-memory screenshot.
For example, the takeScreenshot(callback) method returns in a callback argument a screenshot URL that looks like this:
overwolf://media/screenshots/custom/E:/Desktop%20Capture-07-15-2018%2014-15-22-793.jpg
You can use the retrieved URL later in order to serve the stated screenshot: for example, to upload it to remote server, you can use HTML canvas.
Sample app
Download here a Sample app for using the In-Memory Screenshot API.
takeScreenshot(callback)
Version added: 0.78
Takes a screenshot and calls the callback with the success status and the screenshot URL. The screenshot is saved to the screenshots folder.
As of version 0.310.0.16, this method processes on the GPU for every graphics API and is subject to the same per-app capture rate limit as getScreenshotUrl().
| Parameter | Type | Description |
|---|---|---|
| callback (Optional) | (Result: FileResult) => void | A function called after the screenshot was taken |
takeScreenshot(targetFolder, callback)
Version added: 0.117
Takes a screenshot and calls the callback with the success status and the screenshot URL. The screenshot is saved to the screenshots folder.
| Parameter | Type | Description |
|---|---|---|
| targetFolder | string | Target screen shot folder path |
| callback | (Result: FileResult) => void | A callback function which will be called with the status of the request and the screenshot URL. |
takeScreenshotEx(targetPath, options, callback)
Version added: 0.226
Takes a screenshot and calls the callback with the success status and the screenshot URL. The screenshot is saved to the screenshots folder.
As of version 0.310.0.16, this method processes on the GPU for every graphics API and is subject to the same per-app capture rate limit as getScreenshotUrl().
| Parameter | Type | Description |
|---|---|---|
| targetPath | string | Target screen shot file path |
| options (Optional) | ScreenshotOptions | Extra settings controlling the screenshot |
| callback (Optional) | (Result: FileResult) => void | A callback function which will be called with the status of the request and the screenshot URL. |
takeWindowsScreenshotByHandle(windowHandle, postMediaEvent, callback)
Version added: 0.115
Takes a window screenshot and calls the callback with the success status and the screenshot URL. The screenshot is saved to the screenshots folder.
| Parameter | Type | Description |
|---|---|---|
| windowHandle | int | The window handle number. The handle number can retrieved from overwolf.games.launchers.getRunningLaunchersInfo() |
| postMediaEvent | bool | set true to post (onMediaEvent) |
| callback | (Result: FileResult) => void | A function called after the screenshot was taken |
takeWindowsScreenshotByHandle(windowHandle, postMediaEvent, targetFolder, callback)
Version added: 0.115
Takes a window screenshot and calls the callback with the success status and the screenshot URL. The screenshot is saved to the screenshots folder.
| Parameter | Type | Description |
|---|---|---|
| windowHandle | int | The window handle number. The handle number can retrieved from overwolf.games.launchers.getRunningLaunchersInfo() |
| postMediaEvent | bool | set true to post (onMediaEvent) |
| targetFolder | string | Set target folder path for screenshot |
| callback | (Result: FileResult) => void | A function called after the screenshot was taken |
takeWindowsScreenshotByName(windowTitle, postMediaEvent, callback)
Version added: 0.115
Takes a window screenshot and calls the callback with the success status and the screenshot URL. The screenshot is saved to the screenshots folder.
This function is to capture a native OS window by it's OS window Title - for example - "Untitled - Notepad".
To capture one of your app's windows you should use HTML5 Canvas.toDataURL().
| Parameter | Type | Description |
|---|---|---|
| windowTitle | string | The OS window title |
| postMediaEvent | bool | set true to post (onMediaEvent) |
| callback | (Result: FileResult) => void | A function called after the screenshot was taken |
takeWindowsScreenshotByName(windowTitle, postMediaEvent, targetFolder, callback)
Version added: 0.117
Takes a window screenshot and calls the callback with the success status and the screenshot URL. The screenshot is saved to the
targetFolderfolder.
This function is to capture a native OS window by it's OS window Title - for example - "Untitled - Notepad".
To capture one of your app's windows you should use HTML5 Canvas.toDataURL().
| Parameter | Type | Description |
|---|---|---|
| windowTitle | string | The OS window title |
| postMediaEvent | bool | set true to post (onMediaEvent) |
| targetFolder | string | Set target folder path for screenshot |
| callback | (Result: FileResult) => void | A function called after the screenshot was taken |
getScreenshotUrl(screenshotParams, callback)
Version added: 0.85
Takes a memory screenshot and calls the callback with the success status and the screenshot URL.
- The screenshot will only be placed in the memory and will not be saved to a file (better performance).
- Can only be used while in a game.
- You can take a look at the in-memory screenshot sample app.
- You can read more about the in-memory screenshot here.
| Parameter | Type | Description |
|---|---|---|
| screenshotParams | MemoryScreenshotParams object | A JSON containing the parameters of the screenshot |
| callback (optional) | (Result: FileResult) => void | A function called after the screenshot was taken |
As of version 0.310.0.16, cropping and rescaling run on the GPU for every graphics API: DirectX 9, DirectX 11, DirectX 12, Vulkan, OpenGL, and OOPO games. Before 0.310.0.16, a sized capture in a Vulkan title was decoded, resized on the CPU, and re-encoded; that extra step, and the "avoid rescaling in Vulkan" guidance that came with it, no longer applies.
- One capture in flight per app. Calling
getScreenshotUrl()again before the previous callback returns is refused, not queued. Chain the next call from the callback instead of a timer. - Captures are rate limited to 30 per second with a burst allowance, tracked per app rather than shared across the whole client.
- A capture that can't be submitted now reports failure. Previously such a request was silently dropped and the callback was never called. You now get
success: falsewith an error. - Rescaled output uses mip filtering, so downscaled images have less aliasing than before, particularly on thin strokes. If you compare captures against stored reference images, regenerate them.
Usage Example
overwolf.media.getScreenshotUrl(
{
//Recommended for better rounding.
roundAwayFromZero : "true",
//Optional - Crop the screen (happens before the rescale, if both are used).
//Positive values are absolute, negative values are relative (-1.0 - 0)
crop: {
x: -0.5, //Start cropping at the middle of the screen
y: 0,
width: 400,
height: -0.5
},
//Optional - Rescale the final image to these dimensions
rescale: {
width: 1920,
height: -0.4
}
},
function(result) {
if (result.status == "success")
{
console.log(result.url);
}
}
);
createScreenshotBuffer(params, callback)
Version added: 0.310.0.16
Creates a reusable screenshot buffer handle. Call
capture()on the returned handle to grab raw pixels straight into anArrayBuffer, with no encode, decode, or file round trip.
Use this when you only need to read pixels (recognition, OCR, color sampling in a loop). The buffer holds raw pixels, not an image file, so you cannot set img.src from it. Use getScreenshotUrl() when the capture is meant to be displayed. Not supported on DX9 games.
| Parameter | Type | Description |
|---|---|---|
| params | CreateScreenshotBufferParams object | Pixel format, crop, and rescale settings, fixed once for this handle |
| callback | (Result: CreateScreenshotBufferResult) => void | A function called with the created handle |
A handle can be created before any game is running, since it only stores settings. The absence of a game is reported per capture() call, not at creation. Your app may hold up to 16 open handles at once; call close() on handles you're done with.
Usage Example
overwolf.media.createScreenshotBuffer(
{
format: 'rgba', // or 'bgra', 'gray8'
crop: { x: 0, y: 0, width: 640, height: 480 },
rescale: { width: 320, height: 240 },
roundAwayFromZero: false
},
(createResult) => {
if (!createResult.success) {
console.error(createResult.error);
return;
}
const handle = createResult.screenshotBuffer;
// handle.capture(...) to grab a frame, handle.close() when done
}
);
Capture loop example
Create the handle once, then chain each capture() call from the previous callback, never from setInterval:
let handle = null;
let running = false;
function startLoop() {
overwolf.media.createScreenshotBuffer({ format: 'gray8' }, (r) => {
if (!r.success) {
console.error(r.error);
return;
}
handle = r.screenshotBuffer;
running = true;
grab();
});
}
function grab() {
handle.capture((f) => {
if (!running) {
return;
}
if (!f.success) {
console.error(f.error);
stopLoop();
return;
}
const gray = new Uint8Array(f.buffer);
// gray[y * f.stride + x] is the luminance of one pixel.
grab(); // chain from the callback, never setInterval
});
}
function stopLoop() {
running = false;
if (handle) {
handle.close();
handle = null;
}
}
Errors
| Error | Cause |
|---|---|
No parameters provided | Pass at least {}. |
Unsupported format '<x>'. Supported: 'rgba', 'bgra', 'gray8'. For an encoded image use overwolf.media.getScreenshotUrl. | An encoded format such as png or jpg was requested. Use getScreenshotUrl() instead. |
too many open screenshot buffers (<n>) - close the ones you have finished with | The 16-handle-per-app limit was hit. Call close() on unused handles. |
Width and/or height provided in the rescale params are either <= 0 or width > 2560 or height > 1440. | rescale out of bounds. |
One of the crop inputs is below -1.0 ... / Requested image dimensions are out of bounds ... | crop out of bounds. |
screenshotBuffer.capture(callback)
Version added: 0.310.0.16
Grabs one frame using the handle's fixed settings.
| Parameter | Type | Description |
|---|---|---|
| callback | (Result: CaptureFrameResult) => void | A function called with the captured frame |
Only one capture at a time per handle. Calling capture() again while a previous call on the same handle is still pending fails immediately with success: false; it is not a thrown exception, so a try/catch around the call does not see it. The capture already running is unaffected and still delivers its own callback. This is deliberate back pressure: chain the next capture() from the callback, never from a timer faster than captures complete.
Errors
| Error | Cause |
|---|---|
a capture is already in progress on this buffer - wait for its callback | Another capture() on this handle is still pending. |
this screenshot buffer is closed | close() was already called, or the window that created the handle was closed. |
No game is running | Nothing to capture yet. |
capture did not return raw pixels / Capture failed | The capture engine could not produce a frame. |
could not create the ArrayBuffer ... | The frame arrived but could not be handed to JavaScript. |
A game's back-buffer alpha is whatever its last shader left there, often fully transparent. capture() always replaces it with fully opaque alpha, so you can draw the buffer (for example with putImageData) without touching the alpha channel yourself. This applies only to this raw path; getScreenshotUrl() is unaffected.
screenshotBuffer.close()
Version added: 0.310.0.16
Releases the handle and its slot against the 16-handles-per-app limit. Any later
capture()on it fails withthis screenshot buffer is closed.
The handle is also released when the window that created it closes, so forgetting close() leaks nothing permanently, but it holds a slot until then.
shareImage(image, description, callback)
Version added: 0.78
Opens the social network sharing console to allow the user to share a picture.
| Parameter | Type | Description |
|---|---|---|
| image | Object | A URL or image object to be shared |
| description | string | The description to be used when posting to social networks |
| callback | (Result) => void | Reports success or failure |
postMediaEvent(mediaType, jsonInfo, callback)
Version added: 0.91
Posts a media event for other apps to receive.
| Parameter | Type | Description |
|---|---|---|
| mediaType | eMediaType enum | The type of the event |
| jsonInfo | JObject | A json with additional info about the events |
| callback | (Result) => void | Reports success or failure |
getAppVideoCaptureFolderSize(callback)
Version added: 0.106
Returns the total size of the video capture folder created by the app. This includes all video/thumbnail and other files that are under the apps video folder.
- The apps video folder is located inside the configured Overwolf video capture folder.
- This function can take a long time to return if the folder contains a large amount of files (on some computers) – therefore, try to reduce the amount of times you call it.
| Parameter | Type | Description |
|---|---|---|
| callback | (Result: GetAppVideoCaptureFolderSizeResult) => void A callback with the size in MB |
getAppScreenCaptureFolderSize(callback)
Version added: 0.106
Returns the total size of the screen capture folder created by the app. This includes all images/thumbnail and other files that are under the apps images folder.
- The apps imagee folder is located inside the configured Overwolf image capture folder.
- This function can take a long time to return if the folder contains a large amount of files (on some computers) – therefore, try to reduce the amount of times you call it.
| Parameter | Type | Description |
|---|---|---|
| callback | (Result: GetAppScreenCaptureFolderSizeResult) => void A callback with the size in MB |
getWebcams(callback)
Version added: 0.159
Get all connected Webcams.
| Parameter | Type | Description |
|---|---|---|
| callback | (Result: GetWebcamsResult) => void A callback with the connected Webcams |
isXboxDVREnabled(callback)
Version added: 0.305.0.7
Returns whether Xbox Game DVR is enabled.
| Parameter | Type | Description |
|---|---|---|
| callback | (Result: XboxDVRStatusResult) => void | A callback with the Xbox Game DVR status. |
disableXboxDVR(callback)
Version added: 0.305.0.7
Disables Xbox Game DVR for the current user.
| Parameter | Type | Description |
|---|---|---|
| callback | (Result) => void | A callback with the status of the request. |
onMediaEvent
Version added: 0.78
Fired when a media event has been posted.
Event Data Example: Success
{
"origin": "nafihghfcpikebhfhdhljejkcifgbdahdhngepfb",
"triggerTime": "2018-10-22T16:56:39.000Z",
"events": [
"death"
],
"rawEvents": [
{
"type": "death",
"time": 15000
}
],
"mediaUrl": "overwolf://media/replays/Game+Summary/Fortnite/Fortnite_22-10-2018_19-53-40-1/Fortnite+10-22-2018+19-56-39-385.mp4",
"thumbnailUrl": "overwolf://media/thumbnails/Game+Summary/Fortnite/Fortnite_22-10-2018_19-53-40-1/Fortnite+10-22-2018+19-56-39-385.mp4",
"fullDuration": 20015,
"eventsDuration": 5015
}
onScreenshotTaken
Version added: 0.78
Fired when a screenshot was taken, with the following structure: ScreenshotTakenEvent Object
ScreenshotOptions Object
Version added: 0.226
Container for file screenshot settings.
| Parameter | Type | Description |
|---|---|---|
| imageFormat | ImageFormat | The file format to use for the taken image |
MemoryScreenshotParams Object
Version added: 0.78
Container for memory screenshot settings.
| Parameter | Type | Description |
|---|---|---|
| roundAwayFromZero | bool | When a number is halfway between two others, it is rounded toward the nearest number that is away from zero. Recommended for better precision |
| rescale | RescaleParams Object | The rescale settings |
| crop | CropParams Object | The crop settings |
RescaleParams Object
Version added: 0.78
Describes rescale parameters for memory screenshot.
| Parameter | Type | Description |
|---|---|---|
| width | double | The target width |
| height | double | The target height |
CropParams Object
Version added: 0.78
Describes rescale parameters for memory screenshot.
| Parameter | Type | Description |
|---|---|---|
| x | double | The x offset. Positive value is considered absolute (0 – WIDTH) and negative is considered relative (-1.0 – 0) |
| y | double | The y offset. Positive value is considered absolute (0 – HEIGHT) and negative is considered relative (-1.0 – 0) |
| width | double | The target width |
| height | double | The target height |
CreateScreenshotBufferParams Object
Version added: 0.310.0.16
Settings for a screenshot buffer handle, fixed once at creation.
| Parameter | Type | Description |
|---|---|---|
| format | string | 'rgba' (default), 'bgra', or 'gray8'. rgba is 4 bytes/pixel and the only one ImageData accepts without reordering. gray8 is 1 byte/pixel, the cheapest for recognition work. Encoded formats (png, jpg) are not accepted; use getScreenshotUrl() for those. |
| crop | CropParams object | Same crop settings getScreenshotUrl() accepts. |
| rescale | RescaleParams object | Same rescale settings getScreenshotUrl() accepts. Runs on the GPU on every renderer, Vulkan included. |
| roundAwayFromZero | bool | Rounds halfway values away from zero. Recommended for better precision. Default false. |
ScreenshotBuffer Object
Version added: 0.310.0.16
The reusable handle returned by
createScreenshotBuffer().
| Method | Description |
|---|---|
| capture(callback) | Grabs one frame with this handle's fixed settings. |
| close() | Releases the handle and its slot. |
CreateScreenshotBufferResult Object
Version added: 0.310.0.16
Result of
createScreenshotBuffer().
| Parameter | Type | Description |
|---|---|---|
| success | boolean | |
| status | string | "error" when success is false |
| error | string | Set only when success is false |
| screenshotBuffer | ScreenshotBuffer object | The handle, only when success is true |
CaptureFrameResult Object
Version added: 0.310.0.16
Result of
screenshotBuffer.capture().
| Parameter | Type | Description |
|---|---|---|
| success | boolean | |
| status | string | "error" when success is false |
| error | string | Set only when success is false |
| width | number | Width of the delivered image, in pixels |
| height | number | Height of the delivered image, in pixels |
| stride | number | Bytes per row. Rows are packed, so stride === width * bytesPerPixel and buffer.byteLength === stride * height |
| format | string | The pixel layout actually delivered: 'rgba', 'bgra', or 'gray8' |
| buffer | ArrayBuffer | The pixels. Alpha is always fully opaque. |
ImageFormat enum
Version added: 0.226
Image format to use for a file screenshot.
| Option | Description |
|---|---|
| Jpeg | .jpeg |
| Bmp | .bmp |
Screenshots taken before version 0.226 were always saved as a .jpg. If your app needs to handle those screenshots as well, make sure it
can handle both .jpeg and .jpg images (as well as .bmp if relevant)
eMediaType enum
Version added: 0.78
Media type for the Media Event.
| Option | Description |
|---|---|
| Video | |
| Image |
eSourceType enum
Version added: 0.159
Video source type.
| Option | Description |
|---|---|
| Webcam | |
| Generic | |
| image_source |
eVideoSourceTransform enum
Version added: 0.159
Video transform type.
| Option | Description |
|---|---|
| Stretch | |
| DockTopLeft | |
| DockTopMiddle | |
| DockTopRight | |
| DockMiddleLeft | |
| DockCenter | |
| DockMiddleRight | |
| DockBottomLeft | |
| DockBottomMiddle | |
| DockBottomRight |
FileResult Object
Version added: 0.149
Container for get file URL result.
| Parameter | Type | Description |
|---|---|---|
| url | string | |
| path | string |
Example data: Success
{
"success": true,
"status": "success", //deprecated and kept only for backward compatibility
"url": "overwolf://media/replays/App+Name/Dota+2+06-28-2016+17-59-37-620.mp4",
"path": "E://Video/Overwolf/App Name/Dota 2 06-28-2016 17-59-37-620.mp4"
}
Note that the last part of the file name is the replayId. In the above example, it's 620.
The replayId is needed to finish capturing the replay by calling for example to overwolf.media.replays.stopCapture(). In the above example, it's 620.
GetAppVideoCaptureFolderSizeResult Object
Version added: 0.149
Container for get file getAppVideoCaptureFolderSize result.
| Parameter | Type | Description |
|---|---|---|
| totalVideosSizeMB | number |
Example data: Success
{
"success": true,
"status": "success", //deprecated and kept only for backward compatibility
"totalVideosSizeMB": 12123,
}
GetWebcamsResult Object
Version added: 0.159
Container for get Webcams result.
| Parameter | Type | Description |
|---|---|---|
| WebCams | overwolf.media.Webcam[] |
Example data: Success
{
"success": true,
"status": "success", //deprecated and kept only for backward compatibility
"webCams ": [
{
"name":"Webcam C170",
"path":"\\\\?\\usb#vid_046d&pid_082b&mi_00#7&2c79cd0&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\\global",
"id":"Webcam C170:\\\\?\\usb#vid_046d&pid_082b&mi_00#7&2c79cd0&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\\global"
},
{
"name":"USB2.0 HD UVC WebCam",
"path":"\\\\?\\usb#vid_13d3&pid_5666&mi_00#6&2f2fc667&1&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\\global",
"id":"USB2.0 HD UVC WebCam:\\\\?\\usb#vid_13d3&pid_5666&mi_00#6&2f2fc667&1&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\\global"
},
{
"name":"OBS Virtual Camera",
"path":"",
"id":"OBS Virtual Camera:"
}
],
}
Webcam Object
Version added: 0.159
Container for Webcam proporties.
| Parameter | Type | Description |
|---|---|---|
| name | string | |
| path | string | |
| id | string |
Data example
{
"name":"Webcam C170",
"path":"\\\\?\\usb#vid_046d&pid_082b&mi_00#7&2c79cd0&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\\global",
"id":"Webcam C170:\\\\?\\usb#vid_046d&pid_082b&mi_00#7&2c79cd0&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\\global"
},
XboxDVRStatusResult Object
Version added: 0.305.0.7
Container for the Xbox Game DVR status.
| Parameter | Type | Description |
|---|---|---|
| enabled | bool | Whether Xbox Game DVR is enabled. |
| appCaptureEnabled | bool | Whether the current user has app capture enabled. |
| gameDVREnabled | bool | Whether the current user has Game DVR enabled. |
GetAppScreenCaptureFolderSizeResult Object
Version added: 0.149
Container for get file getAppVideoCaptureFolderSize result.
| Parameter | Type | Description |
|---|---|---|
| screenCaptureSizeMB | number |
Example data: Success
{
"success": true,
"status": "success", //deprecated and kept only for backward compatibility
"screenCaptureSizeMB": 12123,
}
ScreenshotTakenEvent Object
| Parameter | Type | Description |
|---|---|---|
| url | string |
Event data example: Success
{
"success": true,
"url": ""
}