Recording DOSBox in Linux

By t_rf

1. Set up my window manager so that it has borders that are multiples of 2 pixels in width. You can measure this with xwininfo and a window in the top-left(which will be your record window). This is a limitation imposed by the way recordmydesktop works - it is using a lot of tricks for optimization.
2. Open DOSBox/the game. Move the window to the top left. Use double size because it will transcode much better, and recordmydesktop needs it because 320x200 is an odd size by its "16x16" size rule and it'll force it upwards, but won't change 640x400.
3. Start JACK with -C (capture only) and -n6 (6 periods) This gives better latency. This requires an analog loopback - I go through a mixer so I can do voice simultaneously.
4. Start recordmydesktop with:

-channels 2 -freq 44100 -use-jack alsa_pcm:capture_1 \ --no-cursor -fps 30 -x 6 -y 28 -width 640 -height 400

(you may need to adjust x and y for your borders, but recordmydesktop needs multiples of 2 or you end up with a one pixel border at the edge of your recording window.)
5. Play.
6. If you're happy with the raw video, you can convert to Youtube with this shell script:

ffmpeg -i $1 -pass 1 -s 480x300 -r 30 -b 284 -deinterlace \ -mbd 2 -padtop 30 -padbottom 30 \ -vcodec flv -g 9000 -cmp 3 \ -acodec mp3 -ar 22050 -ab 64k -ac 1 -async 1 $2 $3 $4 $5 $6 $7 rm $2 ffmpeg -i $1 -pass 2 -s 480x300 -r 30 -b 284 -deinterlace \ -mbd 2 -padtop 30 -padbottom 30 \ -vcodec flv -g 9000 -cmp 3 \ -acodec mp3 -ar 22050 -ab 64k -ac 1 -async 1 $2 $3 $4 $5 $6 $7


and to Vimeo with this one(it could still be tweaked):

ffmpeg -pass 1 -i $1 -r 30 -b 900k -vcodec h264 -acodec mp3 -ar 22050 \ -ab 96 -ac 1 -async 1 -g 9000 -s 640x400 \ -padtop 40 -padbottom 40 \ $2 rm $2 ffmpeg -pass 2 -i $1 -r 30 -b 900k -vcodec h264 -acodec mp3 -ar 22050 \ -ab 96 -ac 1 -async 1 -g 9000 -s 640x400 \ -padtop 40 -padbottom 40 \ $2


The most important thing in these scripts is "async 1" as it seems to fix all my audio syncing problems. Second most important is padding, as 320x200 has a 1.6 size ratio, while 480x360(Youtube) is 1.3. Vimeo accepts 1.6 but does some weird scrunching to the resulting flv that makes it look worse than Youtube, so I pad it up to the more standard 640x480. Even then, I think my Youtube encodes turn out better than whatever they're doing.

This is where I stopped, before I started editing.

7. The ogg that recordmydesktop makes is poor for editing and gave me errors in the final edited video; unacceptable. So, another script to bring it to the ffv1 codec, which works very well:

ffmpeg -i $1 -r 30 -b 6000k -vcodec ffv1 -acodec mp3 -ar 48000 \ -ab 320 -ac 1 -async 1 -g 30 -s 640x400 \ $2


8. Now I use KDEnlive. The only edits I've done with it are simple cuts, I use the razor tool (shift+W) at cut points, delete the unneeded clips, and then move the remainder together.

9. Something I'm still working on, exporting out of KDEnlive. The main issue is that I can't find a documentation for how to set up the encoder by hand like I do with ffmpeg at the command line, so I've been using the presets, and they screw with the resulting video's size and ratio. Not a happy situation.