Question: I know this question has been asked before, however, I'm unable to find any solutions that work. 

The `Nexus 6` front camera always displays upside down in my app. Some of the solutions are to use "`setDisplayOrientation`", which does flip the camera on the screen. However, we encode the video with `frames` received from `onPreviewFrame`. 

According to the `Android SDK Documentation`, `setDisplayOrientation` doesn't actually change the `byte[]` in `onPreviewFrame`.

> 
> This does not affect the order of byte array passed in onPreviewFrame(byte[], Camera), JPEG pictures, or recorded videos. This method is not allowed to be called during preview.
> 
> 
> 

If it is not possible to get the `Nexus 6` front camera `onPreviewFrame` frames in the `correct orientation`, what is the `fastest` way to flip each frame, without suffering a drop in fps.

Thanks!

Answer: 
I was able to resolve this and keep fps high by using open cv to flip the frames.

```
yuvimage = opencv_core.IplImage.create(frame.getWith / 2, frame.getHeight / 2 * 3 / 2, IPL_DEPTH_8U, 1);
yuvimage.getByteBuffer().clear();
yuvimage.getByteBuffer().put(halveYUV420(frame.getData(), frame.getWidth(), frame.getHeight()));
rgbimage = opencv_core.IplImage.create(frame.getWidth / 2, frame.getHeight / 2, IPL_DEPTH_8U, 3);
rgbimage.getByteBuffer().clear();
opencv_imgproc.cvCvtColor(yuvimage, rgbimage, opencv_imgproc.CV_YUV2BGR_NV21);
opencv_core.cvFlip(rgbimage, rgbimage, 0);

```
The fastest way would be to do the flipping inside the GPU itself.
Render the camera preview on a `GLSurfaceView` and use vertex shaders to flip the image upside down.
Then, use `glReadPixels` to get the bytes of the current frame.
I'm not sure about the performance of `glReadPixels` on other phones, but, it should be pretty fast in Nexus 6/5.