MediaCodec
doesn't put the ByteBuffer
in the correct position. You need to position it manually after the call to dequeueOutputBuffer()
:
int encoderStatus = encoder.dequeueOutputBuffer(info, TIMEOUT_USEC);
...
ByteBuffer encodedData = encoderOutputBuffers[encoderStatus];
encodedData.position(info.offset);
encodedData.limit(info.offset + info.size);
(See EncodeDecodeTest.) That's not the same as rewind()
, though I'm a little surprised that didn't work -- I would have expected that output would usually start at the beginning of the buffer.
There are some known issues with VP8 on Android 4.3, though you don't seem to be hitting those.
If this does not fix your issue, it would be helpful to know the device you're using (S3 for both Android and Cyanogen?), the Android software version, to see the code you're using to configure()
the MediaCodec
, and what values are used.