Esempio n. 1
0
  public void record() throws Exception {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
      throw new UnsupportedOperationException("Video recording supported only on API Level 11+");
    }

    if (displayOrientation != 0 && displayOrientation != 180) {
      throw new UnsupportedOperationException("Video recording supported only in landscape");
    }

    Camera.Parameters pictureParams = camera.getParameters();

    setCameraPictureOrientation(pictureParams);
    camera.setParameters(pictureParams);

    stopPreview();
    camera.unlock();

    try {
      recorder = new MediaRecorder();
      recorder.setCamera(camera);
      getHost().configureRecorderAudio(cameraId, recorder);
      recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
      getHost().configureRecorderProfile(cameraId, recorder);
      getHost().configureRecorderOutput(cameraId, recorder);
      recorder.setOrientationHint(outputOrientation);
      previewStrategy.attach(recorder);
      recorder.prepare();
      recorder.start();
    } catch (IOException e) {
      recorder.release();
      recorder = null;
      throw e;
    }
  }
  @Override
  public boolean onTouchEvent(MotionEvent event) {
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
      if (!_isRecording) {
        _recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
        _recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
        _recorder.setVideoEncoder(MediaRecorder.VideoEncoder.DEFAULT);

        _recorder.setVideoEncodingBitRate(10000000);

        _recorder.setVideoFrameRate(5);

        _recorder.setVideoSize(100, 100);

        _recorder.setOutputFile("/sdcard/sample.3gp");
        _recorder.setPreviewDisplay(_holder.getSurface());

        try {
          _recorder.prepare();
        } catch (Exception e) {
          Log.e("test", "recorder error");
        }
        _recorder.start();
        _isRecording = true;

      } else {
        _recorder.stop();
        _recorder.reset();
        _isRecording = false;
      }
    }
    return true;
  }
Esempio n. 3
0
  public void startRecording(View view) {
    try {
      if (!Utils.isIntentAvailable(this, MediaStore.ACTION_VIDEO_CAPTURE)) {
        Toast.makeText(this, "No camera available", Toast.LENGTH_SHORT).show();
        return;
      }

      camera.unlock();
      recorder = new MediaRecorder();
      recorder.setCamera(camera);

      recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
      recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);

      recorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_480P));
      // no need to set setOutputFormat, setAudioEncoder, setVideoEncoder
      // when I set the profile instead?

      recorder.setOutputFile(Utils.getOutputMediaFilePath(Utils.MEDIA_TYPE_VIDEO));

      recorder.setPreviewDisplay(cameraPreview.getHolder().getSurface());

      recorder.prepare();
      recorder.start();

      Log.i(TAG, "Recording started");

    } catch (Exception e) {
      releaseMediaRecorder();
      Log.e(TAG, e.getMessage());
      e.printStackTrace();
    }
  }
 private boolean prepareVideoRecorder() {
   if (mCamera == null) {
     mCamera = getCameraInstance();
   }
   mMediaRecorder = new MediaRecorder();
   // Step 1: Unlock and set camera to MediaRecorder
   mCamera.unlock();
   mMediaRecorder.setCamera(mCamera);
   // Step 2: Set sources
   mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
   mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
   // Step 3: Set a CamcorderProfile (requires API Level 8 or higher)
   mMediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));
   // 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(TAG, "IllegalStateException preparing MediaRecorder: " + e.getMessage());
     releaseMediaRecorder();
     return false;
   } catch (IOException e) {
     Log.d(TAG, "IOException preparing MediaRecorder: " + e.getMessage());
     releaseMediaRecorder();
     return false;
   }
   return true;
 }
 private void startRecording() {
   if (cameraBusy) return;
   System.out.println("start - lock enabled");
   cameraBusy = true;
   mCamera.unlock();
   recorder = new MediaRecorder();
   recorder.setCamera(mCamera);
   recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
   CamcorderProfile profile = CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH);
   recorder.setOutputFormat(profile.fileFormat);
   recorder.setVideoFrameRate(profile.videoFrameRate);
   recorder.setVideoSize(profile.videoFrameWidth, profile.videoFrameHeight);
   recorder.setVideoEncodingBitRate(profile.videoBitRate);
   recorder.setVideoEncoder(profile.videoCodec);
   recorder.setOutputFile(getOutputMediaFile(MEDIA_TYPE_VIDEO).toString());
   recorder.setPreviewDisplay(mHolder.getSurface());
   try {
     recorder.prepare();
     recorder.start();
     recording = true;
     System.out.println("start - lock disabled");
   } catch (IllegalStateException e) {
     e.printStackTrace();
   } catch (IOException e) {
     e.printStackTrace();
   }
   cameraBusy = false;
 }
