0

With MediaCodec API, i'm getting OutputBufferIndex as -1 everytime. Any possible solution?

outputBufferIndex = codec.dequeueOutputBuffer(info,outtimeout);
loginfo();
if (outputBufferIndex >= 0) 
{
    // outputBuffer is ready to be processed or rendered.
    codec.releaseOutputBuffer(outputBufferIndex, true);
} 
else if (outputBufferIndex == MediaCodec.INFO_OUTPUT_BUFFERS_CHANGED) 
{
    outputBuffers = codec.getOutputBuffers();
    Log.i(TAG, "op_buf_changed");
} 
else if (outputBufferIndex == MediaCodec.INFO_OUTPUT_FORMAT_CHANGED) 
{
    // Subsequent data will conform to new format.
    MediaFormat opmediaformat = codec.getOutputFormat();
    Log.i(TAG, "op_buf_format_changed");
}
else
{
    Log.i(TAG, "no_out_buffer");
}

Also I've got the same problem with inputbufferindex but by setting proper "TimeoutUs" value I got that solved. But in case of OutputBuffer it doesn't help.

jignesh
  • 182
  • 1
  • 12
  • can you provide more code on the parameters of the dequeueOutputBuffer – Calvin Feb 25 '13 at 06:56
  • Which parameters do u want? – jignesh Feb 25 '13 at 07:08
  • Which parameters do u want? private MediaCodec.BufferInfo info = new MediaCodec.BufferInfo(); and outtimeout = 1000; but with any value of outtime, it gives -1 index. – jignesh Feb 25 '13 at 07:16
  • looking at the sample code at http://developer.android.com/reference/android/media/MediaCodec.html#dequeueOutputBuffer(android.media.MediaCodec.BufferInfo, long) i want to know what and how the input for the codec is defined – Calvin Feb 25 '13 at 07:26
  • codec = MediaCodec.createDecoderByType("video/avc"); mediaformat = MediaFormat.createVideoFormat("video/avc", 640/*320*/, 480/*240*/); mediaformat.setInteger(MediaFormat.KEY_COLOR_FORMAT, MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420Planar); codec.configure(mediaformat,surface, null,0); the rest is as shown on developer site. – jignesh Feb 25 '13 at 07:31
  • Thank you for helping. I got the solution. There was problem with maximum buffer size of mediaformat. it works fine now. – jignesh Mar 06 '13 at 12:58

0 Answers0