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


Java MediaCodecList.ALL_CODECS屬性代碼示例

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


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

示例1: printInfo

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private void printInfo() {
	MediaCodecList list = new MediaCodecList(MediaCodecList.ALL_CODECS);
	MediaCodecInfo[] codecInfos = list.getCodecInfos();
	for (MediaCodecInfo info : codecInfos) {
		if (info.isEncoder()) {
			StringBuilder sb = new StringBuilder();
			sb.append(info.getName() + " types=");
			String[] supportedTypes = info.getSupportedTypes();
			for (String string : supportedTypes) {
				sb.append(" " + string);
			}
			LogUtil.e(sb.toString());
		}
	}
}
 
開發者ID:FreeSunny,項目名稱:Amazing,代碼行數:16,代碼來源:ScreenRecordActivity.java

示例2: FindHardWareEncoder21

private static String FindHardWareEncoder21(String mime) {

        MediaCodecList mediaCodecList = new MediaCodecList(MediaCodecList.ALL_CODECS);
        MediaCodecInfo[] mediaCodecInfos = mediaCodecList.getCodecInfos();

        for (int i = 0; i < mediaCodecInfos.length; i++) {
            MediaCodecInfo mediaCodecInfo = mediaCodecInfos[i];
            if (!mediaCodecInfo.isEncoder()) {
                continue;
            }

            String types[] = mediaCodecInfo.getSupportedTypes();
            for (int j = 0; j < types.length; j++) {
                if (types[j].equalsIgnoreCase(mime)) {
                    String decoderName = mediaCodecInfo.getName();
                    Log.e(TAG, "hwDecoderName = " + decoderName);
                    boolean isHardwareEncode = (decoderName.indexOf("google") == -1);
                    if (isHardwareEncode) {
                        return decoderName;
                    }
                }
            }
        }

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

示例3: FindHardWareDecoder21

public int FindHardWareDecoder21(){
    String mimeType = mAVCodeIDToMime.get(mCodeId);
    Log.e(TAG, "mimeType = " + mimeType + "codeid = " + mCodeId);

    MediaCodecList mediaCodecList = new MediaCodecList(MediaCodecList.ALL_CODECS);
    MediaCodecInfo[] mediaCodecInfos =  mediaCodecList.getCodecInfos();
    
    for (int i = 0;i < mediaCodecInfos.length;i++){
        MediaCodecInfo mediaCodecInfo = mediaCodecInfos[i];
        if(mediaCodecInfo.isEncoder()){
            continue;
        }

        String types[] = mediaCodecInfo.getSupportedTypes();
        for (int j = 0;j < types.length;j++){
            if (types[j].equalsIgnoreCase(mimeType)){
                String decoderName = mediaCodecInfo.getName();
                Log.e(TAG,"hwDecoderName = " + decoderName);
                if(decoderName.indexOf("google") == -1){
                	mHWDecoderName = decoderName;
                	return 1;
                }
            }
        }
    }
    return  0;
}
 
開發者ID:lzmlsfe,項目名稱:19porn,代碼行數:27,代碼來源:HardwareDecoder.java

示例4: chooseVideoEncoderAPI21

/**
 * choose the video encoder by mime. API 21+
 */
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private MediaCodecInfo chooseVideoEncoderAPI21(String mime) {
  MediaCodecList mediaCodecList = new MediaCodecList(MediaCodecList.ALL_CODECS);
  MediaCodecInfo[] mediaCodecInfos = mediaCodecList.getCodecInfos();
  for (MediaCodecInfo mci : mediaCodecInfos) {
    if (!mci.isEncoder()) {
      continue;
    }
    String[] types = mci.getSupportedTypes();
    for (String type : types) {
      if (type.equalsIgnoreCase(mime)) {
        Log.i(TAG, String.format("videoEncoder %s type supported: %s", mci.getName(), type));
        MediaCodecInfo.CodecCapabilities codecCapabilities = mci.getCapabilitiesForType(mime);
        for (int color : codecCapabilities.colorFormats) {
          Log.i(TAG, "Color supported: " + color);
          //check if encoder support any yuv420 color
          if (color == FormatVideoEncoder.YUV420PLANAR.getFormatCodec()
              || color == FormatVideoEncoder.YUV420SEMIPLANAR.getFormatCodec()
              || color == FormatVideoEncoder.YUV420PACKEDPLANAR.getFormatCodec()) {
            return mci;
          }
        }
      }
    }
  }
  return null;
}
 
開發者ID:pedroSG94,項目名稱:rtmp-rtsp-stream-client-java,代碼行數:30,代碼來源:VideoEncoder.java

示例5: MediaCodecListCompatV21

public MediaCodecListCompatV21(boolean includeSecure) {
  codecKind = includeSecure ? MediaCodecList.ALL_CODECS : MediaCodecList.REGULAR_CODECS;
}
 
開發者ID:MLNO,項目名稱:airgram,代碼行數:3,代碼來源:MediaCodecUtil.java

示例6: MediaCodecListCompatV21

public MediaCodecListCompatV21(boolean includeSecure) {
    codecKind = includeSecure ? MediaCodecList.ALL_CODECS : MediaCodecList.REGULAR_CODECS;
}
 
開發者ID:trevd,項目名稱:android_packages_apps_tv,代碼行數:3,代碼來源:MediaSoftwareCodecUtil.java

示例7: MediaCodecListCompatV21

public MediaCodecListCompatV21(boolean includeSecure) {
  int codecKind = includeSecure ? MediaCodecList.ALL_CODECS : MediaCodecList.REGULAR_CODECS;
  mediaCodecInfos = new MediaCodecList(codecKind).getCodecInfos();
}
 
開發者ID:Weco,項目名稱:android-exoplayer,代碼行數:4,代碼來源:MediaCodecUtil.java

示例8: prepareEncoder

/**
 * Configures encoder and muxer state, and prepares the input Surface.  Initializes
 * mEncoder, mMuxer, mInputSurface, mBufferInfo, mTrackIndex, and mMuxerStarted.
 */
private void prepareEncoder(int width, int height, int bitRate) throws IOException {
    mBufferInfo = new MediaCodec.BufferInfo();

    MediaFormat format = MediaFormat.createVideoFormat(MIME_TYPE, width, height);

    // Create a MediaCodec encoder, and configure it with our format.  Get a Surface
    // we can use for input and wrap it with a class that handles the EGL work.
    //
    // If you want to have two EGL contexts -- one for display, one for recording --
    // you will likely want to defer instantiation of CodecInputSurface until after the
    // "display" EGL context is created, then modify the eglCreateContext call to
    // take eglGetCurrentContext() as the share_context argument.
    MediaCodecList mediaCodecList = new MediaCodecList(MediaCodecList.ALL_CODECS);
    //mEncoder = MediaCodec.createEncoderByType(MIME_TYPE);
    String codeName = mediaCodecList.findEncoderForFormat(format);
    mEncoder = MediaCodec.createByCodecName(codeName);

    // Set some properties.  Failing to specify some of these can cause the MediaCodec
    // configure() call to throw an unhelpful exception.
    //format.setFeatureEnabled(MediaFormat.KEY_COLOR_FORMAT, true);
    format.setInteger(MediaFormat.KEY_COLOR_FORMAT, MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface);
    //format.setFeatureEnabled(MediaFormat.KEY_BIT_RATE, true);
    format.setInteger(MediaFormat.KEY_BIT_RATE, bitRate);
    //format.setFeatureEnabled(MediaFormat.KEY_FRAME_RATE, true);
    format.setInteger(MediaFormat.KEY_FRAME_RATE, FRAME_RATE);
    //format.setFeatureEnabled(MediaFormat.KEY_I_FRAME_INTERVAL, true);
    format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, IFRAME_INTERVAL);
    if (VERBOSE) {
        Log.d(TAG, "format: " + format);
    }

    mEncoder.configure(format, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
    mInputSurface = new CodecInputSurface(mEncoder.createInputSurface());
    //mEncoder.start();

    // Output filename.  Ideally this would use Context.getFilesDir() rather than a
    // hard-coded output directory.
    String outputPath = new File(OUTPUT_DIR, "test." + width + "x" + height + ".mp4").toString();
    Log.i(TAG, "Output file is " + outputPath);

    // Create a MediaMuxer.  We can't add the video track and start() the muxer here,
    // because our MediaFormat doesn't have the Magic Goodies.  These can only be
    // obtained from the encoder after it has started processing data.
    //
    // We're not actually interested in multiplexing audio.  We just want to convert
    // the raw H.264 elementary stream we get from MediaCodec into a .mp4 file.
    try {
        mMuxer = new MediaMuxer(outputPath, MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4);
    } catch (IOException ioe) {
        throw new RuntimeException("MediaMuxer creation failed", ioe);
    }

    mTrackIndex = -1;
    mMuxerStarted = false;
}
 
開發者ID:xu6148152,項目名稱:binea_project_for_android,代碼行數:59,代碼來源:CameraToMpegTest.java


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