主题A:横条
这很奇怪。视频记录和声音很好,但这些条形代表我的手。好像我正在看一个带肋的耐热玻璃碗:
主题B:
我在三星Galaxy Note 10.1上使用前置相机(API 16)进行测试。一些说明:
我使用CamcorderProfile
选择适当的MediaRecorder
设置。这是我的代码:
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private boolean prepareVideoRecorder() {
// Get screen width and height for supported video sizes
Display display = getWindowManager().getDefaultDisplay();
int width, height;
if (Build.VERSION.SDK_INT < 13) {
width = display.getWidth();
height = display.getHeight();
} else {
Point size = new Point();
display.getSize(size);
width = size.x;
height = size.y;
}
// Check and set the highest quality available recording profile of the camera.
int frontCamera = Camera.CameraInfo.CAMERA_FACING_FRONT;
CamcorderProfile profile = null;
if (CamcorderProfile.hasProfile(frontCamera, CamcorderProfile.QUALITY_1080P))
profile = CamcorderProfile.get(frontCamera, CamcorderProfile.QUALITY_1080P);
else if (CamcorderProfile.hasProfile(frontCamera, CamcorderProfile.QUALITY_720P))
profile = CamcorderProfile.get(frontCamera, CamcorderProfile.QUALITY_720P);
else if (CamcorderProfile.hasProfile(frontCamera, CamcorderProfile.QUALITY_480P))
profile = CamcorderProfile.get(frontCamera, CamcorderProfile.QUALITY_480P);
else if (CamcorderProfile.hasProfile(frontCamera, CamcorderProfile.QUALITY_HIGH))
profile = CamcorderProfile.get(frontCamera, CamcorderProfile.QUALITY_HIGH);
mCamera = CameraHelper.getDefaultFrontFacingCameraInstance();
// Need to make sure that our recording video size is supported by the camera.
// Query camera to find all sizes and choose the optimal size given the dimensions of screen.
Camera.Parameters parameters = mCamera.getParameters();
List<Camera.Size> mSupportedVideoSizes = parameters.getSupportedVideoSizes();
Camera.Size optimalSize = CameraHelper.getOptimalRecordingSize(mSupportedVideoSizes,
width, height);
// link camera to preview surface
try {
mCamera.setPreviewDisplay(mPreview.getHolder());
} catch (IOException e) {
Log.e(TAG, "Surface text is unavailable or unsuitable for preview" + e.getMessage());
return false;
}
// Unlock the camera to allow the Media Recorder to own it
mCamera.unlock();
// Create and assign the Camera to the Media Recorder
mMediaRecorder = new MediaRecorder();
mMediaRecorder.setCamera(mCamera);
// Set Sources
mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
if (profile != null) {
profile.videoFrameWidth = optimalSize.width;
profile.videoFrameHeight = optimalSize.height;
mMediaRecorder.setProfile(profile);
}
// Specify the output file
mMediaRecorder.setOutputFile(CameraHelper.getOutputMediaFile(
CameraHelper.MEDIA_TYPE_VIDEO).toString());
// Prepare configured MediaRecorder
try {
mMediaRecorder.prepare();
} catch (IllegalStateException e) {
Log.d(TAG, "IllegalStateException preparing MediaRecorder: " + e.getMessage());
releaseMediaRecorder();
return false;
} catch (IOException e) {
Log.d(TAG, "IOException preparing MediaRecorder: " + e.getMessage());
releaseMediaRecorder();
return false;
}
return true;
}
我尝试绕过CamcorderProfile
并尝试every MediaRecorder.VideoEncoder
encoder available。文件格式为.mp4,我不相信这是问题,因为设备上的标准Camera应用程序输出.mp4。有什么想法吗?