Good Quality DOSBox Video Capture

By Susam Pal on 15 Jun 2019

IBM/LCSI Logo in DOSBox

Once in a while, I fire up one of the vintage DOS games or language interpreters in DOSBox for nostalgia's sake. I have archived these vintage programs at https://github.com/susam/dosage. Last night, I picked up IBM Personal Computer Logo developed by Logo Computer Systems Inc. (LCSI) in 1983.

A screenshot of IBM Personal Computer Logo with copyright notices of IBM and LCSI, welcome message, and question mark prompt
Welcome screen of IBM Personal Computer Logo

Logo was the first programming language I learnt in my life. I came across it at the age of 8 when I was in Class 4 and our school had a 5¼-inch floppy disk with IBM PC Logo on it. About 20 years later, I would realize that the first programming language I learnt is a dialect of Lisp. How wonderful!

One of the things I enjoyed drawing with Logo was a grid of overlapping circles like this:

A grid made with 20 circles along with Logo source code for it
Grid of circles drawn with IBM Personal Computer Logo

Here is the Logo source code for the above output:

REPEAT 20 [REPEAT 180 [FD 1 RT 2] RT 18]

DOSBox Screenshot Capture

The screenshots above were obtained by running IBM Personal Computer Logo Version 1.00 in DOSBox v0.74-2 in macOS High Sierra version 10.13.6 and then resizing the screenshots such that their aspect ratio matches the aspect ratio of old CRT computer monitors.

To obtain the screenshots, we first press Ctrl + F5 while DOSBox is running. The paths of the screenshots appear in the console output at the terminal where DOSBox was launched. For example:

Capturing Screenshot to /Users/susam/Library/Preferences/capture/logo_000.png
Capturing Screenshot to /Users/susam/Library/Preferences/capture/logo_001.png

The screenshots obtained in this manner have an aspect ratio of 8:5 which makes the output look stretched horizontally. The old CRT computer monitors for which these old DOS programs were written had an aspect ratio of 4:3 instead. This stretched look can be fixed by resizing the images to an aspect ratio of 4:3. Here are the commands used to fix the aspect ratio and produce the images:

convert logo_000.png -sample '640x480!' dosbox-logo-0.png
convert logo_001.png -sample '640x480!' dosbox-logo-1.png

The convert program comes with ImageMagick. There are a few things worth noting here:

By the way, I have donated both images above to Wikimedia Commons under the Creative Commons Attribution 4.0 International (CC BY 4.0) license:

Having the images on Wikimedia Commons helps to include these screenshots in the Wikipedia article on Logo.

DOSBox Video Capture

To start capturing video of DOSBox, we press Ctrl + Alt + F5. The same key combination stops capturing video. The following output appears in the console output to show where the video file is saved:

Capturing Video to /Users/susam/Library/Preferences/capture/logo_000.avi
Stopped capturing video.

Now I wanted to share this video with my contacts who might be on devices that do not support playing AVI files, so I decided to convert this to MP4 format with the following FFmpeg command:

ffmpeg -i logo_000.avi -an -c:v libx264 -crf 17 -preset veryslow \
       -pix_fmt yuv420p -vf scale=640:480:flags=neighbor \
       dosbox-logo-circles.mp4

Here is what the output looks like:

Video capture of IBM Personal Computer Logo [MP4]

Let us briefly discuss the various FFmpeg options used here:

DOSBox GIF Animation

Now just for fun, let us see if we can convert the video capture into a GIF animation. This can be done quite easily with FFmpeg like this:

ffmpeg -i logo_000.avi -vf palettegen palette.png
ffmpeg -i logo_000.avi -i palette.png \
       -lavfi 'fps=30,scale=640:480:flags=neighbor,paletteuse' \
       dosbox-logo-circles.gif

The first command generates a color palette from the video capture. The second command uses this color palette to generate a GIF animation. Like before, we use the neighbor flag to retain the crisp and jagged edges. Here is the output:

An animated image of programming in Logo
GIF Animation of IBM Personal Computer Logo

Further Reading

Here is a bunch of references that contains more details about the commands used in this article: