public byte[] translate(byte[] buffer) {

			if (mOutputColorFormat == MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420Planar) {
				// FIXME: May be issues because of padding here :/
				int wh4 = bufferSize/6; //wh4 = width*height/4
				byte tmp;
				for (i=wh4*4; i<wh4*5; i++) {
					tmp = buffer[i];
					buffer[i] = buffer[i+wh4];
					buffer[i+wh4] = tmp;
				}
			}

			else if (mOutputColorFormat == MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420SemiPlanar) {
				// We need to interleave the U and V channel
				System.arraycopy(buffer, mYSize, tmp, 0, mUVSize*2); // Y
				for (i = 0; i < mUVSize; i++) {
					buffer[mYSize + i*2] = tmp[i + mUVSize]; // Cb (U)
					buffer[mYSize + i*2+1] = tmp[i]; // Cr (V)
				}
			}

			return buffer;
		}
Returns an associative array of the supported color formats and the names of the encoders for a given mime type
This can take up to sec on certain phones the first time you run it...
src/net/majorkernelpanic/streaming/video/CodecManager.java