Recording and Playback on both iPhone and Android

Download on Google Play and on iTunes

My goal was to record little snippets on both iPhone and Android, and share those files between users, on Facebook. As usual, I want old Android users (2.2+) and iPhone (3+) users to participate in this app.

I originally recorded in iPhone CAF, then realized the file size was ginormous. So I downgraded the sample rate. That worked fine. Then, realized Android could do nothing with this. I know, lack of planing, ya di ya di. I thought briefly of setting up a server to re-encode the CAF files for Android. Turns out, on (hosted by TigerTech) the FFMPEG installation is very vanilla and doesn’t use the right libraries.

But let’s look at Android- what can it do? So, using the AMR (THREE_GPP) format, I used MediaRecorder and that worked great. Nice small files, OK quality. Android is a pretty open architecture, so you can use another library, AudioRecorder (vs. MediaRecorder) to record in almost any format you want. Problem is, there are a lot of bells and whistles built into MediaRecorder that make it a simpler choice. With AudioRecorder, if you want to record in WAV, you have to -no joking- go bit by bit through the files and build your own audio file, with headers and data. It’s a lot of code. I went down this road for an hour than realized, I wanted to stay in the happy MediaRecorder world. So now- what can I do with AMR files? Turns out, not a helluva lot. New Android operating systems handle MP3, but the iPhone doesn’t record in that, and I wanted to support older Android versions.

Long story short- I finally figured out a solution:

1. Build Amazon EC2 instance
2. Install FFMPEG with AMR libraries
3. Record iPhone with PCM_16 audio format, and give it the “wav” file extension.
4. Upload to Amazon’s S3 service.
5. Record Android with AMR, and do conversion script:
a) Kick off, asynchronously, a conversion script on my EC2 instance
b) Script converts .3gp to .wav
c) Upload to Amazon’s S3 service.

Now, file is available as *.wav for both Android and iPhone users.

Setting up the Amazon EC2 server with FFMPEG and enable it with just the libraries I need (AMR). That took about 4-5 hours. And it’s not because I did anything wrong, I was actually pretty flawless (yay!) in my Linux installation. I can’t find the awesome tutorial I used to install FFMPEG (should have written this blog post weeks ago) but this one looks good: Justin Hartman’s Install FFMPEG

I made a few tactical changes to my apps. If you’re interested in doing this kind of thing, I recommend thinking about these things beforehand.
– What phones and operating systems you want to support, historically (old phones?)
– Playback vs. recording – is recording absolutely necessary?
– Streaming vs. simple file loading and playback
– Audio quality (speech is lower than, say, music)

No Comments »

No comments submitted yet.

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>