public final class Recorder implements VideoOutput

An implementation of VideoOutput for starting video recordings that are saved to a File, ParcelFileDescriptor, or MediaStore.

A recorder can be used to save the video frames sent from the VideoCapture use case in common recording formats such as MPEG4.

Usage example of setting up VideoCapture with a recorder as output:

ProcessCameraProvider cameraProvider = ...;
CameraSelector cameraSelector = ...;
...
// Create our preview to show on screen
Preview preview = new Preview.Builder.build();
// Create the video capture use case with a Recorder as the output
VideoCapturevideoCapture = VideoCapture.withOutput(new Recorder.Builder().build());

// Bind use cases to Fragment/Activity lifecycle
cameraProvider.bindToLifecycle(this, cameraSelector, preview, videoCapture);

Once the recorder is attached to a video source as a VideoOutput, e.g. using it to create a VideoCapture by calling withOutput, a new recording can be generated with one of the prepareRecording methods, such as prepareRecording. The PendingRecording class then can be used to adjust per-recording settings and to start the recording. It also requires passing a listener to start to listen for VideoRecordEvents such as VideoRecordEvent.Start, VideoRecordEvent.Pause, VideoRecordEvent.Resume, and VideoRecordEvent.Finalize. This listener will also receive regular recording status updates via the VideoRecordEvent.Status event.

Attaching a single Recorder instance to multiple video sources at the same time may causes unexpected behaviors and is not recommended.

A recorder can also capture and save audio alongside video. The audio must be explicitly enabled with withAudioEnabled before starting the recording.

Summary

Constants

DEFAULT_QUALITY_SELECTOR

public static final QualitySelector DEFAULT_QUALITY_SELECTOR

Default quality selector for recordings.

The default quality selector chooses a video quality suitable for recordings based on device and compatibility constraints. It is equivalent to:

QualitySelector.fromOrderedList(Arrays.asList(Quality.FHD, Quality.HD, Quality.SD),
        FallbackStrategy.higherQualityOrLowerThan(Quality.FHD));

VIDEO_CAPABILITIES_SOURCE_CAMCORDER_PROFILE

public static final int VIDEO_CAPABILITIES_SOURCE_CAMCORDER_PROFILE = 0

Video capabilities are derived from CamcorderProfile.

The Quality supported by the video capabilities of this source are determined by the device's CamcorderProfile. This means that the quality of recorded videos is guaranteed by the device manufacturer. This is the recommended type for recording high-quality video.

VIDEO_CAPABILITIES_SOURCE_CODEC_CAPABILITIES

public static final int VIDEO_CAPABILITIES_SOURCE_CODEC_CAPABILITIES = 1

Video capabilities are derived from codec capabilities.

The Quality supported by the video capabilities of this source are determined by the codec capabilities. However, the recorded videos is not guaranteed. For example, there may be frame drops due to thermal throttling or memory pressure. Therefore, it is recommended to use VIDEO_CAPABILITIES_SOURCE_CAMCORDER_PROFILE unless there is a specific reason. A common use case is when the application strives to record UHD video whenever feasible, but the device's CamcorderProfile does not include a UHD quality setting, even though the codec is capable of recording UHD video.

Public methods

getAspectRatio

public int getAspectRatio()

Gets the aspect ratio of this Recorder.

Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

Last updated 2025-10-22 UTC.