Friday, June 22, 2012

Screencasting with Android

Well, if you are already using the Screencast Video Recorder, there's no use of reading this -- but I'm betting you're not because you stumbled onto this tutorial.

First of all, I am not related to the said screencasting app and I am in no way endorsing it.  I haven't even tried that app yet because 1.) it's not supported on my low-end Android device and 2.) it's a paid app -- yes, I'm cheap, sue me. :P

So this tutorial is about creating a screencast of your Android device using a free and open source tools called Android Screen Capture (or AShot) and FFmpeg.  I should warn you that this tutorial is not for the fainthearted -- it's gonna be messy through setting these tools up, and through creating of the screencast video itself.

I'm going to assume you know what we mean by screencast.  And I'm going to assume you are using Windows on your PC.

To start, download the tools:
AShot - http://sourceforge.net/projects/ashot/files/latest/download
FFmpeg - http://ffmpeg.zeranoe.com/builds/win32/shared/ffmpeg-20120620-git-5a90e55-win32-shared.7z

Here's a very detailed tutorial of setting-up AShot, which I'm very glad not to write over again.  It talks about downloading Android SDK, which AShot uses to capture images from your Android device.  One quick note, however, is the copying of the three files, namely:
  • adb.exe
  • AdbWinApi.dll
  • AdbWinUsbApi.dll
from this directory: C:\Program Files\Android\android-sdk\platform-tools

to this directory: C:\Program Files\Android\android-sdk\tools

Again, simply COPY the three files and not MOVE from one to the other.

Lots of troubleshooting is also discussed on that page, so go thoroughly through that page if AShot won't seem to work.



At this stage, I'm assuming you already got AShot working and you're seeing the same image in your PC as what's on your Android device as shown in the photo above.  You might have also tried screencapturing, and saw a tiny little problem -- (aside from the low FPS which is already answered many times on that page mentioned) instead of a video output, AShot outputs a series of PNGs.  Here's where FFmpeg comes in.

The FFmpeg binary download is just a zip file that can easily be extracted by 7zip or WinRAR -- though, I prefer 7zip.

I'm going to assume you extracted it on the root of your computer in such a way that ffmpeg.exe will be in this path: C:\ffmpeg\bin

And I'm also going to assume that you set AShot to output screenshots on this path: C:\ashot\

Now, all you have to do is open a Command Prompt and type this:
cd c:\ashot\
c:\ffmpeg\bin\ffmpeg -f image2 -i screenshot_%05d.png screencast.avi


Then using any movie player -- I use VLC media player by the way -- you can now view your screencast.avi.

Lastly, if you want to adjust the FPS of your AVI, try adding -framerate X when executing ffmpeg, where X is your desired FPS.

Happy screencasting!

~creek23

No comments: