# FrameDropEffect

# FrameDropEffect

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/FrameDropEffect.java+class:androidx.media3.effect.FrameDropEffect)

*** ** * ** ***

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

<br />

```
@UnstableApi
class FrameDropEffect : GlEffect
```

<br />

*** ** * ** ***

Drops frames to lower average frame rate to around`targetFrameRate`.

## Summary

|                                                   ### Public functions                                                    |
|---------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `java-static `[FrameDropEffect](https://developer.android.com/reference/kotlin/androidx/media3/effect/FrameDropEffect)`!` | [createDefaultFrameDropEffect](https://developer.android.com/reference/kotlin/androidx/media3/effect/FrameDropEffect#createDefaultFrameDropEffect(float))`(targetFrameRate: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`)` Creates a[FrameDropEffect](https://developer.android.com/reference/kotlin/androidx/media3/effect/FrameDropEffect)with the default frame dropping strategy.                                                                                                                                                                     |
| `java-static `[FrameDropEffect](https://developer.android.com/reference/kotlin/androidx/media3/effect/FrameDropEffect)`!` | [createSimpleFrameDropEffect](https://developer.android.com/reference/kotlin/androidx/media3/effect/FrameDropEffect#createSimpleFrameDropEffect(float,float))`(` ` expectedFrameRate: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`,` ` targetFrameRate: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) `)` Creates a[FrameDropEffect](https://developer.android.com/reference/kotlin/androidx/media3/effect/FrameDropEffect)that keeps every nth frame, where n is the` inputFrameRate`divided by the`targetFrameRate`. |
| [GlShaderProgram](https://developer.android.com/reference/kotlin/androidx/media3/effect/GlShaderProgram)`!`               | [toGlShaderProgram](https://developer.android.com/reference/kotlin/androidx/media3/effect/FrameDropEffect#toGlShaderProgram(android.content.Context,boolean))`(context: `[Context](https://developer.android.com/reference/android/content/Context.html)`!, useHdr: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`)` Returns a[GlShaderProgram](https://developer.android.com/reference/kotlin/androidx/media3/effect/GlShaderProgram)that applies the effect.                                                                                          |

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             ### Inherited functions                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| From[androidx.media3.common.Effect](https://developer.android.com/reference/kotlin/androidx/media3/common/Effect) |-------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) | [getDurationAfterEffectApplied](https://developer.android.com/reference/kotlin/androidx/media3/common/Effect#getDurationAfterEffectApplied(long))`(durationUs: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`)` Returns the expected duration of the output stream when the effect is applied given a input`durationUs`. |                                                                                                                                                                                                   |
| From[androidx.media3.effect.GlEffect](https://developer.android.com/reference/kotlin/androidx/media3/effect/GlEffect) |-------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | [isNoOp](https://developer.android.com/reference/kotlin/androidx/media3/effect/GlEffect#isNoOp(int,int))`(inputWidth: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, inputHeight: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Returns whether a[GlEffect](https://developer.android.com/reference/kotlin/androidx/media3/effect/GlEffect)applies no change at every timestamp. | |

## Public functions

### createDefaultFrameDropEffect

```
java-static fun createDefaultFrameDropEffect(targetFrameRate: Float): FrameDropEffect!
```

Creates a[FrameDropEffect](https://developer.android.com/reference/kotlin/androidx/media3/effect/FrameDropEffect)with the default frame dropping strategy.

The strategy used is to queue the current frame, x, with timestamp T_x if and only if one of the following is true:

- x is the first frame,
- (T_x - T_lastQueued) is closer to the target frame interval than (T_(x+1) - T_lastQueued)

Where T_lastQueued is the timestamp of the last queued frame and T_(x+1) is the timestamp of the next frame. The target frame interval is determined from`targetFrameRate`.  

|                                             Parameters                                             |
|----------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------|
| `targetFrameRate: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | The number of frames per second the output video should roughly have. |

### createSimpleFrameDropEffect

```
java-static fun createSimpleFrameDropEffect(
    expectedFrameRate: Float,
    targetFrameRate: Float
): FrameDropEffect!
```

Creates a[FrameDropEffect](https://developer.android.com/reference/kotlin/androidx/media3/effect/FrameDropEffect)that keeps every nth frame, where n is the`
inputFrameRate`divided by the`targetFrameRate`.

For example, if the input stream came in at 60fps and the targeted frame rate was 20fps, every 3rd frame would be kept. If n is not an integer, then we round to the nearest one.  

|                                              Parameters                                              |
|------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------|
| `expectedFrameRate: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | The number of frames per second in the input stream.                  |
| `targetFrameRate: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)   | The number of frames per second the output video should roughly have. |

### toGlShaderProgram

```
fun toGlShaderProgram(context: Context!, useHdr: Boolean): GlShaderProgram!
```

Returns a[GlShaderProgram](https://developer.android.com/reference/kotlin/androidx/media3/effect/GlShaderProgram)that applies the effect.  

|                                          Parameters                                           |
|-----------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------|
| `context: `[Context](https://developer.android.com/reference/android/content/Context.html)`!` | A[Context](https://developer.android.com/reference/android/content/Context.html).                                                               |
| `useHdr: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | Whether input textures come from an HDR source. If`true`, colors will be in linear RGB BT.2020. If`false`, colors will be in linear RGB BT.709. |

|                                                                           Throws                                                                            |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------|
| [androidx.media3.common.VideoFrameProcessingException](https://developer.android.com/reference/kotlin/androidx/media3/common/VideoFrameProcessingException) | If an error occurs while creating the[GlShaderProgram](https://developer.android.com/reference/kotlin/androidx/media3/effect/GlShaderProgram). |