MediaCodecInfo.VideoCapabilities

public static final class MediaCodecInfo.VideoCapabilities
extends Object

java.lang.Object
   ↳ android.media.MediaCodecInfo.VideoCapabilities


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

Summary

Nested classes

class MediaCodecInfo.VideoCapabilities.PerformancePoint

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

Public methods

boolean areSizeAndRateSupported(int width, int height, double frameRate)

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

Range<Double> getAchievableFrameRatesFor(int width, int height)

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

Range<Integer> getBitrateRange()

Returns the range of supported bitrates in bits/second.

int getHeightAlignment()

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

Range<Integer> getSupportedFrameRates()

Returns the range of supported frame rates.

Range<Double> getSupportedFrameRatesFor(int width, int height)

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

Range<Integer> getSupportedHeights()

Returns the range of supported video heights.

Range<Integer> getSupportedHeightsFor(int width)

Returns the range of supported video heights for a video width

List<MediaCodecInfo.VideoCapabilities.PerformancePoint> getSupportedPerformancePoints()

Returns the supported performance points.

Range<Integer> getSupportedWidths()

Returns the range of supported video widths.

Range<Integer> getSupportedWidthsFor(int height)

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

int getWidthAlignment()

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

boolean isSizeSupported(int width, int height)

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

Inherited methods

Public methods

areSizeAndRateSupported

Added in API level 21
public boolean areSizeAndRateSupported (int width, 
                int height, 
                double frameRate)

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

Parameters
width int

height int

frameRate double

Returns
boolean

getAchievableFrameRatesFor

Added in API level 23
public Range<Double> getAchievableFrameRatesFor (int width, 
                int height)

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 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 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

Returns
Range<Double>

Throws
IllegalArgumentException if the video size is not supported.

getBitrateRange

Added in API level 21
public Range<Integer> getBitrateRange ()

Returns the range of supported bitrates in bits/second.

Returns
Range<Integer>

getHeightAlignment

Added in API level 21
public int getHeightAlignment ()

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

Returns
int

getSupportedFrameRates

Added in API level 21
public Range<Integer> getSupportedFrameRates ()

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.

Returns
Range<Integer>

getSupportedFrameRatesFor

Added in API level 21
public Range<Double> getSupportedFrameRatesFor (int width, 
                int height)

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

Returns
Range<Double>

getSupportedHeights

Added in API level 21
public Range<Integer> getSupportedHeights ()

Returns the range of supported video heights.

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

Returns
Range<Integer>

getSupportedHeightsFor

Added in API level 21
public Range<Integer> getSupportedHeightsFor (int width)

Returns the range of supported video heights for a video width

Parameters
width int: the width of the video

Returns
Range<Integer>

getSupportedPerformancePoints

Added in API level 29
public List<MediaCodecInfo.VideoCapabilities.PerformancePoint> getSupportedPerformancePoints ()

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.

Returns
List<MediaCodecInfo.VideoCapabilities.PerformancePoint>

getSupportedWidths

Added in API level 21
public Range<Integer> getSupportedWidths ()

Returns the range of supported video widths.

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

Returns
Range<Integer>

getSupportedWidthsFor

Added in API level 21
public Range<Integer> getSupportedWidthsFor (int height)

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

Parameters
height int: the height of the video

Returns
Range<Integer>

getWidthAlignment

Added in API level 21
public int getWidthAlignment ()

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

Returns
int

isSizeSupported

Added in API level 21
public boolean isSizeSupported (int width, 
                int height)

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

Parameters
width int

height int

Returns
boolean