How to use android camera2 api to record 60 fps video with fixed exposure time
60fps recording on Pixel can be done in normal capture settings - take a look at CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES, and just create a normal capture session. You will have to be careful and not set up too high of a resolution as your outputs, since 60fps can't be done at above 1080p, if I remember correctly.
You can confirm that via the StreamConfigurationMap for the sizes/formats that you're aiming to use.
Jian
Updated on June 04, 2022Comments
-
Jian almost 2 years
I want to implement a app to record 60 fps with fixed exposure time. As device I have the Google Pixel. Since its native camera app can do 60 fps and it has hardware level LEVEL_3, I thought this won't be a problem but I can't get it working. With
getSupportedPreviewFpsRange()
(from camera api) I get ranges[15, 15], [24, 24], [7, 30], [30, 30]
and withgetHighSpeedVideoFpsRangesFor
(from camera2 api) I get ranges[30, 120], [120, 120], [30, 240], [240, 240], [240, 240]
. When I set[60, 60]
toCONTROL_AE_TARGET_FPS_RANGE
I get error "Fps range [60, 60] in the request is not a supported high speed fps range".Is it even possible for a custom app to record 60 fps video?
If not, how is it by 120 fps? (I have got 120 fps recording working, but when I set
CONTROL_AE_MODE
off and manually set theSENSOR_EXPOSURE_TIME
andSENSOR_SENSITIVITY
, the frame rate again reduces to 30 fps) -
Jian about 7 yearsthx Eddy, I have successfully achieve 60 fps by video recording and even by YUV capturing (with resolution 1920x1080). That's was a surprise with YUV, because I've checked the minal frame duration for YUV_420_88 both for biggest size (4048x3036) and smallest size (160x120) and they were 33333333 ns. But for size (1920x1080) it's indeed 16666666 ns. But when I set the exposure time and ios value manually with
CONTROL_AE_MODE
andCONTROL_MODE
set to off, the frame rate drops again to 30 fps: Have I done something wrong? Or works 60fps only with auto exposure? -
Eddy Talvala about 7 yearsDid you set the frame duration (developer.android.com/reference/android/hardware/camera2/… )? That's the third manual control; you need to set that to 60fps on your own. The default is likely 1/30s, not 1/60s.
-
Jian about 7 yearsyes I've set the
SENSOR_FRAME_DURATION
to 16666666, which is the exactly value I got from `getOutputMinFrameDuration(ImageFormat.YUV_420_888, new Size (1920, 1080))'. I did the steps that you've described here stackoverflow.com/questions/28293078/how-to-control-iso-manually-in-camera2-android both for preview session and capture session, they both dropped to 30 fps. -
Jian about 7 yearsAlso in the onCaptureCompleted Callback I printed out the Metainfo of CaptureRequest and TotalCaptureResult, I got the following:
request exposure time = 10000000 request iso = 120 reqeust frame duration = 16666668 result exposure time = 9996276 result iso = 120 result frame duration = 33329874
When I set the frame duration longer than 33333333 (1/30fps), e.g. 40000000, it works. But it doesn't work for duration shorter than 1/30. Am I doing something wrong? -
Eddy Talvala almost 7 yearsThat unfortunately sounds like a device bug. If this is on Pixel, you could open a bug at issuetracker.google.com/issues/…
-
You'reAGitForNotUsingGit about 4 years@EddyTalvala Well here we are 3 years later and I'm running into this exact same issue on my Pixel XL. I can get 60FPS working with auto mode, but in manual mode it just doesn't go higher than 30. I can adjust the frame duration to get lower than 30FPS, (e.g. 24), but it refuses to go any higher than 30. Any ideas, now that 3 years has elapsed? Do you still think it's a bug?
-
user924 about 2 years@EddyTalvala how can we check if a specific fps range is supported for a specific resolution?
-
Eddy Talvala about 2 yearsYou can see if that specific resolution/output destination lists a developer.android.com/reference/android/hardware/camera2/params/… that's less than or equal to 1/max fps for the range you care about. So if getOutputMinFrameDuration returns 33ms, then all ranges that have a max FPS <= 30 should work. There's no need to check the min FPS, since it's easy to run slower so that's not a limit.