Q: Android MediaCodec decoding of raw h.264 I'm having a very difficult time with MediaCodc.  I've used it previously to decode a raw h.264 stream and learned a significant amount.  At least I thought I had.
My stream is h.264 in Annex B format.  Looking at the raw data, the structure of my NAL packet code types are as follows:
[0x09][0x09][0x06] and then 8 packets of [0x21].
[0x09][0x09][0x27][0x28][0x06] and then 8 packets of [0x21].

This is not how I am receiving them.  I am attempting to build a complete Access Unit from these raw NAL unit types.
First thing that is strange to me is the double [0x09] which is the Access Unit Delimiter packet.  I am pretty sure the h.264 document specifies only 1 AUD per Access Unit.  BTW, I am able to record the raw data and play it using ffmpeg with, and without, the extra AUD.  For now, I am detecting this message and stripping the first one off before sending the entire Access Unit to the MediaCodec.
Second thing is, I have hardcoded the SPS/PPS byte array messages [0x27/0x28] and I am setting these in the MediaFormat used to initialize the MediaCodec, similar to:
format.setByteBuffer("csd-0", ByteBuffer.wrap( mySPS ));
format.setByteBuffer("csd-1", ByteBuffer.wrap( myPPS ));

My video stream provider vendor tells me the video is 1280 x 720, however, when I convert it to an mp4 file, the metadata says its 960 x 720.  Another oddity.
Changing these different parameters around, I am still unable to get a valid buffer index in my Thread that processes the decoder output (dequeueOutputBuffer returns -1).  I have also varied the timeout for this to no avail.  If I manually set the SPS/PPS as the first packet NOT using the example above, I do get the -3 "output buffers have changed" which is meaningless since I am using API 20.  But everything else I get returned is -1.
I've read about the Emulation Prevention Byte encoding of h.264.  I am able to strip this byte out and send to the MediaCodec.  Doesn't seem to make a difference.  Also, the documentation for MediaCodec doesn't explicitly say if the code is expecting the EPB to be stripped out or not ... ?
Other than the video frame resolution, the only other thing that is different than my previous success is the existence of the SEI packet type [0x06].  I'm not sure if I should be doing something special with this or not?
I know there are a number of folks who have used MediaCodec have had issues with it, mostly because the documentation is not very good.  Can anyone offer any other advice as to what I could be doing wrong?
