本文整理汇总了Java中android.media.CamcorderProfile.get方法的典型用法代码示例。如果您正苦于以下问题:Java CamcorderProfile.get方法的具体用法?Java CamcorderProfile.get怎么用?Java CamcorderProfile.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.media.CamcorderProfile
的用法示例。
在下文中一共展示了CamcorderProfile.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: 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);
}
示例4: chooseCamcorderProfile
import android.media.CamcorderProfile; //导入方法依赖的package包/类
private void chooseCamcorderProfile(Size sizeHint) {
// For android 2.3 devices video quality = low
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB)
profile = (CamcorderProfile.get(CamcorderProfile.QUALITY_LOW));
else {
// For >= Android 3.0 devices select 720p, 480p or low quality of video
if (CamcorderProfile.hasProfile(getCameraID(), CamcorderProfile.QUALITY_720P)
&& (sizeHint == null || sizeHint.height >= 720)) {
profile = (CamcorderProfile.get(CamcorderProfile.QUALITY_720P));
return;
}
if (CamcorderProfile.hasProfile(getCameraID(), CamcorderProfile.QUALITY_480P)
&& (sizeHint == null || sizeHint.height >= 480)) {
profile = (CamcorderProfile.get(CamcorderProfile.QUALITY_480P));
return;
}
profile = (CamcorderProfile.get(CamcorderProfile.QUALITY_LOW));
}
}
示例5: CaptureSurface
import android.media.CamcorderProfile; //导入方法依赖的package包/类
public CaptureSurface(Context context, AttributeSet attrs) {
super(context, attrs);
holder = getHolder();
holder.addCallback(this);
holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
Log.d(Tag, "Setting up recorder.");
recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
CamcorderProfile cpHigh = CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH);
// recorder.setMaxDuration(50000); // 50 seconds
// recorder.setMaxFileSize(5000000); // Approximately 5 megabytes
//CamcorderProfile cpHigh = CamcorderProfile.get(CamcorderProfile.QUALITY_LOW);
recorder.setProfile(cpHigh);
// recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
// recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
// recorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);
outputFile = Environment.getExternalStorageDirectory().getPath() + "/videoexample.mp4";
recorder.setOutputFile(outputFile);
Log.d(Tag, "finished setting up recorder.");
}
示例6: initRecorder
import android.media.CamcorderProfile; //导入方法依赖的package包/类
private void initRecorder() {
Log.d(TAG, "initRecorder");
// recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
CamcorderProfile cpHigh = CamcorderProfile
.get(CamcorderProfile.QUALITY_HIGH);
recorder.setProfile(cpHigh);
VideoFile = MainActivity.getOutputMediaFile(MainActivity.MEDIA_TYPE_VIDEO);
Log.d(TAG, "File is " + VideoFile.toString());
recorder.setOutputFile(VideoFile.toString());
//if you wanted to limit the video size, you can use one of these.
// recorder.setMaxDuration(50000); // 50 seconds
// recorder.setMaxFileSize(5000000); // Approximately 5 megabytes
}
示例7: CaptureSurface
import android.media.CamcorderProfile; //导入方法依赖的package包/类
public CaptureSurface(Context context, AttributeSet attrs) {
super(context, attrs);
holder = getHolder();
holder.addCallback(this);
holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
Log.d(Tag, "Setting up recorder.");
recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
CamcorderProfile cpHigh = CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH);
recorder.setMaxDuration(50000); // 50 seconds
recorder.setMaxFileSize(5000000); // Approximately 5 megabytes
//CamcorderProfile cpHigh = CamcorderProfile.get(CamcorderProfile.QUALITY_LOW);
recorder.setProfile(cpHigh);
// recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
// recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
// recorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);
outputFile = Environment.getExternalStorageDirectory().getPath() +"/videoexample.mp4";
recorder.setOutputFile(outputFile);
Log.d(Tag, "finished setting up recorder.");
}
示例8: getVideoCaptureDurationLimit
import android.media.CamcorderProfile; //导入方法依赖的package包/类
public static int getVideoCaptureDurationLimit(long bytesAvailable) {
CamcorderProfile camcorder = CamcorderProfile.get(CamcorderProfile.QUALITY_LOW);
if (camcorder == null) {
return 0;
}
bytesAvailable *= 8; // convert to bits
long seconds = bytesAvailable / (camcorder.audioBitRate + camcorder.videoBitRate);
// Find the best match for one of the fixed durations
for (int i = sVideoDuration.length - 1; i >= 0; i--) {
if (seconds >= sVideoDuration[i]) {
return sVideoDuration[i];
}
}
return 0;
}
示例9: getRecordingInfo
import android.media.CamcorderProfile; //导入方法依赖的package包/类
private RecordingInfo getRecordingInfo() {
DisplayMetrics displayMetrics = new DisplayMetrics();
WindowManager wm = (WindowManager) context.getSystemService(WINDOW_SERVICE);
wm.getDefaultDisplay().getRealMetrics(displayMetrics);
int displayWidth = displayMetrics.widthPixels;
int displayHeight = displayMetrics.heightPixels;
int displayDensity = displayMetrics.densityDpi;
Timber.d("Display size: %s x %s @ %s", displayWidth, displayHeight, displayDensity);
Configuration configuration = context.getResources().getConfiguration();
boolean isLandscape = configuration.orientation == ORIENTATION_LANDSCAPE;
Timber.d("Display landscape: %s", isLandscape);
// Get the best camera profile available. We assume MediaRecorder supports the highest.
CamcorderProfile camcorderProfile = CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH);
int cameraWidth = camcorderProfile != null ? camcorderProfile.videoFrameWidth : -1;
int cameraHeight = camcorderProfile != null ? camcorderProfile.videoFrameHeight : -1;
int cameraFrameRate = camcorderProfile != null ? camcorderProfile.videoFrameRate : 30;
Timber.d("Camera size: %s x %s framerate: %s", cameraWidth, cameraHeight, cameraFrameRate);
int sizePercentage = videoSizePercentage.get();
Timber.d("Size percentage: %s", sizePercentage);
return calculateRecordingInfo(displayWidth, displayHeight, displayDensity, isLandscape,
cameraWidth, cameraHeight, cameraFrameRate, sizePercentage);
}
示例10: startRecord
import android.media.CamcorderProfile; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.GINGERBREAD_MR1)
void startRecord(boolean audioOnly) {
try {
mRecorder = new MediaRecorder();
if (audioOnly == false) {
mRecorder.setVideoSource(VideoSource.CAMERA);
}
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
CamcorderProfile camcorderProfile_HQ = CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH);
mRecorder.setProfile(camcorderProfile_HQ);
mPreview.getHolder().addCallback(this);
mPreview.getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
//mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mRecorder.setOutputFile(pathName);
// Recording is now started
} catch (Exception e) {
e.printStackTrace();
}
}
示例11: getMaxSupportedVideoRes
import android.media.CamcorderProfile; //导入方法依赖的package包/类
/**
* Determine maximum video resolution that device supports.
*
* @return VIDEO_720P if device supports 720p video recording, <br>
* VIDEO_360P if device supports 360p video recording, and <br>
* UNSUPPORTED if it supports less than 360p video recording.
* <p>
* If it is impossible to determine video recording frame size we
* assume that device support VIDEO_720p.
*/
static public EVideoRecorderCapability getMaxSupportedVideoRes()
{
EVideoRecorderCapability videoResolution = EVideoRecorderCapability.VIDEO_720P;
CamcorderProfile profile = null;
profile = CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH);
if (profile != null) {
if (profile.videoFrameHeight >= 720) {
videoResolution = EVideoRecorderCapability.VIDEO_720P;
} else if (profile.videoFrameHeight >= 360) {
videoResolution = EVideoRecorderCapability.VIDEO_360P;
} else if (profile.videoFrameHeight < 360) {
videoResolution = EVideoRecorderCapability.NOT_SUPPORTED;
}
}
return videoResolution;
}
示例12: refreshCamera
import android.media.CamcorderProfile; //导入方法依赖的package包/类
public void refreshCamera() {
CamcorderProfile profile = CamcorderProfile.get(CamcorderProfile.QUALITY_720P);
Camera.Parameters parameters = camera.getParameters();
parameters.setPreviewSize(profile.videoFrameWidth, profile.videoFrameHeight);
camera.setParameters(parameters);
try {
camera.setPreviewDisplay(surfaceHolder);
camera.startPreview();
} catch (IOException e) {
Log.e(TAG, "Error starting camera preview: " + e.getMessage());
}
}
示例13: _startRecording
import android.media.CamcorderProfile; //导入方法依赖的package包/类
private synchronized void _startRecording(Camera camera, String outPutFile, int rotationHint, int maxdurationMillis)
{
CamcorderProfile profile = CamcorderProfile.get(CamcorderProfile.QUALITY_LOW);
profile.videoFrameWidth = 640;
profile.videoFrameHeight = 480;
profile.audioBitRate = 128;
profile.audioCodec = MediaRecorder.AudioEncoder.AAC;
_startRecording(camera, outPutFile, rotationHint, maxdurationMillis, profile);
}
示例14: canRecordVideo
import android.media.CamcorderProfile; //导入方法依赖的package包/类
public boolean canRecordVideo(@VideoMode int videoMode) {
try {
CamcorderProfile.get(getIdForRequestedCamera(mFacing), videoMode);
return true;
} catch (Exception e) {
return false;
}
}
示例15: getCamcorderProfile
import android.media.CamcorderProfile; //导入方法依赖的package包/类
CamcorderProfile getCamcorderProfile() {
if (CamcorderProfile.hasProfile(cameraId, CamcorderProfile.QUALITY_HIGH)) {
return CamcorderProfile.get(cameraId, CamcorderProfile.QUALITY_HIGH);
}
if (CamcorderProfile.hasProfile(cameraId, CamcorderProfile.QUALITY_480P)) {
return CamcorderProfile.get(cameraId, CamcorderProfile.QUALITY_480P);
}
return CamcorderProfile.get(cameraId, CamcorderProfile.QUALITY_LOW);
}