Class EncoderUtil
- java.lang.Object
-
- com.google.android.exoplayer2.transformer.EncoderUtil
-
@Deprecated public final class EncoderUtil extends Object
Deprecated.com.google.android.exoplayer2 is deprecated. Please migrate to androidx.media3 (which contains the same ExoPlayer code). See the migration guide for more details, including a script to help with the migration.Utility methods forMediaCodec
encoders.
-
-
Field Summary
Fields Modifier and Type Field Description static int
LEVEL_UNSET
Deprecated.A value to indicate the encoding level is not set.
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static void
clearCachedEncoders()
Deprecated.Clears the cached list of encoders.static String
findCodecForFormat(MediaFormat format, boolean isDecoder)
Deprecated.static int
findHighestSupportedEncodingLevel(MediaCodecInfo encoderInfo, String mimeType, int profile)
Deprecated.Finds the highest supported encoding level given a profile.static ImmutableSet<Integer>
findSupportedEncodingProfiles(MediaCodecInfo encoderInfo, String mimeType)
Deprecated.static ImmutableList<Integer>
getCodecProfilesForHdrFormat(String mimeType, @com.google.android.exoplayer2.C.ColorTransfer int colorTransfer)
Deprecated.Returns the profile constants that can be used to encode the given HDR format, if supported by the device (this method does not check device capabilities).static int
getMaxSupportedInstances(MediaCodecInfo encoderInfo, String mimeType)
Deprecated.Returns the number of max number of the supported concurrent codec instances.static Range<Integer>
getSupportedBitrateRange(MediaCodecInfo encoderInfo, String mimeType)
Deprecated.Returns the range of supported bitrates for the given MIME type.static ImmutableList<Integer>
getSupportedColorFormats(MediaCodecInfo encoderInfo, String mimeType)
Deprecated.static ImmutableList<MediaCodecInfo>
getSupportedEncoders(String mimeType)
Deprecated.Returns a list of encoders that support the givenmimeType
, or an empty list if there is none.static ImmutableList<MediaCodecInfo>
getSupportedEncodersForHdrEditing(String mimeType, ColorInfo colorInfo)
Deprecated.Returns a list of encoders that support HDR editing for the givenmimeType
andColorInfo
, or an empty list if the format is unknown or not supported for HDR encoding.static Range<Integer>
getSupportedHeights(MediaCodecInfo encoderInfo, String mimeType, int width)
Deprecated.static ImmutableSet<String>
getSupportedMimeTypes()
Deprecated.Returns a list of MIME types that can be encoded.static Size
getSupportedResolution(MediaCodecInfo encoderInfo, String mimeType, int width, int height)
Deprecated.Finds an encoder's supported resolution from a given resolution.static Pair<Range<Integer>,Range<Integer>>
getSupportedResolutionRanges(MediaCodecInfo encoderInfo, String mimeType)
Deprecated.static boolean
isBitrateModeSupported(MediaCodecInfo encoderInfo, String mimeType, int bitrateMode)
Deprecated.Returns whether the bitrate mode is supported by the encoder.static boolean
isFeatureSupported(MediaCodecInfo encoderInfo, String mimeType, String featureName)
Deprecated.Returns whether a given feature is supported.static boolean
isHardwareAccelerated(MediaCodecInfo encoderInfo, String mimeType)
Deprecated.Checks if a codec is hardware-accelerated.static boolean
isSizeSupported(MediaCodecInfo encoderInfo, String mimeType, int width, int height)
Deprecated.Returns whether the encoder supports the given resolution.
-
-
-
Field Detail
-
LEVEL_UNSET
public static final int LEVEL_UNSET
Deprecated.A value to indicate the encoding level is not set.- See Also:
- Constant Field Values
-
-
Method Detail
-
getSupportedEncoders
public static ImmutableList<MediaCodecInfo> getSupportedEncoders(String mimeType)
Deprecated.Returns a list of encoders that support the givenmimeType
, or an empty list if there is none.
-
getSupportedMimeTypes
public static ImmutableSet<String> getSupportedMimeTypes()
Deprecated.Returns a list of MIME types that can be encoded.
-
clearCachedEncoders
public static void clearCachedEncoders()
Deprecated.Clears the cached list of encoders.
-
getSupportedEncodersForHdrEditing
public static ImmutableList<MediaCodecInfo> getSupportedEncodersForHdrEditing(String mimeType, @Nullable ColorInfo colorInfo)
Deprecated.Returns a list of encoders that support HDR editing for the givenmimeType
andColorInfo
, or an empty list if the format is unknown or not supported for HDR encoding.
-
getCodecProfilesForHdrFormat
public static ImmutableList<Integer> getCodecProfilesForHdrFormat(String mimeType, @com.google.android.exoplayer2.C.ColorTransfer int colorTransfer)
Deprecated.Returns the profile constants that can be used to encode the given HDR format, if supported by the device (this method does not check device capabilities). If multiple profiles are returned, they are ordered by expected level of compatibility, with the most widely compatible profile first.
-
isSizeSupported
public static boolean isSizeSupported(MediaCodecInfo encoderInfo, String mimeType, int width, int height)
Deprecated.Returns whether the encoder supports the given resolution.
-
getSupportedHeights
public static Range<Integer> getSupportedHeights(MediaCodecInfo encoderInfo, String mimeType, int width)
Deprecated.- Throws:
IllegalArgumentException
- When the width is not in the range of supported widths.
-
getSupportedResolutionRanges
public static Pair<Range<Integer>,Range<Integer>> getSupportedResolutionRanges(MediaCodecInfo encoderInfo, String mimeType)
Deprecated.
-
getSupportedResolution
@Nullable public static Size getSupportedResolution(MediaCodecInfo encoderInfo, String mimeType, int width, int height)
Deprecated.Finds an encoder's supported resolution from a given resolution.The input resolution is returned, if it (after aligning to the encoder's requirement) is supported by the encoder.
The resolution will be adjusted to be within the encoder's range of supported resolutions, and will be aligned to the encoder's alignment requirement. 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 supported resolution, or
null
if unable to find a fallback.
-
findSupportedEncodingProfiles
public static ImmutableSet<Integer> findSupportedEncodingProfiles(MediaCodecInfo encoderInfo, String mimeType)
Deprecated.
-
findHighestSupportedEncodingLevel
public static int findHighestSupportedEncodingLevel(MediaCodecInfo encoderInfo, String mimeType, int profile)
Deprecated.Finds the highest supported encoding level given a profile.- Parameters:
encoderInfo
- TheencoderInfo
.mimeType
- The MIME type.profile
- The encoding profile.- Returns:
- The highest supported encoding level, as documented in
MediaCodecInfo.CodecProfileLevel
, orLEVEL_UNSET
if the profile is not supported.
-
findCodecForFormat
@Nullable public static String findCodecForFormat(MediaFormat format, boolean isDecoder)
Deprecated.
-
getSupportedBitrateRange
public static Range<Integer> getSupportedBitrateRange(MediaCodecInfo encoderInfo, String mimeType)
Deprecated.Returns the range of supported bitrates for the given MIME type.
-
isBitrateModeSupported
public static boolean isBitrateModeSupported(MediaCodecInfo encoderInfo, String mimeType, int bitrateMode)
Deprecated.Returns whether the bitrate mode is supported by the encoder.
-
getSupportedColorFormats
public static ImmutableList<Integer> getSupportedColorFormats(MediaCodecInfo encoderInfo, String mimeType)
Deprecated.
-
isHardwareAccelerated
public static boolean isHardwareAccelerated(MediaCodecInfo encoderInfo, String mimeType)
Deprecated.Checks if a codec is hardware-accelerated.
-
isFeatureSupported
public static boolean isFeatureSupported(MediaCodecInfo encoderInfo, String mimeType, String featureName)
Deprecated.Returns whether a given feature is supported.
-
getMaxSupportedInstances
@RequiresApi(23) public static int getMaxSupportedInstances(MediaCodecInfo encoderInfo, String mimeType)
Deprecated.Returns the number of max number of the supported concurrent codec instances.
-
-