Added in API level 21

VideoCapabilities


class VideoCapabilities
kotlin.Any
   ↳ android.media.MediaCodecInfo.VideoCapabilities

A class that supports querying the video capabilities of a codec.

Summary

Nested classes

Video performance points are a set of standard performance points defined by number of pixels, pixel rate and frame rate.

Public methods
Boolean
areSizeAndRateSupported(width: Int, height: Int, frameRate: Double)

Returns whether a given video size (width and height) and frameRate combination is supported.

Range<Double!>?

Returns the range of achievable video frame rates for a video size.

Range<Int!>!

Returns the range of supported bitrates in bits/second.

Int

Returns the alignment requirement for video height (in pixels).

Range<Int!>!

Returns the range of supported frame rates.

Range<Double!>!
getSupportedFrameRatesFor(width: Int, height: Int)

Returns the range of supported video frame rates for a video size.

Range<Int!>!

Returns the range of supported video heights.

Range<Int!>!

Returns the range of supported video heights for a video width

MutableList<MediaCodecInfo.VideoCapabilities.PerformancePoint!>?

Returns the supported performance points.

Range<Int!>!

Returns the range of supported video widths.

Range<Int!>!

Returns the range of supported video widths for a video height.

Int

Returns the alignment requirement for video width (in pixels).

Boolean
isSizeSupported(width: Int, height: Int)

Returns whether a given video size (width and height) is supported.

Public methods

areSizeAndRateSupported

Added in API level 21
fun areSizeAndRateSupported(
    width: Int,
    height: Int,
    frameRate: Double
): Boolean

Returns whether a given video size (width and height) and frameRate combination is supported.

getAchievableFrameRatesFor

Added in API level 23
fun getAchievableFrameRatesFor(
    width: Int,
    height: Int
): Range<Double!>?

Returns the range of achievable video frame rates for a video size. May return null, if the codec did not publish any measurement data.

This is a performance estimate provided by the device manufacturer based on statistical sampling of full-speed decoding and encoding measurements in various configurations of common video sizes supported by the codec. As such it should only be used to compare individual codecs on the device. The value is not suitable for comparing different devices or even different android releases for the same device.

On android.os.Build.VERSION_CODES#M release the returned range corresponds to the fastest frame rates achieved in the tested configurations. As such, it should not be used to gauge guaranteed or even average codec performance on the device.

On android.os.Build.VERSION_CODES#N release the returned range corresponds closer to sustained performance in tested configurations. One can expect to achieve sustained performance higher than the lower limit more than 50% of the time, and higher than half of the lower limit at least 90% of the time in tested configurations. Conversely, one can expect performance lower than twice the upper limit at least 90% of the time.

Tested configurations use a single active codec. For use cases where multiple codecs are active, applications can expect lower and in most cases significantly lower performance.

The returned range value is interpolated from the nearest frame size(s) tested. Codec performance is severely impacted by other activity on the device as well as environmental factors (such as battery level, temperature or power source), and can vary significantly even in a steady environment.

Use this method in cases where only codec performance matters, e.g. to evaluate if a codec has any chance of meeting a performance target. Codecs are listed in MediaCodecList in the preferred order as defined by the device manufacturer. As such, applications should use the first suitable codec in the list to achieve the best balance between power use and performance.

Parameters
width Int: the width of the video
height Int: the height of the video
Exceptions
java.lang.IllegalArgumentException if the video size is not supported.

getBitrateRange

Added in API level 21
fun getBitrateRange(): Range<Int!>!

Returns the range of supported bitrates in bits/second.

getHeightAlignment

Added in API level 21
fun getHeightAlignment(): Int

Returns the alignment requirement for video height (in pixels). This is a power-of-2 value that video height must be a multiple of.

getSupportedFrameRates

Added in API level 21
fun getSupportedFrameRates(): Range<Int!>!

Returns the range of supported frame rates.

This is not a performance indicator. Rather, it expresses the limits specified in the coding standard, based on the complexities of encoding material for later playback at a certain frame rate, or the decoding of such material in non-realtime.

getSupportedFrameRatesFor

Added in API level 21
fun getSupportedFrameRatesFor(
    width: Int,
    height: Int
): Range<Double!>!

Returns the range of supported video frame rates for a video size.

This is not a performance indicator. Rather, it expresses the limits specified in the coding standard, based on the complexities of encoding material of a given size for later playback at a certain frame rate, or the decoding of such material in non-realtime.

Parameters
width Int: the width of the video
height Int: the height of the video

getSupportedHeights

Added in API level 21
fun getSupportedHeights(): Range<Int!>!

Returns the range of supported video heights.

32-bit processes will not support resolutions larger than 4096x4096 due to the limited address space.

getSupportedHeightsFor

Added in API level 21
fun getSupportedHeightsFor(width: Int): Range<Int!>!

Returns the range of supported video heights for a video width

Parameters
width Int: the width of the video

getSupportedPerformancePoints

Added in API level 29
fun getSupportedPerformancePoints(): MutableList<MediaCodecInfo.VideoCapabilities.PerformancePoint!>?

Returns the supported performance points. May return null if the codec did not publish any performance point information (e.g. the vendor codecs have not been updated to the latest android release). May return an empty list if the codec published that if does not guarantee any performance points.

This is a performance guarantee provided by the device manufacturer for hardware codecs based on hardware capabilities of the device.

The returned list is sorted first by decreasing number of pixels, then by decreasing width, and finally by decreasing frame rate. Performance points assume a single active codec. For use cases where multiple codecs are active, should use that highest pixel count, and add the frame rates of each individual codec.

32-bit processes will not support resolutions larger than 4096x4096 due to the limited address space, but performance points will be presented as is. In other words, even though a component publishes a performance point for a resolution higher than 4096x4096, it does not mean that the resolution is supported for 32-bit processes.

getSupportedWidths

Added in API level 21
fun getSupportedWidths(): Range<Int!>!

Returns the range of supported video widths.

32-bit processes will not support resolutions larger than 4096x4096 due to the limited address space.

getSupportedWidthsFor

Added in API level 21
fun getSupportedWidthsFor(height: Int): Range<Int!>!

Returns the range of supported video widths for a video height.

Parameters
height Int: the height of the video

getWidthAlignment

Added in API level 21
fun getWidthAlignment(): Int

Returns the alignment requirement for video width (in pixels). This is a power-of-2 value that video width must be a multiple of.

isSizeSupported

Added in API level 21
fun isSizeSupported(
    width: Int,
    height: Int
): Boolean

Returns whether a given video size (width and height) is supported.