I am trying to use Nexus to verify the encoding using the Mediacodec API. I see that the input buffers provided by the encoder are 119040 (by registering the input Buffers.capacity). But the frame size, that is, the input, is 460800. I received an error message inputBuffer.putwith buffer overflow. So I was going to set the input buffer to 460800. The API I could find is this BufferInfo.set. However, I cannot find a way to bind this parameter to the encoder. Can anyone help? Thank you !!!
inputBuffer.put
buffer overflow
BufferInfo.set
encoder = MediaCodec.createByCodecName(codecInfo.getName()); ByteBuffer[] inputBuffers = encoder.getInputBuffers(); if (inputBufferIndex >= 0) { ByteBuffer inputBuffer = inputBuffers[inputBufferIndex]; inputBuffer.clear(); inputBuffer.put(input); encoder.queueInputBuffer(inputBufferIndex, 0, input.length, 0, 0);}
, : Android MediaCodec , MAX_INPUT_SIZE, - :
int width=800; int height=480; encoder = MediaCodec.createByCodecName(codecInfo.getName()); format = MediaFormat.createVideoFormat ("video/avc", width, height); format.setInteger(MediaFormat.KEY_MAX_INPUT_SIZE,655360); // 0.5MB but adjust it as you need.
. MediaFormat, , , . , , .
MediaFormat
, . . - CTS EncodeDecodeTest. , , , , , , , , , , .
API 18 (Android 4.3), - API 16. , , - CTS API 18, , 4.3 .