Recording Android games

Since the middle of the project we’ve been wondering about making videos of our game and we’ve tried a few options:

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:

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.

The result

So here we have our recorded gameplay-video, after adding pre and post-images and some compositing in Adobe’s Premiere Pro:

No problem, glad to help. Our game uses openGL and Vertex Buffer Objects (VBO’s), although I’m planning on using the OES_draw_texture extension as well. For more information on that, check Chris Pruett’s Google I/O video Writing Real-Time Games for Android.

The game is completely written in Java, performance is fine for these type of games.

Thanks, I already watched it and I strongly recommend the second part and Chris Pruett’s blog. (although you’re probably aware of it)
I find his resources very helpful, even if I’m just using Canvas for my latest game.

I hope to release it soon (no official release date though). The game engine and logic is mostly done, I’m designing levels and fixing bugs now. You can watch the progress at http://www.thesecretpie.com.