Esempio n. 6
0
  @TargetApi(Build.VERSION_CODES.HONEYCOMB)
  private boolean prepareVideoRecorder() {

    // BEGIN_INCLUDE (configure_preview)
    mCamera = CameraHelper.getDefaultCameraInstance();

    Camera.Parameters parameters = mCamera.getParameters();
    parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
    mCamera.setDisplayOrientation(90);
    mCamera.setParameters(parameters);

    // BEGIN_INCLUDE (configure_media_recorder)
    mMediaRecorder = new MediaRecorder();

    // Step 1: Unlock and set camera to MediaRecorder
    mCamera.unlock();

    // Camera.Parameters parameters = mCamera.getParameters();

    mMediaRecorder.setCamera(mCamera);
    CamcorderProfile profile = CamcorderProfile.get(CamcorderProfile.QUALITY_QVGA);

    // Log.d(TAG, profile.videoBitRate+"<- videoBitRate r");
    profile.videoBitRate = 1024000;

    // Step 2: Set sources
    mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);

    // Step 3: Set all values contained in profile except audio settings
    mMediaRecorder.setOutputFormat(profile.fileFormat);
    mMediaRecorder.setVideoEncoder(profile.videoCodec);
    mMediaRecorder.setVideoEncodingBitRate(profile.videoBitRate);
    mMediaRecorder.setVideoFrameRate(profile.videoFrameRate);
    mMediaRecorder.setVideoSize(profile.videoFrameWidth, profile.videoFrameHeight);
    mMediaRecorder.setOrientationHint(90);
    mMediaRecorder.setVideoFrameRate(24);

    // Step 4: Set output file
    save_to = CameraHelper.getOutputMediaFile(CameraHelper.MEDIA_TYPE_VIDEO).toString();
    mMediaRecorder.setOutputFile(save_to);

    mMediaRecorder.setPreviewDisplay(mPreview.getHolder().getSurface());

    // Step 5: Prepare configured MediaRecorder
    try {
      mMediaRecorder.prepare();
    } catch (IllegalStateException e) {
      Log.d(TAG, "IllegalStateException preparing MediaRecorder: " + e.getMessage());
      releaseMediaRecorder();
      return false;
    } catch (IOException e) {
      Log.d(TAG, "IOException preparing MediaRecorder: " + e.getMessage());
      releaseMediaRecorder();
      return false;
    }
    return true;
  }
  @SuppressLint("NewApi")
  private boolean initRecorder() {
    if (!EaseCommonUtils.isExitsSdcard()) {
      showNoSDCardDialog();
      return false;
    }

    if (mCamera == null) {
      if (!initCamera()) {
        showFailDialog();
        return false;
      }
    }
    mVideoView.setVisibility(View.VISIBLE);
    // TODO init button
    mCamera.stopPreview();
    mediaRecorder = new MediaRecorder();
    mCamera.unlock();
    mediaRecorder.setCamera(mCamera);
    mediaRecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
    // 设置录制视频源为Camera(相机)
    mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
    if (frontCamera == 1) {
      mediaRecorder.setOrientationHint(270);
    } else {
      mediaRecorder.setOrientationHint(90);
    }
    // 设置录制完成后视频的封装格式THREE_GPP为3gp.MPEG_4为mp4
    mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
    mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
    // 设置录制的视频编码h263 h264
    mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
    // 设置视频录制的分辨率。必须放在设置编码和格式的后面,否则报错
    mediaRecorder.setVideoSize(previewWidth, previewHeight);
    // 设置视频的比特率
    mediaRecorder.setVideoEncodingBitRate(384 * 1024);
    // // 设置录制的视频帧率。必须放在设置编码和格式的后面,否则报错
    if (defaultVideoFrameRate != -1) {
      mediaRecorder.setVideoFrameRate(defaultVideoFrameRate);
    }
    // 设置视频文件输出的路径
    localPath = PathUtil.getInstance().getVideoPath() + "/" + System.currentTimeMillis() + ".mp4";
    mediaRecorder.setOutputFile(localPath);
    mediaRecorder.setMaxDuration(30000);
    mediaRecorder.setPreviewDisplay(mSurfaceHolder.getSurface());
    try {
      mediaRecorder.prepare();
    } catch (IllegalStateException e) {
      e.printStackTrace();
      return false;
    } catch (IOException e) {
      e.printStackTrace();
      return false;
    }
    return true;
  }
  private void initRecorder() {
    recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
    recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);

    CamcorderProfile cpHigh = CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH);
    recorder.setProfile(cpHigh);
    recorder.setOutputFile("/sdcard/videocapture_example.mp4");
    recorder.setMaxDuration(50000); // 50 seconds
    recorder.setMaxFileSize(5000000); // Approximately 5 megabytes
  }
