# VideoOutput

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/VideoOutput.java+class:androidx.camera.video.VideoOutput) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/camera#1.1.0)

*** ** * ** ***


```
public interface VideoOutput
```

<br />

Known direct subclasses [Recorder](https://developer.android.com/reference/androidx/camera/video/Recorder)

|---|---|
| `https://developer.android.com/reference/androidx/camera/video/Recorder` | An implementation of `https://developer.android.com/reference/androidx/camera/video/VideoOutput` for starting video recordings that are saved to a `https://developer.android.com/reference/java/io/File.html`, `https://developer.android.com/reference/android/os/ParcelFileDescriptor.html`, or `https://developer.android.com/reference/android/provider/MediaStore.html`. |

*** ** * ** ***

A class that will produce video data from a `https://developer.android.com/reference/android/view/Surface.html`.

Implementations will provide a `https://developer.android.com/reference/android/view/Surface.html` to a video frame producer via the `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest` sent to `https://developer.android.com/reference/androidx/camera/video/VideoOutput#onSurfaceRequested(androidx.camera.core.SurfaceRequest)`.

The type of video data produced by a video output and API for saving or communicating that data is left to the implementation. An implementation commonly used for local video saving is `https://developer.android.com/reference/androidx/camera/video/Recorder`. This interface is usually only needs to be implemented by applications for advanced use cases.

## Summary

| ### Public methods |
|---|---|
| `abstract void` | `https://developer.android.com/reference/androidx/camera/video/VideoOutput#onSurfaceRequested(androidx.camera.core.SurfaceRequest)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/camera/core/SurfaceRequest request)` Called when a new `https://developer.android.com/reference/android/view/Surface.html` has been requested by a video frame producer. |

## Public methods

### onSurfaceRequested

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

```
abstract void onSurfaceRequested(@NonNull SurfaceRequest request)
```

Called when a new `https://developer.android.com/reference/android/view/Surface.html` has been requested by a video frame producer.

Users of this class should not call this method directly. It will be called by the video frame producer. Implementors of this class should be aware that this method is called when a video frame producer is ready to receive a surface that it can use to send video frames to the video output. The video frame producer may repeatedly request a surface more than once, but only the latest `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest` should be considered active. All previous surface requests will complete by sending a `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest.Result` to the consumer passed to `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest#provideSurface(android.view.Surface,java.util.concurrent.Executor,androidx.core.util.Consumer<androidx.camera.core.SurfaceRequest.Result>)`.

A request is considered active until it is `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest#provideSurface(android.view.Surface,java.util.concurrent.Executor,androidx.core.util.Consumer<androidx.camera.core.SurfaceRequest.Result>)`, `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest#willNotProvideSurface()`, or `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest#addRequestCancellationListener(java.util.concurrent.Executor,java.lang.Runnable)`. After one of these conditions occurs, a request is considered completed.

Once a request is successfully completed, it is guaranteed that if a new request is made, the `https://developer.android.com/reference/android/view/Surface.html` used to fulfill the previous request will be detached from the video frame producer and the `resultListener` provided in `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest#provideSurface(android.view.Surface,java.util.concurrent.Executor,androidx.core.util.Consumer<androidx.camera.core.SurfaceRequest.Result>)` will be invoked with a `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest.Result` containing `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest.Result#RESULT_SURFACE_USED_SUCCESSFULLY()`.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/camera/core/SurfaceRequest request` | the request for a surface which contains the requirements of the surface and methods for completing the request. |