Video recording framerate#

Camera 1#

Sample code to monitor video recording framerate:

/** Reference on MainCamera peripheral. */
private var cameraRef: Ref<MainCamera>? = null

/** Monitors and prints video recording framerate. */
fun monitorVideoFramerate(drone: Drone) {
    cameraRef = drone.getPeripheral(MainCamera::class.java) { camera ->
        // called on main thread when the camera peripheral changes
        camera?.recording()?.run {
            if (supportedFramerates().isEmpty()) {
                // setting value is not relevant if there is no supported value
                println("No supported value")
            } else {
                // get setting value
                val framerate = framerate()
                println("Current value: $framerate")
                // updating flag
                println("Updating: $isUpdating")
            }
        }
    }
}

Example of output when video recording framerate is 240 fps:

Current value: FPS_240
Updating: false

Sample code to modify video recording framerate:

/** Sets photo video recording framerate. */
fun setVideoFramerate(drone: Drone, framerate: CameraRecording.Framerate) {
    drone.getPeripheral(MainCamera::class.java)?.run {
        // set setting value
        recording().setFramerate(framerate)
    }
}

Trying to change the setting value to an unsupported value has no effect. Values supported by the camera are provided by CameraRecording.Setting.supportedFramerates().

Camera 2#

Video recording framerate is configured with parameter Camera.Config.VIDEO_RECORDING_FRAMERATE.

Sample code to monitor video recording framerate:

/** Reference on MainCamera peripheral. */
private var cameraRef: Ref<MainCamera>? = null

/** Monitors and prints video recording framerate. */
fun monitorVideoFramerate(drone: Drone) {
    cameraRef = drone.getPeripheral(MainCamera::class.java) { camera ->
        // called on main thread when the camera peripheral changes
        camera?.run {
            // get configuration parameter
            config[Camera.Config.VIDEO_RECORDING_FRAMERATE].run {
                if (supportedValues(onlyCurrent = true).isEmpty()) {
                    // parameter value is not relevant
                    // if there is not supported values in current configuration
                    println("No supported value in current configuration")
                } else {
                    println("Current value: $value")
                }
            }
        }
    }
}

Example of output when video recording framerate is 240 fps:

Current value is: FPS_240

Sample code to modify video recording framerate:

/** Sets video recording framerate. */
fun setVideoFramerate(drone: Drone, framerate: Camera.VideoFramerate) {
    drone.getPeripheral(MainCamera::class.java)?.run {
        // create configuration editor, starting from current configuration
        val editor = config.edit(fromScratch = false)
        // get configuration parameter
        editor[Camera.Config.VIDEO_RECORDING_FRAMERATE].let { configParam ->
            // change parameter value,
            // and unset other parameters conflicting with this new value
            configParam.value = framerate
            // complete configuration, by setting missing parameters values
            editor.autoComplete()
            // send new configuration to drone
            editor.commit()
        }
    }
}

Trying to change the parameter value to an unsupported value has no effect. Values supported by the camera are retrieved by calling configParam.supportedValues(onlyCurrent = false).