# VideoDecodingWrapper

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

*** ** * ** ***


```
@UnstableApi
public final class VideoDecodingWrapper implements AutoCloseable
```

<br />

*** ** * ** ***

A wrapper for decoding a video using `https://developer.android.com/reference/android/media/MediaCodec.html`.

This test utility class prefers using a software decoder. Depending on video resolution and device, some hardware decoders fail to write frames in `https://developer.android.com/reference/android/graphics/ImageFormat.html#YUV_420_888` to `https://developer.android.com/reference/android/media/ImageReader.html` for use in CPU test utility functions.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/test/utils/VideoDecodingWrapper#VideoDecodingWrapper(android.content.Context,java.lang.String,int,int)( https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/java/lang/String.html filePath, int comparisonInterval, int maxImagesAllowed )` Creates a new instance. |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/media3/test/utils/VideoDecodingWrapper#close()()` |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/media/Image.html` | `https://developer.android.com/reference/androidx/media3/test/utils/VideoDecodingWrapper#runUntilComparisonFrameOrEnded()()` Returns the next decoded comparison frame, or `null` if the stream has ended. |

## Public constructors

### VideoDecodingWrapper

```
public VideoDecodingWrapper(
    Context context,
    String filePath,
    int comparisonInterval,
    int maxImagesAllowed
)
```

Creates a new instance.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/content/Context.html context` | The `https://developer.android.com/reference/android/content/Context.html`. |
| `https://developer.android.com/reference/java/lang/String.html filePath` | The path to the video file. |
| `int comparisonInterval` | The number of frames between the frames selected for comparison. |
| `int maxImagesAllowed` | The max number of images allowed in `https://developer.android.com/reference/android/media/ImageReader.html`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | When failed to open the video file. |

## Public methods

### close

```
public void close()
```

### runUntilComparisonFrameOrEnded

```
public @Nullable Image runUntilComparisonFrameOrEnded()
```

Returns the next decoded comparison frame, or `null` if the stream has ended. The caller takes ownership of any returned image and is responsible for closing it before calling this method again.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/InterruptedException.html` |   |