use of android.media.CamcorderProfile in project JustAndroid by chinaltz.
the class CaptureVideoActivity method setCamcorderProfile.
@SuppressLint("NewApi")
private void setCamcorderProfile() {
CamcorderProfile profile;
profile = CamcorderProfile.get(CamcorderProfile.QUALITY_480P);
if (profile != null) {
if (currentUsePoint != null) {
profile.videoFrameWidth = currentUsePoint.x;
profile.videoFrameHeight = currentUsePoint.y;
}
profile.fileFormat = MediaRecorder.OutputFormat.MPEG_4;
if (Build.MODEL.equalsIgnoreCase("MB525") || Build.MODEL.equalsIgnoreCase("C8812") || Build.MODEL.equalsIgnoreCase("C8650")) {
profile.videoCodec = MediaRecorder.VideoEncoder.H263;
} else {
profile.videoCodec = MediaRecorder.VideoEncoder.H264;
}
if (Build.VERSION.SDK_INT >= 14) {
profile.audioCodec = MediaRecorder.AudioEncoder.AAC;
} else {
if (Build.DISPLAY != null && Build.DISPLAY.indexOf("MIUI") >= 0) {
profile.audioCodec = MediaRecorder.AudioEncoder.AAC;
} else {
profile.audioCodec = MediaRecorder.AudioEncoder.AMR_NB;
}
}
mediaRecorder.setProfile(profile);
} else {
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mediaRecorder.setVideoSize(VIDEO_WIDTH, VIDEO_HEIGHT);
}
}
use of android.media.CamcorderProfile in project react-native-camera by lwansbrough.
the class Camera1 method setUpMediaRecorder.
private void setUpMediaRecorder(String path, int maxDuration, int maxFileSize, boolean recordAudio, CamcorderProfile profile, int fps) {
mMediaRecorder = new MediaRecorder();
mCamera.unlock();
mMediaRecorder.setCamera(mCamera);
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
if (recordAudio) {
mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
}
mMediaRecorder.setOutputFile(path);
mVideoPath = path;
CamcorderProfile camProfile;
if (CamcorderProfile.hasProfile(mCameraId, profile.quality)) {
camProfile = CamcorderProfile.get(mCameraId, profile.quality);
} else {
camProfile = CamcorderProfile.get(mCameraId, CamcorderProfile.QUALITY_HIGH);
}
camProfile.videoBitRate = profile.videoBitRate;
setCamcorderProfile(camProfile, recordAudio, fps);
mMediaRecorder.setOrientationHint(calcCameraRotation(mOrientation != Constants.ORIENTATION_AUTO ? orientationEnumToRotation(mOrientation) : mDeviceOrientation));
if (maxDuration != -1) {
mMediaRecorder.setMaxDuration(maxDuration);
}
if (maxFileSize != -1) {
mMediaRecorder.setMaxFileSize(maxFileSize);
}
mMediaRecorder.setOnInfoListener(this);
mMediaRecorder.setOnErrorListener(this);
}
use of android.media.CamcorderProfile in project react-native-camera by lwansbrough.
the class Camera2 method setUpMediaRecorder.
private void setUpMediaRecorder(String path, int maxDuration, int maxFileSize, boolean recordAudio, CamcorderProfile profile) {
mMediaRecorder = new MediaRecorder();
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.SURFACE);
if (recordAudio) {
mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
}
mMediaRecorder.setOutputFile(path);
mVideoPath = path;
CamcorderProfile camProfile = profile;
if (!CamcorderProfile.hasProfile(Integer.parseInt(mCameraId), profile.quality)) {
camProfile = CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH);
}
camProfile.videoBitRate = profile.videoBitRate;
setCamcorderProfile(camProfile, recordAudio);
mMediaRecorder.setOrientationHint(getOutputRotation());
if (maxDuration != -1) {
mMediaRecorder.setMaxDuration(maxDuration);
}
if (maxFileSize != -1) {
mMediaRecorder.setMaxFileSize(maxFileSize);
}
mMediaRecorder.setOnInfoListener(this);
mMediaRecorder.setOnErrorListener(this);
}
use of android.media.CamcorderProfile in project react-native-camera by lwansbrough.
the class RNCameraViewHelper method getCamcorderProfile.
public static CamcorderProfile getCamcorderProfile(int quality) {
CamcorderProfile profile = CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH);
int camcorderQuality = getCamcorderProfileQualityFromCameraModuleConstant(quality);
if (CamcorderProfile.hasProfile(camcorderQuality)) {
profile = CamcorderProfile.get(camcorderQuality);
if (quality == CameraModule.VIDEO_4x3) {
profile.videoFrameWidth = 640;
}
}
return profile;
}
use of android.media.CamcorderProfile in project android_packages_apps_Camera by CyanogenMod.
the class VideoModule method readVideoPreferences.
private void readVideoPreferences() {
// The preference stores values from ListPreference and is thus string type for all values.
// We need to convert it to int manually.
String defaultQuality = CameraSettings.getDefaultVideoQuality(mCameraId, mActivity.getResources().getString(R.string.pref_video_quality_default));
String videoQuality = mPreferences.getString(CameraSettings.KEY_VIDEO_QUALITY, defaultQuality);
int quality = Integer.valueOf(videoQuality);
// Set video quality.
Intent intent = mActivity.getIntent();
if (intent.hasExtra(MediaStore.EXTRA_VIDEO_QUALITY)) {
int extraVideoQuality = intent.getIntExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0);
if (extraVideoQuality > 0) {
quality = CamcorderProfile.QUALITY_HIGH;
} else {
// 0 is mms.
quality = CamcorderProfile.QUALITY_LOW;
}
}
// unless it is specified in the intent.
if (intent.hasExtra(MediaStore.EXTRA_DURATION_LIMIT)) {
int seconds = intent.getIntExtra(MediaStore.EXTRA_DURATION_LIMIT, 0);
mMaxVideoDurationInMs = 1000 * seconds;
} else {
mMaxVideoDurationInMs = CameraSettings.getMaxVideoDuration(mActivity);
}
// Set effect
mEffectType = CameraSettings.readEffectType(mPreferences);
if (mEffectType != EffectsRecorder.EFFECT_NONE) {
mEffectParameter = CameraSettings.readEffectParameter(mPreferences);
// Set quality to be no higher than 480p.
CamcorderProfile profile = CamcorderProfile.get(mCameraId, quality);
if (profile.videoFrameHeight > 480) {
quality = getLowVideoQuality();
}
} else {
mEffectParameter = null;
}
// Read time lapse recording interval.
if (ApiHelper.HAS_TIME_LAPSE_RECORDING) {
String frameIntervalStr = mPreferences.getString(CameraSettings.KEY_VIDEO_TIME_LAPSE_FRAME_INTERVAL, mActivity.getString(R.string.pref_video_time_lapse_frame_interval_default));
mTimeBetweenTimeLapseFrameCaptureMs = Integer.parseInt(frameIntervalStr);
mCaptureTimeLapse = (mTimeBetweenTimeLapseFrameCaptureMs != 0);
}
// TODO: This should be checked instead directly +1000.
if (mCaptureTimeLapse)
quality += 1000;
mProfile = CamcorderProfile.get(mCameraId, quality);
getDesiredPreviewSize();
}
Aggregations