Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Getting VideoCapture actual frame rate

47 views
Skip to first unread message
Assigned to wenhu...@google.com by me

Anton Ivanov

unread,
Dec 4, 2024, 12:08:16 PM12/4/24
to Android CameraX Discussion Group
Hello,
How Can I get the actual frame rate(or at least target frame rate) the CameraX VideoCapture would record the video in?
It seems that it is not in Reocording.

Wenhung Teng

unread,
Dec 24, 2024, 11:09:26 AM12/24/24
to Android CameraX Discussion Group, anton....@revolut.com

Hi there,

You're right, the Recording object doesn't currently provide the actual frame rate used for video capture.

The target frame rate you set using setTargetFrameRate() can sometimes be overridden by CameraX to ensure optimal performance and compatibility with other active use cases and the device's capabilities.

For now, the most reliable way to obtain the actual frame rate is through the Camera2Interop API. Here's how you can access the CONTROL_AE_TARGET_FPS_RANGE from the capture results:

```

   val recorderBuilder = Recorder.Builder()

   val recorder = recorderBuilder.build()

   val videoCaptureBuilder = VideoCapture.Builder(recorder)

   Camera2Interop.Extender(videoCaptureBuilder)

     .setSessionCaptureCallback(

       object : CameraCaptureSession.CaptureCallback() {

         override fun onCaptureCompleted(

           session: CameraCaptureSession,

           request: CaptureRequest,

           result: TotalCaptureResult,

         ) {

           val fpsRange = result.get(CaptureResult.CONTROL_AE_TARGET_FPS_RANGE)

           if (fpsRange != null) {

             logger.atInfo().log("fps range: %s", fpsRange)

           } else {

             logger.atInfo().log("fps range is null")

           }

         }

       }

     )

   videoCapture = videoCaptureBuilder.build()

val camera = cameraProvider.bindToLifecycle(lifecycleOwner, cameraSelector, videoCapture)

```
We appreciate your feedback and are considering adding a getter API in the future to make this information more easily accessible.


anton....@revolut.com 在 2024年12月5日 星期四凌晨1:08:16 [UTC+8] 的信中寫道:
Reply all
Reply to author
Forward
0 new messages