title: Android video displayed wrong in specific portrait rotation
body: <p>I am using a <a href="http://www.geniatech.com/pa/atv1220.asp" rel="nofollow noreferrer">Geniatech ATV1220</a> running Android 4.2.2 to display a video in a simple <code>VideoView</code>. It is connected to a monitor via the HDMI port. For my setup I need to display content in different orientations. It all works fine in 3 of the 4 orientations (Landscape, Landscape flipped, Portrait flipped). In Portrait the video is displayed wrong though.</p>
  
  <p>I created a basic application to reproduce this behaviour. (<a href="https://github.com/IngoAlbers/SimpleVideoView" rel="nofollow noreferrer">https://github.com/IngoAlbers/SimpleVideoView</a>)</p>
  
  <p>The relevant parts:</p>
  
  <p><strong>VideoViewActivity</strong></p>
  
  <pre><code>public class VideoViewActivity extends AppCompatActivity {
  
    @Override
    protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_video_view);
  
      final VideoView videoView =
          (VideoView) findViewById(com.ingoalbers.simplevideoview.R.id.videoView);
  
      assert videoView != null;
      videoView.setVideoPath("http://clips.vorwaerts-gmbh.de/VfE_html5.mp4");
      videoView.start();
    }
  }
  </code></pre>
  
  <p><strong>AndroidManifest.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
            package="com.ingoalbers.simplevideoview"&gt;
      &lt;uses-permission android:name="android.permission.INTERNET"/&gt;
      &lt;application
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:theme="@style/AppTheme"&gt;
          &lt;activity
              android:name=".VideoViewActivity"
              android:configChanges="orientation|keyboardHidden|screenSize"
              android:label="@string/app_name"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN"/&gt;
                  &lt;category android:name="android.intent.category.LAUNCHER"/&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
      &lt;/application&gt;
  &lt;/manifest&gt;
  </code></pre>
  
  <p><strong>activity_video_view.xml</strong></p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                  xmlns:tools="http://schemas.android.com/tools"
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  tools:context="com.ingoalbers.simplevideoview.VideoViewActivity"&gt;
      &lt;VideoView
          android:id="@+id/videoView"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_centerInParent="true"/&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p><strong>Portrait flipped</strong></p>
  
  <p><img src="https://i.stack.imgur.com/boxYn.jpg" width="350"></p>
  
  <p><strong>Landscape</strong></p>
  
  <p><img src="https://i.stack.imgur.com/CU0IR.jpg" width="350"></p>
  
  <p><strong>Portrait</strong></p>
  
  <p><img src="https://i.stack.imgur.com/eQvic.jpg" width="350"></p>
  
  <p>As you can see in Portrait mode the video is played but is only using 50% of the screen width and seems to be stretched in the height so you cannot see the whole video.</p>
  
  <p>I had the same behaviour in a <code>TextureView</code> and <code>SurfaceView</code>. So I think the problem is related to the <code>MediaPlayer</code>. I also changed the <code>android:background</code> property of the <code>VideoView</code> to be red and I saw that the actual dimensions of the <code>VideoView</code> were correct.</p>
  
  <p>This is probably a system or hardware related problem, but I might also be able to solve it in a programmatic way, as other applications, like the default VideoPlayer application don't suffer from this behaviour.</p>
  
  <p>It should also be possible for me to change system settings, etc. I will be happy to provide any additional information and files that might be needed to solve this issue.</p>
  
  <p><strong>Update</strong>:</p>
  
  <p>I was able to reproduce the problem using <a href="https://play.google.com/store/apps/details?id=com.mxtech.videoplayer.ad" rel="nofollow noreferrer">MXPlayer</a>. <strong>But</strong> when I switched from HW to SW decoding it was rendered correctly. Also there was no vertical stretching of the video even with HW decoding, but it still only showed 50% of the width.</p>
  
  <p><strong>Update #2</strong>:</p>
  
  <p>When I turn on "Show surface updates" in developer options only half of the screen where the video is displayed is flashing in Portrait mode. In the 3 other orientations the whole screen is flashing. </p>
  
  <p><strong>Portrait flipped</strong></p>
  
  <p><img src="https://i.stack.imgur.com/yBcbG.jpg" width="350"></p>
  
  <p><strong>Portrait</strong></p>
  
  <p><img src="https://i.stack.imgur.com/zyNw1.jpg" width="350"></p>
  
  <p>Additionally I uploaded the system <a href="https://docs.google.com/uc?export=download&amp;id=0BzA08cS2_h09QUlvTzNiU1pRRGc" rel="nofollow noreferrer">VideoPlayer.apk</a>, which can play the video correctly, if it might help anyone.</p>