audio/video recording 관련 API들도 그중 하나로 다루기가 꽤 까다로운 편.
금번 everysing 프로젝트에서도 관련 이슈가 발생했는데 audio recording 과 관련하여 최선의 API call을 정리하려고 한다.
최근 수정일: 2013/05/21
Recommended API calls to record with better quality in Android.
mRec = new MediaRecorder();
mRec.setAudioSource(MediaRecorder.AudioSource.MIC);
boolean isSuperiorModel = false;
if(Build.VERSION.SDK_INT >= 16) {
isSuperiorModel = true;
}
if (isSuperiorModel == true) {
try {
mRec.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
} catch (Exception e) {
mRec.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
}
}
else {
mRec.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
}
if (isSuperiorModel == true) {
try {
mRec.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
} catch (Exception e) {
mRec.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
}
}
else {
mRec.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
}
if (isSuperiorModel == true) {
try {
mRec.setAudioEncodingBitRate(96000);
} catch (Exception e) {
}
}
mRec.setAudioEncodingBitRate(96000);
} catch (Exception e) {
}
}
boolean setAudioSamplingRateSucceed = false;
try {
mRec.setAudioSamplingRate(96000);
setAudioSamplingRateSucceed = true;
} catch (Exception e) {
}
if (setAudioSamplingRateSucceed == false) {
try {
mRec.setAudioSamplingRate(44100);
} catch (Exception e) {
}
}
}
mTempFile = Manager_File.createTempCacheFile();
mRec.setOutputFile(mTempFile.getPath());
mRec.prepare();
The sampling rate really depends on the format for the audio recording, as well as the capabilities of the platform. For instance, the sampling rate supported by AAC audio coding standard ranges from 8 to 96 kHz, the sampling rate supported by AMRNB is 8kHz, and the sampling rate supported by AMRWB is 16kHz.
댓글 없음:
댓글 쓰기