0

Right now I'm showing a preview that occupies only half of the screen using camera(v1) in a TextureView. I apply some matrix transformations to this preview to make it larger and seem cropped. Now I'm trying to record a video of exactly what the user sees in this preview, but all I manage is to get a normal video from the camera, without my transformations.

Here is how I'm recording the video.

private void initRecorder() throws IOException {
    File file = (new DirectoryManager(mContext).getNewVideoFile());

    if( mMediaRecorder == null ) {
        mMediaRecorder = new MediaRecorder();
        mCamera = getCurrentCamera();
        mCamera.unlock();
        //Surface surface = new Surface(surfaceTexture);
        mMediaRecorder.setCamera(mCamera);
        mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
        mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
        //mMediaRecorder.setPreviewDisplay(surface);
        mMediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));
        mMediaRecorder.setOutputFile(file.getPath());
    }
    if(!mStartRecording) {
        try {
            mMediaRecorder.prepare();
            mMediaRecorder.start();
            mStartRecording = true;
        }  catch (IOException e) {
            e.printStackTrace();
        }
    } else {
        mStartRecording = false;
        try {
            mMediaRecorder.stop();
            mMediaRecorder.reset();
            mMediaRecorder.release();
        }
        catch (Exception e){
            e.printStackTrace();
        }
        mMediaRecorder = null;
    }

}

Also I try to use MediaRecorder.VideoSource.SURFACE instead with the same luck.

Any help/hint would be appreciated.

Jose Gonzalez
  • 1,491
  • 3
  • 25
  • 51
  • Are you trying to record the screen? Like a screen capture video? – Opiatefuchs Apr 05 '16 at 13:26
  • No, my preview occupies only half of the screen (I'll add that also as an edit) I wan't to record just that. – Jose Gonzalez Apr 05 '16 at 13:27
  • 1
    recording the screen (or a part of it) will be difficult. Since Lollipop, there is a MediaProjection API, I´ve never used it but maybe this could help: http://stackoverflow.com/questions/14336338/screen-video-record-of-current-activity-android – Opiatefuchs Apr 05 '16 at 13:31

0 Answers0