rweiser
rweiser

Reputation: 329

MediaRecorder.setVideoFrameRate() not having any effect

I'm trying to get my Android app to record video with a lower frame rate (to reduce file size).

Here's my MediaRecorder configuration code:

m_mediaRecorder = new MediaRecorder();
m_mediaRecorder.setCamera(mCamera);
m_mediaRecorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);

CamcorderProfile profile = CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH);
m_mediaRecorder.setOutputFormat(profile.fileFormat);
m_mediaRecorder.setVideoEncodingBitRate(profile.videoBitRate);
m_mediaRecorder.setVideoEncoder(profile.videoCodec);
m_mediaRecorder.setVideoSize(640, 480);
m_mediaRecorder.setVideoFrameRate(10);

m_mediaRecorder.setOrientationHint((int) orientationListener.getPreviewRotation(null));
m_mediaRecorder.setOutputFile(videoDirectory + "/" + uuid + ".mp4");

try {
    m_mediaRecorder.prepare();
    m_mediaRecorder.start();
} catch (Exception e) {
    e.printStackTrace();
}

The video does record successfully, but no matter what I try, the frame rate seems to be fixed at 30 fps. m_mediaRecorder.setVideoFrameRate(10); has no effect. (If I set the videoBitRate to a lower value, this reduces the file size but also reduces the quality of each individual frame - something we do not want to do.)

(For the record - Android 6.0.1; SDK Version 21.)

What am I missing?

Thanks, Reuven

Upvotes: 4

Views: 2684

Answers (2)

    mediaRecorder.setCaptureRate(20);
    mediaRecorder.setVideoFrameRate(20);

I am successfull with this, please try it. Thanks!

Upvotes: 3

Alexey Doilnitsyn
Alexey Doilnitsyn

Reputation: 142

May be it makes sense to limit frame rate on Camera as well?

Anyway, do not expect significant gain from lowering frame rate, because the higher interval between frames, the more bits are required to encode the same picture.

Much more bitrate saving can be achieved by reducing picture resolution.

Upvotes: 0

Related Questions