Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android MediaRecorder API keeps cropping the video bitrate

I'm working with the MediaRecorder API for a while, I thought all problems are behind me but I guess I was wrong.

I'm using the MediaRecorder API for recording video to a file. When I use the setProfile with high quality I get good quality but when I try to set the parameters manually (as in the code below) the quality is bad (since for some reason the bitrate is cropped). I want to get 720p with 1fps.

I keep getting the following warning: WARN/AuthorDriver(268): Video encoding bit rate is set to 480000 bps

The code I'm running:

m_MediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
m_MediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
m_MediaRecorder.setVideoSize(1280, 720);
m_MediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
m_MediaRecorder.setVideoFrameRate(1);
m_MediaRecorder.setVideoEncodingBitRate(8000000);

Any idea? Thanks a lot.

like image 763
Lior Ohana Avatar asked Jul 17 '11 16:07

Lior Ohana


1 Answers

Found the solution...very weird however. Setting the bit-rate before setting the compression type somehow solved the problem. The only question is whether it is a bug in google's code or something else that I don't understand.

Original:

m_MediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
m_MediaRecorder.setVideoFrameRate(1);
m_MediaRecorder.setVideoEncodingBitRate(8000000);

Solution:

m_MediaRecorder.setVideoEncodingBitRate(8000000);
m_MediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
m_MediaRecorder.setVideoFrameRate(1);
like image 109
Lior Ohana Avatar answered Sep 18 '22 12:09

Lior Ohana