Created
September 10, 2015 01:29
-
-
Save JetXing/8eae6cfdcc5b15dfe535 to your computer and use it in GitHub Desktop.
AudioEncodingBitRate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| MediaRecorder recorder = new MediaRecorder(); | |
| recorder.setAudioSource(MediaRecorder.AudioSource.MIC); | |
| if (Build.VERSION.SDK_INT >= 10) { | |
| recorder.setAudioSamplingRate(44100); | |
| recorder.setAudioEncodingBitRate(96000); | |
| recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); | |
| recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC); | |
| } else { | |
| // older version of Android, use crappy sounding voice codec | |
| recorder.setAudioSamplingRate(8000); | |
| recorder.setAudioEncodingBitRate(12200); | |
| recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); | |
| recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); | |
| } | |
| recorder.setOutputFile(file.getAbsolutePath()); | |
| try { | |
| recorder.prepare(); | |
| } catch (IOException e) { | |
| throw new RuntimeException(e); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment