android - decode h264 packets via mediaCodec dequeueInputBuffer() returns "no such buffer is currently available" -



android - decode h264 packets via mediaCodec dequeueInputBuffer() returns "no such buffer is currently available" -

i want decode datagram packets contains h264 video mediadecoder. (the packets sent rtsp server on rtp)

i suppose i'm doing wrong cause i'm getting -1 (that means no such buffer available) dequeueinputbuffer()

i'm searching days can't find suitable solution.

what mean of result? i'm doing wrong?

here code. please help me working.

private void decodevideo() { new thread(new runnable() { @override public void run() { mediacodec codec = mediacodec.createdecoderbytype("video/avc"); mediaformat mediaformat = mediaformat.createvideoformat( "video/avc", 640, 480); mediacodec.bufferinfo info = new mediacodec.bufferinfo(); codec.configure(mediaformat, mholder.getsurface(), null, 0); codec.start(); bytebuffer[] inputbuffers = codec.getinputbuffers(); bytebuffer[] outputbuffers = codec.getoutputbuffers(); while (flag) { int inputbufferindex = codec.dequeueinputbuffer(10000); if (inputbufferindex >= 0) { while (mpackets.size() <= 0) { seek { log.d(tag, "nopackets"); thread.sleep(1000); } grab (interruptedexception e) { e.printstacktrace(); } } log.d(tag, "now have packets!"); datagrampacket currentdatagram = mpackets.remove(); inputbuffers[inputbufferindex] = bytebuffer .wrap(currentdatagram.getdata()); codec.queueinputbuffer(inputbufferindex, 0, currentdatagram.getdata().length, 10000, 0); } int outputbufferindex = codec.dequeueoutputbuffer(info, 10000); if (outputbufferindex >= 0) { codec.releaseoutputbuffer(outputbufferindex, true); } else if (outputbufferindex == mediacodec.info_output_buffers_changed) { outputbuffers = codec.getoutputbuffers(); } else if (outputbufferindex == mediacodec.info_output_format_changed) { // subsequent info conform new format. mediaformat format = codec.getoutputformat(); } } codec.stop(); codec.release(); codec = null; } }).start(); }

thank giving time.

have tried changing timeout parameter?, -1 means infinite:

codec.dequeueinputbuffer(-1);

just in case input buffer availabe later. note timeout in microseconds.

android h.264 decoding mediacodec decoder

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -