Created
October 29, 2016 00:05
-
-
Save endrift/e229869d261309a95d4965e67a1b6a2e to your computer and use it in GitHub Desktop.
Let's take screenshots of a bunch of games.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mgba.core | |
import mgba.image | |
import mgba.log | |
import os, os.path | |
import sys | |
from concurrent.futures import ThreadPoolExecutor | |
logger = mgba.log.NullLogger() | |
mgba.log.installDefault(logger) | |
def runSingle(root, name, out="."): | |
core = mgba.core.loadPath(os.path.join(root, name)) | |
if not core: | |
return | |
screen = mgba.image.Image(*core.desiredVideoDimensions()) | |
core.setVideoBuffer(screen) | |
core.reset() | |
print('Starting %s' % name) | |
for frame in [30, 60, 300, 900, 1800, 3600]: | |
while core.frameCounter() < frame: | |
core.runFrame() | |
with open(os.path.join(out, '%s-%d.png' % (name, frame)), 'wb') as f: | |
screen.savePNG(f) | |
print('Finished %s' % name) | |
if __name__ == '__main__': | |
with ThreadPoolExecutor(max_workers=4) as e: | |
for dirname, _, files in os.walk(sys.argv[1]): | |
for f in files: | |
e.submit(runSingle, dirname, f, sys.argv[2]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment