googlearchive/android-Camera2Video

Unable to set custom FPS

Closed this issue · 1 comments

We were trying out the various suggested configurations for the setting the frame rate of videos captured using camera of Android devices (Pixel, OnePlus, Samsung S9+ and Note 9). We have used setVideoFrameRate and setCaptureRate methods as well as set the CONTROL_AE_TARGET_FPS_RANGE and SENSOR_FRAME_DURATION keys of the CaptureRequest.Builder object to match the required frame rates (tried with 15, 60 and 120). The code snippet from sample app is written below:

mMediaRecorder.setVideoEncodingBitRate((int) Math.ceil(mVideoSize.getHeight() * mVideoSize.getWidth() * FRAME_RATE * 0.07 * 2));
mMediaRecorder.setVideoFrameRate(FRAME_RATE);
mMediaRecorder.setCaptureRate(FRAME_RATE);
mPreviewBuilder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, new Range<>(FRAME_RATE, FRAME_RATE));
mPreviewBuilder.set(CaptureRequest.SENSOR_FRAME_DURATION, 1000000000L / FRAME_RATE);

The recorded video is of 30fps only despite setting the FRAME_RATE variable to 15, 60 or 120. We have tried with 720p, 1080p and 4k resolutions. On a OnePlus 6T device, the setVideoFrameRate method alone was able to produce an FPS of 120 (though it is not returned by the getHighSpeedVideoFpsRangesFor(size) API) but it did not work for 60fps. We have tried setting the CONTROL_AE_MODE key of CaptureRequest.Builder to CONTROL_AE_MODE_OFF but it has no effect on output.

This sample has been migrated to a new location (check README for more information).

As recommended by GitHub, we are closing all issues and pull requests now that this older repo will be archived.

If you still see this issue in the updated repo, please reopen the issue/PR there. Thank you!