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:

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.

The result

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

7 Responses to “Recording Android games”

  1. Nice, thanks for your tips!
    What do you use for drawing in your game? OpenGL or Canvas? Is it written entirely in Java, or has some pieces of native code?

  2. Roy says:

    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.

  3. 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.

  4. Roy says:

    Cool! I haven’t seen part 2 yet, thanks. I’m aware of the blog, it’s been a great resource for ideas on engine architecture.

    What’s your game about? Releasing it soon?

  5. 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.

  6. I just installed “Barrr” and it does a force close right away. :(

  7. Jakob says:

    The link dosn’t work?

Leave a Reply