# FixedFrameRateEstimator

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

*** ** * ** ***


```
@UnstableApi
public final class FixedFrameRateEstimator
```

<br />

*** ** * ** ***

Attempts to detect and refine a fixed frame rate estimate based on frame presentation timestamps.

## Summary

| ### Nested types |
|---|
| `public interface https://developer.android.com/reference/androidx/media3/exoplayer/video/FixedFrameRateEstimator.Listener` A listener for frame rate estimate updates. |

| ### Constants |
|---|---|
| `static final int` | `https://developer.android.com/reference/androidx/media3/exoplayer/video/FixedFrameRateEstimator#CONSECUTIVE_MATCHING_FRAME_DURATIONS_FOR_SYNC() = 15` The number of consecutive matching frame durations required to detect a fixed frame rate. |

| ### Public fields |
|---|---|
| `long` | `https://developer.android.com/reference/androidx/media3/exoplayer/video/FixedFrameRateEstimator#frameIndex()` |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/video/FixedFrameRateEstimator#FixedFrameRateEstimator(androidx.media3.exoplayer.video.FixedFrameRateEstimator.Listener)(https://developer.android.com/reference/androidx/media3/exoplayer/video/FixedFrameRateEstimator.Listener listener)` Creates a new estimator. |

| ### Public methods |
|---|---|
| `long` | `https://developer.android.com/reference/androidx/media3/exoplayer/video/FixedFrameRateEstimator#getFrameDurationNs()()` The currently detected fixed frame duration estimate in nanoseconds, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if the estimator has not detected a fixed frame rate. |
| `long` | `https://developer.android.com/reference/androidx/media3/exoplayer/video/FixedFrameRateEstimator#getFrameIndex()()` Returns the current frame index. |
| `void` | `https://developer.android.com/reference/androidx/media3/exoplayer/video/FixedFrameRateEstimator#onFormatChanged(float)(float formatFrameRate)` Called when the output format changes. |
| `void` | `https://developer.android.com/reference/androidx/media3/exoplayer/video/FixedFrameRateEstimator#onNextFrame(long)(long framePresentationTimeNs)` Called with each frame presentation timestamp. |

## Constants

### CONSECUTIVE_MATCHING_FRAME_DURATIONS_FOR_SYNC

```
public static final int CONSECUTIVE_MATCHING_FRAME_DURATIONS_FOR_SYNC = 15
```

The number of consecutive matching frame durations required to detect a fixed frame rate.

## Public fields

### frameIndex

```
public long frameIndex
```

## Public constructors

### FixedFrameRateEstimator

```
public FixedFrameRateEstimator(FixedFrameRateEstimator.Listener listener)
```

Creates a new estimator.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/video/FixedFrameRateEstimator.Listener listener` | The listener to notify when the frame rate estimate changes. |

## Public methods

### getFrameDurationNs

```
public long getFrameDurationNs()
```

The currently detected fixed frame duration estimate in nanoseconds, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if the estimator has not detected a fixed frame rate. Whilst synced, the estimate is refined each time `https://developer.android.com/reference/androidx/media3/exoplayer/video/FixedFrameRateEstimator#onNextFrame(long)` is called with a new frame presentation timestamp.

### getFrameIndex

```
public long getFrameIndex()
```

Returns the current frame index. The index increases monotonically for each new frame timestamp given to `https://developer.android.com/reference/androidx/media3/exoplayer/video/FixedFrameRateEstimator#onNextFrame(long)`.

### onFormatChanged

```
public void onFormatChanged(float formatFrameRate)
```

Called when the output format changes.

| Parameters |
|---|---|
| `float formatFrameRate` | The format's frame rate, or `https://developer.android.com/reference/androidx/media3/common/Format#NO_VALUE()` if unknown. |

### onNextFrame

```
public void onNextFrame(long framePresentationTimeNs)
```

Called with each frame presentation timestamp.

| Parameters |
|---|---|
| `long framePresentationTimeNs` | The frame presentation timestamp, in nanoseconds. |