Recently, I finally broke off a longtime relationship with Windows. Never again. I've moved over to Linux, and while I have some experience using it as a live boot for one task or another, using it for my primary operating system is quite a learning curve.
Now, I want to be able to record gameplay of Commander Keen mods, but here's the problem: my laptop is a potato. The thing is 10 years old and wasn't exactly top-of-the-line even when it was new. I'd been able to use DOSBox's built-in recorder with no problems under Windows (the default OS), but there's been a few unique issues that have popped up under Linux and with my specific setup.
It was an entire ordeal, but where there's a will there's a way, and I've managed to get things set up so that I can record DOSBox's video and audio about as smoothly as I can hope. In order to hopefully prevent anyone else from dealing with as many headaches as I had to, I'm writing this guide on what I learned.
It should be noted that all the Linux distributions I have experimented with are Debian-based. Given the variety between different Linux distros, I can't guarantee that these tips will work on any others.
Section I -- DOSBOX built-in video recorder
One of my favorite features of DOSBox, and the first screen recorder I had access to. Even for personal use, it's a lot better than screenshots for capturing cool moments! An interesting effect of using the built-in recorder is that any lag caused by the recording process will not be captured in the video file, only showing what was rendered inside of DOSBox's simulation and not how it displayed on your screen. This also applies to other effects external to the actual game emulation, such as DOSBox's fast-forward function. As such, if you're going to be recording a calm area with no hazards in the game, you could get away with using the built-in recorder even if it lags because it won't show up in the video. However, if you're going to be needing any kind of reaction time to play, you'll want to get rid of as much lag as possible.
Now, onto the tips.
DON'T USE CTRL - ALT - F5. This applies no matter how much horsepower your computer has. This is the default key combo that DOSBox uses to start its video capture, which works fine under Windows, but Linux uses this combination to initiate something called tty5, which turns your whole screen into a big scary-looking terminal. If you find yourself in this position and want to escape back to the comfort of a graphical environment, press Ctrl + Alt + F7.
It is possible to disable the tty5 so that Ctrl + Alt + F5 does nothing by itself, but it is a lot simpler (and much less risk of messing up something important) to reconfigure DOSBox to use a different shortcut to record video.
For the beginners:
To assign a different shortcut to DOSBox's video recording, open DOSBox and press Ctrl + F1 (or Ctrl + Fn + F1 if your keyboard requires it) to open the keymapper. Click the box that says "Video", click "Add", press the key you would like to use to toggle video capture, and if you want the shortcut to also require the simultaneous use of Ctrl and Alt (probably a good idea if you don't want to accidentally record video every time you hit your designated key), check the boxes at the bottom of the screen that say "mod1" and "mod2" (these default to "left ctrl" and "left alt", respectively). Click "Save".
VLC DOES NOT DOSBOX. VLC is a video player that comes built-in with many Linux distros, but it doesn't seem to get along well with the ZMBV video codec that DOSBox uses.
One example: It can't seem to handle palette changes that occur during the video. After trying to use DOSBox's recording function on a changed-palette mod, I looked at the footage in VLC and was dismayed to find that the colors displayed were default EGA (all the wrong colors). After some puzzled experimentation, I went and grabbed MPV (another video player) and opened that file, and behold, the colors displayed as they appeared in DOSBox. It wasn't a problem with the video, just VLC.
Another example of VLC's limitations: While trying to figure out just what was wrong with my recording, I tried to open some older DOSBox-created videos that had been recorded under Windows. VLC played the sound from the recording, but only displayed a black screen. I knew these files were fully functional, which is what led me to try a different video player.
Interesting trivia discovered here:
Another effect of the lack of palette shifting is that the fade in/out effect, seen when entering a level for instance, doesn't show up. Instead it displays a hard cut between the fully illuminated world map and new level. This makes it possible to see that in Vorticons Keen, sprites aren't rendered until a frame after the tiles.
The standard patch that is used for palette modification seems to apply the new colors shortly after the game has already initiated. When I started the recording while in the DOSBox console before running the batch file to play the mod, the colors displayed as EGA in the video output, as stated above. However, if the recording was started after the mod was already in the main menu, VLC had no problems seeing the new colors. I tried this with a few changed-palette mods and the effect was the same. The only exception was Operation Ocflore, which instead defines the colors with a command before the game opens. As a result, the palette doesn't change after the mod initiates, and so DOSBox's recording of the program doesn't confuse VLC.
WRITE SPEED IS IMPORTANT. Here's where we start getting into computer performance. When I started testing DOSBox recording on this OS, I was running unmodified Keen 1 and noticed some pretty constant frame lag while recording was active. This didn't make any sense at first, because I had recorded Vorticons gameplay under Windows before and had no performance issues, and everything I knew about Linux indicated that it should, in general, be more efficient on resources than Windows.
It came to me that the issue might just be the fact that I'm currently booting off of a USB thumb drive. (Not exactly an ideal setup, but for right now it's all I got!) USB, especially the older USB 2.0, has a much slower read/write speed than SATA (a standard port used for internal hard drives). As you might assume, Windows had been running off of the internal hard drive, and writing DOSBox video output to it as well. I don't boot from the hard drive anymore, but I still have it inside my laptop. So I thought, "what if I get DOSBox to write the video to the hard drive?"
By default, DOSBox records video to "~/.dosbox/capture" located in your home directory. Since I'm running Linux from a USB thumb drive, my home directory is also stored on the thumb drive. For a quick'n'dirty fix to move the output to the internal hard drive, I went and created a folder somewhere on my hard drive called "capture2". Then I created a symbolic link to that folder inside the "~/.dosbox" directory, and in the DOSBox config file (which is "~/.dosbox/dosbox-0.74-3.conf" for my version) changed the line under the "[dosbox]" section from "captures=capture" to "captures=capture2".
After making this change, I went back and tested again, and vanilla Keen 1 no longer had any frame lag while recording! Who'd've thought. Write speed makes a difference, at least at this level of bare-minimum computing power.
IMPORTANT: Make sure the drive you are recording to is mounted (with read/write access!) before starting to record, otherwise that video output will go nowhere. (And it's not just the video; screenshots and sound are also output to the capture directory!) If you have DOSBox running from a terminal window, it will tell you that it can't open the directory.
More interesting trivia:
While trying to determine the source of the lag, I tested recording a clip of Operation Ocflore, since that was something I had recorded under Windows without many problems. Surprisingly it worked a lot better than vanilla Keen 1, only having lag spikes every 10 seconds or so, whereas Keen 1 had nearly constant frame lag. I guess it must be because despite having a heavier graphical engine, "Goodbye, Galaxy!" had a lot of optimizations added that weren't in "Invasion of the Vorticons" according to this commentary on the production.
Section II -- External screen recorder
But what if it all still isn't enough? If DOSBox still lags while recording, what can be done? Or, maybe you don't want to fill your hard drive with gigabytes of uncompressed video. Seriously, a half hour recording of raw DOSBox video output at the tiny DOS resolution of 320x200 is 373.5 MB, and the same video upscaled to 1280x800 and compressed is 173.0 MB -- less than half the size! As great as it is that DOSBox even has a built-in video recorder, in some cases it may just be a better choice to use something else.
Anyone with a half-decent amount of CPU and RAM will tell you to use OBS Studio, and that was the first thing I tried. However, upon trying to open the program, OBS told me, and I quote, "get a better computer lol" and did not offer me so much as the courtesy of starting up. How rude.
Fortunately, lightweight recording software does exist, thank goodness! I've found one that fits all my needs, and during approximately two hours total of recording there was only about a second of noticeable lag, which is about as good as I could possibly hope for given my meager resources. It's called SimpleScreenRecorder.
SIMPLESCREENRECORDER. There is a fair, but not overwhelming, amount of settings in this program, and after some fiddling I found a good combination to get the fantastic results I mentioned. As I am nearing the end of my desire to continue writing words for this already lengthy essay, rather than giving a detailed analysis on every option in the program, I'll just provide the list of settings I used with some notes.
Code: Select all
VIDEO INPUT
- Select option "Record a fixed rectangle"
Left: [current x position of window]
Top: [current y position of window]
Width: 640
Height: 400
Frame rate: 30
- Check option "Scale video"
Scaled width: 320
Scaled height: 200
- Uncheck option "Record cursor"
VIDEO OUTPUT
FILE
Save as: [base filename and directory]
- Uncheck option "Separate file per segment"
- Check option "Add timestamp"
Container: Matroska (MKV)
VIDEO
Codec: H.264
Constant Rate Factor: 23
Preset: superfast
- Check option "Allow frame skipping"
From my experiments, SimpleScreenRecorder looks to store the video in memory until it is stopped rather than writing it progressively to the hard drive as DOSBox does. Because of this, there may not be any performance benefits during recording from configuring SimpleScreenRecorder to write to the hard drive instead of the thumb drive. However, it may still be preferable as hard drives tend to contain quite a bit more storage space than thumb drives. If you do -- again, remember to mount the hard drive before recording!
IMPORTANT: Remember to select your recording area at the start of every session. There's a good chance the DOSBox window will be in a different place every time! Tip: after clicking the "Select window..." button, to record only the game display of DOSBox, click the middle of the window, but to include the window border and top bar, click anywhere on the window border. If you hold down the mouse button when selecting the recording area it will display a box around the area it is selecting.
I implied at the start of this section that using an external screen recorder should help with frame lag while recording. My theory for this was that since DOSBox is both drawing an image on the screen and outputting it to a file while using its recording function, it might slow down its rendering speed. (Especially since, as noted earlier, when using DOSBox's built-in recorder, the video contains exactly what was simulated inside DOSBox, no more and no less. This could possibly indicate that it might try to wait until the frame is saved before trying to draw another one, which could theoretically cause delays.) Coming to this conclusion is what led me to try the external recorder idea, and it sure seems like it worked!
Being an external program it shouldn't cause any direct interruptions to DOSBox's rendering, and the only concern would be if it uses too much CPU on its own. However, here that wasn't a problem, which is probably largely due to working with such small resolutions. An external video recorder could even theoretically be separated to run on a different CPU thread entirely. (Despite my CPU being slower than most smartphones nowadays, it does at least have two cores!)
Conclusion
I suppose this guide is for a highly specific situation. I find it interesting how Commander Keen is probably one of the most accessible games as far as compatibility and expense goes (including the part where low-end hardware is a lot cheaper), whereas video capture is one of the most resource-intensive activities. Probably any computer made within the last 3 decades can run Commander Keen (although I wonder if there is gap of computers too new to run DOS and too old to run DOSBox). So if you're like me and are stuck with older hardware for whatever reason and are absolutely dead set on getting gameplay video capture to work then hopefully you will get some use out of this. Or if you just want to read about the weird trivia I found while doing this. Hopefully it's interesting. If anyone ever finds this helpful, please let me know!
Coming up next time: How to play Keen mods with a broken left arrow key