的方法setProfile(MediaRecorder的)
我們可以看到,如果:
profile.quality >= CamcorderProfile.QUALITY_TIME_LAPSE_LOW //1002
&&
profile.quality <= CamcorderProfile.QUALITY_TIME_LAPSE_QVGA //1007
不會有setAudio *() 因此,在你的代碼,你可以手動設置profile.quality=[any int from 1002 to 1007]
之前setProfile()
。 它會工作,我試過了。
心中已經找到了正確的答案:
if (getIsMuteShooting()) { // with out audio
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mRecorder.setVideoFrameRate(profile.videoFrameRate);
mRecorder.setVideoSize(profile.videoFrameWidth, profile.videoFrameHeight);
mRecorder.setVideoEncodingBitRate(profile.videoBitRate);
mRecorder.setVideoEncoder(profile.videoCodec);
} else {
mRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mRecorder.setVideoFrameRate(profile.videoFrameRate);
mRecorder.setVideoSize(profile.videoFrameWidth, profile.videoFrameHeight);
mRecorder.setVideoEncodingBitRate(profile.videoBitRate);
mRecorder.setAudioEncodingBitRate(profile.audioBitRate);
mRecorder.setAudioChannels(profile.audioChannels);
mRecorder.setAudioSamplingRate(profile.audioSampleRate);
mRecorder.setVideoEncoder(profile.videoCodec);
mRecorder.setAudioEncoder(profile.audioCodec);
}
這確實應該是適用於CamcorderProfiles任何剪裁;例如如果您不想使用默認的視頻比特率但不是一個(不是所有的配置文件參數都可以更改,有的會四捨五入到最接近的可能值) – ysmartin 2014-05-08 21:37:41