public final class

VideoCaptureConfig.Builder

extends java.lang.Object

implements UseCaseConfig.Builder<VideoCapture, VideoCaptureConfig, VideoCaptureConfig.Builder>, ImageOutputConfig.Builder<VideoCaptureConfig.Builder>, CameraDeviceConfig.Builder<VideoCaptureConfig.Builder>, androidx.camera.core.ThreadConfig.Builder<VideoCaptureConfig.Builder>

 java.lang.Object

↳androidx.camera.core.VideoCaptureConfig.Builder

Overview

Builder for a VideoCaptureConfig.

Summary

Constructors
publicBuilder()

Creates a new Builder object.

Methods
public VideoCaptureConfigbuild()

Builds an immutable VideoCaptureConfig from the current state.

public static VideoCaptureConfig.BuilderfromConfig(VideoCaptureConfig configuration)

Generates a Builder from another Config object

public MutableConfiggetMutableConfig()

public VideoCaptureConfig.BuildersetAudioBitRate(int bitRate)

Sets the bit rate of the audio stream.

public VideoCaptureConfig.BuildersetAudioChannelCount(int channelCount)

Sets the number of audio channels.

public VideoCaptureConfig.BuildersetAudioMinBufferSize(int minBufferSize)

Sets the audio min buffer size.

public VideoCaptureConfig.BuildersetAudioRecordSource(int source)

Sets the audio source.

public VideoCaptureConfig.BuildersetAudioSampleRate(int sampleRate)

Sets the sample rate of the audio stream.

public VideoCaptureConfig.BuildersetBackgroundExecutor(java.util.concurrent.Executor executor)

Sets the default executor that will be used for background tasks.

public VideoCaptureConfig.BuildersetBitRate(int bitRate)

Sets the encoding bit rate.

public VideoCaptureConfig.BuildersetCameraIdFilter(CameraIdFilter cameraIdFilter)

Sets a CameraIdFilter that filter out the unavailable camera id.

public VideoCaptureConfig.BuildersetCaptureOptionUnpacker(CaptureConfig.OptionUnpacker optionUnpacker)

public VideoCaptureConfig.BuildersetDefaultCaptureConfig(CaptureConfig captureConfig)

public VideoCaptureConfig.BuildersetDefaultResolution(Size resolution)

Sets the default resolution of the intended target from this configuration.

public VideoCaptureConfig.BuildersetDefaultSessionConfig(SessionConfig sessionConfig)

public VideoCaptureConfig.BuildersetIFrameInterval(int interval)

Sets number of seconds between each key frame in seconds.

public VideoCaptureConfig.BuildersetLensFacing(androidx.camera.core.CameraX.LensFacing lensFacing)

Sets the primary camera to be configured based on the direction the lens is facing.

public VideoCaptureConfig.BuildersetMaxResolution(Size resolution)

public VideoCaptureConfig.BuildersetSessionOptionUnpacker(SessionConfig.OptionUnpacker optionUnpacker)

public VideoCaptureConfig.BuildersetSupportedResolutions(java.util.List<> resolutions)

public VideoCaptureConfig.BuildersetSurfaceOccupancyPriority(int priority)

public VideoCaptureConfig.BuildersetTargetAspectRatio(AspectRatio aspectRatio)

Sets the aspect ratio of the intended target for images from this configuration.

public VideoCaptureConfig.BuildersetTargetAspectRatioCustom(Rational aspectRatio)

Sets the aspect ratio of the intended target for images from this configuration.

public VideoCaptureConfig.BuildersetTargetClass(java.lang.Class<VideoCapture> targetClass)

public VideoCaptureConfig.BuildersetTargetName(java.lang.String targetName)

Sets the name of the target object being configured.

public VideoCaptureConfig.BuildersetTargetResolution(Size resolution)

Sets the resolution of the intended target from this configuration.

public VideoCaptureConfig.BuildersetTargetRotation(int rotation)

Sets the rotation of the intended target for images from this configuration.

public VideoCaptureConfig.BuildersetUseCaseEventListener(androidx.camera.core.UseCase.EventListener useCaseEventListener)

public VideoCaptureConfig.BuildersetVideoFrameRate(int videoFrameRate)

Sets the recording frames per second.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Builder()

Creates a new Builder object.

Methods

public static VideoCaptureConfig.Builder fromConfig(VideoCaptureConfig configuration)

Generates a Builder from another Config object

Parameters:

configuration: An immutable configuration to pre-populate this builder.

Returns:

The new Builder.

public MutableConfig getMutableConfig()

public VideoCaptureConfig build()

Builds an immutable VideoCaptureConfig from the current state.

Returns:

A VideoCaptureConfig populated with the current state.

public VideoCaptureConfig.Builder setVideoFrameRate(int videoFrameRate)

Sets the recording frames per second.

Parameters:

videoFrameRate: The requested interval in seconds.

Returns:

The current Builder.

public VideoCaptureConfig.Builder setBitRate(int bitRate)

Sets the encoding bit rate.

Parameters:

bitRate: The requested bit rate in bits per second.

Returns:

The current Builder.

public VideoCaptureConfig.Builder setIFrameInterval(int interval)

Sets number of seconds between each key frame in seconds.

Parameters:

interval: The requested interval in seconds.

Returns:

The current Builder.

public VideoCaptureConfig.Builder setAudioBitRate(int bitRate)

Sets the bit rate of the audio stream.

Parameters:

bitRate: The requested bit rate in bits/s.

Returns:

The current Builder.

