当前位置: 首页>>代码示例>>Java>>正文


Java MediaCodecInfo.isEncoder方法代码示例

本文整理汇总了Java中android.media.MediaCodecInfo.isEncoder方法的典型用法代码示例。如果您正苦于以下问题:Java MediaCodecInfo.isEncoder方法的具体用法?Java MediaCodecInfo.isEncoder怎么用?Java MediaCodecInfo.isEncoder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.media.MediaCodecInfo的用法示例。


在下文中一共展示了MediaCodecInfo.isEncoder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: selectCodec

import android.media.MediaCodecInfo; //导入方法依赖的package包/类
/**
 * Returns the first codec capable of encoding the specified MIME type, or null if no match was
 * found.
 */
@TargetApi(18)
public static MediaCodecInfo selectCodec(String mimeType) {
    int numCodecs = MediaCodecList.getCodecCount();
    for (int i = 0; i < numCodecs; i++) {
        MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i);
        if (!codecInfo.isEncoder()) {
            continue;
        }
        String[] types = codecInfo.getSupportedTypes();
        for (int j = 0; j < types.length; j++) {
            if (types[j].equalsIgnoreCase(mimeType)) {
                return codecInfo;
            }
        }
    }
    return null;
}
 
开发者ID:wuyisheng,项目名称:libRtmp,代码行数:22,代码来源:AndroidUntil.java

示例2: printInfo

import android.media.MediaCodecInfo; //导入方法依赖的package包/类
@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,代码行数:17,代码来源:ScreenRecordActivity.java

示例3: selectAudioCodec

import android.media.MediaCodecInfo; //导入方法依赖的package包/类
private static MediaCodecInfo selectAudioCodec(final String mimeType) {
    // get the list of available codecs
    final int numCodecs = MediaCodecList.getCodecCount();
    for (int i = 0; i < numCodecs; i++) {
        final MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i);

        if (!codecInfo.isEncoder()) {    // skipp decoder
            continue;
        }
        final String[] types = codecInfo.getSupportedTypes();
        for (String type : types) {
            if (type.equalsIgnoreCase(mimeType)) {
                return codecInfo;
            }
        }
    }
    return null;
}
 
开发者ID:uestccokey,项目名称:EZFilter,代码行数:19,代码来源:MediaAudioEncoder.java

示例4: chooseVideoEncoder

import android.media.MediaCodecInfo; //导入方法依赖的package包/类
private MediaCodecInfo chooseVideoEncoder(String name) {
    int nbCodecs = MediaCodecList.getCodecCount();
    for (int i = 0; i < nbCodecs; i++) {
        MediaCodecInfo mci = MediaCodecList.getCodecInfoAt(i);
        if (!mci.isEncoder()) {
            continue;
        }

        String[] types = mci.getSupportedTypes();
        for (int j = 0; j < types.length; j++) {
            if (types[j].equalsIgnoreCase(VCODEC)) {
                Log.i(TAG, String.format("vencoder %s types: %s", mci.getName(), types[j]));
                if (name == null) {
                    return mci;
                }

                if (mci.getName().contains(name)) {
                    return mci;
                }
            }
        }
    }

    return null;
}
 
开发者ID:lisnstatic,项目名称:live_master,代码行数:26,代码来源:SrsEncoder.java

示例5: getAvailableEncoders

import android.media.MediaCodecInfo; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static List<String> getAvailableEncoders(int sampleRate) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        MediaFormat format = MediaFormatFactory.createMediaFormat(MediaFormatFactory.Type.FLAC, sampleRate);
        MediaCodecList mcl = new MediaCodecList(MediaCodecList.REGULAR_CODECS);
        String encoderAsStr = mcl.findEncoderForFormat(format);
        List<String> encoders = new ArrayList<>();
        for (MediaCodecInfo info : mcl.getCodecInfos()) {
            if (info.isEncoder()) {
                if (info.getName().equals(encoderAsStr)) {
                    encoders.add("*** " + info.getName() + ": " + TextUtils.join(", ", info.getSupportedTypes()));
                } else {
                    encoders.add(info.getName() + ": " + TextUtils.join(", ", info.getSupportedTypes()));
                }
            }
        }
        return encoders;
    }
    return Collections.emptyList();
}
 
