0

With the help of the AudioRecord API I am now able to record audio using the microphone of the watch. However, this is uncompressed audio and the file sizes get pretty big.

Around 5.3MB per minute recording at 16bit, 44.1Khz, mono. So I started looking into reducing the size by encoding it to a different format.

I looked into MediaCodec and the other low level audio multimedia support that is mentioned.

Looping over the available codecs:

MediaCodecList codecs = new MediaCodecList(MediaCodecList.REGULAR_CODECS);
MediaCodecInfo[] infos = codecs.getCodecInfos();
for(MediaCodecInfo info : infos) {
  Log.d(TAG, "Name: " + info.getName());
  Log.d(TAG, "Types: " + Arrays.toString(info.getSupportedTypes()));
  Log.d(TAG, "Encoder? " + info.isEncoder());
}    

It turns out that none of them are encoders. Just 9 decoders. Attempting to use any of these in MediaCodec.createByCodecName() results in an exception. Any idea how I can compress my recorded audio on Android Wear?

J_J
  • 123
  • 1
  • 7
  • This shouldn't be anything particular to Wear, and there are lots of references around for audio encoding on Android generally. Example: http://stackoverflow.com/questions/19826809 – Sterling Mar 16 '16 at 14:51
  • 1
    It is something particular to Wear. You can not use the MediaPlayer API on Android Wear. Which is probably related to the fact that Android Wear does not have any encoding codecs available. It does work on an Android phone. – J_J Mar 16 '16 at 15:42
  • OK, my apologies. What about streaming the uncompressed audio to the linked phone (using the Channel API) and compressing it there? Might be a better place to save the file anyway. – Sterling Mar 16 '16 at 16:33
  • Yes, I do want to store the file on the phone. I just don't want to take the risk of corrupting the recording if the connection is interrupted. For now I will record and store the file on the watch, synchronize it to the phone and encode it to a different format on there. The downside is that a rather large file needs to be sent to the phone, but it seems like the best solution for now. – J_J Mar 18 '16 at 10:15

0 Answers0