I'm developing my camera app for my LG G4 and I can't find a way to record at a constant framerate. I took the google sample Camera2 app to add my features.
When I want to record in UHD :
mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.SURFACE);
mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
if (mNextVideoAbsolutePath == null || mNextVideoAbsolutePath.isEmpty()) {
mNextVideoAbsolutePath = getVideoFilePath(getActivity());
}
mMediaRecorder.setOutputFile(mNextVideoAbsolutePath);
mMediaRecorder.setVideoEncodingBitRate(35 * 1000 * 1000);
mMediaRecorder.setVideoSize(3840, 2160);
mMediaRecorder.setVideoFrameRate(30);
mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
The framerate of 3 differents output videos is 27.61, 28.39, 26.24 etc .. I can't get a constant framterate at 29.97 of 30fps. I tried to increase bitrate to 50Mbps, decrease it to 30Mbps but it doesn't change anything.
The weirdest part is that I can't even record above 30fps in 1080p :
mMediaRecorder.setVideoSize(1920, 1080);
mMediaRecorder.setVideoFrameRate(60);
It records a FHD footage at 29.69 last time I tried but it is as random as UHD footage. What am I doing wrong ?
I've checked Recording 60fps video with Camera2(on Android version 21) API out but it doesn't work either. I also found some answers but they were using the old camera API (with Camera.Parameters) which is deprecated now.
Is there another parameter ?