I hope this question isn’t inherently nonsensical.
I’m developing a game. I’ve separated out the underlying game engine (in Python) from the graphics component. I have a script that fuzzes some parameters, simulates part of a game using the game engine, and then visualizes it using Pygame.
I’d like to automate the following process:
- Run simulation as cronjob
- Visualize it using Pygame (headlessly)
- Save visualization as a short (~10 sec) video file
- Programmatically upload video to Youtube
Ideally, I’d like to do this a few times a day so non-technical members of my team could view the video and give feedback on visual aspects of the game.
I’d like to use Pygame because I’ve already got the code ready to go. But I suspect I should probably use something like PIL to create a series of image files and go from there.
Is this possible with Pygame? Should I just use PIL? Any other ideas for accomplishing something like this?
Assuming you are running on linux, and your graphics engine works in X, you can headlessly run any application you want using Xvfb (X virtual framebuffer). You can run a video encoder of the virtual (headless) framebuffer session. There are a couple of utilities to make this task easier:
You’d want to make a top level script which would:
Xvfb and ffmpeg are definitely the way to go for recording the game headlessly, this ensures you can record your game as is with no modifications. It should be doable but not necessarily easy. The above scripts should hopefully get you started.