r/mpv 11d ago

User Scripts & Shaders Batch Screenshots?

I was wondering if there’s a way to set a specific amount of screenshots & have Mpv stop automatically after it’s reached that amount? I’m using Mac & I use opt + s to start taking screenshots. But for example I would like to cap it around 80.

For reference, I’m on macOS Ventura, & using Mpv v. 0.29.0
Any help would be appreciated!

3 Upvotes

3 comments sorted by

1

u/kiameliala 11d ago

1

u/mila0814 11d ago

I'm new & not too familiar with script 🥲. Is this it:

// callback hell...

function callbackScreenshot(counter, screenshots) {

mp.command_native_async(["seek", calculateSeekTime(counter), "absolute", "exact"], function (success, _, error) {

if (!success) {

callback(false, error, []);

}

var imagePath = mp.utils.join_path(screenshotDir, "temp_screenshot-".concat(counter, ".").concat(ssFormat));

function waitForSeekAndScreenshot() {

var isSeeking = mp.get_property_bool('seeking', false);

if (isSeeking) {

setTimeout(waitForSeekAndScreenshot, 50);

}

else {

mp.command_native_async(["screenshot-to-file", imagePath, options.mode], function (success, _, error) {

if (!success) {

callback(false, error, screenshots);

return;

}

// if counter is equal to totalImages, we are done

if (counter >= totalImages) {

callback(true, undefined, __spreadArray(__spreadArray([], screenshots, true), [imagePath], false));

return;

Or is there something else i should be looking for?