use following code to find aspect ration from source size and destination size.
private int[] getVideoSizeWithAspect(int srcWidth, int srcHeight, int destWidth, int destHeight) { int aspectWidthByDestWidth, aspectHeightByDestWidth; int aspectWidthByDestHeight, aspectHeightByDestHeight; /* aspect sizes related to width */ aspectWidthByDestWidth = destWidth; aspectHeightByDestWidth = aspectWidthByDestWidth * srcHeight / srcWidth; /* aspect sizes related to height */ aspectHeightByDestHeight = destHeight; aspectWidthByDestHeight = aspectHeightByDestHeight * srcWidth / srcHeight; if (aspectWidthByDestWidth > aspectWidthByDestHeight && aspectHeightByDestWidth <= destHeight) { int[] videoViewSize = new int[2]; videoViewSize[0] = aspectWidthByDestWidth; videoViewSize[1] = aspectHeightByDestWidth; return videoViewSize; } else { int[] videoViewSize = new int[2]; videoViewSize[0] = aspectWidthByDestHeight; videoViewSize[1] = aspectHeightByDestHeight; return videoViewSize; } }