Esempio n. 9
0
  private void configureMediaRecorder() {
    mediaRecorder.setCamera(camera);
    mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);

    mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);

    mediaRecorder.setVideoSize(1280, 720);
    mediaRecorder.setVideoEncodingBitRate(17000000);
    mediaRecorder.setVideoFrameRate(30);

    mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H263);
  }
Esempio n. 10
0
  private boolean prepareMediaRecorder() {
    myCamera = getCameraInstance(switchCam);
    Camera.Parameters parameters = myCamera.getParameters();
    parameters.setFlashMode(getFlashModeSetting());
    if (getResources().getConfiguration().orientation != Configuration.ORIENTATION_LANDSCAPE) {
      myCamera.setDisplayOrientation(90);
    } else {
      myCamera.setDisplayOrientation(0);
    }

    myCamera.setParameters(parameters);
    myCamera.unlock();

    mediaRecorder = new MediaRecorder();
    mediaRecorder.setCamera(myCamera);
    mediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
    mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);

    if (switchCam == 1) {
      mediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_LOW));
      mediaRecorder.setVideoFrameRate(15);
    } else {
      mediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));
      mediaRecorder.setVideoFrameRate(30);
    }

    if (switchCam == 0) {
      if (getResources().getConfiguration().orientation != Configuration.ORIENTATION_LANDSCAPE) {
        mediaRecorder.setOrientationHint(90);
      } else {
        mediaRecorder.setOrientationHint(0);
      }
    } else {
      mediaRecorder.setOrientationHint(270);
    }

    mediaRecorder.setOutputFile("/sdcard/" + customVideoPath + ".mp4");
    mediaRecorder.setMaxDuration(240000); // Set max duration 4 mins.
    mediaRecorder.setMaxFileSize(8000000); // Set max file size 8M
    mediaRecorder.setPreviewDisplay(myCameraSurfaceView.getHolder().getSurface());

    try {
      mediaRecorder.prepare();
    } catch (IllegalStateException e) {
      releaseMediaRecorder();
      return false;
    } catch (IOException e) {
      releaseMediaRecorder();
      return false;
    }
    return true;
  }
