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.