Android 12 Developer Preview is here! Try it out, and give us your feedback!

OutputFileOptions

public abstract class OutputFileOptions
extends Object

java.lang.Object
   ↳ androidx.camera.view.video.OutputFileOptions


Options for saving newly captured video.

this class is used to configure save location and metadata. Save location can be either a File, MediaStore. The metadata will be stored with the saved video.

Summary

Nested classes

class OutputFileOptions.Builder

Builder class for OutputFileOptions

Public methods

static OutputFileOptions.Builder builder(ParcelFileDescriptor fileDescriptor)

Creates options to write captured video to a ParcelFileDescriptor.

static OutputFileOptions.Builder builder(ContentResolver contentResolver, Uri saveCollection, ContentValues contentValues)

Creates options to write captured video to MediaStore.

static OutputFileOptions.Builder builder(File file)

Creates options to write captured video to a File.

abstract Metadata getMetadata()

Returns the metadata which is set by the OutputFileOptions.Builder.

Inherited methods

Public methods

builder

public static OutputFileOptions.Builder builder (ParcelFileDescriptor fileDescriptor)

Creates options to write captured video to a ParcelFileDescriptor.

Using a ParcelFileDescriptor to record a video is only supported for Android 8.0 or above.

Parameters
fileDescriptor ParcelFileDescriptor: to save the video.

Returns
OutputFileOptions.Builder

Throws
IllegalArgumentException when the device is not running Android 8.0 or above.

builder

public static OutputFileOptions.Builder builder (ContentResolver contentResolver, 
                Uri saveCollection, 
                ContentValues contentValues)

Creates options to write captured video to MediaStore. Example:

ContentValues contentValues = new ContentValues();
 contentValues.put(MediaStore.MediaColumns.DISPLAY_NAME, "NEW_VIDEO");
 contentValues.put(MediaStore.MediaColumns.MIME_TYPE, "video/mp4");

 OutputFileOptions options = OutputFileOptions.builder(
         getContentResolver(),
         MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
         contentValues).build();

 

Parameters
contentResolver ContentResolver: to access MediaStore

saveCollection Uri: The URI of the table to insert into.

contentValues ContentValues: to be included in the created video file.

Returns
OutputFileOptions.Builder

builder

public static OutputFileOptions.Builder builder (File file)

Creates options to write captured video to a File.

Parameters
file File: save location of the video.

Returns
OutputFileOptions.Builder

getMetadata

public abstract Metadata getMetadata ()

Returns the metadata which is set by the OutputFileOptions.Builder.

Returns
Metadata