Esempio n. 11
0
  private boolean prepareVideoRecorder() {
    mMediaRecorder = new MediaRecorder();

    // Step 1: Unlock and set camera to MediaRecorder
    camera.unlock();
    mMediaRecorder.setCamera(camera);

    // Step 2: Set sources
    mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
    mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);

    // Step 3: Set a CamcorderProfile (requires API Level 8 or higher)
    // mMediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));

    // Step 3: Set output format and encoding (for versions prior to API Level 8)
    mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
    mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
    mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H263);

    // Step 4: Set output file
    mMediaRecorder.setOutputFile(ls.getFileDescriptor());

    // Step 5: Set the preview output
    // mMediaRecorder.setPreviewDisplay(mPreview.getHolder().getSurface());
    mMediaRecorder.setPreviewDisplay(holder.getSurface());

    Log.i(TAG, "Surface valid: " + holder.getSurface().isValid());

    /*mMediaRecorder.setVideoSize(176, 144);
    mMediaRecorder.setVideoFrameRate(20);
    mMediaRecorder.setAudioChannels(1);
    */

    // Step 6: Prepare configured MediaRecorder
    try {
      mMediaRecorder.prepare();
    } catch (Exception e) {
      Log.d(TAG, "Exception preparing MediaRecorder: " + e.getMessage());
      releaseMediaRecorder();
      return false;
    }
    return true;
  }
  @Override
  public void recordVideo(CameraSession session, VideoTransaction xact) throws Exception {
    Descriptor descriptor = (Descriptor) session.getDescriptor();
    Camera camera = descriptor.getCamera();

    if (camera != null) {
      camera.stopPreview();
      camera.unlock();

      try {
        recorder = new MediaRecorder();
        recorder.setCamera(camera);
        recorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
        recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);

        int cameraId = descriptor.getCameraId();
        boolean canGoHigh = CamcorderProfile.hasProfile(cameraId, CamcorderProfile.QUALITY_HIGH);
        boolean canGoLow = CamcorderProfile.hasProfile(cameraId, CamcorderProfile.QUALITY_LOW);

        if (canGoHigh && (xact.getQuality() == 1 || !canGoLow)) {
          recorder.setProfile(CamcorderProfile.get(cameraId, CamcorderProfile.QUALITY_HIGH));
        } else if (canGoLow) {
          recorder.setProfile(CamcorderProfile.get(cameraId, CamcorderProfile.QUALITY_LOW));
        } else {
          throw new IllegalStateException("cannot find valid CamcorderProfile");
        }

        recorder.setOutputFile(xact.getOutputPath().getAbsolutePath());
        recorder.setMaxFileSize(xact.getSizeLimit());
        recorder.setMaxDuration(xact.getDurationLimit());
        recorder.setOnInfoListener(this);
        // recorder.setOrientationHint(...);
        recorder.prepare();
        recorder.start();
        this.xact = xact;
      } catch (IOException e) {
        recorder.release();
        recorder = null;
        throw e;
      }
    }
  }
