你好我正在在我使用自定義的相機記錄camera.I我有三星device.I問題無法媒體記錄的個人資料設置爲CamcorderProfile.get(cameraid, CamcorderProfile.QUALITY_HIGH)
如何在三星設備android上錄製特定寬度和高度的視頻?
還當嘗試使用
一個Android應用程序profile = CamcorderProfile.get(cameraid, CamcorderProfile.QUALITY_LOW);
profile.videoFrameHeight=360;
profile.videoFrameWidth=640;
然後我的應用程序工作的一些設備,但在許多devices.Any類型的幫助下崩潰會appreciable.Thanks事先請檢查代碼
Camera.Parameters param = mCamera.getParameters();
param.set("cam_mode", 1);
// Enable video stabilization. Convenience methods not available in API
// level <= 14
String vstabSupported = param.get("video-stabilization-supported");
if ("true".equals(vstabSupported)) {
param.set("video-stabilization", "true");
}
List<Size> sizes = mCamera.getParameters() .getSupportedVideoSizes();
mCamera.setParameters(param);
mMediaRecorder = new MediaRecorder();
// Step 1: Unlock and set camera to MediaRecorder
mCamera.unlock();
mMediaRecorder.setCamera(mCamera);
mMediaRecorder.setPreviewDisplay(mPreview.getHolder().getSurface());
// Step 2: Set sources
mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
String deviceMan = android.os.Build.MANUFACTURER;
Toast.makeText(getApplicationContext(), deviceMan, Toast.LENGTH_SHORT).show();
// Step 3: Set a CamcorderProfile (requires API Level 8 or higher)
CamcorderProfile profile = CamcorderProfile.get(cameraid, CamcorderProfile.QUALITY_LOW);
// if(!CamcorderProfile.hasProfile(CamcorderProfile.QUALITY_HIGH)){Log.d("", "the camcorder profile instance is null");
int currentapiVersion = android.os.Build.VERSION.SDK_INT;
if (currentapiVersion >= android.os.Build.VERSION_CODES.FROYO){
// Do something for froyo and above versions
boolean tellbol=CamcorderProfile.hasProfile(CamcorderProfile.QUALITY_HIGH);
if(deviceMan.equals("samsung")){
profile = CamcorderProfile.get(cameraid, CamcorderProfile.QUALITY_LOW);
profile.videoFrameHeight=360;
profile.videoFrameWidth=640;
}
else{
profile = CamcorderProfile.get(cameraid, CamcorderProfile.QUALITY_HIGH);
}
mMediaRecorder.setProfile(profile);
} else{
// do something for phones running an SDK before froyo
mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
// mMediaRecorder.setVideoSize(720, 480);
mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);
}
// Step 4: Set output file
mMediaRecorder.setOutputFile(getOutputMediaFile(MEDIA_TYPE_VIDEO).toString());
// Step 5: Set the preview output
// Step 6: Prepare configured MediaRecorder
try {
mMediaRecorder.prepare();
} catch (IllegalStateException e) {
Log.d("Video", "IllegalStateException preparing MediaRecorder: " + e.getMessage());
releaseMediaRecorder();
return false;
} catch (IOException e) {
Log.d("Video", "IOException preparing MediaRecorder: " + e.getMessage());
releaseMediaRecorder();
return false;
}
return true;
謝謝您的回答,我會嘗試這一點,讓你知道它是否正在工作或不是 – Nitin
看看更新。你可以使用getSupportedVideoSizes()而不是我之前告訴過你的功能,剩下的就像你想象的那樣... –
我曾用這種方法 – Nitin