开发者ID:vaibhavs4424,项目名称:AI-Powered-Intelligent-Banking-Platform,代码行数:21,代码来源:AudioUtils.java

示例6: FindHardWareEncoder21

import android.media.MediaCodecInfo; //导入方法依赖的package包/类
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,代码行数:27,代码来源:EncodeUtils.java

示例7: selectVideoCodec

import android.media.MediaCodecInfo; //导入方法依赖的package包/类
/**
 * select the first codec that match a specific MIME type
 * @param mimeType
 * @return null if no codec matched
 */
protected static final MediaCodecInfo selectVideoCodec(final String mimeType) {
	if (DEBUG) Log.v(TAG, "selectVideoCodec:");

	// get the list of available codecs
    final int numCodecs = MediaCodecList.getCodecCount();
    for (int i = 0; i < numCodecs; i++) {
    	final MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i);

        if (!codecInfo.isEncoder()) {	// skipp decoder
            continue;
        }
        // select first codec that match a specific MIME type and color format
        final String[] types = codecInfo.getSupportedTypes();
        for (int j = 0; j < types.length; j++) {
            if (types[j].equalsIgnoreCase(mimeType)) {
            	if (DEBUG) Log.i(TAG, "codec:" + codecInfo.getName() + ",MIME=" + types[j]);
        		final int format = selectColorFormat(codecInfo, mimeType);
            	if (format > 0) {
            		return codecInfo;
            	}
            }
        }
    }
    return null;
}
 
开发者ID:FacePlusPlus,项目名称:MegviiFacepp-Android-SDK,代码行数:31,代码来源:MediaVideoEncoder.java

示例8: selectVideoCodec

import android.media.MediaCodecInfo; //导入方法依赖的package包/类
private static MediaCodecInfo selectVideoCodec(final String mimeType) {
    // get the list of available codecs
    final int numCodecs = MediaCodecList.getCodecCount();
    for (int i = 0; i < numCodecs; i++) {
        final MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i);

        if (!codecInfo.isEncoder()) {    // skipp decoder
            continue;
        }
        // select first codec that match a specific MIME type and color format
        for (String type : codecInfo.getSupportedTypes()) {
            if (type.equalsIgnoreCase(mimeType)) {
                final int format = selectColorFormat(codecInfo, mimeType);
                if (format > 0) {
                    return codecInfo;
                }
            }
        }
    }
    return null;
}
 
开发者ID:uestccokey,项目名称:EZFilter,代码行数:22,代码来源:MediaVideoEncoder.java

示例9: selectAudioCodec

import android.media.MediaCodecInfo; //导入方法依赖的package包/类
/**
   * select the first codec that match a specific MIME type
   * @param mimeType
   * @return
   */
  private static final MediaCodecInfo selectAudioCodec(final String mimeType) {
  	if (DEBUG) Log.v(TAG, "selectAudioCodec:");

  	MediaCodecInfo result = null;
  	// get the list of available codecs
      final int numCodecs = MediaCodecList.getCodecCount();
for (int i = 0; i < numCodecs; i++) {
      	final MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i);
          if (!codecInfo.isEncoder()) {	// skipp decoder
              continue;
          }
          final String[] types = codecInfo.getSupportedTypes();
          for (int j = 0; j < types.length; j++) {
          	if (DEBUG) Log.i(TAG, "supportedType:" + codecInfo.getName() + ",MIME=" + types[j]);
              if (types[j].equalsIgnoreCase(mimeType)) {
              	if (result == null) {
              		result = codecInfo;
             			return result;
              	}
              }
          }
      }
 		return result;
  }
 
开发者ID:zhangyaqiang,项目名称:Fatigue-Detection,代码行数:30,代码来源:MediaAudioEncoder.java

示例10: selectVideoCodec

import android.media.MediaCodecInfo; //导入方法依赖的package包/类
/**
 * select the first codec that match a specific MIME type
 *
 * @param mimeType
 * @return null if no codec matched
 */
