看来,即使我将录像机配置文件设置为低,视频的质量也是最高的。
这是我的代码:
camera.setDisplayOrientation(90);
camera.unlock();
recorder.reset();
recorder.setCamera(camera);
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
recorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_LOW));
//when removing these comments I get an exception on my 4.2.2 device when calling start() on the recorder.
/* recorder.setVideoFrameRate(24);
recorder.setVideoSize(480, 360);
*/
recorder.setOrientationHint(90);
file = FileUtils.getFileName(FileTypes.VIDEO);
if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
recorder.setOutputFile(FileUtils.getFileName(FileTypes.VIDEO).toString());
recorder.setMaxDuration(45000);
最佳答案
试试这个。虽然这看起来与您的代码相同,但它对我有用。为 CamcorderProfile 创建一个单独的实例并将记录器配置文件设置为此实例。
CamcorderProfile cprofileLow = CamcorderProfile
.get(CamcorderProfile.QUALITY_LOW);
recorder.setProfile(cprofileLow);
recorder.setOutputFile("/sdcard/videocapture_example.mp4");
recorder.setMaxDuration(50000); // 50 seconds
recorder.setMaxFileSize(3000000); // Approximately 3 megabytes
请注意,您拥有高端设备(因为您的设备是4.2.2),您可能会获得相对较好的分辨率,这是您设备中可能的最低分辨率。
关于Android 设备无法在 Jelly Bean 4.2.2 上捕捉低质量视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16170218/