Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.graphics.ImageFormat;

import android.media.MediaCodecInfo;

import android.os.Build;

public class Main {
    public static int getEncoderColorFormat(int previewFormat) {
        if (Build.VERSION.SDK_INT >= 21) {
            return MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420Flexible;
        }
        switch (previewFormat) {
        case ImageFormat.NV21:
            return MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420SemiPlanar;
        case ImageFormat.YV12:
            return MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420Planar;
        }
        return -1;
    }
}