- We tried using the emulator, it turned out to be really slow when it comes to OpenGL.
- We tried capturing a Android-phone running our game with a camera, but that didn’t turn out very pretty.
- We then experimented with making screenshots really fast, that too wasn’t really an option because it slowed the framerate to a griding halt.
At the end of it all we just made some screenshots and decided to use those and feel bad about not having a video. Or did we?
The emulator revisited
When I tested the emulator I came to the conclusion it was way to slow to run our game, I got between 5 and 10 frames per second out of it on a decent workstation. Since our engine is framerate-independent the game was playable but just very slow.
We wanted to record a movie at 30fps, about 4 times what the emulator could put out, no way we could boost and tweak it to get the required 30fps.
Playing with time
Someone probably already thought of this, but it only hit me while showering and I think it’s a pretty neat trick. I’ve got a low framerate and framerate-independent game. What about slowing the game down?
Our engine is based on Chris Pruett’s ideas outlined in his Google I/O 2009 presentation Writing Real-Time Games for Android and blog, including the framerate-independentness (which is quite normal in games I guess, I thought it was a neat trick).
Our gameloop takes a delta time, which basically is how much milliseconds went by since the last “step”.
All I had to do was divide that by 4 to get a slow running game:
Recording the video
So now we’ve got our game running 4 times slower than usual, how do we get that into a video? On ubuntu, there’s a very nice tool, recordMyDesktop and after playing a bit with the graphical tool gtk-recordMyDesktop I had a line that recorded the portion of my screen where the emulator’s screen was:
recordmydesktop -o /home/roy/barrr-screencap.ogv --fps 30 --no-sound --no-cursor -x 2000 -y 49 --width 480 --height 320 --channels 1 --freq 22050 --device plughw:1,0 --v_quality 63 --s_quality 10 --workdir /tmp
This outputs a movie at 30fps (it’s a bit much for the 5fps the emulator runs at but the conversion below is clearer this way).
Great, now we’ve got a quite long video showing our game. We’ll need to speed it up. To achieve that we’ll use the tools ffmpeg and yuvfps with this line:
ffmpeg -i barrr-screencap.ogv -f yuv4mpegpipe - | yuvfps -s 120:1 -r 30:1 | ffmpeg -f yuv4mpegpipe -i - -b 28800k -y output.avi
The first part pipes the input movie towards yuvfps. We tell yuvfps to assume the input is 120fps (it’s actually 30 but we want to speed the video up, 4*30=120) and to output it at 30fps. We pipe that to ffmpeg again and tell it to output a .avi file.
Great! We now have a movie showing our gameplay at the correct framerate and captured from the screen.
But won’t the sound be all wrong?
Yes, it will.
RecordMyDesktop can capture audio but it isn’t useful, since the sound effects are at the correct speed but spaced apart. To get sound, the best you can do is put the sounds in again in and editing program.
We’ve chosen to add sounds manually. It’s boring work but the result is rewarding.
So here we have our recorded gameplay-video, after adding pre and post-images and some compositing in Adobe’s Premiere Pro: