本文整理汇总了Java中android.media.CamcorderProfile类的典型用法代码示例。如果您正苦于以下问题:Java CamcorderProfile类的具体用法?Java CamcorderProfile怎么用?Java CamcorderProfile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CamcorderProfile类属于android.media包,在下文中一共展示了CamcorderProfile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getVideoQualityOptions
import android.media.CamcorderProfile; //导入依赖的package包/类
@Override
public CharSequence[] getVideoQualityOptions() {
final List<CharSequence> videoQualities = new ArrayList<>();
if (configurationProvider.getMinimumVideoDuration() > 0)
videoQualities.add(new VideoQualityOption(Configuration.MEDIA_QUALITY_AUTO, CameraHelper.getCamcorderProfile(Configuration.MEDIA_QUALITY_AUTO, getCurrentCameraId()), configurationProvider.getMinimumVideoDuration()));
CamcorderProfile camcorderProfile = CameraHelper.getCamcorderProfile(Configuration.MEDIA_QUALITY_HIGH, currentCameraId);
double videoDuration = CameraHelper.calculateApproximateVideoDuration(camcorderProfile, configurationProvider.getVideoFileSize());
videoQualities.add(new VideoQualityOption(Configuration.MEDIA_QUALITY_HIGH, camcorderProfile, videoDuration));
camcorderProfile = CameraHelper.getCamcorderProfile(Configuration.MEDIA_QUALITY_MEDIUM, currentCameraId);
videoDuration = CameraHelper.calculateApproximateVideoDuration(camcorderProfile, configurationProvider.getVideoFileSize());
videoQualities.add(new VideoQualityOption(Configuration.MEDIA_QUALITY_MEDIUM, camcorderProfile, videoDuration));
camcorderProfile = CameraHelper.getCamcorderProfile(Configuration.MEDIA_QUALITY_LOW, currentCameraId);
videoDuration = CameraHelper.calculateApproximateVideoDuration(camcorderProfile, configurationProvider.getVideoFileSize());
videoQualities.add(new VideoQualityOption(Configuration.MEDIA_QUALITY_LOW, camcorderProfile, videoDuration));
CharSequence[] array = new CharSequence[videoQualities.size()];
videoQualities.toArray(array);
return array;
}
示例2: getVideoQualityOptions
import android.media.CamcorderProfile; //导入依赖的package包/类
@Override
public CharSequence[] getVideoQualityOptions() {
final List<CharSequence> videoQualities = new ArrayList<>();
if (configurationProvider.getMinimumVideoDuration() > 0)
videoQualities.add(new VideoQualityOption(Configuration.MEDIA_QUALITY_AUTO, CameraHelper.getCamcorderProfile(Configuration.MEDIA_QUALITY_AUTO, getCurrentCameraId()), configurationProvider.getMinimumVideoDuration()));
CamcorderProfile camcorderProfile = CameraHelper.getCamcorderProfile(Configuration.MEDIA_QUALITY_HIGH, getCurrentCameraId());
double videoDuration = CameraHelper.calculateApproximateVideoDuration(camcorderProfile, configurationProvider.getVideoFileSize());
videoQualities.add(new VideoQualityOption(Configuration.MEDIA_QUALITY_HIGH, camcorderProfile, videoDuration));
camcorderProfile = CameraHelper.getCamcorderProfile(Configuration.MEDIA_QUALITY_MEDIUM, getCurrentCameraId());
videoDuration = CameraHelper.calculateApproximateVideoDuration(camcorderProfile, configurationProvider.getVideoFileSize());
videoQualities.add(new VideoQualityOption(Configuration.MEDIA_QUALITY_MEDIUM, camcorderProfile, videoDuration));
camcorderProfile = CameraHelper.getCamcorderProfile(Configuration.MEDIA_QUALITY_LOW, getCurrentCameraId());
videoDuration = CameraHelper.calculateApproximateVideoDuration(camcorderProfile, configurationProvider.getVideoFileSize());
videoQualities.add(new VideoQualityOption(Configuration.MEDIA_QUALITY_LOW, camcorderProfile, videoDuration));
final CharSequence[] array = new CharSequence[videoQualities.size()];
videoQualities.toArray(array);
return array;
}
示例3: getCamcorderProfile
import android.media.CamcorderProfile; //导入依赖的package包/类
public static CamcorderProfile getCamcorderProfile(int currentCameraId, long maximumFileSize, int minimumDurationInSeconds) {
if (maximumFileSize <= 0)
return CamcorderProfile.get(currentCameraId, Configuration.MEDIA_QUALITY_HIGHEST);
int[] qualities = new int[]{Configuration.MEDIA_QUALITY_HIGHEST,
Configuration.MEDIA_QUALITY_HIGH, Configuration.MEDIA_QUALITY_MEDIUM,
Configuration.MEDIA_QUALITY_LOW, Configuration.MEDIA_QUALITY_LOWEST};
CamcorderProfile camcorderProfile;
for (int i = 0; i < qualities.length; ++i) {
camcorderProfile = CameraHelper.getCamcorderProfile(qualities[i], currentCameraId);
double fileSize = CameraHelper.calculateApproximateVideoSize(camcorderProfile, minimumDurationInSeconds);
if (fileSize > maximumFileSize) {
long minimumRequiredBitRate = calculateMinimumRequiredBitRate(camcorderProfile, maximumFileSize, minimumDurationInSeconds);
if (minimumRequiredBitRate >= camcorderProfile.videoBitRate / 4 && minimumRequiredBitRate <= camcorderProfile.videoBitRate) {
camcorderProfile.videoBitRate = (int) minimumRequiredBitRate;
return camcorderProfile;
}
} else return camcorderProfile;
}
return CameraHelper.getCamcorderProfile(Configuration.MEDIA_QUALITY_LOWEST, currentCameraId);
}
示例4: setUpMediaRecorder
import android.media.CamcorderProfile; //导入依赖的package包/类
private void setUpMediaRecorder() throws IOException {
final Activity activity = (Activity) getContext();
if (null == activity) {
return;
}
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mediaRecorder.setVideoSource(MediaRecorder.VideoSource.SURFACE);
mediaRecorder.setOutputFile(getOutputMediaFile(MEDIA_TYPE_VIDEO).toString());
if (sensorOrientation == SENSOR_ORIENTATION_DEFAULT_DEGREES) {
mediaRecorder.setOrientationHint(ORIENTATION_90);
} else {
mediaRecorder.setOrientationHint(ORIENTATION_270);
}
CamcorderProfile profile = getCamcorderProfile();
profile.videoFrameWidth = videoSize.getWidth();
profile.videoFrameHeight = videoSize.getHeight();
mediaRecorder.setProfile(profile);
mediaRecorder.setVideoEncodingBitRate(BITRATE);
mediaRecorder.prepare();
}
示例5: configureRecorder
import android.media.CamcorderProfile; //导入依赖的package包/类
protected void configureRecorder(int quality, MediaRecorder recorder) {
Camera.CameraInfo info = new Camera.CameraInfo();
Camera.getCameraInfo(cameraInfo.cameraId, info);
int displayOrientation = getDisplayOrientation(info, false);
recorder.setOrientationHint(displayOrientation);
int highProfile = getHigh();
boolean canGoHigh = CamcorderProfile.hasProfile(cameraInfo.cameraId, highProfile);
boolean canGoLow = CamcorderProfile.hasProfile(cameraInfo.cameraId, CamcorderProfile.QUALITY_LOW);
if (canGoHigh && (quality == 1 || !canGoLow)) {
recorder.setProfile(CamcorderProfile.get(cameraInfo.cameraId, highProfile));
} else if (canGoLow) {
recorder.setProfile(CamcorderProfile.get(cameraInfo.cameraId, CamcorderProfile.QUALITY_LOW));
} else {
throw new IllegalStateException("cannot find valid CamcorderProfile");
}
isVideo = true;
}
示例6: getCamcorderProfile
import android.media.CamcorderProfile; //导入依赖的package包/类
public static CamcorderProfile getCamcorderProfile(int currentCameraId, long maximumFileSize, int minimumDurationInSeconds) {
if (maximumFileSize <= 0)
return CamcorderProfile.get(currentCameraId, CameraConfiguration.MEDIA_QUALITY_HIGHEST);
int[] qualities = new int[]{CameraConfiguration.MEDIA_QUALITY_HIGHEST,
CameraConfiguration.MEDIA_QUALITY_HIGH, CameraConfiguration.MEDIA_QUALITY_MEDIUM,
CameraConfiguration.MEDIA_QUALITY_LOW, CameraConfiguration.MEDIA_QUALITY_LOWEST};
CamcorderProfile camcorderProfile;
for (int i = 0; i < qualities.length; ++i) {
camcorderProfile = CameraHelper.getCamcorderProfile(qualities[i], currentCameraId);
double fileSize = CameraHelper.calculateApproximateVideoSize(camcorderProfile, minimumDurationInSeconds);
if (fileSize > maximumFileSize) {
long minimumRequiredBitRate = calculateMinimumRequiredBitRate(camcorderProfile, maximumFileSize, minimumDurationInSeconds);
if (minimumRequiredBitRate >= camcorderProfile.videoBitRate / 4 && minimumRequiredBitRate <= camcorderProfile.videoBitRate) {
camcorderProfile.videoBitRate = (int) minimumRequiredBitRate;
return camcorderProfile;
}
} else return camcorderProfile;
}
return CameraHelper.getCamcorderProfile(CameraConfiguration.MEDIA_QUALITY_LOWEST, currentCameraId);
}
示例7: getVideoQualityOptions
import android.media.CamcorderProfile; //导入依赖的package包/类
@Override
protected CharSequence[] getVideoQualityOptions() {
List<CharSequence> videoQualities = new ArrayList<>();
if (getMinimumVideoDuration() > 0)
videoQualities.add(new VideoQualityOption(CameraConfiguration.MEDIA_QUALITY_AUTO, CameraHelper.getCamcorderProfile(CameraConfiguration.MEDIA_QUALITY_AUTO, getCameraController().getCurrentCameraId()), getMinimumVideoDuration()));
CamcorderProfile camcorderProfile = CameraHelper.getCamcorderProfile(CameraConfiguration.MEDIA_QUALITY_HIGH, getCameraController().getCurrentCameraId());
double videoDuration = CameraHelper.calculateApproximateVideoDuration(camcorderProfile, getVideoFileSize());
videoQualities.add(new VideoQualityOption(CameraConfiguration.MEDIA_QUALITY_HIGH, camcorderProfile, videoDuration));
camcorderProfile = CameraHelper.getCamcorderProfile(CameraConfiguration.MEDIA_QUALITY_MEDIUM, getCameraController().getCurrentCameraId());
videoDuration = CameraHelper.calculateApproximateVideoDuration(camcorderProfile, getVideoFileSize());
videoQualities.add(new VideoQualityOption(CameraConfiguration.MEDIA_QUALITY_MEDIUM, camcorderProfile, videoDuration));
camcorderProfile = CameraHelper.getCamcorderProfile(CameraConfiguration.MEDIA_QUALITY_LOW, getCameraController().getCurrentCameraId());
videoDuration = CameraHelper.calculateApproximateVideoDuration(camcorderProfile, getVideoFileSize());
videoQualities.add(new VideoQualityOption(CameraConfiguration.MEDIA_QUALITY_LOW, camcorderProfile, videoDuration));
CharSequence[] array = new CharSequence[videoQualities.size()];
videoQualities.toArray(array);
return array;
}
示例8: getVideoQualityOptions
import android.media.CamcorderProfile; //导入依赖的package包/类
@Override
protected CharSequence[] getVideoQualityOptions() {
List<CharSequence> videoQualities = new ArrayList<>();
if (getMinimumVideoDuration() > 0)
videoQualities.add(new VideoQualityOption(CameraConfiguration.MEDIA_QUALITY_AUTO, CameraHelper.getCamcorderProfile(CameraConfiguration.MEDIA_QUALITY_AUTO, getCameraController().getCurrentCameraId()), getMinimumVideoDuration()));
CamcorderProfile camcorderProfile = CameraHelper.getCamcorderProfile(CameraConfiguration.MEDIA_QUALITY_HIGH, getCameraController().getCurrentCameraId());
double videoDuration = CameraHelper.calculateApproximateVideoDuration(camcorderProfile, getVideoFileSize());
videoQualities.add(new VideoQualityOption(CameraConfiguration.MEDIA_QUALITY_HIGH, camcorderProfile, videoDuration));
camcorderProfile = CameraHelper.getCamcorderProfile(CameraConfiguration.MEDIA_QUALITY_MEDIUM, getCameraController().getCurrentCameraId());
videoDuration = CameraHelper.calculateApproximateVideoDuration(camcorderProfile, getVideoFileSize());
videoQualities.add(new VideoQualityOption(CameraConfiguration.MEDIA_QUALITY_MEDIUM, camcorderProfile, videoDuration));
camcorderProfile = CameraHelper.getCamcorderProfile(CameraConfiguration.MEDIA_QUALITY_LOW, getCameraController().getCurrentCameraId());
videoDuration = CameraHelper.calculateApproximateVideoDuration(camcorderProfile, getVideoFileSize());
videoQualities.add(new VideoQualityOption(CameraConfiguration.MEDIA_QUALITY_LOW, camcorderProfile, videoDuration));
CharSequence[] array = new CharSequence[videoQualities.size()];
videoQualities.toArray(array);
return array;
}
示例9: mediaRecorderShouldHaveMediaRecorderOptions
import android.media.CamcorderProfile; //导入依赖的package包/类
@Test
public void mediaRecorderShouldHaveMediaRecorderOptions() throws Exception {
final CaptureConfiguration config = new CaptureConfiguration();
CamcorderProfile profile = getEmptyCamcorderProfile();
final VideoRecorder recorder =
new VideoRecorder(null, config, mock(VideoFile.class), createMockCameraWrapperForPrepare(profile), mock(SurfaceHolder.class));
final MediaRecorder mockRecorder = mock(MediaRecorder.class);
recorder.configureMediaRecorder(mockRecorder, mock(Camera.class));
verify(mockRecorder, times(1)).setAudioSource(config.getAudioSource());
verify(mockRecorder, times(1)).setVideoSource(config.getVideoSource());
assertEquals(profile.fileFormat, config.getOutputFormat());
assertEquals(profile.audioCodec, config.getAudioEncoder());
assertEquals(profile.videoCodec, config.getVideoEncoder());
verify(mockRecorder, times(1)).setProfile(profile);
}
示例10: mediaRecorderShouldHaveConfigurationOptions
import android.media.CamcorderProfile; //导入依赖的package包/类
@Test
public void mediaRecorderShouldHaveConfigurationOptions() throws Exception {
final CaptureConfiguration config = new CaptureConfiguration();
CamcorderProfile profile = getEmptyCamcorderProfile();
CameraWrapper mockWrapper = createMockCameraWrapperForPrepare(profile);
doReturn(new RecordingSize(777, 888)).when(mockWrapper).getSupportedRecordingSize(anyInt(), anyInt());
final VideoRecorder recorder = new VideoRecorder(null, config, mock(VideoFile.class), mockWrapper, mock(SurfaceHolder.class));
final MediaRecorder mockRecorder = mock(MediaRecorder.class);
recorder.configureMediaRecorder(mockRecorder, mock(Camera.class));
assertEquals(profile.videoFrameWidth, 777);
assertEquals(profile.videoFrameHeight, 888);
assertEquals(profile.videoBitRate, config.getVideoBitrate());
verify(mockRecorder, times(1)).setMaxDuration(config.getMaxCaptureDuration());
verify(mockRecorder, times(1)).setProfile(profile);
verify(mockRecorder, times(1)).setMaxFileSize(config.getMaxCaptureFileSize());
}
示例11: getCamcorderProfile
import android.media.CamcorderProfile; //导入依赖的package包/类
public static CamcorderProfile getCamcorderProfile(int currentCameraId, long maximumFileSize, int minimumDurationInSeconds) {
if (maximumFileSize <= 0)
return CamcorderProfile.get(currentCameraId, AnncaConfiguration.MEDIA_QUALITY_HIGHEST);
int[] qualities = new int[]{AnncaConfiguration.MEDIA_QUALITY_HIGHEST,
AnncaConfiguration.MEDIA_QUALITY_HIGH, AnncaConfiguration.MEDIA_QUALITY_MEDIUM,
AnncaConfiguration.MEDIA_QUALITY_LOW, AnncaConfiguration.MEDIA_QUALITY_LOWEST};
CamcorderProfile camcorderProfile;
for (int i = 0; i < qualities.length; ++i) {
camcorderProfile = CameraHelper.getCamcorderProfile(qualities[i], currentCameraId);
double fileSize = CameraHelper.calculateApproximateVideoSize(camcorderProfile, minimumDurationInSeconds);
if (fileSize > maximumFileSize) {
long minimumRequiredBitRate = calculateMinimumRequiredBitRate(camcorderProfile, maximumFileSize, minimumDurationInSeconds);
if (minimumRequiredBitRate >= camcorderProfile.videoBitRate / 4 && minimumRequiredBitRate <= camcorderProfile.videoBitRate) {
camcorderProfile.videoBitRate = (int) minimumRequiredBitRate;
return camcorderProfile;
}
} else return camcorderProfile;
}
return CameraHelper.getCamcorderProfile(AnncaConfiguration.MEDIA_QUALITY_LOWEST, currentCameraId);
}
示例12: getVideoQualityOptions
import android.media.CamcorderProfile; //导入依赖的package包/类
@Override
protected CharSequence[] getVideoQualityOptions() {
List<CharSequence> videoQualities = new ArrayList<>();
if (getMinimumVideoDuration() > 0)
videoQualities.add(new VideoQualityOption(AnncaConfiguration.MEDIA_QUALITY_AUTO, CameraHelper.getCamcorderProfile(AnncaConfiguration.MEDIA_QUALITY_AUTO, getCameraController().getCurrentCameraId()), getMinimumVideoDuration()));
CamcorderProfile camcorderProfile = CameraHelper.getCamcorderProfile(AnncaConfiguration.MEDIA_QUALITY_HIGH, getCameraController().getCurrentCameraId());
double videoDuration = CameraHelper.calculateApproximateVideoDuration(camcorderProfile, getVideoFileSize());
videoQualities.add(new VideoQualityOption(AnncaConfiguration.MEDIA_QUALITY_HIGH, camcorderProfile, videoDuration));
camcorderProfile = CameraHelper.getCamcorderProfile(AnncaConfiguration.MEDIA_QUALITY_MEDIUM, getCameraController().getCurrentCameraId());
videoDuration = CameraHelper.calculateApproximateVideoDuration(camcorderProfile, getVideoFileSize());
videoQualities.add(new VideoQualityOption(AnncaConfiguration.MEDIA_QUALITY_MEDIUM, camcorderProfile, videoDuration));
camcorderProfile = CameraHelper.getCamcorderProfile(AnncaConfiguration.MEDIA_QUALITY_LOW, getCameraController().getCurrentCameraId());
videoDuration = CameraHelper.calculateApproximateVideoDuration(camcorderProfile, getVideoFileSize());
videoQualities.add(new VideoQualityOption(AnncaConfiguration.MEDIA_QUALITY_LOW, camcorderProfile, videoDuration));
CharSequence[] array = new CharSequence[videoQualities.size()];
videoQualities.toArray(array);
return array;
}
示例13: getVideoQualityOptions
import android.media.CamcorderProfile; //导入依赖的package包/类
@Override
protected CharSequence[] getVideoQualityOptions() {
List<CharSequence> videoQualities = new ArrayList<>();
if (getMinimumVideoDuration() > 0)
videoQualities.add(new VideoQualityOption(AnncaConfiguration.MEDIA_QUALITY_AUTO, CameraHelper.getCamcorderProfile(AnncaConfiguration.MEDIA_QUALITY_AUTO, getCameraController().getCurrentCameraId()), getMinimumVideoDuration()));
CamcorderProfile camcorderProfile = CameraHelper.getCamcorderProfile(AnncaConfiguration.MEDIA_QUALITY_HIGH, getCameraController().getCurrentCameraId());
double videoDuration = CameraHelper.calculateApproximateVideoDuration(camcorderProfile, getVideoFileSize());
videoQualities.add(new VideoQualityOption(AnncaConfiguration.MEDIA_QUALITY_HIGH, camcorderProfile, videoDuration));
camcorderProfile = CameraHelper.getCamcorderProfile(AnncaConfiguration.MEDIA_QUALITY_MEDIUM, getCameraController().getCurrentCameraId());
videoDuration = CameraHelper.calculateApproximateVideoDuration(camcorderProfile, getVideoFileSize());
videoQualities.add(new VideoQualityOption(AnncaConfiguration.MEDIA_QUALITY_MEDIUM, camcorderProfile, videoDuration));
camcorderProfile = CameraHelper.getCamcorderProfile(AnncaConfiguration.MEDIA_QUALITY_LOW, getCameraController().getCurrentCameraId());
videoDuration = CameraHelper.calculateApproximateVideoDuration(camcorderProfile, getVideoFileSize());
videoQualities.add(new VideoQualityOption(AnncaConfiguration.MEDIA_QUALITY_LOW, camcorderProfile, videoDuration));
CharSequence[] array = new CharSequence[videoQualities.size()];
videoQualities.toArray(array);
return array;
}
示例14: prepareMediaRecorder
import android.media.CamcorderProfile; //导入依赖的package包/类
private boolean prepareMediaRecorder() {
mMediaRecorder = new MediaRecorder();
mCamera.unlock();
mMediaRecorder.setCamera(mCamera);
mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mMediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_1080P));
mMediaRecorder.setPreviewDisplay(mHolder.getSurface());
String path = getSDPath();
if (path != null) {
File dir = new File(path + "/VideoRecorderTest");
if (!dir.exists()) {
dir.mkdir();
}
path = dir + "/" + getDate() + ".mp4";
mMediaRecorder.setOutputFile(path);
try {
mMediaRecorder.prepare();
} catch (IOException e) {
releaseMediaRecorder();
e.printStackTrace();
}
}
return true;
}
示例15: startRecording
import android.media.CamcorderProfile; //导入依赖的package包/类
@Override
public void startRecording(Camera.PreviewCallback previewCallback) {
recording = true;
mCamera.unlock();
mRecordbutton.setBackgroundResource(R.drawable.red_circle_background);
mMediaRecorder = new MediaRecorder();
mMediaRecorder.setCamera(mCamera);
mMediaRecorder.setPreviewDisplay(mSurfaceHolder.getSurface());
mMediaRecorder.setOutputFile("/sdcard/Video.mp4");
mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mMediaRecorder.setOrientationHint(90);
mMediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));
try {
mMediaRecorder.prepare();
mMediaRecorder.start();
mCamera.startPreview();
mCamera.setPreviewCallback(previewCallback);
} catch (IOException e) {
e.printStackTrace();
}
}