# FileOutputOptions.Builder

Artifact: [androidx.camera:camera-video](https://developer.android.com/jetpack/androidx/releases/camera) [View Source](https://cs.android.com/search?q=file:androidx/camera/video/FileOutputOptions.java+class:androidx.camera.video.FileOutputOptions.Builder) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/camera#1.1.0)

*** ** * ** ***


```
class FileOutputOptions.Builder
```

<br />

*** ** * ** ***

The builder of the `https://developer.android.com/reference/kotlin/androidx/camera/video/FileOutputOptions` object.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/video/FileOutputOptions.Builder#Builder(java.io.File)(file: https://developer.android.com/reference/java/io/File.html)` Creates a builder of the `https://developer.android.com/reference/kotlin/androidx/camera/video/FileOutputOptions` with a file object. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/video/FileOutputOptions` | `https://developer.android.com/reference/kotlin/androidx/camera/video/FileOutputOptions.Builder#build()()` Builds the `https://developer.android.com/reference/kotlin/androidx/camera/video/FileOutputOptions` instance. |
| `B` | `https://developer.android.com/reference/kotlin/androidx/camera/video/FileOutputOptions.Builder#setDurationLimitMillis(long)(durationLimitMillis: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Sets the limit for the video duration in milliseconds. |
| `B` | `https://developer.android.com/reference/kotlin/androidx/camera/video/FileOutputOptions.Builder#setFileSizeLimit(long)(fileSizeLimitBytes: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Sets the limit for the file length in bytes. |
| `B` | `https://developer.android.com/reference/kotlin/androidx/camera/video/FileOutputOptions.Builder#setLocation(android.location.Location)(location: https://developer.android.com/reference/android/location/Location.html?)` Sets a `https://developer.android.com/reference/android/location/Location.html` object representing a geographic location where the video was recorded. |

## Public constructors

### Builder

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/camera#1.1.0)

```
Builder(file: File)
```

Creates a builder of the `https://developer.android.com/reference/kotlin/androidx/camera/video/FileOutputOptions` with a file object.

The file object can be created with a path using the `https://developer.android.com/reference/java/io/File.html` APIs. The path must be seekable and writable.

| Parameters |
|---|---|
| `file: https://developer.android.com/reference/java/io/File.html` | the file object. |

| See also |
|---|---|
| `https://developer.android.com/reference/java/io/File.html` |   |

## Public functions

### build

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/camera#1.1.0)

```
fun build(): FileOutputOptions
```

Builds the `https://developer.android.com/reference/kotlin/androidx/camera/video/FileOutputOptions` instance.

### setDurationLimitMillis

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/camera#1.3.0)

```
fun setDurationLimitMillis(durationLimitMillis: @IntRange(from = 0) Long): B
```

Sets the limit for the video duration in milliseconds.

When used to generate recording with `https://developer.android.com/reference/kotlin/androidx/camera/video/Recorder`, if the specified duration limit is reached while the recording is being recorded, the recording will be finalized with `https://developer.android.com/reference/kotlin/androidx/camera/video/VideoRecordEvent.Finalize#ERROR_DURATION_LIMIT_REACHED()`.

If not set or set with zero, the duration will be `https://developer.android.com/reference/kotlin/androidx/camera/video/OutputOptions#DURATION_UNLIMITED()`. If set with a negative value, an `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` will be thrown.

| Parameters |
|---|---|
| `durationLimitMillis: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | the video duration limit in milliseconds. |

| Returns |
|---|---|
| `B` | this Builder. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if the specified duration limit is negative. |

### setFileSizeLimit

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/camera#1.1.0)

```
fun setFileSizeLimit(fileSizeLimitBytes: @IntRange(from = 0) Long): B
```

Sets the limit for the file length in bytes.

When used with `https://developer.android.com/reference/kotlin/androidx/camera/video/Recorder` to generate recording, if the specified file size limit is reached while the recording is being recorded, the recording will be finalized with `https://developer.android.com/reference/kotlin/androidx/camera/video/VideoRecordEvent.Finalize#ERROR_FILE_SIZE_LIMIT_REACHED()`.

If not set or set with zero, the file size will be `https://developer.android.com/reference/kotlin/androidx/camera/video/OutputOptions#FILE_SIZE_UNLIMITED()`. If set with a negative value, an `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` will be thrown.

| Parameters |
|---|---|
| `fileSizeLimitBytes: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | the file size limit in bytes. |

| Returns |
|---|---|
| `B` | this Builder. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if the specified file size limit is negative. |

### setLocation

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/camera#1.2.0)

```
fun setLocation(location: Location?): B
```

Sets a `https://developer.android.com/reference/android/location/Location.html` object representing a geographic location where the video was recorded.

When used with `https://developer.android.com/reference/kotlin/androidx/camera/video/Recorder`, only the latitude and longitude from the `https://developer.android.com/reference/android/location/Location.html` are stored in the udta box if the output format is MP4, and are ignored for other formats. Other location data (such as altitude) is not stored. The geographic location is stored according to the ISO-6709 standard.

If `null`, no location information will be saved with the video. Default value is `null`.

| Parameters |
|---|---|
| `location: https://developer.android.com/reference/android/location/Location.html?` | the location object, or `null` if no location should be saved. |

| Returns |
|---|---|
| `B` | this Builder. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if the latitude of the location is not in the range `[-90, 90]` or the longitude of the location is not in the range `[-180, 180]`. |