Jump to content

Tutorial for automated screenshot stitching of video game levels

From Gassy GaoGao wiki

The Gassy GaoGao wiki uses stitched screenshots to show level layouts. Stitching together screenshots into one big screenshot manually could be doable for small maps. But if one is tasked to stitch 400 levels as with the case with the Gassy GaoGao wiki, that can quickly become unreasonable.

A horizontal capture of a video game level. The main character who is a dragon is placed on the left. Doors are placed on the right side of the level. The level is split by a gap in the middle.
A sample Gassy GaoGao stage. S001's level layout captured in whole. The level normally spans multiple screens. Yet, it is displayed in one image.

Enter the world of automation. This is a task that can be done by tools like Animmerger.

This guide mostly assumes the user is on a Windows system. Contributions for documenting other operating systems are welcomed.

Setting up OBS (Windows)

Animmerger operates by using image frames. It's recommended to set OBS to output lossless video, both in the codec and color profile. This is required because Animmerger's motion tracker gets easily derailed by lossy input.

Start by creating a new profile. Profile > new. Settings for color profile, video codec, filtering and scaling will be changed.

Scaling

Likely, the game is a low-resolution retro game being emulated. Or uses pixel art graphics (Just hope those pixels are actually aligned!). Since the video being created isn't intended for people to see, it'll be best to avoid upscaling those pixels.

In settings, configure OBS to use a canvas resolution that matches the game's native resolution. Don't use the scaled resolution, it'll probably still work, but we like small files.

Potentially, the scene will need to be downscaled. Resize the game's source to fit within the canvas. If the game had to be resized, it's important to set its filtering to work best with pixel graphics. Open up the context menu for the scene and select Scale Filter > Point.

Color profile

A common mistake with setting up lossless encoding for OBS is also missing the color format.

In OBS settings, hit the Advanced tab, find the Video group and see the Color Format option. Select I444 (8-bit, 4:4:4, 3 planes) to prepare capturing those raw RGB pixels.

Lossless video encoding

On the output tab in OBS settings, the simple recording preset for "Lossless Quality" can be fine for short recordings.

For efficient lossless recording, advanced settings must be used.

Video stitching with Animmerger

Preparation and installation

Animmerger and FFmpeg are CLI programs. That means they won't pop open a window if one were to use it like a standard Windows program. To make the most use out of them, a terminal is required.

There are many ways to open up command prompt in Windows. But I like doing it through Windows Explorer. On the address bar, click on an empty space and enter cmd. Depending on user preference, either Windows Terminal or Command Prompt will open. Notably, this will set the terminal's current working directory in the folder that Windows Explorer was in.

Chances are, FFmpeg is already installed. Check by executing ffmpeg -version if something like ffmpeg version n8.1 Copyright (c) 2000-2026 the FFmpeg developers shows up, it's installed. Otherwise, install FFmpeg for the target operating system.

Download Animmerger (archive). For Windows, a binary is available on the file which ends as -win32.zip.

Windows needs to explicitly know what programs are installed by the user. The program's directory needs to be added to the user or system's PATH environment variable. Though, this guide won't dive into that. Instead, we'll be executing Animmerger by specifying an absolute path. This guide might say to run animmerger but that can easily be substituted for something like "C:\Users\Moon Moon\Downloads\animmerger\animmerger.exe"

Extract video frames

With the lossless video recorded, it's time to send it to Animmerger for processing. This command extracts frames of a given video into many PNG files:

ffmpeg -i ./video.avi ./frame%04d.png

The video might have some transitional frames. In that case, those frames can be deleted.

Stitching frames together

In the same directory, simply execute animmerger -pf ./*.png[1] and let it run. It should produce a whole image stitched together.

The -pf flag tells Animmerger to keep the first pixels that appears. This is useful for figuring out initial enemy positions. Though, this will come at the cost of distorting any moving sprites. Some manual cleanup may be necessary.

A good tip is to allow the video recorder to record more frames per second. Gassy GaoGao always runs at 60 FPS.

Animmerger can do more. Check out its website for more examples.

Tips

It's sometimes necessary to guide Animmerger's motion tracker. A border on the frames of the images can help. Using ImageMagick and this PowerShell script, vertical or horizontal sides can be added to the frame images.

$count = 1000
$border = "0x2" # 0x2 for horizontal levels. 2x0 for vertical levels.

for ($i = 1; $i -le $count; $i++) {
	$number = $i.ToString().PadLeft(4, "0")
	magick "./frame$number.png" -bordercolor "#ffffff" -border $border "./Bordered frames/frame$number.png"
}
  1. This is assuming that the system is aware of what "animmerger" means. See the "Preparation and installation" section for substitution notes.