Esempio n. 13
0
  @TargetApi(Build.VERSION_CODES.HONEYCOMB)
  private boolean prepareVideoRecorder() {
    mCamera = tbs.beamr.android.sid.CamHelper.getDefaultCameraInstance();
    final Camera.Parameters parameters = mCamera.getParameters();
    List<Camera.Size> sizes = parameters.getSupportedPreviewSizes();
    if (sizes == null || sizes.size() < 1) {
      sizes = parameters.getSupportedVideoSizes();
    }

    Log.e("supported sizes > ", getSizeString(sizes));
    final Camera.Size size = getCameraSize(sizes);

    switch (hasAutoFocus(parameters)) {
      case 0:
        break;
      case 1:
        parameters.set("cam_mode", 1);
        parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
        break;
      case 2:
        parameters.set("cam_mode", 1);
        parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
        break;
    }

    mCamera.setParameters(parameters);
    try {
      mCamera.setPreviewDisplay(mPreview.getHolder());
    } catch (IOException e) {
      Log.e(TAG, "Surface View is unavailable or unsuitable" + e.getMessage());
      return false;
    }
    mMediaRecorder = new MediaRecorder();

    // Step 1: Unlock and set camera to MediaRecorder
    mCamera.setDisplayOrientation(90);
    mCamera.unlock();
    mMediaRecorder.setCamera(mCamera);

    // Step 2: Set sources
    mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
    mMediaRecorder.setOrientationHint(90);

    mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
    final CamcorderProfile profile =
        CamcorderProfile.get(
            CamcorderProfile.hasProfile(CamcorderProfile.QUALITY_480P)
                ? CamcorderProfile.QUALITY_480P
                : CamcorderProfile.QUALITY_HIGH);
    //        profile.videoFrameRate = 25;
    //            profile.videoBitRate = 7200000;
    mMediaRecorder.setProfile(profile);
    //        if (size == null) {
    //            mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
    //            final CamcorderProfile profile =
    // CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH);
    ////            profile.videoFrameRate = 30;
    ////            profile.videoBitRate = 7200000;
    //            mMediaRecorder.setProfile(profile);
    //        } else {
    //            // Step 3: Set a CamcorderProfile (requires API Level 8 or higher)
    //            if (CamcorderProfile.hasProfile(CamcorderProfile.QUALITY_720P)) {
    //                final CamcorderProfile profile =
    // CamcorderProfile.get(CamcorderProfile.QUALITY_720P);
    //                Log.e("recordingSize > ", String.valueOf(profile.videoFrameWidth) + "x" +
    // String.valueOf(profile.videoFrameHeight));
    //                mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
    //                mMediaRecorder.setProfile(profile);
    //            } else {
    //                mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
    //                mMediaRecorder.setVideoEncodingBitRate(8200000);
    //                mMediaRecorder.setVideoSize(size.width, size.height);
    ////            mMediaRecorder.setVideoFrameRate(20);
    //                mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.DEFAULT);
    //            }
    //        }

    // Step 4: Set output file
    // Todo
    //        final String name = Environment.getExternalStorageDirectory().getAbsolutePath() +
    // "/tbs_beamR/received_file_" + (new Date(System.currentTimeMillis())).toString() + ".mp4";
    final String name =
        Environment.getExternalStorageDirectory().getAbsolutePath() + "/test/test.mp4";
    final File file = new File(name);
    if (!file.exists()) {
      try {
        file.getParentFile().mkdirs();
        //                file.createNewFile();
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
    mMediaRecorder.setOutputFile(name);

    // Step 5: Prepare configured MediaRecorder
    try {
      mMediaRecorder.prepare();
    } catch (IllegalStateException e) {
      Log.e(TAG, "IllegalStateException preparing MediaRecorder: " + e.getMessage());
      releaseMediaRecorder();
      return false;
    } catch (IOException e) {
      Log.e(TAG, "IOException preparing MediaRecorder: " + e.getMessage());
      releaseMediaRecorder();
      return false;
    }
    return true;
  }
Esempio n. 14
0
  private boolean startRecording() {
    prCamera.stopPreview();
    try {
      prCamera.unlock();
      prMediaRecorder.setCamera(prCamera);
      // set audio source as Microphone, video source as camera
      // state: Initial=>Initialized
      // prMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
      prMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
      // set the file output format: 3gp or mp4
      // state: Initialized=>DataSourceConfigured

      String lDisplayMsg = "Current container format: ";

      if (Utils.puContainerFormat == SettingsDialog.cpu3GP) {
        lDisplayMsg += "3GP\n";
        videoFormat = ".3gp";
        prMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
      } else if (Utils.puContainerFormat == SettingsDialog.cpuMP4) {
        lDisplayMsg += "MP4\n";
        videoFormat = ".mp4";
        prMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
      } else {
        lDisplayMsg += "3GP\n";
        videoFormat = ".3gp";
        prMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
      }

      lDisplayMsg += "Current encoding format: ";
      if (Utils.puEncodingFormat == SettingsDialog.cpuH263) {
        lDisplayMsg += "H263\n";
        prMediaRecorder.setVideoEncoder(VideoEncoder.H263);
      } else if (Utils.puEncodingFormat == SettingsDialog.cpuMP4_SP) {
        lDisplayMsg += "MPEG4-SP\n";
        prMediaRecorder.setVideoEncoder(VideoEncoder.MPEG_4_SP);
      } else if (Utils.puEncodingFormat == SettingsDialog.cpuH264) {
        lDisplayMsg += "H264\n";
        prMediaRecorder.setVideoEncoder(VideoEncoder.H264);
      } else {
        lDisplayMsg += "H263\n";
        prMediaRecorder.setVideoEncoder(VideoEncoder.H263);
      }
      videoFileFullPath =
          myVideoFilePath + String.valueOf(System.currentTimeMillis()) + videoFormat;
      prRecordedFile = new File(videoFileFullPath);
      prMediaRecorder.setOutputFile(prRecordedFile.getPath());
      if (Utils.puResolutionChoice == SettingsDialog.cpuRes176) {
        prMediaRecorder.setVideoSize(176, 144);
      } else if (Utils.puResolutionChoice == SettingsDialog.cpuRes320) {
        prMediaRecorder.setVideoSize(320, 240);
      } else if (Utils.puResolutionChoice == SettingsDialog.cpuRes720) {
        prMediaRecorder.setVideoSize(720, 480);
      }
      Toast.makeText(prContext, lDisplayMsg, Toast.LENGTH_LONG).show();
      prMediaRecorder.setVideoFrameRate(cFrameRate);
      prMediaRecorder.setPreviewDisplay(prSurfaceHolder.getSurface());
      prMediaRecorder.setMaxFileSize(cMaxFileSizeInBytes);
      // prepare for capturing
      // state: DataSourceConfigured => prepared
      prMediaRecorder.prepare();
      // start recording
      // state: prepared => recording
      prMediaRecorder.start();
      btnStartRecorder.setText("Stop");
      prRecordInProcess = true;
      return true;
    } catch (IOException _le) {
      _le.printStackTrace();
      return false;
    }
  }
  public void onBtnClick(View view) {
    try {
      switch (view.getId()) {
        case R.id.btnRec:
          if (mRecorder != null) {
            mRecorder.stop();
            mRecorder.release();
            mRecorder = null;
          }

          mRecorder = new MediaRecorder();
          mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
          // 비디오 추가
          mRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
          mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); // 옵션을 바꾸면 화질을 개선할 수 있다.
          mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
          mRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.DEFAULT);

          // 저장장소를 추가해준다.
          // 내부저장: /data/data/com.example.user.helloworld/files/videoRec.mp4
          FileOutputStream outStream = openFileOutput(REC_FILE, MODE_PRIVATE);
          mRecorder.setOutputFile(outStream.getFD());

          // 미리보기 부분 추가
          mRecorder.setPreviewDisplay(mHolder.getSurface());

          mRecorder.prepare();
          mRecorder.start();

          break;
        case R.id.btnRecStop:
          if (mRecorder == null) return;

          mRecorder.stop();
          mRecorder.release();
          mRecorder = null;

          // 앨범에 등록하는 부분
          // ContentValues => 안드로이드 갤러리

          break;
        case R.id.btnPlay:
          if (mPlayer != null) {
            mPlayer.stop();
            mPlayer.release();
            mPlayer = null;
          }

          mPlayer = new MediaPlayer();

          // 내부 저장된 파일을 읽어 온다.
          // 내부저장: /data/data/com.example.user.helloworld/files/videoRec.mp4
          FileInputStream inStream = openFileInput(REC_FILE);
          mPlayer.setDataSource(inStream.getFD());
          // 서피스뷰에 재생을 시킨다.
          mPlayer.setDisplay(mHolder);
          mPlayer.prepare();
          mPlayer.start();

          break;
        case R.id.btnStop:
          break;
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
 private boolean startRecording() {
   prCamera.stopPreview();
   try {
     prCamera.unlock();
     prMediaRecorder.setCamera(prCamera);
     // set audio source as Microphone, video source as camera
     // state: Initial=>Initialized
     prMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
     prMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
     // set the file output format: 3gp or mp4
     // state: Initialized=>DataSourceConfigured
     String lDisplayMsg = "Current container format: ";
     int lContainerFormat = SettingsStatic.getContainerFormat(this.getApplicationContext());
     if (lContainerFormat == SettingsDialog.cpu3GP) {
       lDisplayMsg += "3GP\n";
       mVideoFileFullPath = ".3gp";
       prMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
     } else if (lContainerFormat == SettingsDialog.cpuMP4) {
       lDisplayMsg += "MP4\n";
       mVideoFileFullPath = ".mp4";
       prMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
     } else {
       lDisplayMsg += "3GP\n";
       mVideoFileFullPath = ".3gp";
       prMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
     }
     // the encoders:
     // audio: AMR-NB
     // prMediaRecorder.setAudioEncoder(AudioEncoder.AMR_NB);
     prMediaRecorder.setAudioEncoder(AudioEncoder.AAC);
     // video: H.263, MP4-SP, or H.264
     // prMediaRecorder.setVideoEncoder(VideoEncoder.H263);
     // prMediaRecorder.setVideoEncoder(VideoEncoder.MPEG_4_SP);
     lDisplayMsg += "Current encoding format: ";
     int lEncodingFormat = SettingsStatic.getEncodingFormat(getApplicationContext());
     if (lEncodingFormat == SettingsDialog.cpuH263) {
       lDisplayMsg += "H263\n";
       prMediaRecorder.setVideoEncoder(VideoEncoder.H263);
     } else if (lEncodingFormat == SettingsDialog.cpuMP4_SP) {
       lDisplayMsg += "MPEG4-SP\n";
       prMediaRecorder.setVideoEncoder(VideoEncoder.MPEG_4_SP);
     } else if (lEncodingFormat == SettingsDialog.cpuH264) {
       lDisplayMsg += "H264\n";
       prMediaRecorder.setVideoEncoder(VideoEncoder.H264);
     } else {
       lDisplayMsg += "H263\n";
       prMediaRecorder.setVideoEncoder(VideoEncoder.H263);
     }
     mVideoFileFullPath =
         FileUtilsStatic.DEFAULT_DIR
             + DateTimeUtilsStatic.get_current_date_time_format1_str()
             + mVideoFileFullPath;
     prRecordedFile = new File(mVideoFileFullPath);
     prMediaRecorder.setOutputFile(prRecordedFile.getPath());
     int lRes = SettingsStatic.getResolutionChoice(this.getApplicationContext());
     if (lRes == SettingsDialog.cpuRes176) {
       prMediaRecorder.setVideoSize(176, 144);
     } else if (lRes == SettingsDialog.cpuRes320) {
       prMediaRecorder.setVideoSize(320, 240);
     } else if (lRes == SettingsDialog.cpuRes720) {
       prMediaRecorder.setVideoSize(720, 480);
     }
     lDisplayMsg += "Video recording to file: " + mVideoFileFullPath;
     Toast.makeText(prContext, lDisplayMsg, Toast.LENGTH_LONG).show();
     prMediaRecorder.setVideoFrameRate(cFrameRate);
     prMediaRecorder.setPreviewDisplay(prSurfaceHolder.getSurface());
     prMediaRecorder.setMaxDuration(cMaxRecordDurationInMs);
     prMediaRecorder.setMaxFileSize(cMaxFileSizeInBytes);
     // prepare for capturing
     // state: DataSourceConfigured => prepared
     prMediaRecorder.prepare();
     // start recording
     // state: prepared => recording
     prMediaRecorder.start();
     prStartBtn.setText("Stop");
     prRecordInProcess = true;
     return true;
   } catch (IOException _le) {
     _le.printStackTrace();
     return false;
   }
 }