本文整理匯總了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());
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例5: MediaCodecListCompatV21
public MediaCodecListCompatV21(boolean includeSecure) {
codecKind = includeSecure ? MediaCodecList.ALL_CODECS : MediaCodecList.REGULAR_CODECS;
}
示例6: MediaCodecListCompatV21
public MediaCodecListCompatV21(boolean includeSecure) {
codecKind = includeSecure ? MediaCodecList.ALL_CODECS : MediaCodecList.REGULAR_CODECS;
}
示例7: MediaCodecListCompatV21
public MediaCodecListCompatV21(boolean includeSecure) {
int codecKind = includeSecure ? MediaCodecList.ALL_CODECS : MediaCodecList.REGULAR_CODECS;
mediaCodecInfos = new MediaCodecList(codecKind).getCodecInfos();
}
示例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;
}