Record Video using mediRecorder API | Techbirds
Steps to record video are
mCamera = mPreview.getCamera(); //get Camera Intance mRecorder = new MediaRecorder(); //step1 mCamera.unlock(); mRecorder.setCamera(mCamera); //step2 mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); mRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA); //step 3 //mRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH)); mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); mRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.DEFAULT); //step4 mRecorder.setOutputFile(getOutputFile(MEDIA_TYPE_VIDEO).toString()); //step 5 mRecorder.setPreviewDisplay(mPreview.getMyHolder().getSurface()); try { //step 6 mRecorder.prepare(); Thread.sleep(1000); mRecorder.start(); Toast.makeText(CameraPreview.this, “Recording Started”, Toast.LENGTH_LONG); } catch (Exception e) { releaseRecorder(); Toast.makeText(CameraPreview.this, “Recording error couldn’t start”, Toast.LENGTH_LONG); }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
mCamera = mPreview.getCamera(); //get Camera Intance mRecorder = new MediaRecorder(); //step1 mCamera.unlock(); mRecorder.setCamera(mCamera); //step2 mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); mRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA); //step 3 //mRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH)); mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); mRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.DEFAULT); //step4 mRecorder.setOutputFile(getOutputFile(MEDIA_TYPE_VIDEO).toString()); //step 5 mRecorder.setPreviewDisplay(mPreview.getMyHolder().getSurface()); try { //step 6 mRecorder.prepare(); Thread.sleep(1000); mRecorder.start(); Toast.makeText(CameraPreview.this, “Recording Started”, Toast.LENGTH_LONG); } catch (Exception e) { releaseRecorder(); Toast.makeText(CameraPreview.this, “Recording error couldn’t start”, Toast.LENGTH_LONG); } |
503 total views, 2 views today
Share this On