tcking / GiraffeCompressor

video compressor on android
70 stars 27 forks source link

Portrait videos are getting converted to distorted landscape videos #5

Open nkunadeveloper opened 6 years ago

nkunadeveloper commented 6 years ago

Landscape videos work fine but portrait videos get distorted ...I think it's swapping the width and height. Using ExifInterface to check orientation should resolve this...please fix @tcking

TrevorIkky commented 5 years ago

could you please give more details on how to use exifinterface to solve this

shtompa commented 5 years ago

i don't know how to reach them but i wrote a code that can solve this issues if they implement it in BaseMediaCodecVideoCompressor.java -> func initOutputVideoMediaFormat() just after retrieving height and width of the video


int rotationValue = trackInfo.getVideoMediaFormat().getInteger(MediaFormat.KEY_ROTATION);
        if (Build.VERSION.SDK_INT > 20) {
            if (rotationValue == 90) {
                int temp = height;
                height = width;
                width = temp;
                rotationValue = 0;
                rotateRender = 270;
            } else if (rotationValue == 180) {
                rotateRender = 180;
                rotationValue = 0;
            } else if (rotationValue == 270) {
                int temp = height;
                height = width;
                width = temp;
                rotationValue = 0;
                rotateRender = 90;
            }
        }