SpeedChangeEffect


@UnstableApi
public final class SpeedChangeEffect implements GlEffect


Applies a speed change by updating the frame timestamps.

This effect doesn't drop any frames.

This effect is not supported for effects previewing.

Summary

Public constructors

SpeedChangeEffect(@FloatRange(from = 0, fromInclusive = false) float speed)

Creates an instance that applies the same speed change to all the timestamps.

Creates an instance.

Public methods

long

Returns the expected duration of the output stream when the effect is applied given a input durationUs.

boolean
isNoOp(int inputWidth, int inputHeight)

Returns whether a GlEffect applies no change at every timestamp.

GlShaderProgram
toGlShaderProgram(Context context, boolean useHdr)

Returns a GlShaderProgram that applies the effect.

Public constructors

SpeedChangeEffect

public SpeedChangeEffect(@FloatRange(from = 0, fromInclusive = false) float speed)

Creates an instance that applies the same speed change to all the timestamps.

SpeedChangeEffect

public SpeedChangeEffect(SpeedProvider speedProvider)

Creates an instance.

Parameters
SpeedProvider speedProvider

The SpeedProvider specifying the speed changes. Applied on each stream assuming the first frame timestamp of the input media is 0.

Public methods

getDurationAfterEffectApplied

public long getDurationAfterEffectApplied(long durationUs)

Returns the expected duration of the output stream when the effect is applied given a input durationUs.

isNoOp

public boolean isNoOp(int inputWidth, int inputHeight)

Returns whether a GlEffect applies no change at every timestamp.

This can be used as a hint to skip this instance.

Parameters
int inputWidth

The input frame width, in pixels.

int inputHeight

The input frame height, in pixels.

toGlShaderProgram

public GlShaderProgram toGlShaderProgram(Context context, boolean useHdr)

Returns a GlShaderProgram that applies the effect.

Parameters
Context context

A Context.

boolean useHdr

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

If an error occurs while creating the .