List of usage examples for android.media CamcorderProfile QUALITY_480P
int QUALITY_480P
To view the source code for android.media CamcorderProfile QUALITY_480P.
Click Source Link
From source file:com.czh.testmpeg.videorecord.CameraActivity.java
private void reloadQualities(int idCamera) { SharedPreferences prefs = getSharedPreferences("RECORDING", Context.MODE_PRIVATE); quality = prefs.getInt("QUALITY", CamcorderProfile.QUALITY_480P); changeVideoQuality(quality);/*from w ww.j a v a 2 s . co m*/ final ArrayList<String> list = new ArrayList<String>(); int maxQualitySupported = CamcorderProfile.QUALITY_480P; if (CamcorderProfile.hasProfile(idCamera, CamcorderProfile.QUALITY_480P)) { list.add("480p"); maxQualitySupported = CamcorderProfile.QUALITY_480P; } if (CamcorderProfile.hasProfile(idCamera, CamcorderProfile.QUALITY_720P)) { list.add("720p"); maxQualitySupported = CamcorderProfile.QUALITY_720P; } if (CamcorderProfile.hasProfile(idCamera, CamcorderProfile.QUALITY_1080P)) { list.add("1080p"); maxQualitySupported = CamcorderProfile.QUALITY_1080P; } if (CamcorderProfile.hasProfile(idCamera, CamcorderProfile.QUALITY_2160P)) { list.add("2160p"); maxQualitySupported = CamcorderProfile.QUALITY_2160P; } if (!CamcorderProfile.hasProfile(idCamera, quality)) { quality = maxQualitySupported; updateButtonText(maxQualitySupported); } final StableArrayAdapter adapter = new StableArrayAdapter(this, android.R.layout.simple_list_item_1, list); mBinding.listOfQualities.setAdapter(adapter); mBinding.listOfQualities.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, final View view, int position, long id) { final String item = (String) parent.getItemAtPosition(position); mBinding.buttonQuality.setText(item); if (item.equals("480p")) { changeVideoQuality(CamcorderProfile.QUALITY_480P); } else if (item.equals("720p")) { changeVideoQuality(CamcorderProfile.QUALITY_720P); } else if (item.equals("1080p")) { changeVideoQuality(CamcorderProfile.QUALITY_1080P); } else if (item.equals("2160p")) { changeVideoQuality(CamcorderProfile.QUALITY_2160P); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { mBinding.listOfQualities.animate().setDuration(200).alpha(0).withEndAction(new Runnable() { @Override public void run() { mBinding.listOfQualities.setVisibility(View.GONE); } }); } else { mBinding.listOfQualities.setVisibility(View.GONE); } } }); }
From source file:com.czh.testmpeg.videorecord.CameraActivity.java
private void updateButtonText(int quality) { if (quality == CamcorderProfile.QUALITY_480P) mBinding.buttonQuality.setText("480p"); if (quality == CamcorderProfile.QUALITY_720P) mBinding.buttonQuality.setText("720p"); if (quality == CamcorderProfile.QUALITY_1080P) mBinding.buttonQuality.setText("1080p"); if (quality == CamcorderProfile.QUALITY_2160P) mBinding.buttonQuality.setText("2160p"); }
From source file:com.almalence.plugins.capture.video.VideoCapturePlugin.java
private void prepareMediaRecorder() { mMediaRecorder = CameraController.getMediaRecorder(); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ApplicationScreen.getMainContext()); if (Build.VERSION.SDK_INT > Build.VERSION_CODES.ICE_CREAM_SANDWICH && videoStabilization) CameraController.setVideoStabilization(true); CameraController.unlockCamera();/* ww w. j a v a2 s.com*/ // Step 2: Set sources if (!CameraController.isUseCamera2()) { CameraController.configureMediaRecorder(mMediaRecorder); mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA); } else { mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.SURFACE); } if (ApplicationScreen.isMicrophonePermissionGranted()) mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER); int quality = Integer.parseInt( prefs.getString(CameraController.getCameraIndex() == 0 ? ApplicationScreen.sImageSizeVideoBackPref : ApplicationScreen.sImageSizeVideoFrontPref, DEFAULT_VIDEO_QUALITY)); if (maxQuality()) { quality = CamcorderProfile.QUALITY_HIGH; } boolean useProfile = true; if (!CamcorderProfile.hasProfile(CameraController.getCameraIndex(), quality)) useProfile = false; // Step 3: Set a CamcorderProfile (requires API Level 8 or higher) try { try { if (swChecked) { int qualityTimeLapse = quality; // if time lapse activated switch (quality) { case CamcorderProfile.QUALITY_QCIF: quality = CamcorderProfile.QUALITY_TIME_LAPSE_QCIF; break; case CamcorderProfile.QUALITY_CIF: quality = CamcorderProfile.QUALITY_TIME_LAPSE_CIF; break; case CamcorderProfile.QUALITY_2160P: quality = CamcorderProfile.QUALITY_TIME_LAPSE_2160P; break; case CamcorderProfile.QUALITY_1080P: quality = CamcorderProfile.QUALITY_TIME_LAPSE_1080P; break; case CamcorderProfile.QUALITY_720P: quality = CamcorderProfile.QUALITY_TIME_LAPSE_720P; break; case CamcorderProfile.QUALITY_480P: quality = CamcorderProfile.QUALITY_TIME_LAPSE_480P; break; case QUALITY_4K: quality = QUALITY_4K; break; case CamcorderProfile.QUALITY_HIGH: quality = CamcorderProfile.QUALITY_TIME_LAPSE_HIGH; break; default: break; } if (!CamcorderProfile.hasProfile(CameraController.getCameraIndex(), quality)) { Toast.makeText(ApplicationScreen.instance, "Time lapse not supported", Toast.LENGTH_LONG) .show(); } else quality = qualityTimeLapse; } } catch (Exception e) { e.printStackTrace(); Log.e("Video", "Time lapse error catched" + e.getMessage()); swChecked = false; } lastUseProfile = useProfile; if (useProfile) { CamcorderProfile pr = CamcorderProfile.get(CameraController.getCameraIndex(), quality); if (ApplicationScreen.isMicrophonePermissionGranted()) { mMediaRecorder.setProfile(pr); } else { // If we don't have access to microphone, then configure only video settings of MediaREcorder. mMediaRecorder.setOutputFormat(pr.fileFormat); mMediaRecorder.setVideoEncoder(pr.videoCodec); mMediaRecorder.setVideoSize(pr.videoFrameWidth, pr.videoFrameHeight); mMediaRecorder.setVideoFrameRate(pr.videoFrameRate); mMediaRecorder.setVideoEncodingBitRate(pr.videoBitRate); } lastCamcorderProfile = pr; } else { boolean useProf = false; lastUseProf = useProf; CameraController.Size sz = null; switch (quality) { case CamcorderProfile.QUALITY_QCIF: sz = new CameraController.Size(176, 144); break; case CamcorderProfile.QUALITY_CIF: sz = new CameraController.Size(352, 288); break; case CamcorderProfile.QUALITY_480P: sz = new CameraController.Size(640, 480); break; case CamcorderProfile.QUALITY_720P: sz = new CameraController.Size(1280, 720); break; case CamcorderProfile.QUALITY_1080P: sz = new CameraController.Size(1920, 1080); break; case CamcorderProfile.QUALITY_2160P: { if (CamcorderProfile.hasProfile(CameraController.getCameraIndex(), CamcorderProfile.QUALITY_2160P)) sz = new CameraController.Size(3840, 2160); else { CamcorderProfile prof = CamcorderProfile.get(CameraController.getCameraIndex(), CamcorderProfile.QUALITY_HIGH); prof.videoFrameWidth = 3840; prof.videoFrameHeight = 2160; prof.videoBitRate = (int) (prof.videoBitRate * 2.8); // need a higher bitrate for the better quality - this is roughly based on the bitrate used by an S5's native camera app at 4K (47.6 Mbps, compared to 16.9 Mbps which is what's returned by the QUALITY_HIGH profile) if (ApplicationScreen.isMicrophonePermissionGranted()) { mMediaRecorder.setProfile(prof); } else { mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264); mMediaRecorder.setVideoSize(prof.videoFrameWidth, prof.videoFrameHeight); mMediaRecorder.setVideoFrameRate(30); mMediaRecorder.setVideoEncodingBitRate((int) (prof.videoBitRate * 2.8)); // need a higher bitrate for the better quality } lastCamcorderProfile = prof; useProf = true; lastUseProf = useProf; } } break; case QUALITY_4K: { if (CamcorderProfile.hasProfile(CameraController.getCameraIndex(), CamcorderProfile.QUALITY_1080P)) { CamcorderProfile prof = CamcorderProfile.get(CamcorderProfile.QUALITY_1080P); prof.videoFrameHeight = 2160; prof.videoFrameWidth = 4096; if (ApplicationScreen.isMicrophonePermissionGranted()) { mMediaRecorder.setProfile(prof); } else { mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264); mMediaRecorder.setVideoSize(prof.videoFrameWidth, prof.videoFrameHeight); mMediaRecorder.setVideoFrameRate(30); mMediaRecorder.setVideoEncodingBitRate(prof.videoBitRate * 4); // 2160p has 4x more pixels then 1080p. } lastCamcorderProfile = prof; useProf = true; lastUseProf = useProf; } else sz = new CameraController.Size(4096, 2160); } break; default: break; } if (!useProf) { mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264); mMediaRecorder.setVideoSize(sz.getWidth(), sz.getHeight()); mMediaRecorder.setVideoFrameRate(30); // Other parameters just copy from CamcorderProfile.QUALITY_1080P CamcorderProfile prof = CamcorderProfile.get(CamcorderProfile.QUALITY_1080P); mMediaRecorder.setVideoEncodingBitRate(prof.videoBitRate * 4); // 2160p has 4x more pixels then 1080p. if (ApplicationScreen.isMicrophonePermissionGranted()) { mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC); mMediaRecorder.setAudioChannels(prof.audioChannels); mMediaRecorder.setAudioEncodingBitRate(prof.audioBitRate); mMediaRecorder.setAudioSamplingRate(prof.audioSampleRate); } lastSz = sz; } else lastUseProfile = true; } if (swChecked) { double val1 = Double.valueOf(stringInterval[interval]); int val2 = measurementVal; switch (val2) { case 0: val2 = 1; break; case 1: val2 = 60; break; case 2: val2 = 3600; break; default: break; } captureRate = 1 / (val1 * val2); mMediaRecorder.setCaptureRate(captureRate); } } catch (Exception e) { e.printStackTrace(); releaseMediaRecorder(); // release the MediaRecorder object return; } // Step 4: Set output file if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { DocumentFile file = getOutputMediaDocumentFile(); try { documentFileSavedFd = ApplicationScreen.instance.getContentResolver() .openFileDescriptor(file.getUri(), "w"); FileDescriptor fileDescriptor = documentFileSavedFd.getFileDescriptor(); mMediaRecorder.setOutputFile(fileDescriptor); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); mMediaRecorder.setOutputFile(getOutputMediaFile().toString()); } } else { mMediaRecorder.setOutputFile(getOutputMediaFile().toString()); } // Step 5: Set the preview output if (!CameraController.isUseCamera2()) { mMediaRecorder.setPreviewDisplay(ApplicationScreen.getPreviewSurfaceHolder().getSurface()); } mMediaRecorder.setOrientationHint(CameraController.isFrontCamera() ? (ApplicationScreen.getWantLandscapePhoto() ? ApplicationScreen.getGUIManager().getImageDataOrientation() : (ApplicationScreen.getGUIManager().getImageDataOrientation() + 180) % 360) : ApplicationScreen.getGUIManager().getImageDataOrientation()); // Step 6: Prepare configured MediaRecorder try { mMediaRecorder.prepare(); } catch (Exception e) { Log.d("Video", "Exception preparing MediaRecorder: " + e.getMessage()); releaseMediaRecorder(); CameraController.lockCamera(); // take camera access back from MediaRecorder return; } }
From source file:com.almalence.plugins.capture.video.VideoCapturePlugin.java
@Override public void onCameraParametersSetup() { supportedVideoSizesOrderedList.clear(); List<CameraController.Size> vsz = CameraController.getSupportedVideoSizes(); if (Util.listContainsSize(vsz, new CameraController.Size(176, 144))) { supportedVideoSizesOrderedList.add(CamcorderProfile.QUALITY_QCIF); }// ww w .j ava2 s.c o m if (Util.listContainsSize(vsz, new CameraController.Size(352, 288))) { supportedVideoSizesOrderedList.add(CamcorderProfile.QUALITY_CIF); } if (Util.listContainsSize(vsz, new CameraController.Size(640, 480))) { supportedVideoSizesOrderedList.add(CamcorderProfile.QUALITY_480P); } if (Util.listContainsSize(vsz, new CameraController.Size(1280, 720))) { supportedVideoSizesOrderedList.add(CamcorderProfile.QUALITY_720P); } if (Util.listContainsSize(vsz, new CameraController.Size(1920, 1080)) || Util.listContainsSize(vsz, new CameraController.Size(1920, 1088))) { supportedVideoSizesOrderedList.add(CamcorderProfile.QUALITY_1080P); } if (Util.listContainsSize(vsz, new CameraController.Size(3840, 2160))) { supportedVideoSizesOrderedList.add(CamcorderProfile.QUALITY_2160P); } if (Util.listContainsSize(vsz, new CameraController.Size(4096, 2160))) { supportedVideoSizesOrderedList.add(QUALITY_4K); } // Order list asc. Collections.sort(supportedVideoSizesOrderedList, new Comparator<Integer>() { @Override public int compare(Integer a, Integer b) { return a - b; } }); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ApplicationScreen.getMainContext()); setupVideoSize(prefs); if (!CameraController.isGalaxyS4 && !CameraController.isGalaxyNote3) { CameraController.setPreviewFrameRate(30); CameraController.setRecordingHint(true); } }
From source file:com.almalence.plugins.capture.video.VideoCapturePlugin.java
private CameraController.Size getBestPreviewSizeDRO(final int quality) { int width;/*from w ww . j a va2 s. c om*/ int height; switch (quality) { case CamcorderProfile.QUALITY_QCIF: width = 176; height = 144; break; case CamcorderProfile.QUALITY_CIF: width = 352; height = 288; break; case CamcorderProfile.QUALITY_480P: width = 720; height = 480; break; case CamcorderProfile.QUALITY_720P: width = 1280; height = 720; break; case CamcorderProfile.QUALITY_1080P: width = 1920; height = 1080; break; case CamcorderProfile.QUALITY_2160P: width = 3840; height = 2160; break; case QUALITY_4K: width = 4096; height = 2160; break; default: return getBestPreviewSizeNormal(false); } if (maxQuality() && modeDRO()) { width = 720; height = 480; } else if (maxQuality()) { width = 1920; height = 1080; } final List<CameraController.Size> sizes = CameraController.getSupportedPreviewSizes(); CameraController.Size size_best = sizes.get(0); for (final CameraController.Size size : sizes) { if (Math.sqrt(sqr(size.getWidth() - width) + sqr(size.getHeight() - height)) < Math .sqrt(sqr(size_best.getWidth() - width) + sqr(size_best.getHeight() - height))) { size_best = size; } } return size_best; }