title: Android MediaCodec for HEVC
body: <p>I'm looking into using the android MediaCodec class to decode HEVC. Are there any examples of projects that do this?</p>
  
  <p>At present I configure the decoder with the following:</p>
  
  <pre><code>AMEDIAFORMAT_KEY_MIME: "video/hevc"
  AMEDIAFORMAT_KEY_MAX_HEIGHT: 4320
  AMEDIAFORMAT_KEY_MAX_WIDTH: 8192
  AMEDIAFORMAT_KEY_HEIGHT: 1600
  AMEDIAFORMAT_KEY_WIDTH: 3840
  AMEDIAFORMAT_KEY_FRAME_RATE: 24
  AMEDIAFORMAT_KEY_PUSH_BLANK_BUFFERS_ON_STOP: 1
  </code></pre>
  
  <p>When using this setup, I get no video output. I've also tried setting <code>csd-0</code>, <code>csd-1</code> and <code>csd-2</code> to the VPS, SPS and PPS respectively, but have had no luck.</p>
  
  <p>I get the following error in the console, but have been assured it is unrelated:</p>
  
  <pre><code>01-19 15:40:36.048: E/OMXNodeInstance(17230): OMX_GetExtensionIndex OMX.google.android.index.storeMetaDataInBuffers failed
  01-19 15:40:36.048: E/ACodec(17230): [OMX.google.hevc.decoder] storeMetaDataInBuffers failed w/ err -2147483648
  </code></pre>
  
  <p>I have found that <code>dequeueOutputBuffer</code> is always returning <code>-1</code>. It appears that <code>dequeueInputBuffer</code> is returning indices that have been queued by <code>queueInputBuffer</code> before they are obtained from <code>dequeueOutputBuffer</code>.</p>
  
  <p>Has anyone managed to decode HEVC video on Android?</p>