protected static final MediaCodecInfo selectVideoCodec(final String mimeType) {
    if (DEBUG) Log.v(TAG, "selectVideoCodec:");

    // get the list of available codecs
    final int numCodecs = MediaCodecList.getCodecCount();
    for (int i = 0; i < numCodecs; i++) {
        final MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i);

        if (!codecInfo.isEncoder()) {    // skipp decoder
            continue;
        }
        // select first codec that match a specific MIME type and color format
        final String[] types = codecInfo.getSupportedTypes();
        for (int j = 0; j < types.length; j++) {
            if (types[j].equalsIgnoreCase(mimeType)) {
                if (DEBUG) Log.i(TAG, "codec:" + codecInfo.getName() + ",MIME=" + types[j]);
                final int format = selectColorFormat(codecInfo, mimeType);
                if (format > 0) {
                    return codecInfo;
                }
            }
        }
    }
    return null;
}
 
开发者ID:vipycm,项目名称:mao-android,代码行数:32,代码来源:MediaVideoEncoder.java

示例11: selectCodec

import android.media.MediaCodecInfo; //导入方法依赖的package包/类
public static MediaCodecInfo selectCodec(String mimeType) {
    int numCodecs = MediaCodecList.getCodecCount();
    MediaCodecInfo lastCodecInfo = null;
    for (int i = 0; i < numCodecs; i++) {
        MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i);
        if (!codecInfo.isEncoder()) {
            continue;
        }
        String[] types = codecInfo.getSupportedTypes();
        for (String type : types) {
            if (type.equalsIgnoreCase(mimeType)) {
                lastCodecInfo = codecInfo;
                if (!lastCodecInfo.getName().equals("OMX.SEC.avc.enc")) {
                    return lastCodecInfo;
                } else if (lastCodecInfo.getName().equals("OMX.SEC.AVC.Encoder")) {
                    return lastCodecInfo;
                }
            }
        }
    }
    return lastCodecInfo;
}
 
开发者ID:fishwjy,项目名称:VideoCompressor,代码行数:23,代码来源:VideoController.java

示例12: findCodecForType

import android.media.MediaCodecInfo; //导入方法依赖的package包/类
private MediaCodecInfo findCodecForType(VideoCodecType type) {
  // HW decoding is not supported on builds before KITKAT.
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
    return null;
  }

  for (int i = 0; i < MediaCodecList.getCodecCount(); ++i) {
    MediaCodecInfo info = null;
    try {
      info = MediaCodecList.getCodecInfoAt(i);
    } catch (IllegalArgumentException e) {
      Logging.e(TAG, "Cannot retrieve encoder codec info", e);
    }

    if (info == null || info.isEncoder()) {
      continue;
    }

    if (isSupportedCodec(info, type)) {
      return info;
    }
  }
  return null; // No support for this type.
}
 
开发者ID:Piasy,项目名称:AppRTC-Android,代码行数:25,代码来源:HardwareVideoDecoderFactory.java

示例13: FindHardWareDecoder21

import android.media.MediaCodecInfo; //导入方法依赖的package包/类
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,代码行数:28,代码来源:HardwareDecoder.java

示例14: chooseVideoEncoder

import android.media.MediaCodecInfo; //导入方法依赖的package包/类
/**
 * choose the video encoder by mime. API < 21
 */
private MediaCodecInfo chooseVideoEncoder(String mime) {
  int count = MediaCodecList.getCodecCount();
  for (int i = 0; i < count; i++) {
    MediaCodecInfo mci = MediaCodecList.getCodecInfoAt(i);
    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

示例15: isCodecInfoSupported

import android.media.MediaCodecInfo; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
	private static boolean isCodecInfoSupported(MediaCodecInfo codecInfo, String codecType, boolean allowSwCodec) {
		if (codecInfo.isEncoder())
// || (!allowSwCodec && ( codecInfo.getName().startsWith("OMX.google") 
//                                                              || codecInfo.getName().toLowerCase().contains("sw") )))
			return false;

		String[] types = codecInfo.getSupportedTypes();
		for (String type : types) {
			if (type.equalsIgnoreCase(codecType))
				return true;
		}
		return false;
	}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:15,代码来源:CodecDiscovery.java


注:本文中的android.media.MediaCodecInfo.isEncoder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。