我正在使用MediaRecorder通过前置摄像头录制视频。这适用于我测试的大多数手机,但在Galaxy S3上,预览是空白的,它不记录任何视频(保存空的32字节文件)。
以下是我对MediaRecorder的配置:
@Override
public void startRecord() {
camera.stopPreview();
recorder = new MediaRecorder();
camera.unlock();
recorder.setCamera(camera);
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
recorder.setVideoFrameRate(profile.videoFrameRate);
recorder.setVideoSize(profile.videoFrameWidth, profile.videoFrameHeight);
recorder.setVideoEncodingBitRate(profile.videoBitRate);
recorder.setAudioEncodingBitRate(profile.audioBitRate);
recorder.setAudioChannels(profile.audioChannels);
recorder.setAudioSamplingRate(profile.audioSampleRate);
recorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
recorder.setOutputFile(outputFile);
recorder.setOrientationHint(orientation);
try {
recorder.prepare();
} catch (Exception e) {
}
recorder.start();
}
我的代码有什么问题吗?