Reputation: 5472
When I attempt to set the video size for my MediaRecorder, I get a RuntimeException at the start method.
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
Upvotes: 1
Views: 1059
Reputation: 5472
Here's what I've found to be the most elegant solution in my case:
CamcorderProfile profile = CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH);
mRecorder.setVideoSize(profile.videoFrameWidth, profile.videoFrameHeight);
Upvotes: 3
Reputation: 1006584
Use getSupportedVideoSizes()
on Camera.Parameters
to get the supported video sizes. Cameras frequently cannot arbitrarily scale the image, presumably for performance reasons.
Upvotes: 2