Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I fixed this problem. </p> <p>Following is the my working code.</p> <pre><code> private boolean prepareVideoRecorder() { if(mMediaRecorder == null){ mMediaRecorder = new MediaRecorder(); }else{ Log.d(Constants.TAG,"MediaRecoder is Not Null"); } // Step 1: Unlock and set camera to MediaRecorder mCamera.stopPreview(); mCamera.unlock(); mMediaRecorder.setCamera(mCamera); // Step 2: Set sources mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER); mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA); // Step 3: Set output format and encoding (for versions prior to API Level 8) CamcorderProfile camcorderProfile = CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH); camcorderProfile.videoFrameWidth = 640; camcorderProfile.videoFrameHeight = 480; // camcorderProfile.videoFrameRate = 15; camcorderProfile.videoCodec = MediaRecorder.VideoEncoder.H264; // camcorderProfile.audioCodec = MediaRecorder.AudioEncoder.AAC; camcorderProfile.fileFormat = MediaRecorder.OutputFormat.MPEG_4; mMediaRecorder.setProfile(camcorderProfile); // Step 4: Set output file mMediaRecorder.setOutputFile(getOutputMediaFile(MEDIA_TYPE_VIDEO).toString()); // Step 5: Set the preview output mMediaRecorder.setPreviewDisplay(mPreview.getHolder().getSurface()); // Step 6: Prepare configured MediaRecorder try { mMediaRecorder.prepare(); } catch (IllegalStateException e) { Log.d("DEBUG", "IllegalStateException preparing MediaRecorder: " + e.getMessage()); releaseMediaRecorder(); return false; } catch (IOException e) { Log.d("DEBUG", "IOException preparing MediaRecorder: " + e.getMessage()); releaseMediaRecorder(); return false; } return true; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload