# MultipleInputVideoGraph

Artifact: [androidx.media3:media3-effect](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/effect/MultipleInputVideoGraph.java+class:androidx.media3.effect.MultipleInputVideoGraph)

*** ** * ** ***


```
@UnstableApi
public final class MultipleInputVideoGraph implements VideoGraph
```

<br />

*** ** * ** ***

A `https://developer.android.com/reference/androidx/media3/common/VideoGraph` that handles multiple input streams.

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/media3/effect/MultipleInputVideoGraph.Factory implements https://developer.android.com/reference/androidx/media3/common/VideoGraph.Factory` A `https://developer.android.com/reference/androidx/media3/common/VideoGraph.Factory` for `https://developer.android.com/reference/androidx/media3/effect/MultipleInputVideoGraph`. |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/media3/effect/MultipleInputVideoGraph#flush()()` Flushes the `https://developer.android.com/reference/androidx/media3/common/VideoGraph#registerInput(int)` of the `VideoGraph`. |
| `https://developer.android.com/reference/android/view/Surface.html` | `https://developer.android.com/reference/androidx/media3/effect/MultipleInputVideoGraph#getInputSurface(int)(int inputIndex)` Returns the input `https://developer.android.com/reference/android/view/Surface.html` at `inputIndex`. |
| `int` | `https://developer.android.com/reference/androidx/media3/effect/MultipleInputVideoGraph#getPendingInputFrameCount(int)(int inputIndex)` Returns the number of pending input frames at `inputIndex` that has not been processed yet. |
| `boolean` | `https://developer.android.com/reference/androidx/media3/effect/MultipleInputVideoGraph#hasProducedFrameWithTimestampZero()()` Returns whether the `VideoGraph` has produced a frame with zero presentation timestamp. |
| `void` | `https://developer.android.com/reference/androidx/media3/effect/MultipleInputVideoGraph#initialize()()` Initialize the VideoGraph}. |
| `boolean` | `https://developer.android.com/reference/androidx/media3/effect/MultipleInputVideoGraph#queueInputBitmap(int,android.graphics.Bitmap,androidx.media3.common.util.TimestampIterator)( int inputIndex, https://developer.android.com/reference/android/graphics/Bitmap.html inputBitmap, https://developer.android.com/reference/androidx/media3/common/util/TimestampIterator timestampIterator )` Queues the input `https://developer.android.com/reference/android/graphics/Bitmap.html` at `inputIndex`. |
| `boolean` | `https://developer.android.com/reference/androidx/media3/effect/MultipleInputVideoGraph#queueInputTexture(int,int,long)( int inputIndex, int textureId, long presentationTimeUs )` Queues the input texture at `inputIndex`. |
| `void` | `https://developer.android.com/reference/androidx/media3/effect/MultipleInputVideoGraph#redraw()()` Updates an `https://developer.android.com/reference/androidx/media3/common/VideoGraph.Listener#onOutputFrameAvailableForRendering(long,boolean)` with the modified effects. |
| `void` | `https://developer.android.com/reference/androidx/media3/effect/MultipleInputVideoGraph#registerInput(int)(@https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) int inputIndex)` Registers a new input to the `VideoGraph`. |
| `boolean` | `https://developer.android.com/reference/androidx/media3/effect/MultipleInputVideoGraph#registerInputFrame(int)(int inputIndex)` Registers a new input frame at `inputIndex`. |
| `void` | `https://developer.android.com/reference/androidx/media3/effect/MultipleInputVideoGraph#registerInputStream(int,int,androidx.media3.common.Format,java.util.List<androidx.media3.common.Effect>,long)( int inputIndex, @https://developer.android.com/reference/androidx/media3/common/VideoFrameProcessor.InputType int inputType, https://developer.android.com/reference/androidx/media3/common/Format format, https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/common/Effect> effects, long offsetToAddUs )` Informs the graph that a new input stream will be queued to the graph input corresponding to `inputIndex`. |
| `void` | `https://developer.android.com/reference/androidx/media3/effect/MultipleInputVideoGraph#release()()` Releases the associated resources. |
| `void` | `https://developer.android.com/reference/androidx/media3/effect/MultipleInputVideoGraph#renderOutputFrame(long)(long renderTimeNs)` Renders the output frame from the `VideoGraph`. |
| `void` | `https://developer.android.com/reference/androidx/media3/effect/MultipleInputVideoGraph#setCompositionEffects(java.util.List<androidx.media3.common.Effect>)(https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/common/Effect> compositionEffects)` Sets the Composition-level video effects that are applied after the effects on single `https://developer.android.com/reference/androidx/media3/common/VideoGraph#registerInputStream(int,int,androidx.media3.common.Format,java.util.List<androidx.media3.common.Effect>,long)`. |
| `void` | `https://developer.android.com/reference/androidx/media3/effect/MultipleInputVideoGraph#setCompositorSettings(androidx.media3.common.VideoCompositorSettings)(https://developer.android.com/reference/androidx/media3/common/VideoCompositorSettings videoCompositorSettings)` Sets the `https://developer.android.com/reference/androidx/media3/common/VideoCompositorSettings`. |
| `void` | `https://developer.android.com/reference/androidx/media3/effect/MultipleInputVideoGraph#setOnInputFrameProcessedListener(int,androidx.media3.common.OnInputFrameProcessedListener)( int inputIndex, https://developer.android.com/reference/androidx/media3/common/OnInputFrameProcessedListener listener )` Sets the `https://developer.android.com/reference/androidx/media3/common/OnInputFrameProcessedListener` at `inputIndex`. |
| `void` | `https://developer.android.com/reference/androidx/media3/effect/MultipleInputVideoGraph#setOnInputSurfaceReadyListener(int,java.lang.Runnable)(int inputIndex, https://developer.android.com/reference/java/lang/Runnable.html listener)` Sets a listener that's called when the `https://developer.android.com/reference/androidx/media3/common/VideoGraph#getInputSurface(int)` is ready to use at `inputIndex`. |
| `void` | `https://developer.android.com/reference/androidx/media3/effect/MultipleInputVideoGraph#setOutputSurfaceInfo(androidx.media3.common.SurfaceInfo)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/SurfaceInfo outputSurfaceInfo)` Sets the output surface and supporting information. |
| `void` | `https://developer.android.com/reference/androidx/media3/effect/MultipleInputVideoGraph#signalEndOfInput(int)(int inputIndex)` Informs that no further inputs should be accepted at `inputIndex`. |

## Public methods

### flush

```
public void flush()
```

Flushes the `https://developer.android.com/reference/androidx/media3/common/VideoGraph#registerInput(int)` of the `VideoGraph`.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/VideoFrameProcessor#flush()` |   |

### getInputSurface

```
public Surface getInputSurface(int inputIndex)
```

Returns the input `https://developer.android.com/reference/android/view/Surface.html` at `inputIndex`.

### getPendingInputFrameCount

```
public int getPendingInputFrameCount(int inputIndex)
```

Returns the number of pending input frames at `inputIndex` that has not been processed yet.

### hasProducedFrameWithTimestampZero

```
public boolean hasProducedFrameWithTimestampZero()
```

Returns whether the `VideoGraph` has produced a frame with zero presentation timestamp.

### initialize

```
public void initialize()
```

Initialize the VideoGraph}.

This method must be called before calling other methods.

If the method throws, the caller must call #release.

This method must be called at most once.

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/VideoFrameProcessingException` |   |

### queueInputBitmap

```
public boolean queueInputBitmap(
    int inputIndex,
    Bitmap inputBitmap,
    TimestampIterator timestampIterator
)
```

Queues the input `https://developer.android.com/reference/android/graphics/Bitmap.html` at `inputIndex`.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/VideoFrameProcessor#queueInputBitmap(android.graphics.Bitmap,androidx.media3.common.util.TimestampIterator)` |   |

### queueInputTexture

```
public boolean queueInputTexture(
    int inputIndex,
    int textureId,
    long presentationTimeUs
)
```

Queues the input texture at `inputIndex`.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/VideoFrameProcessor#queueInputTexture(int,long)` |   |

### redraw

```
public void redraw()
```

Updates an `https://developer.android.com/reference/androidx/media3/common/VideoGraph.Listener#onOutputFrameAvailableForRendering(long,boolean)` with the modified effects.

### registerInput

```
public void registerInput(@IntRange(from = 0) int inputIndex)
```

Registers a new input to the `VideoGraph`.

All inputs must be registered before rendering frames by calling `https://developer.android.com/reference/androidx/media3/common/VideoGraph#registerInputFrame(int)`, `https://developer.android.com/reference/androidx/media3/common/VideoGraph#queueInputBitmap(int,android.graphics.Bitmap,androidx.media3.common.util.TimestampIterator)` or `https://developer.android.com/reference/androidx/media3/common/VideoGraph#queueInputTexture(int,int,long)`.

If the method throws, the caller must call `https://developer.android.com/reference/androidx/media3/common/VideoGraph#release()`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) int inputIndex` | The index of the input which could be used to order the inputs. The index must start from 0. |

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/VideoFrameProcessingException` |   |

### registerInputFrame

```
public boolean registerInputFrame(int inputIndex)
```

Registers a new input frame at `inputIndex`.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/VideoFrameProcessor#registerInputFrame()` |   |

### registerInputStream

```
public void registerInputStream(
    int inputIndex,
    @VideoFrameProcessor.InputType int inputType,
    Format format,
    List<Effect> effects,
    long offsetToAddUs
)
```

Informs the graph that a new input stream will be queued to the graph input corresponding to `inputIndex`.

After registering the first input stream, this method must only be called for the same index after the last frame of the already-registered input stream has been `https://developer.android.com/reference/androidx/media3/common/VideoGraph#registerInputFrame(int)`, last bitmap `https://developer.android.com/reference/androidx/media3/common/VideoGraph#queueInputBitmap(int,android.graphics.Bitmap,androidx.media3.common.util.TimestampIterator)` or last texture id `https://developer.android.com/reference/androidx/media3/common/VideoGraph#queueInputTexture(int,int,long)`.

This method blocks the calling thread until the previous input stream corresponding to the same `inputIndex` has been fully registered internally.

| Parameters |
|---|---|
| `int inputIndex` | The index of the input for which a new input stream should be registered. This index must start from 0. |
| `@https://developer.android.com/reference/androidx/media3/common/VideoFrameProcessor.InputType int inputType` | The `https://developer.android.com/reference/androidx/media3/common/VideoFrameProcessor.InputType` of the new input stream. |
| `https://developer.android.com/reference/androidx/media3/common/Format format` | The `https://developer.android.com/reference/androidx/media3/common/Format` of the new input stream. The `https://developer.android.com/reference/androidx/media3/common/Format#colorInfo()`, the `https://developer.android.com/reference/androidx/media3/common/Format#width()`, the `https://developer.android.com/reference/androidx/media3/common/Format#height()` and the `https://developer.android.com/reference/androidx/media3/common/Format#pixelWidthHeightRatio()` must be set. |
| `https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/common/Effect> effects` | The list of `https://developer.android.com/reference/androidx/media3/common/Effect` to apply to the new input stream. |
| `long offsetToAddUs` | The offset that must be added to the frame presentation timestamps, in microseconds. This offset is not part of the input timestamps. It is added to the frame timestamps before processing, and is retained in the output timestamps. |

### release

```
public void release()
```

Releases the associated resources.

This `VideoGraph` instance must not be used after this method is called.

### renderOutputFrame

```
public void renderOutputFrame(long renderTimeNs)
```

Renders the output frame from the `VideoGraph`.

This method must be called only for frames that have become `https://developer.android.com/reference/androidx/media3/common/VideoGraph.Listener#onOutputFrameAvailableForRendering(long,boolean)`, calling the method renders the frame that becomes available the earliest but not yet rendered.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/VideoFrameProcessor#renderOutputFrame(long)` |   |

### setCompositionEffects

```
public void setCompositionEffects(List<Effect> compositionEffects)
```

Sets the Composition-level video effects that are applied after the effects on single `https://developer.android.com/reference/androidx/media3/common/VideoGraph#registerInputStream(int,int,androidx.media3.common.Format,java.util.List<androidx.media3.common.Effect>,long)`.

This method should be called before `https://developer.android.com/reference/androidx/media3/common/VideoGraph#registerInputStream(int,int,androidx.media3.common.Format,java.util.List<androidx.media3.common.Effect>,long)` to set the desired composition level `https://developer.android.com/reference/androidx/media3/common/Effect`.

### setCompositorSettings

```
public void setCompositorSettings(VideoCompositorSettings videoCompositorSettings)
```

Sets the `https://developer.android.com/reference/androidx/media3/common/VideoCompositorSettings`.

This method should be called before `https://developer.android.com/reference/androidx/media3/common/VideoGraph#registerInputStream(int,int,androidx.media3.common.Format,java.util.List<androidx.media3.common.Effect>,long)` to set the desired composition level `https://developer.android.com/reference/androidx/media3/common/VideoCompositorSettings`.

Setting a custom `https://developer.android.com/reference/androidx/media3/common/VideoCompositorSettings` where `https://developer.android.com/reference/androidx/media3/common/VideoGraph.Factory#supportsMultipleInputs()` returns `false` throws an `https://developer.android.com/reference/java/lang/IllegalArgumentException.html`.

### setOnInputFrameProcessedListener

```
public void setOnInputFrameProcessedListener(
    int inputIndex,
    OnInputFrameProcessedListener listener
)
```

Sets the `https://developer.android.com/reference/androidx/media3/common/OnInputFrameProcessedListener` at `inputIndex`.

### setOnInputSurfaceReadyListener

```
public void setOnInputSurfaceReadyListener(int inputIndex, Runnable listener)
```

Sets a listener that's called when the `https://developer.android.com/reference/androidx/media3/common/VideoGraph#getInputSurface(int)` is ready to use at `inputIndex`.

### setOutputSurfaceInfo

```
public void setOutputSurfaceInfo(@Nullable SurfaceInfo outputSurfaceInfo)
```

Sets the output surface and supporting information.

The new output `https://developer.android.com/reference/androidx/media3/common/SurfaceInfo` is applied from the next output frame rendered onwards. If the output `https://developer.android.com/reference/androidx/media3/common/SurfaceInfo` is `null`, the `VideoGraph` will stop rendering pending frames and resume rendering once a non-null `https://developer.android.com/reference/androidx/media3/common/SurfaceInfo` is set.

If the dimensions given in `https://developer.android.com/reference/androidx/media3/common/SurfaceInfo` do not match the `https://developer.android.com/reference/androidx/media3/common/VideoGraph.Listener#onOutputSizeChanged(int,int)` the frames are resized before rendering to the surface and letter/pillar-boxing is applied.

The caller is responsible for tracking the lifecycle of the `https://developer.android.com/reference/androidx/media3/common/SurfaceInfo#surface()` including calling this method with a new surface if it is destroyed. When this method returns, the previous output surface is no longer being used and can safely be released by the caller.

### signalEndOfInput

```
public void signalEndOfInput(int inputIndex)
```

Informs that no further inputs should be accepted at `inputIndex`.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/VideoFrameProcessor#signalEndOfInput()` |   |