当我试图为我的MediaRecorder设置视频大小时,我会在start方法中得到一个RuntimeException。
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
if (isVideo)
mRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
if (isVideo) {
mRecorder.setVideoSize(480, 360); // Works fine when this is removed
mRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
}
mRecorder.setOutputFile(newFilePath);
if (isVideo)
mRecorder.setPreviewDisplay(surfaceHolder.getSurface());
mRecorder.prepare(); // Prepare recorder
mRecorder.start(); // Start recording发布于 2014-05-23 19:41:40
下面是我发现的最优雅的解决方案:
CamcorderProfile profile = CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH);mRecorder.setVideoSize(profile.videoFrameWidth, profile.videoFrameHeight);发布于 2014-05-23 19:09:19
使用Camera.Parameters获取支持的视频大小。相机经常不能任意缩放图像,大概是因为性能原因。
https://stackoverflow.com/questions/23836393
复制相似问题