MediaCodec getInputImage return null on Some Devices : <p>I want to encode using MediaCodec by setting color format to <code>COLOR_FormatYUV420Flexible</code>.
My Input buffer's is yuv420p.When I input buffer like this :</p>

<pre><code>    int inputBufferIndex = mEncoder.dequeueInputBuffer(-1);
    mCurrentBufferIndex = inputBufferIndex;
    if (inputBufferIndex &gt;= 0) {
        ByteBuffer inputBuffer = inputBuffers[inputBufferIndex];
        //if(VERBOSE)
            Log.i(TAG,"pos:"+inputBuffer.position()+"\tlimit:"+inputBuffer.limit());
        inputBuffer.clear();
        return inputBuffer;
    }
</code></pre>

<p>But some devices get wrong color.
So I try this :</p>

<pre><code>    int inputBufferIndex = mEncoder.dequeueInputBuffer(-1);
    mCurrentBufferIndex = inputBufferIndex;
    if (inputBufferIndex &gt;= 0) {
        Image img = mEncoder.getInputImage(inputBufferIndex);
        if(img==null)
            return null;
        //mCurrentInputPlanes = img.getPlanes();
        ByteBuffer buffers[]={img.getPlanes()[0].getBuffer(),
                img.getPlanes()[1].getBuffer(),
                img.getPlanes()[2].getBuffer()};
</code></pre>

<p>I fill the buffer to YUV channels .It work on some devices. But moto X pro and huawei P7 get null when calling  getInputImage.
The documentation say the image doesn't contains raw data.
But it also mentions <code>COLOR_FormatYUV420Flexible</code> is supported since API 21.So how should I fix this.</p>
