Java Code Examples for android.media.MediaCodec#getCodecInfo()
The following examples show how to use
android.media.MediaCodec#getCodecInfo() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VideoUtil.java From VideoProcessor with Apache License 2.0 | 6 votes |
public static boolean trySetProfileAndLevel(MediaCodec codec, String mime, MediaFormat format, int profileInt, int levelInt) { MediaCodecInfo codecInfo = codec.getCodecInfo(); MediaCodecInfo.CodecCapabilities capabilities = codecInfo.getCapabilitiesForType(mime); MediaCodecInfo.CodecProfileLevel[] profileLevels = capabilities.profileLevels; if (profileLevels == null) { return false; } for (MediaCodecInfo.CodecProfileLevel level : profileLevels) { if (level.profile == profileInt) { if (level.level == levelInt) { format.setInteger(MediaFormat.KEY_PROFILE, profileInt); format.setInteger(MediaFormat.KEY_LEVEL, levelInt); return true; } } } return false; }
Example 2
Source File: MediaCodecUtil.java From 365browser with Apache License 2.0 | 6 votes |
/** * Returns true if the given codec supports adaptive playback (dynamic resolution change). * @param mediaCodec the codec. * @param mime MIME type that corresponds to the codec creation. * @return true if this codec and mime type combination supports adaptive playback. */ @TargetApi(Build.VERSION_CODES.KITKAT) private static boolean codecSupportsAdaptivePlayback(MediaCodec mediaCodec, String mime) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT || mediaCodec == null) { return false; } try { MediaCodecInfo info = mediaCodec.getCodecInfo(); if (info.isEncoder()) { return false; } if (isAdaptivePlaybackBlacklisted(mime)) { return false; } MediaCodecInfo.CodecCapabilities capabilities = info.getCapabilitiesForType(mime); return (capabilities != null) && capabilities.isFeatureSupported( MediaCodecInfo.CodecCapabilities.FEATURE_AdaptivePlayback); } catch (IllegalArgumentException e) { Log.e(TAG, "Cannot retrieve codec information", e); } return false; }
Example 3
Source File: VideoUtil.java From VideoProcessor with Apache License 2.0 | 5 votes |
public static int getMaxSupportBitrate(MediaCodec codec, String mime) { try { MediaCodecInfo codecInfo = codec.getCodecInfo(); MediaCodecInfo.CodecCapabilities capabilities = codecInfo.getCapabilitiesForType(mime); Integer maxBitrate = capabilities.getVideoCapabilities().getBitrateRange().getUpper(); return maxBitrate; } catch (Exception e) { CL.e(e); return -1; } }