title: Capturing 4:3 camera picture via android Camera2 API on camera with 16:9 sensor array
body: <p>I want to capture video with 4:3 aspect ratio from android fron-facing camera using Camera2 API (added in 5.0 version of android). It works correctly unless camera has 16:9 sensor array (as front-facing camera on Samsung Galaxy S5). In such case picture looks stretched as if 16:9 picture was being captured and squeezed into 4:3 surface provided by MediaRecorder.</p>
  
  <p>According to documentation there shouldn't be any additional configuration needed as long as MediaRecorder's size has been set to one of sizes provided by <a href="https://developer.android.com/reference/android/hardware/camera2/params/StreamConfigurationMap.html#getOutputSizes(java.lang.Class%3CT%3E)" rel="noreferrer">getOutputSizes(MediaRecorder.class)</a>. Camera should automatically crop picture so it fits size of MediaRecorder's surface.</p>
  
  <p>I tested also reversed situation - recording 16:9 video on camera with 4:3 sensor array (front-facing camera of Nexus-5). It works properly - picture is cropped to 16:9 aspect ratio.</p>
  
  <p>I assume this is a bug in android API but would like to see whether there's something I miss here.</p>
  
  <p>The simplest way to reproduce that problem is to use <a href="https://github.com/googlesamples/android-Camera2Basic" rel="noreferrer">camera2Basic</a> sample app provided by google with the following <a href="https://github.com/mikosik/android-Camera2Basic/commit/c3cf9f3755d2844d3398fa6252f3e324eee63e92" rel="noreferrer">change</a> that switches to using front-facing camera and 4:3 size for preview. It works correctly on Nexus-5 but provides stretched image on Samsung Galaxy S5. Below screenshot of camera2Basic app on Samsung Galaxy S5 (android 5.0).</p>
  
  <p><img src="https://i.stack.imgur.com/WCJaj.jpg" alt="enter image description here"></p>