androidclient
androidclient copied to clipboard
Higher quality voice recordings
Please consider using Opus codec for voice notes.
Opus is not supported properly on a lot of Android devices and weaker devices are not powerful enough to play Opus files even if they would be flashed to run a recent enough Android. I very much consider this a bad idea, it decreases the already small audio file size at the cost of breaking support for many devices.
I was researching on the Opus codec just now and saw that it required using the NDK because the codec is in a C library which should be wrapped (which is not impossible, but it would require multiple architecture support, something I would not like to explore right now). And of course also what @TheLastProject said. Nevertheless, all of this could change in the future, so I'm not rejecting it either. Let's put into the Future milestone and wait.
WhatsApp uses opus and plays it fine. I'm running Android 4.4.4, I can also play standalone opus files in VLC player. I understand what you are saying, I just thought it would be a nice improvement regarding audio quality. :) Thanks for taking it into consideration.
weaker devices are not powerful enough to play Opus files
Really? Judging from http://www.rockbox.org/wiki/CodecPerformanceComparison, Opus does indeed require more processing power to decode than MP3 (though the benchmark is not really intended/optimized for comparisons between codecs). However, you typically need just around 50 MHz to decode Opus at full speed, and the Opus lib is still being optimized so that requirement may drop even further. I wouldn't think even 100 MHz for decoding audio is a problem at all.
+1 for Opus.
Consider using https://github.com/google/ExoPlayer
From http://cynic.cc/blog/posts/2017-04-20-android_recording_audio_quality/
Roughly sorted by quality:
amr_nb in 3gpp < amr_wb in 3gpp < aac_lc in m4a < aac+ in m4a (only in Android 4.0+) < opus in webm (only in android 5+) < pcm in wav (only in android 4.1+)
Taking into consideration the compatibility of the codecs (mainly with Android and with the popular WhatsApp and Telegram messengers), the best options seem to be:
aac_lc in m4a < aac+ in m4a (API >= 16) < vorbis/opus in webm (API >= 21) < pcm in wav (only in android 4.1+)
For a device running API 14, we can use something like this (MediaRecorder.OutputFormat constants):
- For very low quality/very low bitrate/very long recording times, use AMR-NB in 3GPP container. Parameters summary: 8kHz and bitrate 12.8kbps Works pretty much anywhere.
- For low quality/low bitrate/long recording times, use AAC in MP4 container, with m4a extension. Works pretty much anywhere. Example code adapted from: https://developer.android.com/guide/topics/media/mediarecorder.html
private void startRecording() {
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); // other?
mRecorder.setOutputFile(mFileName); // end in m4a, for compatibility
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC); // AAC_HE, if supported
try {
mRecorder.prepare();
} catch (IOException e) {
Log.e(LOG_TAG, "prepare() failed");
}
mRecorder.start();
}