Java tutorial
//package com.java2s; public class Main { public static byte[] YV12toYUV420SemiPlanar(final byte[] input, final byte[] output, final int width, final int height) { /* * COLOR_FormatYUV420SemiPlanar is NV12 * We convert by putting the corresponding U and V bytes together (interleaved). */ final int frameSize = width * height; final int qFrameSize = frameSize / 4; System.arraycopy(input, 0, output, 0, frameSize); // Y for (int i = 0; i < qFrameSize; i++) { output[frameSize + i * 2] = input[frameSize + i + qFrameSize]; // Cb (U) output[frameSize + i * 2 + 1] = input[frameSize + i]; // Cr (V) } return output; } }