Java – How to reduce video size while recording, Android?

How to reduce video size while recording, Android?… here is a solution to the problem.

How to reduce video size while recording, Android?

FFMPEG, MediaCodec, and MP4parser codecs take time to compress, so is there any other way to reduce the size of the video recording at the same time?

I’m using MediaRecorder for recording video, But it generates a lot of data and I want to reduce it because I can’t upload it.

Solution

I got the answer by using a media recording document and added these lines in the code:

mediaRecorder.setVideoEncodingBitRate(1000000);
mediaRecorder.setVideoSize(1280, 720);
mediaRecorder.setOutputFile(folder.getAbsolutePath()+"/"+mediaFileName+".mp4");
mediaRecorder.setPreviewDisplay(surfaceHolder.getSurface());
mediaRecorder.setVideoFrameRate(18);
mediaRecorder.setOrientationHint(mOrientation);

After this, I got a good quality video with a smaller size.

Related Problems and Solutions