當前位置: 首頁>>代碼示例>>Java>>正文


Java MediaCodecInfo.CodecProfileLevel方法代碼示例

本文整理匯總了Java中android.media.MediaCodecInfo.CodecProfileLevel方法的典型用法代碼示例。如果您正苦於以下問題:Java MediaCodecInfo.CodecProfileLevel方法的具體用法?Java MediaCodecInfo.CodecProfileLevel怎麽用?Java MediaCodecInfo.CodecProfileLevel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.media.MediaCodecInfo的用法示例。


在下文中一共展示了MediaCodecInfo.CodecProfileLevel方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: chooseVideoEncoder

import android.media.MediaCodecInfo; //導入方法依賴的package包/類
private int chooseVideoEncoder() {
    // choose the encoder "video/avc":
    //      1. select default one when type matched.
    //      2. google avc is unusable.
    //      3. choose qcom avc.
    vmci = chooseVideoEncoder(null);
    //vmci = chooseVideoEncoder("google");
    //vmci = chooseVideoEncoder("qcom");

    int matchedColorFormat = 0;
    MediaCodecInfo.CodecCapabilities cc = vmci.getCapabilitiesForType(VCODEC);
    for (int i = 0; i < cc.colorFormats.length; i++) {
        int cf = cc.colorFormats[i];
        Log.i(TAG, String.format("vencoder %s supports color fomart 0x%x(%d)", vmci.getName(), cf, cf));

        // choose YUV for h.264, prefer the bigger one.
        // corresponding to the color space transform in onPreviewFrame
        if (cf >= cc.COLOR_FormatYUV420Planar && cf <= cc.COLOR_FormatYUV420SemiPlanar) {
            if (cf > matchedColorFormat) {
                matchedColorFormat = cf;
            }
        }
    }

    for (int i = 0; i < cc.profileLevels.length; i++) {
        MediaCodecInfo.CodecProfileLevel pl = cc.profileLevels[i];
        Log.i(TAG, String.format("vencoder %s support profile %d, level %d", vmci.getName(), pl.profile, pl.level));
    }

    Log.i(TAG, String.format("vencoder %s choose color format 0x%x(%d)", vmci.getName(), matchedColorFormat, matchedColorFormat));
    return matchedColorFormat;
}
 
開發者ID:lisnstatic,項目名稱:live_master,代碼行數:33,代碼來源:SrsEncoder.java

示例2: getEncodVieoeCapability

import android.media.MediaCodecInfo; //導入方法依賴的package包/類
public static EncodeVideoCapability getEncodVieoeCapability(MediaCodec mediaCodec, String mime)
    {
        if( mediaCodec == null || Build.VERSION.SDK_INT < 18) {
            return null;
        }

        EncodeVideoCapability retCapability = new EncodeVideoCapability();
        //String mime = mEncodeFormat.getValue();
        MediaCodecInfo codecInfo = mediaCodec.getCodecInfo();
        MediaCodecInfo.CodecCapabilities capabilities = codecInfo.getCapabilitiesForType(mime);
        int[] deviceColor = capabilities.colorFormats;
        retCapability.colorFormat = deviceColor;
        MediaCodecInfo.CodecProfileLevel[] profileLevels = capabilities.profileLevels;

        if(null != profileLevels)
        {
            retCapability.profileLevel = new EncodeVideoCapability.ProfileLevel[profileLevels.length];
            for(int i = 0; i < profileLevels.length; ++i)
            {
                retCapability.profileLevel[i] = new EncodeVideoCapability.ProfileLevel(profileLevels[i].profile, profileLevels[i].level);
            }
        }


        Range<Integer> widthRange = null;
        Range<Integer> heightRange = null;
        if(Build.VERSION.SDK_INT >= 21) {
                MediaCodecInfo.VideoCapabilities videoCapabilities = capabilities.getVideoCapabilities();
                heightRange = videoCapabilities.getSupportedHeights();
                widthRange = videoCapabilities.getSupportedWidths();

                retCapability.heightAlignment = videoCapabilities.getHeightAlignment();
                retCapability.widthAlignment  = videoCapabilities.getWidthAlignment();
        }
        else //for old device limite max width / height
        {
//            retCapability.widthUpper = 1280;
//            retCapability.widthLower = 176;
//            retCapability.heightUpper = 720;
//            retCapability.heightLower = 144;

            retCapability.heightAlignment = 2;
            retCapability.widthAlignment = 2;
        }

        if(null != widthRange)
        {
            retCapability.widthUpper = widthRange.getUpper();
            retCapability.widthLower = widthRange.getLower();
        }

        if(null != heightRange)
        {
            retCapability.heightUpper = heightRange.getUpper();
            retCapability.heightLower = heightRange.getLower();
        }

        return retCapability;
    }
 
開發者ID:lzmlsfe,項目名稱:19porn,代碼行數:60,代碼來源:EncodeUtils.java

示例3: VideoEncodeParam

import android.media.MediaCodecInfo; //導入方法依賴的package包/類
public VideoEncodeParam(MediaCodecInfo.CodecProfileLevel codecProfileLevel, Range<Integer> widthRange, Range<Integer> heightRanger) {
    this.codecProfileLevel = codecProfileLevel;
    this.widthRange = widthRange;
    this.heightRanger = heightRanger;
}
 
開發者ID:lzmlsfe,項目名稱:19porn,代碼行數:6,代碼來源:VideoEncoder.java


注:本文中的android.media.MediaCodecInfo.CodecProfileLevel方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。