Format
class Format
Represents a media format.
When building formats, populate all fields whose values are known and relevant to the type of format being constructed. For information about different types of format, see ExoPlayer's Supported formats page.
Fields commonly relevant to all formats
Fields relevant to container formats
containerMimeType- If the container only contains a single media track, fields relevant to sample formats can are also be relevant and can be set to describe the sample format of that track.
- If the container only contains one track of a given type (possibly alongside tracks of other types), then fields relevant to that track type can be set to describe the properties of the track. See the sections below for video, audio and text formats.
Fields relevant to sample formats
sampleMimeTypemaxInputSizeinitializationDatadrmInitDatasubsampleOffsetUs- Fields relevant to the sample format's track type are also relevant. See the sections below for video, audio and text formats.
Fields relevant to video formats
widthheightdecodedWidthdecodedHeightframeRaterotationDegreespixelWidthHeightRatioprojectionDatastereoModecolorInfomaxSubLayers
Fields relevant to audio formats
Fields relevant to text formats
Fields relevant to image formats
Summary
Nested types |
|---|
@UnstableApiBuilds |
@UnstableApiThe replacement behaviors for consecutive samples in a |
Constants |
|
|---|---|
const Int |
Subsequent cues should be merged with any previous cues that should still be shown on screen. |
const Int |
Subsequent cues should replace all previous cues. |
const Int |
NO_VALUE = -1A value for various fields to indicate that the field's value is unknown or not applicable. |
const Long |
@UnstableApiA value for |
Public functions |
|
|---|---|
Format.Builder! |
Returns a |
Format! |
@UnstableApiReturns a copy of this format with the specified |
Boolean |
|
java-static Format! |
@UnstableApiRestores a |
Int |
Returns the number of pixels if this is a video format whose |
Int |
hashCode() |
Boolean |
@UnstableApiReturns whether the |
Bundle! |
Returns a |
java-static String! |
@UnstableApiReturns a prettier |
String! |
toString() |
Format! |
@UnstableApi |
Public properties |
|
|---|---|
Int |
The Accessibility channel, or |
Int |
The auxiliary track type. |
Int |
The average bitrate in bits per second, or |
Int |
The bitrate in bits per second. |
Int |
The number of audio channels, or |
String? |
Codecs of the format as described in RFC 6381, or null if unknown or not applicable. |
ColorInfo? |
The color metadata associated with the video, or null if not applicable. |
String? |
The MIME type of the container, or null if unknown or not applicable. |
Int |
The type of crypto that must be used to decode samples associated with this format, or |
Int |
The replacement behavior that should be followed when handling consecutive samples in a |
Any? |
An extra opaque object that can be added to the |
Int |
The height of the video decoded picture in pixels, or |
Int |
The width of the video decoded picture in pixels, or |
DrmInitData? |
DRM initialization data if the stream is protected, or null otherwise. |
Int |
The number of frames to trim from the start of the decoded audio stream, or 0 if not applicable. |
Int |
The number of frames to trim from the end of the decoded audio stream, or 0 if not applicable. |
Float |
The frame rate in frames per second, or |
Boolean |
Indicates whether the stream contains preroll samples. |
Int |
The height of the video in pixels, or |
String? |
An identifier for the format, or null if unknown or not applicable. |
(Mutable)List<ByteArray<Byte>!>! |
Initialization data that must be provided to the decoder. |
String? |
The default human readable label, or null if unknown or not applicable. |
(Mutable)List<Label!>! |
The human readable list of labels, or an empty list if unknown or not applicable. |
String? |
The language as an IETF BCP 47 conformant tag, or null if unknown or not applicable. |
Int |
The maximum size of a buffer of data (typically one sample), or |
Int |
The maximum number of samples that must be stored to correctly re-order samples from decode order to presentation order. |
Int |
The maximum number of temporal scalable sub-layers in the video bitstream, or |
Metadata? |
Metadata, or null if unknown or not applicable. |
Int |
The |
Int |
The peak bitrate in bits per second, or |
Float |
The width to height ratio of pixels in the video, or 1.0 if unknown or not applicable. |
ByteArray<Byte>? |
The projection data for 360/VR video, or null if not applicable. |
Int |
Track role flags. |
Int |
The clockwise rotation that should be applied to the video for it to be rendered in the correct orientation, or 0 if unknown or not applicable. |
String? |
The sample MIME type, or null if unknown or not applicable. |
Int |
The audio sampling rate in Hz, or |
Int |
Track selection flags. |
Int |
The stereo layout for 360/3D/VR video, or |
Long |
For samples that contain subsamples, this is an offset that should be added to subsample timestamps. |
Int |
The number of horizontal tiles in an image, or |
Int |
The number of vertical tiles in an image, or |
Int |
The width of the video in pixels, or |
Constants
CUE_REPLACEMENT_BEHAVIOR_MERGE
@UnstableApi
const val CUE_REPLACEMENT_BEHAVIOR_MERGE = 1: Int
Subsequent cues should be merged with any previous cues that should still be shown on screen.
Tracks with this behavior must not contain samples with an unset duration.
CUE_REPLACEMENT_BEHAVIOR_REPLACE
@UnstableApi
const val CUE_REPLACEMENT_BEHAVIOR_REPLACE = 2: Int
Subsequent cues should replace all previous cues.
Tracks with this behavior may contain samples with an unset duration (but the duration may also be set to a 'real' value).
NO_VALUE
const val NO_VALUE = -1: Int
A value for various fields to indicate that the field's value is unknown or not applicable.
OFFSET_SAMPLE_RELATIVE
@UnstableApi
const val OFFSET_SAMPLE_RELATIVE = 9223372036854775807: Long
A value for subsampleOffsetUs to indicate that subsample timestamps are relative to the timestamps of their parent samples.
Public functions
buildUpon
@UnstableApi
fun buildUpon(): Format.Builder!
Returns a Format.Builder initialized with the values of this instance.
copyWithCryptoType
@UnstableApi
fun copyWithCryptoType(@C.CryptoType cryptoType: Int): Format!
Returns a copy of this format with the specified cryptoType.
fromBundle
@UnstableApi
java-static fun fromBundle(bundle: Bundle!): Format!
Restores a Format from a Bundle.
getPixelCount
@UnstableApi
fun getPixelCount(): Int
Returns the number of pixels if this is a video format whose width and height are known, or NO_VALUE otherwise
initializationDataEquals
@UnstableApi
fun initializationDataEquals(other: Format!): Boolean
Returns whether the initializationDatas belonging to this format and other are equal.
| Parameters | |
|---|---|
other: Format! |
The other format whose |
| Returns | |
|---|---|
Boolean |
Whether the |
toBundle
@UnstableApi
fun toBundle(): Bundle!
Returns a Bundle representing the information stored in this object. If
excludeMetadata is true, metadata is excluded.
toLogString
@UnstableApi
java-static fun toLogString(format: Format?): String!
Returns a prettier String than toString, intended for logging.
Public properties
accessibilityChannel
@UnstableApi
val accessibilityChannel: Int
The Accessibility channel, or NO_VALUE if not known or applicable.
auxiliaryTrackType
@UnstableApi
@C.AuxiliaryTrackType
val auxiliaryTrackType: Int
The auxiliary track type.
averageBitrate
@UnstableApi
val averageBitrate: Int
The average bitrate in bits per second, or NO_VALUE if unknown or not applicable. The way in which this field is populated depends on the type of media to which the format corresponds:
- DASH representations: Always
NO_VALUE. - HLS variants: The
AVERAGE-BANDWIDTHattribute defined on the correspondingEXT-X-STREAM-INFtag in the multivariant playlist, orNO_VALUEif not present. - SmoothStreaming track elements: The
Bitrateattribute defined on the correspondingTrackElementin the manifest, orNO_VALUEif not present. - Progressive container formats: Often
NO_VALUE, but may be populated with the average bitrate of the container if known. - Sample formats: Often
NO_VALUE, but may be populated with the average bitrate of the stream of samples with typesampleMimeTypeif known. Note that ifsampleMimeTypeis a compressed format (e.g.,AUDIO_AAC), then this bitrate is for the stream of still compressed samples.
bitrate
@UnstableApi
val bitrate: Int
The bitrate in bits per second. This is the peak bitrate if known, or else the average bitrate if known, or else NO_VALUE. Equivalent to: peakBitrate != NO_VALUE ?
peakBitrate : averageBitrate.
channelCount
val channelCount: Int
The number of audio channels, or NO_VALUE if unknown or not applicable.
codecs
val codecs: String?
Codecs of the format as described in RFC 6381, or null if unknown or not applicable.
colorInfo
@UnstableApi
val colorInfo: ColorInfo?
The color metadata associated with the video, or null if not applicable.
containerMimeType
val containerMimeType: String?
The MIME type of the container, or null if unknown or not applicable.
cryptoType
@UnstableApi
@C.CryptoType
val cryptoType: Int
The type of crypto that must be used to decode samples associated with this format, or CRYPTO_TYPE_NONE if the content is not encrypted. Cannot be CRYPTO_TYPE_NONE if drmInitData is non-null, but may be CRYPTO_TYPE_UNSUPPORTED to indicate that the samples are encrypted using an unsupported crypto type.
cueReplacementBehavior
@UnstableApi
@Format.CueReplacementBehavior
val cueReplacementBehavior: Int
The replacement behavior that should be followed when handling consecutive samples in a text track of type APPLICATION_MEDIA3_CUES.
customData
@UnstableApi
val customData: Any?
An extra opaque object that can be added to the Format to provide additional information that can be passed through the player.
This value is not included in serialized Bundle instances of this class that are used to transfer data to other processes.
decodedHeight
@UnstableApi
val decodedHeight: Int
The height of the video decoded picture in pixels, or NO_VALUE if unknown or not applicable.
May be larger than height if cropping is applied before display.
decodedWidth
@UnstableApi
val decodedWidth: Int
The width of the video decoded picture in pixels, or NO_VALUE if unknown or not applicable.
May be larger than width if cropping is applied before display.
drmInitData
@UnstableApi
val drmInitData: DrmInitData?
DRM initialization data if the stream is protected, or null otherwise.
encoderDelay
@UnstableApi
val encoderDelay: Int
The number of frames to trim from the start of the decoded audio stream, or 0 if not applicable.
encoderPadding
@UnstableApi
val encoderPadding: Int
The number of frames to trim from the end of the decoded audio stream, or 0 if not applicable.
frameRate
val frameRate: Float
The frame rate in frames per second, or NO_VALUE if unknown or not applicable.
hasPrerollSamples
@UnstableApi
val hasPrerollSamples: Boolean
Indicates whether the stream contains preroll samples.
When this field is set to true, it means that the stream includes decode-only samples that occur before the intended playback start position. These samples are necessary for decoding but are not meant to be rendered and should be skipped after decoding.
initializationData
@UnstableApi
val initializationData: (Mutable)List<ByteArray<Byte>!>!
Initialization data that must be provided to the decoder. Will not be null, but may be empty if initialization data is not required.
label
val label: String?
The default human readable label, or null if unknown or not applicable.
If non-null, the same label will be part of labels too. If null, labels will be empty.
labels
@UnstableApi
val labels: (Mutable)List<Label!>!
The human readable list of labels, or an empty list if unknown or not applicable.
If non-empty, the default label will be part of this list. If empty, the default label will be null.
language
val language: String?
The language as an IETF BCP 47 conformant tag, or null if unknown or not applicable.
maxInputSize
@UnstableApi
val maxInputSize: Int
The maximum size of a buffer of data (typically one sample), or NO_VALUE if unknown or not applicable.
maxNumReorderSamples
@UnstableApi
val maxNumReorderSamples: Int
The maximum number of samples that must be stored to correctly re-order samples from decode order to presentation order.
maxSubLayers
@UnstableApi
val maxSubLayers: Int
The maximum number of temporal scalable sub-layers in the video bitstream, or NO_VALUE if not applicable.
pcmEncoding
@UnstableApi
@C.PcmEncoding
val pcmEncoding: Int
The C.PcmEncoding for PCM or losslessly compressed audio. Set to NO_VALUE for other media types.
peakBitrate
@UnstableApi
val peakBitrate: Int
The peak bitrate in bits per second, or NO_VALUE if unknown or not applicable. The way in which this field is populated depends on the type of media to which the format corresponds:
- DASH representations: The
@bandwidthattribute of the correspondingRepresentationelement in the manifest. - HLS variants: The
BANDWIDTHattribute defined on the correspondingEXT-X-STREAM-INFtag. - SmoothStreaming track elements: Always
NO_VALUE. - Progressive container formats: Often
NO_VALUE, but may be populated with the peak bitrate of the container if known. - Sample formats: Often
NO_VALUE, but may be populated with the peak bitrate of the stream of samples with typesampleMimeTypeif known. Note that ifsampleMimeTypeis a compressed format (e.g.,AUDIO_AAC), then this bitrate is for the stream of still compressed samples.
pixelWidthHeightRatio
val pixelWidthHeightRatio: Float
The width to height ratio of pixels in the video, or 1.0 if unknown or not applicable.
projectionData
@UnstableApi
val projectionData: ByteArray<Byte>?
The projection data for 360/VR video, or null if not applicable.
rotationDegrees
@UnstableApi
val rotationDegrees: Int
The clockwise rotation that should be applied to the video for it to be rendered in the correct orientation, or 0 if unknown or not applicable. Only 0, 90, 180 and 270 are supported.
sampleMimeType
val sampleMimeType: String?
The sample MIME type, or null if unknown or not applicable.
sampleRate
val sampleRate: Int
The audio sampling rate in Hz, or NO_VALUE if unknown or not applicable.
stereoMode
@UnstableApi
@C.StereoMode
val stereoMode: Int
The stereo layout for 360/3D/VR video, or NO_VALUE if not applicable. Valid stereo modes are STEREO_MODE_MONO, STEREO_MODE_TOP_BOTTOM, STEREO_MODE_LEFT_RIGHT, STEREO_MODE_STEREO_MESH.
subsampleOffsetUs
@UnstableApi
val subsampleOffsetUs: Long
For samples that contain subsamples, this is an offset that should be added to subsample timestamps. A value of OFFSET_SAMPLE_RELATIVE indicates that subsample timestamps are relative to the timestamps of their parent samples.
tileCountHorizontal
@UnstableApi
val tileCountHorizontal: Int
The number of horizontal tiles in an image, or NO_VALUE if not known or applicable.
tileCountVertical
@UnstableApi
val tileCountVertical: Int
The number of vertical tiles in an image, or NO_VALUE if not known or applicable.