title: How to get a Surface from a SurfaceTexture for MediaCodec?
body: <p>MediaCodec can render directly to a Surface, which can be setted by the <a href="https://developer.android.com/reference/android/media/MediaCodec.html#configure(android.media.MediaFormat,%20android.view.Surface,%20android.media.MediaCrypto,%20int)" rel="nofollow noreferrer">configure</a> method:</p>
  
  <pre><code>public void configure (MediaFormat format, 
                  Surface surface, 
                  MediaCrypto crypto, 
                  int flags)
  </code></pre>
  
  <p>I have working code that renders to a <code>SurfaceTexture</code>. Also, <code>Surface</code>'s <a href="https://developer.android.com/reference/android/view/Surface.html" rel="nofollow noreferrer">documentation</a> says that</p>
  
  <blockquote>
    <p>A Surface is generally created by or from a consumer of image buffers
    (such as a SurfaceTexture, MediaRecorder, or Allocation),</p>
  </blockquote>
  
  <p>But I didn't find any methods in <code>SurfaceTexture</code> or <code>Surface</code> that permits conversion between them</p>