# VideoDecodingWrapper

# 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)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/media3/test/utils/VideoDecodingWrapper "View this page in Java")

<br />

```
@UnstableApi
class VideoDecodingWrapper : AutoCloseable
```

<br />

*** ** * ** ***

A wrapper for decoding a video using[MediaCodec](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[YUV_420_888](https://developer.android.com/reference/android/graphics/ImageFormat.html#YUV_420_888())to[ImageReader](https://developer.android.com/reference/android/media/ImageReader.html)for use in CPU test utility functions.

## Summary

|                                                                                                                                                                                                                                                                                                        ### Public constructors                                                                                                                                                                                                                                                                                                         |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [VideoDecodingWrapper](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/VideoDecodingWrapper#VideoDecodingWrapper(android.content.Context,java.lang.String,int,int))`(` ` context: `[Context](https://developer.android.com/reference/android/content/Context.html)`!,` ` filePath: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!,` ` comparisonInterval: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` maxImagesAllowed: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) `)` Creates a new instance. |

|                             ### Public functions                              |
|-------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [close](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/VideoDecodingWrapper#close())`()`                                                                                                                               |
| [Image](https://developer.android.com/reference/android/media/Image.html)`?`  | [runUntilComparisonFrameOrEnded](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/VideoDecodingWrapper#runUntilComparisonFrameOrEnded())`()` Returns the next decoded comparison frame, or`null`if the stream has ended. |

## Public constructors

### VideoDecodingWrapper

```
VideoDecodingWrapper(
    context: Context!,
    filePath: String!,
    comparisonInterval: Int,
    maxImagesAllowed: Int
)
```

Creates a new instance.  

|                                            Parameters                                             |
|---------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------|
| `context: `[Context](https://developer.android.com/reference/android/content/Context.html)`!`     | The[Context](https://developer.android.com/reference/android/content/Context.html).                                       |
| `filePath: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!`  | The path to the video file.                                                                                               |
| `comparisonInterval: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The number of frames between the frames selected for comparison.                                                          |
| `maxImagesAllowed: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)   | The max number of images allowed in[ImageReader](https://developer.android.com/reference/android/media/ImageReader.html). |

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

## Public functions

### close

```
fun close(): Unit
```  

### runUntilComparisonFrameOrEnded

```
fun runUntilComparisonFrameOrEnded(): Image?
```

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                                                     |
|---------------------------------------------------------------------------------------------------------------|---|
| [java.lang.InterruptedException](https://developer.android.com/reference/java/lang/InterruptedException.html) |   |