Class EncoderUtil
- java.lang.Object
-
- com.google.android.exoplayer2.transformer.EncoderUtil
-
public final class EncoderUtil extends Object
Utility methods forMediaCodec
encoders.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
getClosestSupportedBitrate(MediaCodecInfo encoderInfo, String mimeType, int bitrate)
Finds theencoder
's closest supported bitrate from the given bitrate.static Pair<Integer,Integer>
getClosestSupportedResolution(MediaCodecInfo encoderInfo, String mimeType, int width, int height)
Finds theencoder
's closest supported resolution from the given resolution.static ImmutableList<MediaCodecInfo>
getSupportedEncoders(String mimeType)
Returns a list ofencoders
that support the givenmimeType
, or an empty list if there is none.static boolean
isProfileLevelSupported(MediaCodecInfo encoderInfo, String mimeType, int profile, int level)
Returns whether theencoder
supports the given profile and level.
-
-
-
Method Detail
-
getSupportedEncoders
public static ImmutableList<MediaCodecInfo> getSupportedEncoders(String mimeType)
Returns a list ofencoders
that support the givenmimeType
, or an empty list if there is none.
-
getClosestSupportedResolution
@Nullable public static Pair<Integer,Integer> getClosestSupportedResolution(MediaCodecInfo encoderInfo, String mimeType, int width, int height)
Finds theencoder
's closest supported resolution from the given resolution.The input resolution is returned, if it is supported by the
encoder
.The resolution will be clamped to the
encoder
's range of supported resolutions, and adjusted to theencoder
's size alignment. The adjustment process takes into account the original aspect ratio. But the fixed resolution may not preserve the original aspect ratio, depending on the encoder's required size alignment.- Parameters:
encoderInfo
- TheMediaCodecInfo
of the encoder.mimeType
- The output MIME type.width
- The original width.height
- The original height.- Returns:
- A
Pair
of width and height, ornull
if unable to find a fix.
-
isProfileLevelSupported
public static boolean isProfileLevelSupported(MediaCodecInfo encoderInfo, String mimeType, int profile, int level)
Returns whether theencoder
supports the given profile and level.
-
getClosestSupportedBitrate
public static int getClosestSupportedBitrate(MediaCodecInfo encoderInfo, String mimeType, int bitrate)
Finds theencoder
's closest supported bitrate from the given bitrate.
-
-