# MpegAudioUtil

# MpegAudioUtil

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

*** ** * ** ***

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

<br />

```
@UnstableApi
class MpegAudioUtil
```

<br />

*** ** * ** ***

Utility methods for handling MPEG audio streams.

## Summary

|                                                                              ### Nested types                                                                              |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `class `[MpegAudioUtil.Header](https://developer.android.com/reference/kotlin/androidx/media3/extractor/MpegAudioUtil.Header) Stores the metadata for an MPEG audio frame. |

|                                    ### Constants                                    |
|-------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [MAX_FRAME_SIZE_BYTES](https://developer.android.com/reference/kotlin/androidx/media3/extractor/MpegAudioUtil#MAX_FRAME_SIZE_BYTES())` = 4096` Theoretical maximum frame size for an MPEG audio stream, which occurs when playing a Layer 2 MPEG 2.5 audio stream at 16 kb/s (with padding). |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [MAX_RATE_BYTES_PER_SECOND](https://developer.android.com/reference/kotlin/androidx/media3/extractor/MpegAudioUtil#MAX_RATE_BYTES_PER_SECOND())` = 40000` Maximum rate for an MPEG audio stream corresponding to MPEG-1 layer III (320 kbit/s), in bytes per second.                         |

|                                   ### Public functions                                    |
|-------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `java-static `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [getFrameSize](https://developer.android.com/reference/kotlin/androidx/media3/extractor/MpegAudioUtil#getFrameSize(int))`(headerData: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Returns the size of the frame associated with`header`, or[LENGTH_UNSET](https://developer.android.com/reference/kotlin/androidx/media3/common/C#LENGTH_UNSET())if it is invalid.                                                   |
| `java-static `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [parseMpegAudioFrameSampleCount](https://developer.android.com/reference/kotlin/androidx/media3/extractor/MpegAudioUtil#parseMpegAudioFrameSampleCount(int))`(headerData: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Returns the number of samples per frame associated with`headerData`, or[LENGTH_UNSET](https://developer.android.com/reference/kotlin/androidx/media3/common/C#LENGTH_UNSET())if it is invalid. |

## Constants

### MAX_FRAME_SIZE_BYTES

```
const val MAX_FRAME_SIZE_BYTES = 4096: Int
```

Theoretical maximum frame size for an MPEG audio stream, which occurs when playing a Layer 2 MPEG 2.5 audio stream at 16 kb/s (with padding). The size is 1152 sample/frame \* 160000 bit/s / (8000 sample/s \* 8 bit/byte) + 1 padding byte/frame = 2881 byte/frame. The next power of two size is 4 KiB.  

### MAX_RATE_BYTES_PER_SECOND

```
const val MAX_RATE_BYTES_PER_SECOND = 40000: Int
```

Maximum rate for an MPEG audio stream corresponding to MPEG-1 layer III (320 kbit/s), in bytes per second.  

## Public functions

### getFrameSize

```
java-static fun getFrameSize(headerData: Int): Int
```

Returns the size of the frame associated with`header`, or[LENGTH_UNSET](https://developer.android.com/reference/kotlin/androidx/media3/common/C#LENGTH_UNSET())if it is invalid.  

### parseMpegAudioFrameSampleCount

```
java-static fun parseMpegAudioFrameSampleCount(headerData: Int): Int
```

Returns the number of samples per frame associated with`headerData`, or[LENGTH_UNSET](https://developer.android.com/reference/kotlin/androidx/media3/common/C#LENGTH_UNSET())if it is invalid.