Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to record the original video? #437

Closed
stonyz opened this issue Dec 3, 2018 · 2 comments
Closed

How to record the original video? #437

stonyz opened this issue Dec 3, 2018 · 2 comments

Comments

@stonyz
Copy link

stonyz commented Dec 3, 2018

I use GPUImage to preview. and want to record the original video from camera.

The problem is, once I start recording, the preview will stop.

Preview in GPUImage,
mGPUImage.setUpCamera(camera, orientation, flipHorizontal, false);

it works fine.

Once I start recording, the preview will stop and can't recover even I stoped recording. and has no any exception. and I noticed that GPUImageRenderer.onPreviewFrame isn't called when preview stopped.

private void startRecordVideo(String videoFile) {
		if (true) {
//			return;
		}
		if (camera == null) {
			Log.e(TAG, "startRecordVideo, camera is not open. file: " + videoFile );
			return;
		}
		if (mRecorder == null) {
			mRecorder = new MediaRecorder();
		}
		try {
			mRecorder.reset();

			camera.unlock();
			mRecorder.setCamera(camera);

	
			mRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
			mRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);

			// Set output file format
			mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);

			
			mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
			mRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);

			mRecorder.setVideoSize(640, 480);
			mRecorder.setVideoFrameRate(30);
			mRecorder.setVideoEncodingBitRate(Double.valueOf(1.8 * 1024 * 1024).intValue());
			mRecorder.setOrientationHint(90);
		
			mRecorder.setMaxDuration(30 * 1000);
//			mRecorder.setPreviewDisplay(cameraSurfaceView);
			Log.d(TAG, "record: path " + videoFile);

			mRecorder.setOutputFile(videoFile);
			mRecorder.prepare();
			mRecorder.start();

		} catch (Exception e) {
			e.printStackTrace();
		}
	}
@stonyz
Copy link
Author

stonyz commented Jan 21, 2019

Fixed it, by switching camera2.

@stonyz stonyz closed this as completed Jan 21, 2019
@nikunjparadva
Copy link

Hello @stonyz Can you enter the code of camera2 Integration.. It ll be more helpful to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants