title: How to change Android MediaCodec video orientation
body: <p>I'm using libstreaming (<a href="https://github.com/fyhertz/libstreaming" rel="nofollow">https://github.com/fyhertz/libstreaming</a>) for my live video streaming but the orientation of the video is always in landscape orientation at the receiver(server) side. I tried rotating my byte using the  rotateYUV420Degree90(data,mQuality.resX,mQuality.resY) but the issue has not solved. I'm attaching the code used the libstreaming library for converting the byte below.</p>
  
  <pre><code> public byte[] convert(byte[] data) {
  
      // A buffer large enough for every case
      if (mBuffer==null || mBuffer.length != 3*mSliceHeight*mStride/2+mYPadding) {
          mBuffer = new byte[3*mSliceHeight*mStride/2+mYPadding];
      }
  
      if (!mPlanar) {
          if (mSliceHeight==mHeight &amp;&amp; mStride==mWidth) {
              // Swaps U and V
              if (!mPanesReversed) {
                  for (int i = mSize; i &lt; mSize+mSize/2; i += 2) {
                      mBuffer[0] = data[i+1];
                      data[i+1] = data[i];
                      data[i] = mBuffer[0]; 
                  }
              }
              if (mYPadding&gt;0) {
                  System.arraycopy(data, 0, mBuffer, 0, mSize);
                  System.arraycopy(data, mSize, mBuffer, mSize+mYPadding, mSize/2);
                  return mBuffer;
              }
              return data;
          }
      } else {
          if (mSliceHeight==mHeight &amp;&amp; mStride==mWidth) {
              // De-interleave U and V
              if (!mPanesReversed) {
                  for (int i = 0; i &lt; mSize/4; i+=1) {
                      mBuffer[i] = data[mSize+2*i+1];
                      mBuffer[mSize/4+i] = data[mSize+2*i];
                  }
              } else {
                  for (int i = 0; i &lt; mSize/4; i+=1) {
                      mBuffer[i] = data[mSize+2*i];
                      mBuffer[mSize/4+i] = data[mSize+2*i+1];
                  }
              }
              if (mYPadding == 0) {
                  System.arraycopy(mBuffer, 0, data, mSize, mSize/2);
              } else {
                  System.arraycopy(data, 0, mBuffer, 0, mSize);
                  System.arraycopy(mBuffer, 0, mBuffer, mSize+mYPadding, mSize/2);
                  return mBuffer;
              }
              return data;
          }
      }
  
      return data;
  }   
  </code></pre>
  
  <p>Is there any way to handle the camera orientation or the recorded video orientation. Please do help me resolve the issue.</p>