title: Output video gets cropped in MasayukiSuda:CameraRecorder camera library
body: <p>I'm creating a camera app using MasayukiSuda:CameraRecorder library. The camera preview is working correctly but the recorded video is cropped and zoomed.</p>
  
  <p>public class BaseCameraActivity extends AppCompatActivity {</p>
  
  <pre><code>    private SampleGLView sampleGLView;
      protected CameraRecorder cameraRecorder;
      private String filepath;
      private TextView recordBtn;
      protected LensFacing lensFacing = LensFacing.BACK;
      protected int cameraWidth = 1280;
      protected int cameraHeight = 720;
      protected int videoWidth = 720;
      protected int videoHeight = 720;
      private AlertDialog filterDialog;
      private boolean toggleClick = false;
  
      protected void onCreateActivity() {
          getSupportActionBar().hide();
          recordBtn = findViewById(R.id.btn_record);
          recordBtn.setOnClickListener(v -&gt; {
  
              if (recordBtn.getText().equals(getString(R.string.app_record))) {
                  filepath = getVideoFilePath();
                  cameraRecorder.start(filepath);
                  recordBtn.setText("Stop");
              } else {
                  cameraRecorder.stop();
                  recordBtn.setText(getString(R.string.app_record));
              }
  
          });
          findViewById(R.id.btn_flash).setOnClickListener(v -&gt; {
              if (cameraRecorder != null &amp;&amp; cameraRecorder.isFlashSupport()) {
                  cameraRecorder.switchFlashMode();
                  cameraRecorder.changeAutoFocus();
              }
          });
  
          findViewById(R.id.btn_switch_camera).setOnClickListener(v -&gt; {
              releaseCamera();
              if (lensFacing == LensFacing.BACK) {
                  lensFacing = LensFacing.FRONT;
              } else {
                  lensFacing = LensFacing.BACK;
              }
              toggleClick = true;
          });
  
          findViewById(R.id.btn_filter).setOnClickListener(v -&gt; {
              if (filterDialog == null) {
  
                  AlertDialog.Builder builder = new AlertDialog.Builder(v.getContext());
                  builder.setTitle("Choose a filter");
                  builder.setOnDismissListener(dialog -&gt; {
                      filterDialog = null;
                  });
  
                  final Filters[] filters = Filters.values();
                  CharSequence[] charList = new CharSequence[filters.length];
                  for (int i = 0, n = filters.length; i &lt; n; i++) {
                      charList[i] = filters[i].name();
                  }
                  builder.setItems(charList, (dialog, item) -&gt; {
                      changeFilter(filters[item]);
                  });
                  filterDialog = builder.show();
              } else {
                  filterDialog.dismiss();
              }
  
          });
  
          findViewById(R.id.btn_image_capture).setOnClickListener(v -&gt; {
              captureBitmap(bitmap -&gt; {
                  new Handler().post(() -&gt; {
                      String imagePath = getImageFilePath();
                      saveAsPngImage(bitmap, imagePath);
                      exportPngToGallery(getApplicationContext(), imagePath);
                  });
              });
          });
  
  
          getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
  
      }
  
      @Override
      protected void onResume() {
          super.onResume();
          setUpCamera();
      }
  
      @Override
      protected void onStop() {
          super.onStop();
          releaseCamera();
      }
  
      private void releaseCamera() {
          if (sampleGLView != null) {
              sampleGLView.onPause();
          }
  
          if (cameraRecorder != null) {
              cameraRecorder.stop();
              cameraRecorder.release();
              cameraRecorder = null;
          }
  
          if (sampleGLView != null) {
              ((FrameLayout) findViewById(R.id.wrap_view)).removeView(sampleGLView);
              sampleGLView = null;
          }
      }
  
  
      private void setUpCameraView() {
          runOnUiThread(() -&gt; {
              FrameLayout frameLayout = findViewById(R.id.wrap_view);
              frameLayout.removeAllViews();
              sampleGLView = null;
              sampleGLView = new SampleGLView(getApplicationContext());
              sampleGLView.setTouchListener((event, width, height) -&gt; {
                  if (cameraRecorder == null) return;
                  cameraRecorder.changeManualFocusPoint(event.getX(), event.getY(), width, height);
              });
              frameLayout.addView(sampleGLView);
          });
      }
  
  
      private void setUpCamera() {
          setUpCameraView();
  
          cameraRecorder = new CameraRecorderBuilder(this, sampleGLView)
                  //.recordNoFilter(true)
                  .cameraRecordListener(new CameraRecordListener() {
                      @Override
                      public void onGetFlashSupport(boolean flashSupport) {
                          runOnUiThread(() -&gt; {
                              findViewById(R.id.btn_flash).setEnabled(flashSupport);
                          });
                      }
  
                      @Override
                      public void onRecordComplete() {
                          exportMp4ToGallery(getApplicationContext(), filepath);
                      }
  
                      @Override
                      public void onRecordStart() {
  
                      }
  
                      @Override
                      public void onError(Exception exception) {
                          Log.e("CameraRecorder", exception.toString());
                      }
  
                      @Override
                      public void onCameraThreadFinish() {
                          if (toggleClick) {
                              runOnUiThread(() -&gt; {
                                  setUpCamera();
                              });
                          }
                          toggleClick = false;
                      }
                  })
                  .videoSize(videoWidth, videoHeight)
                  .cameraSize(cameraWidth, cameraHeight)
                  .lensFacing(lensFacing)
                  .build();
  
  
      }
  
      private void changeFilter(Filters filters) {
          cameraRecorder.setFilter(Filters.getFilterInstance(filters, getApplicationContext()));
      }
  
  
      private interface BitmapReadyCallbacks {
          void onBitmapReady(Bitmap bitmap);
      }
  
      private void captureBitmap(final BitmapReadyCallbacks bitmapReadyCallbacks) {
          sampleGLView.queueEvent(() -&gt; {
              EGL10 egl = (EGL10) EGLContext.getEGL();
              GL10 gl = (GL10) egl.eglGetCurrentContext().getGL();
              Bitmap snapshotBitmap = createBitmapFromGLSurface(sampleGLView.getMeasuredWidth(), sampleGLView.getMeasuredHeight(), gl);
  
              runOnUiThread(() -&gt; {
                  bitmapReadyCallbacks.onBitmapReady(snapshotBitmap);
              });
          });
      }
  
      private Bitmap createBitmapFromGLSurface(int w, int h, GL10 gl) {
  
          int bitmapBuffer[] = new int[w * h];
          int bitmapSource[] = new int[w * h];
          IntBuffer intBuffer = IntBuffer.wrap(bitmapBuffer);
          intBuffer.position(0);
  
          try {
              gl.glReadPixels(0, 0, w, h, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, intBuffer);
              int offset1, offset2, texturePixel, blue, red, pixel;
              for (int i = 0; i &lt; h; i++) {
                  offset1 = i * w;
                  offset2 = (h - i - 1) * w;
                  for (int j = 0; j &lt; w; j++) {
                      texturePixel = bitmapBuffer[offset1 + j];
                      blue = (texturePixel &gt;&gt; 16) &amp; 0xff;
                      red = (texturePixel &lt;&lt; 16) &amp; 0x00ff0000;
                      pixel = (texturePixel &amp; 0xff00ff00) | red | blue;
                      bitmapSource[offset2 + j] = pixel;
                  }
              }
          } catch (GLException e) {
              Log.e("CreateBitmap", "createBitmapFromGLSurface: " + e.getMessage(), e);
              return null;
          }
  
          return Bitmap.createBitmap(bitmapSource, w, h, Bitmap.Config.ARGB_8888);
      }
  
      public void saveAsPngImage(Bitmap bitmap, String filePath) {
          try {
              File file = new File(filePath);
              FileOutputStream outStream = new FileOutputStream(file);
              bitmap.compress(Bitmap.CompressFormat.PNG, 100, outStream);
              outStream.close();
  
          } catch (FileNotFoundException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          }
      }
  
  
      public static void exportMp4ToGallery(Context context, String filePath) {
          final ContentValues values = new ContentValues(2);
          values.put(MediaStore.Video.Media.MIME_TYPE, "video/mp4");
          values.put(MediaStore.Video.Media.DATA, filePath);
          context.getContentResolver().insert(MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
                  values);
          context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE,
                  Uri.parse("file://" + filePath)));
      }
  
      public static String getVideoFilePath() {
          return getAndroidMoviesFolder().getAbsolutePath() + "/" + new SimpleDateFormat("yyyyMM_dd-HHmmss").format(new Date()) + "cameraRecorder.mp4";
      }
  
      public static File getAndroidMoviesFolder() {
          return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES);
      }
  
      private static void exportPngToGallery(Context context, String filePath) {
          Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
          File f = new File(filePath);
          Uri contentUri = Uri.fromFile(f);
          mediaScanIntent.setData(contentUri);
          context.sendBroadcast(mediaScanIntent);
      }
  
      public static String getImageFilePath() {
          return getAndroidImageFolder().getAbsolutePath() + "/" + new SimpleDateFormat("yyyyMM_dd-HHmmss").format(new Date()) + "cameraRecorder.png";
      }
  
      public static File getAndroidImageFolder() {
          return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
      }
  
  }
  </code></pre>
  
  <p>The following is the repository I am following : <a href="https://github.com/MasayukiSuda/CameraRecorder-android" rel="nofollow noreferrer">https://github.com/MasayukiSuda/CameraRecorder-android</a></p>