public VideoCaptureConfig.Builder setAudioSampleRate(int sampleRate)

Sets the sample rate of the audio stream.

Parameters:

sampleRate: The requested sample rate in bits/s.

Returns:

The current Builder.

public VideoCaptureConfig.Builder setAudioChannelCount(int channelCount)

Sets the number of audio channels.

Parameters:

channelCount: The requested number of audio channels.

Returns:

The current Builder.

public VideoCaptureConfig.Builder setAudioRecordSource(int source)

Sets the audio source.

Parameters:

source: The audio source. Currently only AudioSource.MIC is supported.

Returns:

The current Builder.

public VideoCaptureConfig.Builder setAudioMinBufferSize(int minBufferSize)

Sets the audio min buffer size.

Parameters:

minBufferSize: The requested audio minimum buffer size, in bytes.

Returns:

The current Builder.

public VideoCaptureConfig.Builder setTargetClass(java.lang.Class<VideoCapture> targetClass)

public VideoCaptureConfig.Builder setTargetName(java.lang.String targetName)

Sets the name of the target object being configured.

The name should be a value that can uniquely identify an instance of the object being configured.

Parameters:

targetName: A unique string identifier for the instance of the class being configured.

Returns:

the current Builder.

public VideoCaptureConfig.Builder setLensFacing(androidx.camera.core.CameraX.LensFacing lensFacing)

Sets the primary camera to be configured based on the direction the lens is facing.

If multiple cameras exist with equivalent lens facing direction, the first ("primary") camera for that direction will be chosen.

Parameters:

lensFacing: The direction of the camera's lens.

Returns:

the current Builder.

public VideoCaptureConfig.Builder setCameraIdFilter(CameraIdFilter cameraIdFilter)

Sets a CameraIdFilter that filter out the unavailable camera id.

The camera id filter will be used to filter those cameras with lens facing specified in the config.

Parameters:

cameraIdFilter: The CameraIdFilter.

Returns:

the current Builder.

public VideoCaptureConfig.Builder setTargetAspectRatioCustom(Rational aspectRatio)

Sets the aspect ratio of the intended target for images from this configuration.

This is the ratio of the target's width to the image's height, where the numerator of the provided corresponds to the width, and the denominator corresponds to the height.

The target aspect ratio is used as a hint when determining the resulting output aspect ratio which may differ from the request, possibly due to device constraints. Application code should check the resulting output's resolution.

This method can be used to request an aspect ratio that is not from the standard set of aspect ratios defined in the AspectRatio.

This method will remove any value set by setTargetAspectRatio().

For VideoCapture the output is the output video file.

Parameters:

aspectRatio: A representing the ratio of the target's width and height.

Returns:

The current Builder.

public VideoCaptureConfig.Builder setTargetAspectRatio(AspectRatio aspectRatio)

Sets the aspect ratio of the intended target for images from this configuration.

It is not allowed to set both target aspect ratio and target resolution on the same use case.

The target aspect ratio is used as a hint when determining the resulting output aspect ratio which may differ from the request, possibly due to device constraints. Application code should check the resulting output's resolution.

Parameters:

aspectRatio: A AspectRatio representing the ratio of the target's width and height.

Returns:

The current Builder.

public VideoCaptureConfig.Builder setTargetRotation(int rotation)

Sets the rotation of the intended target for images from this configuration.

This is one of four valid values: , , , . Rotation values are relative to the "natural" rotation, .

Parameters:

rotation: The rotation of the intended target.

Returns:

The current Builder.

public VideoCaptureConfig.Builder setTargetResolution(Size resolution)

Sets the resolution of the intended target from this configuration.

The target resolution attempts to establish a minimum bound for the image resolution. The actual image resolution will be the closest available resolution in size that is not smaller than the target resolution, as determined by the Camera implementation. However, if no resolution exists that is equal to or larger than the target resolution, the nearest available resolution smaller than the target resolution will be chosen.

It is not allowed to set both target aspect ratio and target resolution on the same use case.

The target aspect ratio will also be set the same as the aspect ratio of the provided . Make sure to set the target resolution with the correct orientation.

Parameters:

resolution: The target resolution to choose from supported output sizes list.

Returns:

The current Builder.

public VideoCaptureConfig.Builder setDefaultResolution(Size resolution)

Sets the default resolution of the intended target from this configuration.

Parameters:

resolution: The default resolution to choose from supported output sizes list.

Returns:

The current Builder.

public VideoCaptureConfig.Builder setMaxResolution(Size resolution)

public VideoCaptureConfig.Builder setSupportedResolutions(java.util.List<> resolutions)

public VideoCaptureConfig.Builder setBackgroundExecutor(java.util.concurrent.Executor executor)

Sets the default executor that will be used for background tasks.

Parameters:

executor: The executor which will be used for background tasks.

Returns:

the current Builder.

public VideoCaptureConfig.Builder setDefaultSessionConfig(SessionConfig sessionConfig)

public VideoCaptureConfig.Builder setDefaultCaptureConfig(CaptureConfig captureConfig)

public VideoCaptureConfig.Builder setSessionOptionUnpacker(SessionConfig.OptionUnpacker optionUnpacker)

public VideoCaptureConfig.Builder setCaptureOptionUnpacker(CaptureConfig.OptionUnpacker optionUnpacker)

public VideoCaptureConfig.Builder setSurfaceOccupancyPriority(int priority)

public VideoCaptureConfig.Builder setUseCaseEventListener(androidx.camera.core.UseCase.EventListener useCaseEventListener)